@fieldwangai/agentflow 0.1.71 → 0.1.73

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,296 +0,0 @@
1
- var eM=Object.defineProperty;var tM=(e,t,n)=>t in e?eM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var or=(e,t,n)=>tM(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 o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var Wf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var QC={exports:{}},Gg={},ZC={exports:{}},Kt={};/**
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 _p=Symbol.for("react.element"),nM=Symbol.for("react.portal"),rM=Symbol.for("react.fragment"),sM=Symbol.for("react.strict_mode"),iM=Symbol.for("react.profiler"),oM=Symbol.for("react.provider"),aM=Symbol.for("react.context"),lM=Symbol.for("react.forward_ref"),cM=Symbol.for("react.suspense"),uM=Symbol.for("react.memo"),dM=Symbol.for("react.lazy"),Tk=Symbol.iterator;function fM(e){return e===null||typeof e!="object"?null:(e=Tk&&e[Tk]||e["@@iterator"],typeof e=="function"?e:null)}var eE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tE=Object.assign,nE={};function dd(e,t,n){this.props=e,this.context=t,this.refs=nE,this.updater=n||eE}dd.prototype.isReactComponent={};dd.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")};dd.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rE(){}rE.prototype=dd.prototype;function gv(e,t,n){this.props=e,this.context=t,this.refs=nE,this.updater=n||eE}var yv=gv.prototype=new rE;yv.constructor=gv;tE(yv,dd.prototype);yv.isPureReactComponent=!0;var Rk=Array.isArray,sE=Object.prototype.hasOwnProperty,xv={current:null},iE={key:!0,ref:!0,__self:!0,__source:!0};function oE(e,t,n){var r,s={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)sE.call(t,r)&&!iE.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var u=Array(l),d=0;d<l;d++)u[d]=arguments[d+2];s.children=u}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:_p,type:e,key:o,ref:a,props:s,_owner:xv.current}}function pM(e,t){return{$$typeof:_p,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function wv(e){return typeof e=="object"&&e!==null&&e.$$typeof===_p}function hM(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Mk=/\/+/g;function qy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?hM(""+e.key):t.toString(36)}function pm(e,t,n,r,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case _p:case nM:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+qy(a,0):r,Rk(s)?(n="",e!=null&&(n=e.replace(Mk,"$&/")+"/"),pm(s,t,n,"",function(d){return d})):s!=null&&(wv(s)&&(s=pM(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Mk,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",Rk(e))for(var l=0;l<e.length;l++){o=e[l];var u=r+qy(o,l);a+=pm(o,t,n,u,s)}else if(u=fM(e),typeof u=="function")for(e=u.call(e),l=0;!(o=e.next()).done;)o=o.value,u=r+qy(o,l++),a+=pm(o,t,n,u,s);else if(o==="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 xh(e,t,n){if(e==null)return e;var r=[],s=0;return pm(e,r,"","",function(o){return t.call(n,o,s++)}),r}function mM(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 Ns={current:null},hm={transition:null},gM={ReactCurrentDispatcher:Ns,ReactCurrentBatchConfig:hm,ReactCurrentOwner:xv};function aE(){throw Error("act(...) is not supported in production builds of React.")}Kt.Children={map:xh,forEach:function(e,t,n){xh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return xh(e,function(){t++}),t},toArray:function(e){return xh(e,function(t){return t})||[]},only:function(e){if(!wv(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Kt.Component=dd;Kt.Fragment=rM;Kt.Profiler=iM;Kt.PureComponent=gv;Kt.StrictMode=sM;Kt.Suspense=cM;Kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=gM;Kt.act=aE;Kt.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=tE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=xv.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(u in t)sE.call(t,u)&&!iE.hasOwnProperty(u)&&(r[u]=t[u]===void 0&&l!==void 0?l[u]:t[u])}var u=arguments.length-2;if(u===1)r.children=n;else if(1<u){l=Array(u);for(var d=0;d<u;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:_p,type:e.type,key:s,ref:o,props:r,_owner:a}};Kt.createContext=function(e){return e={$$typeof:aM,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:oM,_context:e},e.Consumer=e};Kt.createElement=oE;Kt.createFactory=function(e){var t=oE.bind(null,e);return t.type=e,t};Kt.createRef=function(){return{current:null}};Kt.forwardRef=function(e){return{$$typeof:lM,render:e}};Kt.isValidElement=wv;Kt.lazy=function(e){return{$$typeof:dM,_payload:{_status:-1,_result:e},_init:mM}};Kt.memo=function(e,t){return{$$typeof:uM,type:e,compare:t===void 0?null:t}};Kt.startTransition=function(e){var t=hm.transition;hm.transition={};try{e()}finally{hm.transition=t}};Kt.unstable_act=aE;Kt.useCallback=function(e,t){return Ns.current.useCallback(e,t)};Kt.useContext=function(e){return Ns.current.useContext(e)};Kt.useDebugValue=function(){};Kt.useDeferredValue=function(e){return Ns.current.useDeferredValue(e)};Kt.useEffect=function(e,t){return Ns.current.useEffect(e,t)};Kt.useId=function(){return Ns.current.useId()};Kt.useImperativeHandle=function(e,t,n){return Ns.current.useImperativeHandle(e,t,n)};Kt.useInsertionEffect=function(e,t){return Ns.current.useInsertionEffect(e,t)};Kt.useLayoutEffect=function(e,t){return Ns.current.useLayoutEffect(e,t)};Kt.useMemo=function(e,t){return Ns.current.useMemo(e,t)};Kt.useReducer=function(e,t,n){return Ns.current.useReducer(e,t,n)};Kt.useRef=function(e){return Ns.current.useRef(e)};Kt.useState=function(e){return Ns.current.useState(e)};Kt.useSyncExternalStore=function(e,t,n){return Ns.current.useSyncExternalStore(e,t,n)};Kt.useTransition=function(){return Ns.current.useTransition()};Kt.version="18.3.1";ZC.exports=Kt;var m=ZC.exports;const ht=Sl(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 yM=m,xM=Symbol.for("react.element"),wM=Symbol.for("react.fragment"),bM=Object.prototype.hasOwnProperty,vM=yM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kM={key:!0,ref:!0,__self:!0,__source:!0};function lE(e,t,n){var r,s={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)bM.call(t,r)&&!kM.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:xM,type:e,key:o,ref:a,props:s,_owner:vM.current}}Gg.Fragment=wM;Gg.jsx=lE;Gg.jsxs=lE;QC.exports=Gg;var i=QC.exports,xw={},cE={exports:{}},ui={},uE={exports:{}},dE={};/**
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,O){var E=A.length;A.push(O);e:for(;0<E;){var J=E-1>>>1,Z=A[J];if(0<s(Z,O))A[J]=O,A[E]=Z,E=J;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var O=A[0],E=A.pop();if(E!==O){A[0]=E;e:for(var J=0,Z=A.length,K=Z>>>1;J<K;){var oe=2*(J+1)-1,de=A[oe],he=oe+1,we=A[he];if(0>s(de,E))he<Z&&0>s(we,de)?(A[J]=we,A[he]=E,J=he):(A[J]=de,A[oe]=E,J=oe);else if(he<Z&&0>s(we,E))A[J]=we,A[he]=E,J=he;else break e}}return O}function s(A,O){var E=A.sortIndex-O.sortIndex;return E!==0?E:A.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var u=[],d=[],p=1,c=null,f=3,h=!1,g=!1,b=!1,k=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 O=n(d);O!==null;){if(O.callback===null)r(d);else if(O.startTime<=A)r(d),O.sortIndex=O.expirationTime,t(u,O);else break;O=n(d)}}function N(A){if(b=!1,x(A),!g)if(n(u)!==null)g=!0,I(_);else{var O=n(d);O!==null&&z(N,O.startTime-A)}}function _(A,O){g=!1,b&&(b=!1,y(F),F=-1),h=!0;var E=f;try{for(x(O),c=n(u);c!==null&&(!(c.expirationTime>O)||A&&!D());){var J=c.callback;if(typeof J=="function"){c.callback=null,f=c.priorityLevel;var Z=J(c.expirationTime<=O);O=e.unstable_now(),typeof Z=="function"?c.callback=Z:c===n(u)&&r(u),x(O)}else r(u);c=n(u)}if(c!==null)var K=!0;else{var oe=n(d);oe!==null&&z(N,oe.startTime-O),K=!1}return K}finally{c=null,f=E,h=!1}}var C=!1,T=null,F=-1,R=5,H=-1;function D(){return!(e.unstable_now()-H<R)}function $(){if(T!==null){var A=e.unstable_now();H=A;var O=!0;try{O=T(!0,A)}finally{O?B():(C=!1,T=null)}}else C=!1}var B;if(typeof w=="function")B=function(){w($)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,M=L.port2;L.port1.onmessage=$,B=function(){M.postMessage(null)}}else B=function(){k($,0)};function I(A){T=A,C||(C=!0,B())}function z(A,O){F=k(function(){A(e.unstable_now())},O)}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,I(_))},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"):R=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(A){switch(f){case 1:case 2:case 3:var O=3;break;default:O=f}var E=f;f=O;try{return A()}finally{f=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,O){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var E=f;f=A;try{return O()}finally{f=E}},e.unstable_scheduleCallback=function(A,O,E){var J=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?J+E:J):E=J,A){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=E+Z,A={id:p++,callback:O,priorityLevel:A,startTime:E,expirationTime:Z,sortIndex:-1},E>J?(A.sortIndex=E,t(d,A),n(u)===null&&A===n(d)&&(b?(y(F),F=-1):b=!0,z(N,E-J))):(A.sortIndex=Z,t(u,A),g||h||(g=!0,I(_))),A},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(A){var O=f;return function(){var E=f;f=O;try{return A.apply(this,arguments)}finally{f=E}}}})(dE);uE.exports=dE;var SM=uE.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 NM=m,li=SM;function Te(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 fE=new Set,Vf={};function Pc(e,t){Wu(e,t),Wu(e+"Capture",t)}function Wu(e,t){for(Vf[e]=t,e=0;e<t.length;e++)fE.add(t[e])}var ha=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ww=Object.prototype.hasOwnProperty,jM=/^[: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]*$/,Lk={},Ok={};function CM(e){return ww.call(Ok,e)?!0:ww.call(Lk,e)?!1:jM.test(e)?Ok[e]=!0:(Lk[e]=!0,!1)}function EM(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 _M(e,t,n,r){if(t===null||typeof t>"u"||EM(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 js(e,t,n,r,s,o,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=o,this.removeEmptyString=a}var Qr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Qr[e]=new js(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Qr[t]=new js(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Qr[e]=new js(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Qr[e]=new js(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){Qr[e]=new js(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Qr[e]=new js(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Qr[e]=new js(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Qr[e]=new js(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Qr[e]=new js(e,5,!1,e.toLowerCase(),null,!1,!1)});var bv=/[\-:]([a-z])/g;function vv(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(bv,vv);Qr[t]=new js(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(bv,vv);Qr[t]=new js(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(bv,vv);Qr[t]=new js(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Qr[e]=new js(e,1,!1,e.toLowerCase(),null,!1,!1)});Qr.xlinkHref=new js("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Qr[e]=new js(e,1,!1,e.toLowerCase(),null,!0,!0)});function kv(e,t,n,r){var s=Qr.hasOwnProperty(t)?Qr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(_M(t,n,s,r)&&(n=null),r||s===null?CM(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 va=NM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,wh=Symbol.for("react.element"),fu=Symbol.for("react.portal"),pu=Symbol.for("react.fragment"),Sv=Symbol.for("react.strict_mode"),bw=Symbol.for("react.profiler"),pE=Symbol.for("react.provider"),hE=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),vw=Symbol.for("react.suspense"),kw=Symbol.for("react.suspense_list"),jv=Symbol.for("react.memo"),qa=Symbol.for("react.lazy"),mE=Symbol.for("react.offscreen"),$k=Symbol.iterator;function qd(e){return e===null||typeof e!="object"?null:(e=$k&&e[$k]||e["@@iterator"],typeof e=="function"?e:null)}var rr=Object.assign,Yy;function ff(e){if(Yy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Yy=t&&t[1]||""}return`
34
- `+Yy+e}var Gy=!1;function Xy(e,t){if(!e||Gy)return"";Gy=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
- `),o=r.stack.split(`
36
- `),a=s.length-1,l=o.length-1;1<=a&&0<=l&&s[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==o[l]){var u=`
37
- `+s[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=l);break}}}finally{Gy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ff(e):""}function PM(e){switch(e.tag){case 5:return ff(e.type);case 16:return ff("Lazy");case 13:return ff("Suspense");case 19:return ff("SuspenseList");case 0:case 2:case 15:return e=Xy(e.type,!1),e;case 11:return e=Xy(e.type.render,!1),e;case 1:return e=Xy(e.type,!0),e;default:return""}}function Sw(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 pu:return"Fragment";case fu:return"Portal";case bw:return"Profiler";case Sv:return"StrictMode";case vw:return"Suspense";case kw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case hE:return(e.displayName||"Context")+".Consumer";case pE:return(e._context.displayName||"Context")+".Provider";case Nv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case jv:return t=e.displayName||null,t!==null?t:Sw(e.type)||"Memo";case qa:t=e._payload,e=e._init;try{return Sw(e(t))}catch{}}return null}function AM(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 Sw(t);case 8:return t===Sv?"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 ml(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function IM(e){var t=gE(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,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,o.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 bh(e){e._valueTracker||(e._valueTracker=IM(e))}function yE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Dm(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 Nw(e,t){var n=t.checked;return rr({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Dk(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ml(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 xE(e,t){t=t.checked,t!=null&&kv(e,"checked",t,!1)}function jw(e,t){xE(e,t);var n=ml(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")?Cw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Cw(e,t.type,ml(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Fk(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 Cw(e,t,n){(t!=="number"||Dm(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var pf=Array.isArray;function Au(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=""+ml(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 Ew(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Te(91));return rr({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function zk(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Te(92));if(pf(n)){if(1<n.length)throw Error(Te(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ml(n)}}function wE(e,t){var n=ml(t.value),r=ml(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 Hk(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function bE(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 _w(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?bE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var vh,vE=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(vh=vh||document.createElement("div"),vh.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=vh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Kf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sf={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},TM=["Webkit","ms","Moz","O"];Object.keys(Sf).forEach(function(e){TM.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Sf[t]=Sf[e]})});function kE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Sf.hasOwnProperty(e)&&Sf[e]?(""+t).trim():t+"px"}function SE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=kE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var RM=rr({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 Pw(e,t){if(t){if(RM[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Te(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Te(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Te(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Te(62))}}function Aw(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 Iw=null;function Cv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Tw=null,Iu=null,Tu=null;function Bk(e){if(e=Ip(e)){if(typeof Tw!="function")throw Error(Te(280));var t=e.stateNode;t&&(t=ey(t),Tw(e.stateNode,e.type,t))}}function NE(e){Iu?Tu?Tu.push(e):Tu=[e]:Iu=e}function jE(){if(Iu){var e=Iu,t=Tu;if(Tu=Iu=null,Bk(e),t)for(e=0;e<t.length;e++)Bk(t[e])}}function CE(e,t){return e(t)}function EE(){}var Jy=!1;function _E(e,t,n){if(Jy)return e(t,n);Jy=!0;try{return CE(e,t,n)}finally{Jy=!1,(Iu!==null||Tu!==null)&&(EE(),jE())}}function Uf(e,t){var n=e.stateNode;if(n===null)return null;var r=ey(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(Te(231,t,typeof n));return n}var Rw=!1;if(ha)try{var Yd={};Object.defineProperty(Yd,"passive",{get:function(){Rw=!0}}),window.addEventListener("test",Yd,Yd),window.removeEventListener("test",Yd,Yd)}catch{Rw=!1}function MM(e,t,n,r,s,o,a,l,u){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(p){this.onError(p)}}var Nf=!1,Fm=null,zm=!1,Mw=null,LM={onError:function(e){Nf=!0,Fm=e}};function OM(e,t,n,r,s,o,a,l,u){Nf=!1,Fm=null,MM.apply(LM,arguments)}function $M(e,t,n,r,s,o,a,l,u){if(OM.apply(this,arguments),Nf){if(Nf){var d=Fm;Nf=!1,Fm=null}else throw Error(Te(198));zm||(zm=!0,Mw=d)}}function Ac(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 PE(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 Wk(e){if(Ac(e)!==e)throw Error(Te(188))}function DM(e){var t=e.alternate;if(!t){if(t=Ac(e),t===null)throw Error(Te(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return Wk(s),e;if(o===r)return Wk(s),t;o=o.sibling}throw Error(Te(188))}if(n.return!==r.return)n=s,r=o;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=o;break}if(l===r){a=!0,r=s,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=s;break}if(l===r){a=!0,r=o,n=s;break}l=l.sibling}if(!a)throw Error(Te(189))}}if(n.alternate!==r)throw Error(Te(190))}if(n.tag!==3)throw Error(Te(188));return n.stateNode.current===n?e:t}function AE(e){return e=DM(e),e!==null?IE(e):null}function IE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=IE(e);if(t!==null)return t;e=e.sibling}return null}var TE=li.unstable_scheduleCallback,Vk=li.unstable_cancelCallback,FM=li.unstable_shouldYield,zM=li.unstable_requestPaint,pr=li.unstable_now,HM=li.unstable_getCurrentPriorityLevel,Ev=li.unstable_ImmediatePriority,RE=li.unstable_UserBlockingPriority,Hm=li.unstable_NormalPriority,BM=li.unstable_LowPriority,ME=li.unstable_IdlePriority,Xg=null,Mo=null;function WM(e){if(Mo&&typeof Mo.onCommitFiberRoot=="function")try{Mo.onCommitFiberRoot(Xg,e,void 0,(e.current.flags&128)===128)}catch{}}var eo=Math.clz32?Math.clz32:UM,VM=Math.log,KM=Math.LN2;function UM(e){return e>>>=0,e===0?32:31-(VM(e)/KM|0)|0}var kh=64,Sh=4194304;function hf(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 Bm(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=hf(l):(o&=a,o!==0&&(r=hf(o)))}else a=n&~s,a!==0?r=hf(a):o!==0&&(r=hf(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&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-eo(t),s=1<<n,r|=e[n],t&=~s;return r}function qM(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 YM(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-eo(o),l=1<<a,u=s[a];u===-1?(!(l&n)||l&r)&&(s[a]=qM(l,t)):u<=t&&(e.expiredLanes|=l),o&=~l}}function Lw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function LE(){var e=kh;return kh<<=1,!(kh&4194240)&&(kh=64),e}function Qy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Pp(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-eo(t),e[t]=n}function GM(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-eo(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function _v(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-eo(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var pn=0;function OE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var $E,Pv,DE,FE,zE,Ow=!1,Nh=[],rl=null,sl=null,il=null,qf=new Map,Yf=new Map,Xa=[],XM="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 Kk(e,t){switch(e){case"focusin":case"focusout":rl=null;break;case"dragenter":case"dragleave":sl=null;break;case"mouseover":case"mouseout":il=null;break;case"pointerover":case"pointerout":qf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Yf.delete(t.pointerId)}}function Gd(e,t,n,r,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},t!==null&&(t=Ip(t),t!==null&&Pv(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function JM(e,t,n,r,s){switch(t){case"focusin":return rl=Gd(rl,e,t,n,r,s),!0;case"dragenter":return sl=Gd(sl,e,t,n,r,s),!0;case"mouseover":return il=Gd(il,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return qf.set(o,Gd(qf.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Yf.set(o,Gd(Yf.get(o)||null,e,t,n,r,s)),!0}return!1}function HE(e){var t=rc(e.target);if(t!==null){var n=Ac(t);if(n!==null){if(t=n.tag,t===13){if(t=PE(n),t!==null){e.blockedOn=t,zE(e.priority,function(){DE(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 mm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=$w(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Iw=r,n.target.dispatchEvent(r),Iw=null}else return t=Ip(n),t!==null&&Pv(t),e.blockedOn=n,!1;t.shift()}return!0}function Uk(e,t,n){mm(e)&&n.delete(t)}function QM(){Ow=!1,rl!==null&&mm(rl)&&(rl=null),sl!==null&&mm(sl)&&(sl=null),il!==null&&mm(il)&&(il=null),qf.forEach(Uk),Yf.forEach(Uk)}function Xd(e,t){e.blockedOn===t&&(e.blockedOn=null,Ow||(Ow=!0,li.unstable_scheduleCallback(li.unstable_NormalPriority,QM)))}function Gf(e){function t(s){return Xd(s,e)}if(0<Nh.length){Xd(Nh[0],e);for(var n=1;n<Nh.length;n++){var r=Nh[n];r.blockedOn===e&&(r.blockedOn=null)}}for(rl!==null&&Xd(rl,e),sl!==null&&Xd(sl,e),il!==null&&Xd(il,e),qf.forEach(t),Yf.forEach(t),n=0;n<Xa.length;n++)r=Xa[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Xa.length&&(n=Xa[0],n.blockedOn===null);)HE(n),n.blockedOn===null&&Xa.shift()}var Ru=va.ReactCurrentBatchConfig,Wm=!0;function ZM(e,t,n,r){var s=pn,o=Ru.transition;Ru.transition=null;try{pn=1,Av(e,t,n,r)}finally{pn=s,Ru.transition=o}}function eL(e,t,n,r){var s=pn,o=Ru.transition;Ru.transition=null;try{pn=4,Av(e,t,n,r)}finally{pn=s,Ru.transition=o}}function Av(e,t,n,r){if(Wm){var s=$w(e,t,n,r);if(s===null)lx(e,t,r,Vm,n),Kk(e,r);else if(JM(s,e,t,n,r))r.stopPropagation();else if(Kk(e,r),t&4&&-1<XM.indexOf(e)){for(;s!==null;){var o=Ip(s);if(o!==null&&$E(o),o=$w(e,t,n,r),o===null&&lx(e,t,r,Vm,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else lx(e,t,r,null,n)}}var Vm=null;function $w(e,t,n,r){if(Vm=null,e=Cv(r),e=rc(e),e!==null)if(t=Ac(e),t===null)e=null;else if(n=t.tag,n===13){if(e=PE(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 Vm=e,null}function BE(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(HM()){case Ev:return 1;case RE:return 4;case Hm:case BM:return 16;case ME:return 536870912;default:return 16}default:return 16}}var Za=null,Iv=null,gm=null;function WE(){if(gm)return gm;var e,t=Iv,n=t.length,r,s="value"in Za?Za.value:Za.textContent,o=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[o-r];r++);return gm=s.slice(e,1<r?1-r:void 0)}function ym(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 jh(){return!0}function qk(){return!1}function di(e){function t(n,r,s,o,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?jh:qk,this.isPropagationStopped=qk,this}return rr(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=jh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=jh)},persist:function(){},isPersistent:jh}),t}var fd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Tv=di(fd),Ap=rr({},fd,{view:0,detail:0}),tL=di(Ap),Zy,ex,Jd,Jg=rr({},Ap,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rv,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!==Jd&&(Jd&&e.type==="mousemove"?(Zy=e.screenX-Jd.screenX,ex=e.screenY-Jd.screenY):ex=Zy=0,Jd=e),Zy)},movementY:function(e){return"movementY"in e?e.movementY:ex}}),Yk=di(Jg),nL=rr({},Jg,{dataTransfer:0}),rL=di(nL),sL=rr({},Ap,{relatedTarget:0}),tx=di(sL),iL=rr({},fd,{animationName:0,elapsedTime:0,pseudoElement:0}),oL=di(iL),aL=rr({},fd,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),lL=di(aL),cL=rr({},fd,{data:0}),Gk=di(cL),uL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dL={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"},fL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=fL[e])?!!t[e]:!1}function Rv(){return pL}var hL=rr({},Ap,{key:function(e){if(e.key){var t=uL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ym(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?dL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rv,charCode:function(e){return e.type==="keypress"?ym(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ym(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),mL=di(hL),gL=rr({},Jg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xk=di(gL),yL=rr({},Ap,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rv}),xL=di(yL),wL=rr({},fd,{propertyName:0,elapsedTime:0,pseudoElement:0}),bL=di(wL),vL=rr({},Jg,{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}),kL=di(vL),SL=[9,13,27,32],Mv=ha&&"CompositionEvent"in window,jf=null;ha&&"documentMode"in document&&(jf=document.documentMode);var NL=ha&&"TextEvent"in window&&!jf,VE=ha&&(!Mv||jf&&8<jf&&11>=jf),Jk=" ",Qk=!1;function KE(e,t){switch(e){case"keyup":return SL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function UE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hu=!1;function jL(e,t){switch(e){case"compositionend":return UE(t);case"keypress":return t.which!==32?null:(Qk=!0,Jk);case"textInput":return e=t.data,e===Jk&&Qk?null:e;default:return null}}function CL(e,t){if(hu)return e==="compositionend"||!Mv&&KE(e,t)?(e=WE(),gm=Iv=Za=null,hu=!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 VE&&t.locale!=="ko"?null:t.data;default:return null}}var EL={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 Zk(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!EL[e.type]:t==="textarea"}function qE(e,t,n,r){NE(r),t=Km(t,"onChange"),0<t.length&&(n=new Tv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Cf=null,Xf=null;function _L(e){s_(e,0)}function Qg(e){var t=yu(e);if(yE(t))return e}function PL(e,t){if(e==="change")return t}var YE=!1;if(ha){var nx;if(ha){var rx="oninput"in document;if(!rx){var eS=document.createElement("div");eS.setAttribute("oninput","return;"),rx=typeof eS.oninput=="function"}nx=rx}else nx=!1;YE=nx&&(!document.documentMode||9<document.documentMode)}function tS(){Cf&&(Cf.detachEvent("onpropertychange",GE),Xf=Cf=null)}function GE(e){if(e.propertyName==="value"&&Qg(Xf)){var t=[];qE(t,Xf,e,Cv(e)),_E(_L,t)}}function AL(e,t,n){e==="focusin"?(tS(),Cf=t,Xf=n,Cf.attachEvent("onpropertychange",GE)):e==="focusout"&&tS()}function IL(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Qg(Xf)}function TL(e,t){if(e==="click")return Qg(t)}function RL(e,t){if(e==="input"||e==="change")return Qg(t)}function ML(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var no=typeof Object.is=="function"?Object.is:ML;function Jf(e,t){if(no(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(!ww.call(t,s)||!no(e[s],t[s]))return!1}return!0}function nS(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function rS(e,t){var n=nS(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=nS(n)}}function XE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?XE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function JE(){for(var e=window,t=Dm();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Dm(e.document)}return t}function Lv(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 LL(e){var t=JE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&XE(n.ownerDocument.documentElement,n)){if(r!==null&&Lv(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,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=rS(n,o);var a=rS(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(),o>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 OL=ha&&"documentMode"in document&&11>=document.documentMode,mu=null,Dw=null,Ef=null,Fw=!1;function sS(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fw||mu==null||mu!==Dm(r)||(r=mu,"selectionStart"in r&&Lv(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}),Ef&&Jf(Ef,r)||(Ef=r,r=Km(Dw,"onSelect"),0<r.length&&(t=new Tv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=mu)))}function Ch(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var gu={animationend:Ch("Animation","AnimationEnd"),animationiteration:Ch("Animation","AnimationIteration"),animationstart:Ch("Animation","AnimationStart"),transitionend:Ch("Transition","TransitionEnd")},sx={},QE={};ha&&(QE=document.createElement("div").style,"AnimationEvent"in window||(delete gu.animationend.animation,delete gu.animationiteration.animation,delete gu.animationstart.animation),"TransitionEvent"in window||delete gu.transitionend.transition);function Zg(e){if(sx[e])return sx[e];if(!gu[e])return e;var t=gu[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in QE)return sx[e]=t[n];return e}var ZE=Zg("animationend"),e_=Zg("animationiteration"),t_=Zg("animationstart"),n_=Zg("transitionend"),r_=new Map,iS="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 Nl(e,t){r_.set(e,t),Pc(t,[e])}for(var ix=0;ix<iS.length;ix++){var ox=iS[ix],$L=ox.toLowerCase(),DL=ox[0].toUpperCase()+ox.slice(1);Nl($L,"on"+DL)}Nl(ZE,"onAnimationEnd");Nl(e_,"onAnimationIteration");Nl(t_,"onAnimationStart");Nl("dblclick","onDoubleClick");Nl("focusin","onFocus");Nl("focusout","onBlur");Nl(n_,"onTransitionEnd");Wu("onMouseEnter",["mouseout","mouseover"]);Wu("onMouseLeave",["mouseout","mouseover"]);Wu("onPointerEnter",["pointerout","pointerover"]);Wu("onPointerLeave",["pointerout","pointerover"]);Pc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Pc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Pc("onBeforeInput",["compositionend","keypress","textInput","paste"]);Pc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Pc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Pc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var mf="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(" "),FL=new Set("cancel close invalid load scroll toggle".split(" ").concat(mf));function oS(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,$M(r,t,void 0,e),e.currentTarget=null}function s_(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 o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],u=l.instance,d=l.currentTarget;if(l=l.listener,u!==o&&s.isPropagationStopped())break e;oS(s,l,d),o=u}else for(a=0;a<r.length;a++){if(l=r[a],u=l.instance,d=l.currentTarget,l=l.listener,u!==o&&s.isPropagationStopped())break e;oS(s,l,d),o=u}}}if(zm)throw e=Mw,zm=!1,Mw=null,e}function Dn(e,t){var n=t[Vw];n===void 0&&(n=t[Vw]=new Set);var r=e+"__bubble";n.has(r)||(i_(t,e,2,!1),n.add(r))}function ax(e,t,n){var r=0;t&&(r|=4),i_(n,e,r,t)}var Eh="_reactListening"+Math.random().toString(36).slice(2);function Qf(e){if(!e[Eh]){e[Eh]=!0,fE.forEach(function(n){n!=="selectionchange"&&(FL.has(n)||ax(n,!1,e),ax(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Eh]||(t[Eh]=!0,ax("selectionchange",!1,t))}}function i_(e,t,n,r){switch(BE(t)){case 1:var s=ZM;break;case 4:s=eL;break;default:s=Av}n=s.bind(null,t,n,e),s=void 0,!Rw||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 lx(e,t,n,r,s){var o=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 u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===s||u.nodeType===8&&u.parentNode===s))return;a=a.return}for(;l!==null;){if(a=rc(l),a===null)return;if(u=a.tag,u===5||u===6){r=o=a;continue e}l=l.parentNode}}r=r.return}_E(function(){var d=o,p=Cv(n),c=[];e:{var f=r_.get(e);if(f!==void 0){var h=Tv,g=e;switch(e){case"keypress":if(ym(n)===0)break e;case"keydown":case"keyup":h=mL;break;case"focusin":g="focus",h=tx;break;case"focusout":g="blur",h=tx;break;case"beforeblur":case"afterblur":h=tx;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=Yk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=rL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=xL;break;case ZE:case e_:case t_:h=oL;break;case n_:h=bL;break;case"scroll":h=tL;break;case"wheel":h=kL;break;case"copy":case"cut":case"paste":h=lL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Xk}var b=(t&4)!==0,k=!b&&e==="scroll",y=b?f!==null?f+"Capture":null:f;b=[];for(var w=d,x;w!==null;){x=w;var N=x.stateNode;if(x.tag===5&&N!==null&&(x=N,y!==null&&(N=Uf(w,y),N!=null&&b.push(Zf(w,N,x)))),k)break;w=w.return}0<b.length&&(f=new h(f,g,null,n,p),c.push({event:f,listeners:b}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",f&&n!==Iw&&(g=n.relatedTarget||n.fromElement)&&(rc(g)||g[ma]))break e;if((h||f)&&(f=p.window===p?p:(f=p.ownerDocument)?f.defaultView||f.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=d,g=g?rc(g):null,g!==null&&(k=Ac(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=d),h!==g)){if(b=Yk,N="onMouseLeave",y="onMouseEnter",w="mouse",(e==="pointerout"||e==="pointerover")&&(b=Xk,N="onPointerLeave",y="onPointerEnter",w="pointer"),k=h==null?f:yu(h),x=g==null?f:yu(g),f=new b(N,w+"leave",h,n,p),f.target=k,f.relatedTarget=x,N=null,rc(p)===d&&(b=new b(y,w+"enter",g,n,p),b.target=x,b.relatedTarget=k,N=b),k=N,h&&g)t:{for(b=h,y=g,w=0,x=b;x;x=tu(x))w++;for(x=0,N=y;N;N=tu(N))x++;for(;0<w-x;)b=tu(b),w--;for(;0<x-w;)y=tu(y),x--;for(;w--;){if(b===y||y!==null&&b===y.alternate)break t;b=tu(b),y=tu(y)}b=null}else b=null;h!==null&&aS(c,f,h,b,!1),g!==null&&k!==null&&aS(c,k,g,b,!0)}}e:{if(f=d?yu(d):window,h=f.nodeName&&f.nodeName.toLowerCase(),h==="select"||h==="input"&&f.type==="file")var _=PL;else if(Zk(f))if(YE)_=RL;else{_=IL;var C=AL}else(h=f.nodeName)&&h.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(_=TL);if(_&&(_=_(e,d))){qE(c,_,n,p);break e}C&&C(e,f,d),e==="focusout"&&(C=f._wrapperState)&&C.controlled&&f.type==="number"&&Cw(f,"number",f.value)}switch(C=d?yu(d):window,e){case"focusin":(Zk(C)||C.contentEditable==="true")&&(mu=C,Dw=d,Ef=null);break;case"focusout":Ef=Dw=mu=null;break;case"mousedown":Fw=!0;break;case"contextmenu":case"mouseup":case"dragend":Fw=!1,sS(c,n,p);break;case"selectionchange":if(OL)break;case"keydown":case"keyup":sS(c,n,p)}var T;if(Mv)e:{switch(e){case"compositionstart":var F="onCompositionStart";break e;case"compositionend":F="onCompositionEnd";break e;case"compositionupdate":F="onCompositionUpdate";break e}F=void 0}else hu?KE(e,n)&&(F="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(F="onCompositionStart");F&&(VE&&n.locale!=="ko"&&(hu||F!=="onCompositionStart"?F==="onCompositionEnd"&&hu&&(T=WE()):(Za=p,Iv="value"in Za?Za.value:Za.textContent,hu=!0)),C=Km(d,F),0<C.length&&(F=new Gk(F,e,null,n,p),c.push({event:F,listeners:C}),T?F.data=T:(T=UE(n),T!==null&&(F.data=T)))),(T=NL?jL(e,n):CL(e,n))&&(d=Km(d,"onBeforeInput"),0<d.length&&(p=new Gk("onBeforeInput","beforeinput",null,n,p),c.push({event:p,listeners:d}),p.data=T))}s_(c,t)})}function Zf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Km(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Uf(e,n),o!=null&&r.unshift(Zf(e,o,s)),o=Uf(e,t),o!=null&&r.push(Zf(e,o,s))),e=e.return}return r}function tu(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function aS(e,t,n,r,s){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,u=l.alternate,d=l.stateNode;if(u!==null&&u===r)break;l.tag===5&&d!==null&&(l=d,s?(u=Uf(n,o),u!=null&&a.unshift(Zf(n,u,l))):s||(u=Uf(n,o),u!=null&&a.push(Zf(n,u,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var zL=/\r\n?/g,HL=/\u0000|\uFFFD/g;function lS(e){return(typeof e=="string"?e:""+e).replace(zL,`
38
- `).replace(HL,"")}function _h(e,t,n){if(t=lS(t),lS(e)!==t&&n)throw Error(Te(425))}function Um(){}var zw=null,Hw=null;function Bw(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 Ww=typeof setTimeout=="function"?setTimeout:void 0,BL=typeof clearTimeout=="function"?clearTimeout:void 0,cS=typeof Promise=="function"?Promise:void 0,WL=typeof queueMicrotask=="function"?queueMicrotask:typeof cS<"u"?function(e){return cS.resolve(null).then(e).catch(VL)}:Ww;function VL(e){setTimeout(function(){throw e})}function cx(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),Gf(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Gf(t)}function ol(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 uS(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 pd=Math.random().toString(36).slice(2),Ao="__reactFiber$"+pd,ep="__reactProps$"+pd,ma="__reactContainer$"+pd,Vw="__reactEvents$"+pd,KL="__reactListeners$"+pd,UL="__reactHandles$"+pd;function rc(e){var t=e[Ao];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ma]||n[Ao]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=uS(e);e!==null;){if(n=e[Ao])return n;e=uS(e)}return t}e=n,n=e.parentNode}return null}function Ip(e){return e=e[Ao]||e[ma],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function yu(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Te(33))}function ey(e){return e[ep]||null}var Kw=[],xu=-1;function jl(e){return{current:e}}function Hn(e){0>xu||(e.current=Kw[xu],Kw[xu]=null,xu--)}function An(e,t){xu++,Kw[xu]=e.current,e.current=t}var gl={},us=jl(gl),Hs=jl(!1),mc=gl;function Vu(e,t){var n=e.type.contextTypes;if(!n)return gl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Bs(e){return e=e.childContextTypes,e!=null}function qm(){Hn(Hs),Hn(us)}function dS(e,t,n){if(us.current!==gl)throw Error(Te(168));An(us,t),An(Hs,n)}function o_(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(Te(108,AM(e)||"Unknown",s));return rr({},n,r)}function Ym(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||gl,mc=us.current,An(us,e),An(Hs,Hs.current),!0}function fS(e,t,n){var r=e.stateNode;if(!r)throw Error(Te(169));n?(e=o_(e,t,mc),r.__reactInternalMemoizedMergedChildContext=e,Hn(Hs),Hn(us),An(us,e)):Hn(Hs),An(Hs,n)}var sa=null,ty=!1,ux=!1;function a_(e){sa===null?sa=[e]:sa.push(e)}function qL(e){ty=!0,a_(e)}function Cl(){if(!ux&&sa!==null){ux=!0;var e=0,t=pn;try{var n=sa;for(pn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}sa=null,ty=!1}catch(s){throw sa!==null&&(sa=sa.slice(e+1)),TE(Ev,Cl),s}finally{pn=t,ux=!1}}return null}var wu=[],bu=0,Gm=null,Xm=0,wi=[],bi=0,gc=null,aa=1,la="";function Ql(e,t){wu[bu++]=Xm,wu[bu++]=Gm,Gm=e,Xm=t}function l_(e,t,n){wi[bi++]=aa,wi[bi++]=la,wi[bi++]=gc,gc=e;var r=aa;e=la;var s=32-eo(r)-1;r&=~(1<<s),n+=1;var o=32-eo(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,aa=1<<32-eo(t)+s|n<<s|r,la=o+e}else aa=1<<o|n<<s|r,la=e}function Ov(e){e.return!==null&&(Ql(e,1),l_(e,1,0))}function $v(e){for(;e===Gm;)Gm=wu[--bu],wu[bu]=null,Xm=wu[--bu],wu[bu]=null;for(;e===gc;)gc=wi[--bi],wi[bi]=null,la=wi[--bi],wi[bi]=null,aa=wi[--bi],wi[bi]=null}var oi=null,si=null,Gn=!1,Gi=null;function c_(e,t){var n=Si(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 pS(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,oi=e,si=ol(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,oi=e,si=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=gc!==null?{id:aa,overflow:la}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Si(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,oi=e,si=null,!0):!1;default:return!1}}function Uw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function qw(e){if(Gn){var t=si;if(t){var n=t;if(!pS(e,t)){if(Uw(e))throw Error(Te(418));t=ol(n.nextSibling);var r=oi;t&&pS(e,t)?c_(r,n):(e.flags=e.flags&-4097|2,Gn=!1,oi=e)}}else{if(Uw(e))throw Error(Te(418));e.flags=e.flags&-4097|2,Gn=!1,oi=e}}}function hS(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;oi=e}function Ph(e){if(e!==oi)return!1;if(!Gn)return hS(e),Gn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Bw(e.type,e.memoizedProps)),t&&(t=si)){if(Uw(e))throw u_(),Error(Te(418));for(;t;)c_(e,t),t=ol(t.nextSibling)}if(hS(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Te(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){si=ol(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}si=null}}else si=oi?ol(e.stateNode.nextSibling):null;return!0}function u_(){for(var e=si;e;)e=ol(e.nextSibling)}function Ku(){si=oi=null,Gn=!1}function Dv(e){Gi===null?Gi=[e]:Gi.push(e)}var YL=va.ReactCurrentBatchConfig;function Qd(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(Te(309));var r=n.stateNode}if(!r)throw Error(Te(147,e));var s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=s.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Te(284));if(!n._owner)throw Error(Te(290,e))}return e}function Ah(e,t){throw e=Object.prototype.toString.call(t),Error(Te(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function mS(e){var t=e._init;return t(e._payload)}function d_(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=ul(y,w),y.index=0,y.sibling=null,y}function o(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,N){return w===null||w.tag!==6?(w=yx(x,y.mode,N),w.return=y,w):(w=s(w,x),w.return=y,w)}function u(y,w,x,N){var _=x.type;return _===pu?p(y,w,x.props.children,N,x.key):w!==null&&(w.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===qa&&mS(_)===w.type)?(N=s(w,x.props),N.ref=Qd(y,w,x),N.return=y,N):(N=Nm(x.type,x.key,x.props,null,y.mode,N),N.ref=Qd(y,w,x),N.return=y,N)}function d(y,w,x,N){return w===null||w.tag!==4||w.stateNode.containerInfo!==x.containerInfo||w.stateNode.implementation!==x.implementation?(w=xx(x,y.mode,N),w.return=y,w):(w=s(w,x.children||[]),w.return=y,w)}function p(y,w,x,N,_){return w===null||w.tag!==7?(w=cc(x,y.mode,N,_),w.return=y,w):(w=s(w,x),w.return=y,w)}function c(y,w,x){if(typeof w=="string"&&w!==""||typeof w=="number")return w=yx(""+w,y.mode,x),w.return=y,w;if(typeof w=="object"&&w!==null){switch(w.$$typeof){case wh:return x=Nm(w.type,w.key,w.props,null,y.mode,x),x.ref=Qd(y,null,w),x.return=y,x;case fu:return w=xx(w,y.mode,x),w.return=y,w;case qa:var N=w._init;return c(y,N(w._payload),x)}if(pf(w)||qd(w))return w=cc(w,y.mode,x,null),w.return=y,w;Ah(y,w)}return null}function f(y,w,x,N){var _=w!==null?w.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return _!==null?null:l(y,w,""+x,N);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case wh:return x.key===_?u(y,w,x,N):null;case fu:return x.key===_?d(y,w,x,N):null;case qa:return _=x._init,f(y,w,_(x._payload),N)}if(pf(x)||qd(x))return _!==null?null:p(y,w,x,N,null);Ah(y,x)}return null}function h(y,w,x,N,_){if(typeof N=="string"&&N!==""||typeof N=="number")return y=y.get(x)||null,l(w,y,""+N,_);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case wh:return y=y.get(N.key===null?x:N.key)||null,u(w,y,N,_);case fu:return y=y.get(N.key===null?x:N.key)||null,d(w,y,N,_);case qa:var C=N._init;return h(y,w,x,C(N._payload),_)}if(pf(N)||qd(N))return y=y.get(x)||null,p(w,y,N,_,null);Ah(w,N)}return null}function g(y,w,x,N){for(var _=null,C=null,T=w,F=w=0,R=null;T!==null&&F<x.length;F++){T.index>F?(R=T,T=null):R=T.sibling;var H=f(y,T,x[F],N);if(H===null){T===null&&(T=R);break}e&&T&&H.alternate===null&&t(y,T),w=o(H,w,F),C===null?_=H:C.sibling=H,C=H,T=R}if(F===x.length)return n(y,T),Gn&&Ql(y,F),_;if(T===null){for(;F<x.length;F++)T=c(y,x[F],N),T!==null&&(w=o(T,w,F),C===null?_=T:C.sibling=T,C=T);return Gn&&Ql(y,F),_}for(T=r(y,T);F<x.length;F++)R=h(T,y,F,x[F],N),R!==null&&(e&&R.alternate!==null&&T.delete(R.key===null?F:R.key),w=o(R,w,F),C===null?_=R:C.sibling=R,C=R);return e&&T.forEach(function(D){return t(y,D)}),Gn&&Ql(y,F),_}function b(y,w,x,N){var _=qd(x);if(typeof _!="function")throw Error(Te(150));if(x=_.call(x),x==null)throw Error(Te(151));for(var C=_=null,T=w,F=w=0,R=null,H=x.next();T!==null&&!H.done;F++,H=x.next()){T.index>F?(R=T,T=null):R=T.sibling;var D=f(y,T,H.value,N);if(D===null){T===null&&(T=R);break}e&&T&&D.alternate===null&&t(y,T),w=o(D,w,F),C===null?_=D:C.sibling=D,C=D,T=R}if(H.done)return n(y,T),Gn&&Ql(y,F),_;if(T===null){for(;!H.done;F++,H=x.next())H=c(y,H.value,N),H!==null&&(w=o(H,w,F),C===null?_=H:C.sibling=H,C=H);return Gn&&Ql(y,F),_}for(T=r(y,T);!H.done;F++,H=x.next())H=h(T,y,F,H.value,N),H!==null&&(e&&H.alternate!==null&&T.delete(H.key===null?F:H.key),w=o(H,w,F),C===null?_=H:C.sibling=H,C=H);return e&&T.forEach(function($){return t(y,$)}),Gn&&Ql(y,F),_}function k(y,w,x,N){if(typeof x=="object"&&x!==null&&x.type===pu&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case wh:e:{for(var _=x.key,C=w;C!==null;){if(C.key===_){if(_=x.type,_===pu){if(C.tag===7){n(y,C.sibling),w=s(C,x.props.children),w.return=y,y=w;break e}}else if(C.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===qa&&mS(_)===C.type){n(y,C.sibling),w=s(C,x.props),w.ref=Qd(y,C,x),w.return=y,y=w;break e}n(y,C);break}else t(y,C);C=C.sibling}x.type===pu?(w=cc(x.props.children,y.mode,N,x.key),w.return=y,y=w):(N=Nm(x.type,x.key,x.props,null,y.mode,N),N.ref=Qd(y,w,x),N.return=y,y=N)}return a(y);case fu:e:{for(C=x.key;w!==null;){if(w.key===C)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=xx(x,y.mode,N),w.return=y,y=w}return a(y);case qa:return C=x._init,k(y,w,C(x._payload),N)}if(pf(x))return g(y,w,x,N);if(qd(x))return b(y,w,x,N);Ah(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=yx(x,y.mode,N),w.return=y,y=w),a(y)):n(y,w)}return k}var Uu=d_(!0),f_=d_(!1),Jm=jl(null),Qm=null,vu=null,Fv=null;function zv(){Fv=vu=Qm=null}function Hv(e){var t=Jm.current;Hn(Jm),e._currentValue=t}function Yw(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 Mu(e,t){Qm=e,Fv=vu=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Os=!0),e.firstContext=null)}function ji(e){var t=e._currentValue;if(Fv!==e)if(e={context:e,memoizedValue:t,next:null},vu===null){if(Qm===null)throw Error(Te(308));vu=e,Qm.dependencies={lanes:0,firstContext:e}}else vu=vu.next=e;return t}var sc=null;function Bv(e){sc===null?sc=[e]:sc.push(e)}function p_(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Bv(t)):(n.next=s.next,s.next=n),t.interleaved=n,ga(e,r)}function ga(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 Ya=!1;function Wv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function h_(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 fa(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function al(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Zt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ga(e,n)}return s=r.interleaved,s===null?(t.next=t,Bv(r)):(t.next=s.next,s.next=t),r.interleaved=t,ga(e,n)}function xm(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,_v(e,n)}}function gS(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=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};o===null?s=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,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 Zm(e,t,n,r){var s=e.updateQueue;Ya=!1;var o=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var u=l,d=u.next;u.next=null,a===null?o=d:a.next=d,a=u;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==a&&(l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=u))}if(o!==null){var c=s.baseState;a=0,p=d=u=null,l=o;do{var f=l.lane,h=l.eventTime;if((r&f)===f){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(f=t,h=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){c=g.call(h,c,f);break e}c=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,f=typeof g=="function"?g.call(h,c,f):g,f==null)break e;c=rr({},c,f);break e;case 2:Ya=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else h={eventTime:h,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(d=p=h,u=c):p=p.next=h,a|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(p===null&&(u=c),s.baseState=u,s.firstBaseUpdate=d,s.lastBaseUpdate=p,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);xc|=a,e.lanes=a,e.memoizedState=c}}function yS(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(Te(191,s));s.call(r)}}}var Tp={},Lo=jl(Tp),tp=jl(Tp),np=jl(Tp);function ic(e){if(e===Tp)throw Error(Te(174));return e}function Vv(e,t){switch(An(np,t),An(tp,e),An(Lo,Tp),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:_w(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=_w(t,e)}Hn(Lo),An(Lo,t)}function qu(){Hn(Lo),Hn(tp),Hn(np)}function m_(e){ic(np.current);var t=ic(Lo.current),n=_w(t,e.type);t!==n&&(An(tp,e),An(Lo,n))}function Kv(e){tp.current===e&&(Hn(Lo),Hn(tp))}var tr=jl(0);function eg(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 dx=[];function Uv(){for(var e=0;e<dx.length;e++)dx[e]._workInProgressVersionPrimary=null;dx.length=0}var wm=va.ReactCurrentDispatcher,fx=va.ReactCurrentBatchConfig,yc=0,nr=null,jr=null,Or=null,tg=!1,_f=!1,rp=0,GL=0;function os(){throw Error(Te(321))}function qv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!no(e[n],t[n]))return!1;return!0}function Yv(e,t,n,r,s,o){if(yc=o,nr=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,wm.current=e===null||e.memoizedState===null?ZL:eO,e=n(r,s),_f){o=0;do{if(_f=!1,rp=0,25<=o)throw Error(Te(301));o+=1,Or=jr=null,t.updateQueue=null,wm.current=tO,e=n(r,s)}while(_f)}if(wm.current=ng,t=jr!==null&&jr.next!==null,yc=0,Or=jr=nr=null,tg=!1,t)throw Error(Te(300));return e}function Gv(){var e=rp!==0;return rp=0,e}function Co(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Or===null?nr.memoizedState=Or=e:Or=Or.next=e,Or}function Ci(){if(jr===null){var e=nr.alternate;e=e!==null?e.memoizedState:null}else e=jr.next;var t=Or===null?nr.memoizedState:Or.next;if(t!==null)Or=t,jr=e;else{if(e===null)throw Error(Te(310));jr=e,e={memoizedState:jr.memoizedState,baseState:jr.baseState,baseQueue:jr.baseQueue,queue:jr.queue,next:null},Or===null?nr.memoizedState=Or=e:Or=Or.next=e}return Or}function sp(e,t){return typeof t=="function"?t(e):t}function px(e){var t=Ci(),n=t.queue;if(n===null)throw Error(Te(311));n.lastRenderedReducer=e;var r=jr,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=a=null,u=null,d=o;do{var p=d.lane;if((yc&p)===p)u!==null&&(u=u.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var c={lane:p,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};u===null?(l=u=c,a=r):u=u.next=c,nr.lanes|=p,xc|=p}d=d.next}while(d!==null&&d!==o);u===null?a=r:u.next=l,no(r,t.memoizedState)||(Os=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=u,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do o=s.lane,nr.lanes|=o,xc|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function hx(e){var t=Ci(),n=t.queue;if(n===null)throw Error(Te(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do o=e(o,a.action),a=a.next;while(a!==s);no(o,t.memoizedState)||(Os=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function g_(){}function y_(e,t){var n=nr,r=Ci(),s=t(),o=!no(r.memoizedState,s);if(o&&(r.memoizedState=s,Os=!0),r=r.queue,Xv(b_.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Or!==null&&Or.memoizedState.tag&1){if(n.flags|=2048,ip(9,w_.bind(null,n,r,s,t),void 0,null),Fr===null)throw Error(Te(349));yc&30||x_(n,t,s)}return s}function x_(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=nr.updateQueue,t===null?(t={lastEffect:null,stores:null},nr.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function w_(e,t,n,r){t.value=n,t.getSnapshot=r,v_(t)&&k_(e)}function b_(e,t,n){return n(function(){v_(t)&&k_(e)})}function v_(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!no(e,n)}catch{return!0}}function k_(e){var t=ga(e,1);t!==null&&to(t,e,1,-1)}function xS(e){var t=Co();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sp,lastRenderedState:e},t.queue=e,e=e.dispatch=QL.bind(null,nr,e),[t.memoizedState,e]}function ip(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=nr.updateQueue,t===null?(t={lastEffect:null,stores:null},nr.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 S_(){return Ci().memoizedState}function bm(e,t,n,r){var s=Co();nr.flags|=e,s.memoizedState=ip(1|t,n,void 0,r===void 0?null:r)}function ny(e,t,n,r){var s=Ci();r=r===void 0?null:r;var o=void 0;if(jr!==null){var a=jr.memoizedState;if(o=a.destroy,r!==null&&qv(r,a.deps)){s.memoizedState=ip(t,n,o,r);return}}nr.flags|=e,s.memoizedState=ip(1|t,n,o,r)}function wS(e,t){return bm(8390656,8,e,t)}function Xv(e,t){return ny(2048,8,e,t)}function N_(e,t){return ny(4,2,e,t)}function j_(e,t){return ny(4,4,e,t)}function C_(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 E_(e,t,n){return n=n!=null?n.concat([e]):null,ny(4,4,C_.bind(null,t,e),n)}function Jv(){}function __(e,t){var n=Ci();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&qv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function P_(e,t){var n=Ci();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&qv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function A_(e,t,n){return yc&21?(no(n,t)||(n=LE(),nr.lanes|=n,xc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Os=!0),e.memoizedState=n)}function XL(e,t){var n=pn;pn=n!==0&&4>n?n:4,e(!0);var r=fx.transition;fx.transition={};try{e(!1),t()}finally{pn=n,fx.transition=r}}function I_(){return Ci().memoizedState}function JL(e,t,n){var r=cl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},T_(e))R_(t,n);else if(n=p_(e,t,n,r),n!==null){var s=Ss();to(n,e,r,s),M_(n,t,r)}}function QL(e,t,n){var r=cl(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(T_(e))R_(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(s.hasEagerState=!0,s.eagerState=l,no(l,a)){var u=t.interleaved;u===null?(s.next=s,Bv(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}n=p_(e,t,s,r),n!==null&&(s=Ss(),to(n,e,r,s),M_(n,t,r))}}function T_(e){var t=e.alternate;return e===nr||t!==null&&t===nr}function R_(e,t){_f=tg=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function M_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_v(e,n)}}var ng={readContext:ji,useCallback:os,useContext:os,useEffect:os,useImperativeHandle:os,useInsertionEffect:os,useLayoutEffect:os,useMemo:os,useReducer:os,useRef:os,useState:os,useDebugValue:os,useDeferredValue:os,useTransition:os,useMutableSource:os,useSyncExternalStore:os,useId:os,unstable_isNewReconciler:!1},ZL={readContext:ji,useCallback:function(e,t){return Co().memoizedState=[e,t===void 0?null:t],e},useContext:ji,useEffect:wS,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,bm(4194308,4,C_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return bm(4194308,4,e,t)},useInsertionEffect:function(e,t){return bm(4,2,e,t)},useMemo:function(e,t){var n=Co();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Co();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=JL.bind(null,nr,e),[r.memoizedState,e]},useRef:function(e){var t=Co();return e={current:e},t.memoizedState=e},useState:xS,useDebugValue:Jv,useDeferredValue:function(e){return Co().memoizedState=e},useTransition:function(){var e=xS(!1),t=e[0];return e=XL.bind(null,e[1]),Co().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=nr,s=Co();if(Gn){if(n===void 0)throw Error(Te(407));n=n()}else{if(n=t(),Fr===null)throw Error(Te(349));yc&30||x_(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,wS(b_.bind(null,r,o,e),[e]),r.flags|=2048,ip(9,w_.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Co(),t=Fr.identifierPrefix;if(Gn){var n=la,r=aa;n=(r&~(1<<32-eo(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=rp++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=GL++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},eO={readContext:ji,useCallback:__,useContext:ji,useEffect:Xv,useImperativeHandle:E_,useInsertionEffect:N_,useLayoutEffect:j_,useMemo:P_,useReducer:px,useRef:S_,useState:function(){return px(sp)},useDebugValue:Jv,useDeferredValue:function(e){var t=Ci();return A_(t,jr.memoizedState,e)},useTransition:function(){var e=px(sp)[0],t=Ci().memoizedState;return[e,t]},useMutableSource:g_,useSyncExternalStore:y_,useId:I_,unstable_isNewReconciler:!1},tO={readContext:ji,useCallback:__,useContext:ji,useEffect:Xv,useImperativeHandle:E_,useInsertionEffect:N_,useLayoutEffect:j_,useMemo:P_,useReducer:hx,useRef:S_,useState:function(){return hx(sp)},useDebugValue:Jv,useDeferredValue:function(e){var t=Ci();return jr===null?t.memoizedState=e:A_(t,jr.memoizedState,e)},useTransition:function(){var e=hx(sp)[0],t=Ci().memoizedState;return[e,t]},useMutableSource:g_,useSyncExternalStore:y_,useId:I_,unstable_isNewReconciler:!1};function Ki(e,t){if(e&&e.defaultProps){t=rr({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Gw(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:rr({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ry={isMounted:function(e){return(e=e._reactInternals)?Ac(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ss(),s=cl(e),o=fa(r,s);o.payload=t,n!=null&&(o.callback=n),t=al(e,o,s),t!==null&&(to(t,e,s,r),xm(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ss(),s=cl(e),o=fa(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=al(e,o,s),t!==null&&(to(t,e,s,r),xm(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ss(),r=cl(e),s=fa(n,r);s.tag=2,t!=null&&(s.callback=t),t=al(e,s,r),t!==null&&(to(t,e,r,n),xm(t,e,r))}};function bS(e,t,n,r,s,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!Jf(n,r)||!Jf(s,o):!0}function L_(e,t,n){var r=!1,s=gl,o=t.contextType;return typeof o=="object"&&o!==null?o=ji(o):(s=Bs(t)?mc:us.current,r=t.contextTypes,o=(r=r!=null)?Vu(e,s):gl),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ry,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function vS(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&&ry.enqueueReplaceState(t,t.state,null)}function Xw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Wv(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=ji(o):(o=Bs(t)?mc:us.current,s.context=Vu(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Gw(e,t,o,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&&ry.enqueueReplaceState(s,s.state,null),Zm(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Yu(e,t){try{var n="",r=t;do n+=PM(r),r=r.return;while(r);var s=n}catch(o){s=`
39
- Error generating stack: `+o.message+`
40
- `+o.stack}return{value:e,source:t,stack:s,digest:null}}function mx(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Jw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var nO=typeof WeakMap=="function"?WeakMap:Map;function O_(e,t,n){n=fa(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){sg||(sg=!0,ab=r),Jw(e,t)},n}function $_(e,t,n){n=fa(-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(){Jw(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Jw(e,t),typeof r!="function"&&(ll===null?ll=new Set([this]):ll.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function kS(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new nO;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=gO.bind(null,e,t,n),t.then(e,e))}function SS(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 NS(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=fa(-1,1),t.tag=2,al(n,t,1))),n.lanes|=1),e)}var rO=va.ReactCurrentOwner,Os=!1;function bs(e,t,n,r){t.child=e===null?f_(t,null,n,r):Uu(t,e.child,n,r)}function jS(e,t,n,r,s){n=n.render;var o=t.ref;return Mu(t,s),r=Yv(e,t,n,r,o,s),n=Gv(),e!==null&&!Os?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ya(e,t,s)):(Gn&&n&&Ov(t),t.flags|=1,bs(e,t,r,s),t.child)}function CS(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!i0(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,D_(e,t,o,r,s)):(e=Nm(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:Jf,n(a,r)&&e.ref===t.ref)return ya(e,t,s)}return t.flags|=1,e=ul(o,r),e.ref=t.ref,e.return=t,t.child=e}function D_(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Jf(o,r)&&e.ref===t.ref)if(Os=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Os=!0);else return t.lanes=e.lanes,ya(e,t,s)}return Qw(e,t,n,r,s)}function F_(e,t,n){var r=t.pendingProps,s=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},An(Su,ti),ti|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,An(Su,ti),ti|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,An(Su,ti),ti|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,An(Su,ti),ti|=r;return bs(e,t,s,n),t.child}function z_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Qw(e,t,n,r,s){var o=Bs(n)?mc:us.current;return o=Vu(t,o),Mu(t,s),n=Yv(e,t,n,r,o,s),r=Gv(),e!==null&&!Os?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ya(e,t,s)):(Gn&&r&&Ov(t),t.flags|=1,bs(e,t,n,s),t.child)}function ES(e,t,n,r,s){if(Bs(n)){var o=!0;Ym(t)}else o=!1;if(Mu(t,s),t.stateNode===null)vm(e,t),L_(t,n,r),Xw(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var u=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=ji(d):(d=Bs(n)?mc:us.current,d=Vu(t,d));var p=n.getDerivedStateFromProps,c=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function";c||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||u!==d)&&vS(t,a,r,d),Ya=!1;var f=t.memoizedState;a.state=f,Zm(t,r,a,s),u=t.memoizedState,l!==r||f!==u||Hs.current||Ya?(typeof p=="function"&&(Gw(t,n,p,r),u=t.memoizedState),(l=Ya||bS(t,n,l,r,f,u,d))?(c||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=u),a.props=r,a.state=u,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,h_(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Ki(t.type,l),a.props=d,c=t.pendingProps,f=a.context,u=n.contextType,typeof u=="object"&&u!==null?u=ji(u):(u=Bs(n)?mc:us.current,u=Vu(t,u));var h=n.getDerivedStateFromProps;(p=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==c||f!==u)&&vS(t,a,r,u),Ya=!1,f=t.memoizedState,a.state=f,Zm(t,r,a,s);var g=t.memoizedState;l!==c||f!==g||Hs.current||Ya?(typeof h=="function"&&(Gw(t,n,h,r),g=t.memoizedState),(d=Ya||bS(t,n,d,r,f,g,u)||!1)?(p||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),a.props=r,a.state=g,a.context=u,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Zw(e,t,n,r,o,s)}function Zw(e,t,n,r,s,o){z_(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&fS(t,n,!1),ya(e,t,o);r=t.stateNode,rO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Uu(t,e.child,null,o),t.child=Uu(t,null,l,o)):bs(e,t,l,o),t.memoizedState=r.state,s&&fS(t,n,!0),t.child}function H_(e){var t=e.stateNode;t.pendingContext?dS(e,t.pendingContext,t.pendingContext!==t.context):t.context&&dS(e,t.context,!1),Vv(e,t.containerInfo)}function _S(e,t,n,r,s){return Ku(),Dv(s),t.flags|=256,bs(e,t,n,r),t.child}var eb={dehydrated:null,treeContext:null,retryLane:0};function tb(e){return{baseLanes:e,cachePool:null,transitions:null}}function B_(e,t,n){var r=t.pendingProps,s=tr.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),An(tr,s&1),e===null)return qw(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,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=oy(a,r,0,null),e=cc(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=tb(n),t.memoizedState=eb,e):Qv(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return sO(e,t,a,r,l,s,n);if(o){o=r.fallback,a=t.mode,s=e.child,l=s.sibling;var u={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=ul(s,u),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=ul(l,o):(o=cc(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?tb(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=eb,r}return o=e.child,e=o.sibling,r=ul(o,{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 Qv(e,t){return t=oy({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ih(e,t,n,r){return r!==null&&Dv(r),Uu(t,e.child,null,n),e=Qv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function sO(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=mx(Error(Te(422))),Ih(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=oy({mode:"visible",children:r.children},s,0,null),o=cc(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Uu(t,e.child,null,a),t.child.memoizedState=tb(a),t.memoizedState=eb,o);if(!(t.mode&1))return Ih(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Te(419)),r=mx(o,r,void 0),Ih(e,t,a,r)}if(l=(a&e.childLanes)!==0,Os||l){if(r=Fr,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!==o.retryLane&&(o.retryLane=s,ga(e,s),to(r,e,s,-1))}return s0(),r=mx(Error(Te(421))),Ih(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=yO.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,si=ol(s.nextSibling),oi=t,Gn=!0,Gi=null,e!==null&&(wi[bi++]=aa,wi[bi++]=la,wi[bi++]=gc,aa=e.id,la=e.overflow,gc=t),t=Qv(t,r.children),t.flags|=4096,t)}function PS(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Yw(e.return,t,n)}function gx(e,t,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function W_(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(bs(e,t,r.children,n),r=tr.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&&PS(e,n,t);else if(e.tag===19)PS(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(An(tr,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&&eg(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),gx(t,!1,s,n,o);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&eg(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}gx(t,!0,n,null,o);break;case"together":gx(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function vm(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ya(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),xc|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Te(153));if(t.child!==null){for(e=t.child,n=ul(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ul(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function iO(e,t,n){switch(t.tag){case 3:H_(t),Ku();break;case 5:m_(t);break;case 1:Bs(t.type)&&Ym(t);break;case 4:Vv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;An(Jm,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(An(tr,tr.current&1),t.flags|=128,null):n&t.child.childLanes?B_(e,t,n):(An(tr,tr.current&1),e=ya(e,t,n),e!==null?e.sibling:null);An(tr,tr.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return W_(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),An(tr,tr.current),r)break;return null;case 22:case 23:return t.lanes=0,F_(e,t,n)}return ya(e,t,n)}var V_,nb,K_,U_;V_=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}};nb=function(){};K_=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,ic(Lo.current);var o=null;switch(n){case"input":s=Nw(e,s),r=Nw(e,r),o=[];break;case"select":s=rr({},s,{value:void 0}),r=rr({},r,{value:void 0}),o=[];break;case"textarea":s=Ew(e,s),r=Ew(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Um)}Pw(n,r);var a;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Vf.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in r){var u=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&u!==l&&(u!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in u)u.hasOwnProperty(a)&&l[a]!==u[a]&&(n||(n={}),n[a]=u[a])}else n||(o||(o=[]),o.push(d,n)),n=u;else d==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,l=l?l.__html:void 0,u!=null&&l!==u&&(o=o||[]).push(d,u)):d==="children"?typeof u!="string"&&typeof u!="number"||(o=o||[]).push(d,""+u):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Vf.hasOwnProperty(d)?(u!=null&&d==="onScroll"&&Dn("scroll",e),o||l===u||(o=[])):(o=o||[]).push(d,u))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};U_=function(e,t,n,r){n!==r&&(t.flags|=4)};function Zd(e,t){if(!Gn)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 as(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 oO(e,t,n){var r=t.pendingProps;switch($v(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return as(t),null;case 1:return Bs(t.type)&&qm(),as(t),null;case 3:return r=t.stateNode,qu(),Hn(Hs),Hn(us),Uv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ph(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Gi!==null&&(ub(Gi),Gi=null))),nb(e,t),as(t),null;case 5:Kv(t);var s=ic(np.current);if(n=t.type,e!==null&&t.stateNode!=null)K_(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Te(166));return as(t),null}if(e=ic(Lo.current),Ph(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ao]=t,r[ep]=o,e=(t.mode&1)!==0,n){case"dialog":Dn("cancel",r),Dn("close",r);break;case"iframe":case"object":case"embed":Dn("load",r);break;case"video":case"audio":for(s=0;s<mf.length;s++)Dn(mf[s],r);break;case"source":Dn("error",r);break;case"img":case"image":case"link":Dn("error",r),Dn("load",r);break;case"details":Dn("toggle",r);break;case"input":Dk(r,o),Dn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Dn("invalid",r);break;case"textarea":zk(r,o),Dn("invalid",r)}Pw(n,o),s=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&_h(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&_h(r.textContent,l,e),s=["children",""+l]):Vf.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Dn("scroll",r)}switch(n){case"input":bh(r),Fk(r,o,!0);break;case"textarea":bh(r),Hk(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Um)}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=bE(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[Ao]=t,e[ep]=r,V_(e,t,!1,!1),t.stateNode=e;e:{switch(a=Aw(n,r),n){case"dialog":Dn("cancel",e),Dn("close",e),s=r;break;case"iframe":case"object":case"embed":Dn("load",e),s=r;break;case"video":case"audio":for(s=0;s<mf.length;s++)Dn(mf[s],e);s=r;break;case"source":Dn("error",e),s=r;break;case"img":case"image":case"link":Dn("error",e),Dn("load",e),s=r;break;case"details":Dn("toggle",e),s=r;break;case"input":Dk(e,r),s=Nw(e,r),Dn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=rr({},r,{value:void 0}),Dn("invalid",e);break;case"textarea":zk(e,r),s=Ew(e,r),Dn("invalid",e);break;default:s=r}Pw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var u=l[o];o==="style"?SE(e,u):o==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&vE(e,u)):o==="children"?typeof u=="string"?(n!=="textarea"||u!=="")&&Kf(e,u):typeof u=="number"&&Kf(e,""+u):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Vf.hasOwnProperty(o)?u!=null&&o==="onScroll"&&Dn("scroll",e):u!=null&&kv(e,o,u,a))}switch(n){case"input":bh(e),Fk(e,r,!1);break;case"textarea":bh(e),Hk(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ml(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Au(e,!!r.multiple,o,!1):r.defaultValue!=null&&Au(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Um)}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 as(t),null;case 6:if(e&&t.stateNode!=null)U_(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Te(166));if(n=ic(np.current),ic(Lo.current),Ph(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ao]=t,(o=r.nodeValue!==n)&&(e=oi,e!==null))switch(e.tag){case 3:_h(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&_h(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ao]=t,t.stateNode=r}return as(t),null;case 13:if(Hn(tr),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Gn&&si!==null&&t.mode&1&&!(t.flags&128))u_(),Ku(),t.flags|=98560,o=!1;else if(o=Ph(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Te(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Te(317));o[Ao]=t}else Ku(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;as(t),o=!1}else Gi!==null&&(ub(Gi),Gi=null),o=!0;if(!o)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||tr.current&1?Er===0&&(Er=3):s0())),t.updateQueue!==null&&(t.flags|=4),as(t),null);case 4:return qu(),nb(e,t),e===null&&Qf(t.stateNode.containerInfo),as(t),null;case 10:return Hv(t.type._context),as(t),null;case 17:return Bs(t.type)&&qm(),as(t),null;case 19:if(Hn(tr),o=t.memoizedState,o===null)return as(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Zd(o,!1);else{if(Er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=eg(e),a!==null){for(t.flags|=128,Zd(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return An(tr,tr.current&1|2),t.child}e=e.sibling}o.tail!==null&&pr()>Gu&&(t.flags|=128,r=!0,Zd(o,!1),t.lanes=4194304)}else{if(!r)if(e=eg(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Zd(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Gn)return as(t),null}else 2*pr()-o.renderingStartTime>Gu&&n!==1073741824&&(t.flags|=128,r=!0,Zd(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=pr(),t.sibling=null,n=tr.current,An(tr,r?n&1|2:n&1),t):(as(t),null);case 22:case 23:return r0(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ti&1073741824&&(as(t),t.subtreeFlags&6&&(t.flags|=8192)):as(t),null;case 24:return null;case 25:return null}throw Error(Te(156,t.tag))}function aO(e,t){switch($v(t),t.tag){case 1:return Bs(t.type)&&qm(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return qu(),Hn(Hs),Hn(us),Uv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Kv(t),null;case 13:if(Hn(tr),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Te(340));Ku()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Hn(tr),null;case 4:return qu(),null;case 10:return Hv(t.type._context),null;case 22:case 23:return r0(),null;case 24:return null;default:return null}}var Th=!1,ls=!1,lO=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function ku(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ar(e,t,r)}else n.current=null}function rb(e,t,n){try{n()}catch(r){ar(e,t,r)}}var AS=!1;function cO(e,t){if(zw=Wm,e=JE(),Lv(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,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,u=-1,d=0,p=0,c=e,f=null;t:for(;;){for(var h;c!==n||s!==0&&c.nodeType!==3||(l=a+s),c!==o||r!==0&&c.nodeType!==3||(u=a+r),c.nodeType===3&&(a+=c.nodeValue.length),(h=c.firstChild)!==null;)f=c,c=h;for(;;){if(c===e)break t;if(f===n&&++d===s&&(l=a),f===o&&++p===r&&(u=a),(h=c.nextSibling)!==null)break;c=f,f=c.parentNode}c=h}n=l===-1||u===-1?null:{start:l,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Hw={focusedElem:e,selectionRange:n},Wm=!1,Xe=t;Xe!==null;)if(t=Xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Xe=e;else for(;Xe!==null;){t=Xe;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,k=g.memoizedState,y=t.stateNode,w=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:Ki(t.type,b),k);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(Te(163))}}catch(N){ar(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return g=AS,AS=!1,g}function Pf(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 o=s.destroy;s.destroy=void 0,o!==void 0&&rb(t,n,o)}s=s.next}while(s!==r)}}function sy(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 sb(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 q_(e){var t=e.alternate;t!==null&&(e.alternate=null,q_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ao],delete t[ep],delete t[Vw],delete t[KL],delete t[UL])),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 Y_(e){return e.tag===5||e.tag===3||e.tag===4}function IS(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Y_(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 ib(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=Um));else if(r!==4&&(e=e.child,e!==null))for(ib(e,t,n),e=e.sibling;e!==null;)ib(e,t,n),e=e.sibling}function ob(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(ob(e,t,n),e=e.sibling;e!==null;)ob(e,t,n),e=e.sibling}var Gr=null,qi=!1;function Ha(e,t,n){for(n=n.child;n!==null;)G_(e,t,n),n=n.sibling}function G_(e,t,n){if(Mo&&typeof Mo.onCommitFiberUnmount=="function")try{Mo.onCommitFiberUnmount(Xg,n)}catch{}switch(n.tag){case 5:ls||ku(n,t);case 6:var r=Gr,s=qi;Gr=null,Ha(e,t,n),Gr=r,qi=s,Gr!==null&&(qi?(e=Gr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Gr.removeChild(n.stateNode));break;case 18:Gr!==null&&(qi?(e=Gr,n=n.stateNode,e.nodeType===8?cx(e.parentNode,n):e.nodeType===1&&cx(e,n),Gf(e)):cx(Gr,n.stateNode));break;case 4:r=Gr,s=qi,Gr=n.stateNode.containerInfo,qi=!0,Ha(e,t,n),Gr=r,qi=s;break;case 0:case 11:case 14:case 15:if(!ls&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&rb(n,t,a),s=s.next}while(s!==r)}Ha(e,t,n);break;case 1:if(!ls&&(ku(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ar(n,t,l)}Ha(e,t,n);break;case 21:Ha(e,t,n);break;case 22:n.mode&1?(ls=(r=ls)||n.memoizedState!==null,Ha(e,t,n),ls=r):Ha(e,t,n);break;default:Ha(e,t,n)}}function TS(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new lO),t.forEach(function(r){var s=xO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Hi(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Gr=l.stateNode,qi=!1;break e;case 3:Gr=l.stateNode.containerInfo,qi=!0;break e;case 4:Gr=l.stateNode.containerInfo,qi=!0;break e}l=l.return}if(Gr===null)throw Error(Te(160));G_(o,a,s),Gr=null,qi=!1;var u=s.alternate;u!==null&&(u.return=null),s.return=null}catch(d){ar(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)X_(t,e),t=t.sibling}function X_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Hi(t,e),No(e),r&4){try{Pf(3,e,e.return),sy(3,e)}catch(b){ar(e,e.return,b)}try{Pf(5,e,e.return)}catch(b){ar(e,e.return,b)}}break;case 1:Hi(t,e),No(e),r&512&&n!==null&&ku(n,n.return);break;case 5:if(Hi(t,e),No(e),r&512&&n!==null&&ku(n,n.return),e.flags&32){var s=e.stateNode;try{Kf(s,"")}catch(b){ar(e,e.return,b)}}if(r&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&xE(s,o),Aw(l,a);var d=Aw(l,o);for(a=0;a<u.length;a+=2){var p=u[a],c=u[a+1];p==="style"?SE(s,c):p==="dangerouslySetInnerHTML"?vE(s,c):p==="children"?Kf(s,c):kv(s,p,c,d)}switch(l){case"input":jw(s,o);break;case"textarea":wE(s,o);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?Au(s,!!o.multiple,h,!1):f!==!!o.multiple&&(o.defaultValue!=null?Au(s,!!o.multiple,o.defaultValue,!0):Au(s,!!o.multiple,o.multiple?[]:"",!1))}s[ep]=o}catch(b){ar(e,e.return,b)}}break;case 6:if(Hi(t,e),No(e),r&4){if(e.stateNode===null)throw Error(Te(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(b){ar(e,e.return,b)}}break;case 3:if(Hi(t,e),No(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Gf(t.containerInfo)}catch(b){ar(e,e.return,b)}break;case 4:Hi(t,e),No(e);break;case 13:Hi(t,e),No(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(t0=pr())),r&4&&TS(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(ls=(d=ls)||p,Hi(t,e),ls=d):Hi(t,e),No(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!p&&e.mode&1)for(Xe=e,p=e.child;p!==null;){for(c=Xe=p;Xe!==null;){switch(f=Xe,h=f.child,f.tag){case 0:case 11:case 14:case 15:Pf(4,f,f.return);break;case 1:ku(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(b){ar(r,n,b)}}break;case 5:ku(f,f.return);break;case 22:if(f.memoizedState!==null){MS(c);continue}}h!==null?(h.return=f,Xe=h):MS(c)}p=p.sibling}e:for(p=null,c=e;;){if(c.tag===5){if(p===null){p=c;try{s=c.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=c.stateNode,u=c.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,l.style.display=kE("display",a))}catch(b){ar(e,e.return,b)}}}else if(c.tag===6){if(p===null)try{c.stateNode.nodeValue=d?"":c.memoizedProps}catch(b){ar(e,e.return,b)}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===e)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===e)break e;for(;c.sibling===null;){if(c.return===null||c.return===e)break e;p===c&&(p=null),c=c.return}p===c&&(p=null),c.sibling.return=c.return,c=c.sibling}}break;case 19:Hi(t,e),No(e),r&4&&TS(e);break;case 21:break;default:Hi(t,e),No(e)}}function No(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Y_(n)){var r=n;break e}n=n.return}throw Error(Te(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Kf(s,""),r.flags&=-33);var o=IS(e);ob(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=IS(e);ib(e,l,a);break;default:throw Error(Te(161))}}catch(u){ar(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function uO(e,t,n){Xe=e,J_(e)}function J_(e,t,n){for(var r=(e.mode&1)!==0;Xe!==null;){var s=Xe,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Th;if(!a){var l=s.alternate,u=l!==null&&l.memoizedState!==null||ls;l=Th;var d=ls;if(Th=a,(ls=u)&&!d)for(Xe=s;Xe!==null;)a=Xe,u=a.child,a.tag===22&&a.memoizedState!==null?LS(s):u!==null?(u.return=a,Xe=u):LS(s);for(;o!==null;)Xe=o,J_(o),o=o.sibling;Xe=s,Th=l,ls=d}RS(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Xe=o):RS(e)}}function RS(e){for(;Xe!==null;){var t=Xe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:ls||sy(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!ls)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Ki(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&yS(t,o,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}yS(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&n.focus();break;case"img":u.src&&(n.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var p=d.memoizedState;if(p!==null){var c=p.dehydrated;c!==null&&Gf(c)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Te(163))}ls||t.flags&512&&sb(t)}catch(f){ar(t,t.return,f)}}if(t===e){Xe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function MS(e){for(;Xe!==null;){var t=Xe;if(t===e){Xe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function LS(e){for(;Xe!==null;){var t=Xe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{sy(4,t)}catch(u){ar(t,n,u)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(u){ar(t,s,u)}}var o=t.return;try{sb(t)}catch(u){ar(t,o,u)}break;case 5:var a=t.return;try{sb(t)}catch(u){ar(t,a,u)}}}catch(u){ar(t,t.return,u)}if(t===e){Xe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Xe=l;break}Xe=t.return}}var dO=Math.ceil,rg=va.ReactCurrentDispatcher,Zv=va.ReactCurrentOwner,Ni=va.ReactCurrentBatchConfig,Zt=0,Fr=null,wr=null,Xr=0,ti=0,Su=jl(0),Er=0,op=null,xc=0,iy=0,e0=0,Af=null,Ls=null,t0=0,Gu=1/0,ra=null,sg=!1,ab=null,ll=null,Rh=!1,el=null,ig=0,If=0,lb=null,km=-1,Sm=0;function Ss(){return Zt&6?pr():km!==-1?km:km=pr()}function cl(e){return e.mode&1?Zt&2&&Xr!==0?Xr&-Xr:YL.transition!==null?(Sm===0&&(Sm=LE()),Sm):(e=pn,e!==0||(e=window.event,e=e===void 0?16:BE(e.type)),e):1}function to(e,t,n,r){if(50<If)throw If=0,lb=null,Error(Te(185));Pp(e,n,r),(!(Zt&2)||e!==Fr)&&(e===Fr&&(!(Zt&2)&&(iy|=n),Er===4&&Ja(e,Xr)),Ws(e,r),n===1&&Zt===0&&!(t.mode&1)&&(Gu=pr()+500,ty&&Cl()))}function Ws(e,t){var n=e.callbackNode;YM(e,t);var r=Bm(e,e===Fr?Xr:0);if(r===0)n!==null&&Vk(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Vk(n),t===1)e.tag===0?qL(OS.bind(null,e)):a_(OS.bind(null,e)),WL(function(){!(Zt&6)&&Cl()}),n=null;else{switch(OE(r)){case 1:n=Ev;break;case 4:n=RE;break;case 16:n=Hm;break;case 536870912:n=ME;break;default:n=Hm}n=iP(n,Q_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Q_(e,t){if(km=-1,Sm=0,Zt&6)throw Error(Te(327));var n=e.callbackNode;if(Lu()&&e.callbackNode!==n)return null;var r=Bm(e,e===Fr?Xr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=og(e,r);else{t=r;var s=Zt;Zt|=2;var o=eP();(Fr!==e||Xr!==t)&&(ra=null,Gu=pr()+500,lc(e,t));do try{hO();break}catch(l){Z_(e,l)}while(!0);zv(),rg.current=o,Zt=s,wr!==null?t=0:(Fr=null,Xr=0,t=Er)}if(t!==0){if(t===2&&(s=Lw(e),s!==0&&(r=s,t=cb(e,s))),t===1)throw n=op,lc(e,0),Ja(e,r),Ws(e,pr()),n;if(t===6)Ja(e,r);else{if(s=e.current.alternate,!(r&30)&&!fO(s)&&(t=og(e,r),t===2&&(o=Lw(e),o!==0&&(r=o,t=cb(e,o))),t===1))throw n=op,lc(e,0),Ja(e,r),Ws(e,pr()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Te(345));case 2:Zl(e,Ls,ra);break;case 3:if(Ja(e,r),(r&130023424)===r&&(t=t0+500-pr(),10<t)){if(Bm(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Ss(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Ww(Zl.bind(null,e,Ls,ra),t);break}Zl(e,Ls,ra);break;case 4:if(Ja(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-eo(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=pr()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*dO(r/1960))-r,10<r){e.timeoutHandle=Ww(Zl.bind(null,e,Ls,ra),r);break}Zl(e,Ls,ra);break;case 5:Zl(e,Ls,ra);break;default:throw Error(Te(329))}}}return Ws(e,pr()),e.callbackNode===n?Q_.bind(null,e):null}function cb(e,t){var n=Af;return e.current.memoizedState.isDehydrated&&(lc(e,t).flags|=256),e=og(e,t),e!==2&&(t=Ls,Ls=n,t!==null&&ub(t)),e}function ub(e){Ls===null?Ls=e:Ls.push.apply(Ls,e)}function fO(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],o=s.getSnapshot;s=s.value;try{if(!no(o(),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 Ja(e,t){for(t&=~e0,t&=~iy,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-eo(t),r=1<<n;e[n]=-1,t&=~r}}function OS(e){if(Zt&6)throw Error(Te(327));Lu();var t=Bm(e,0);if(!(t&1))return Ws(e,pr()),null;var n=og(e,t);if(e.tag!==0&&n===2){var r=Lw(e);r!==0&&(t=r,n=cb(e,r))}if(n===1)throw n=op,lc(e,0),Ja(e,t),Ws(e,pr()),n;if(n===6)throw Error(Te(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Zl(e,Ls,ra),Ws(e,pr()),null}function n0(e,t){var n=Zt;Zt|=1;try{return e(t)}finally{Zt=n,Zt===0&&(Gu=pr()+500,ty&&Cl())}}function wc(e){el!==null&&el.tag===0&&!(Zt&6)&&Lu();var t=Zt;Zt|=1;var n=Ni.transition,r=pn;try{if(Ni.transition=null,pn=1,e)return e()}finally{pn=r,Ni.transition=n,Zt=t,!(Zt&6)&&Cl()}}function r0(){ti=Su.current,Hn(Su)}function lc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,BL(n)),wr!==null)for(n=wr.return;n!==null;){var r=n;switch($v(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&qm();break;case 3:qu(),Hn(Hs),Hn(us),Uv();break;case 5:Kv(r);break;case 4:qu();break;case 13:Hn(tr);break;case 19:Hn(tr);break;case 10:Hv(r.type._context);break;case 22:case 23:r0()}n=n.return}if(Fr=e,wr=e=ul(e.current,null),Xr=ti=t,Er=0,op=null,e0=iy=xc=0,Ls=Af=null,sc!==null){for(t=0;t<sc.length;t++)if(n=sc[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=s,r.next=a}n.pending=r}sc=null}return e}function Z_(e,t){do{var n=wr;try{if(zv(),wm.current=ng,tg){for(var r=nr.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}tg=!1}if(yc=0,Or=jr=nr=null,_f=!1,rp=0,Zv.current=null,n===null||n.return===null){Er=1,op=t,wr=null;break}e:{var o=e,a=n.return,l=n,u=t;if(t=Xr,l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var d=u,p=l,c=p.tag;if(!(p.mode&1)&&(c===0||c===11||c===15)){var f=p.alternate;f?(p.updateQueue=f.updateQueue,p.memoizedState=f.memoizedState,p.lanes=f.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=SS(a);if(h!==null){h.flags&=-257,NS(h,a,l,o,t),h.mode&1&&kS(o,d,t),t=h,u=d;var g=t.updateQueue;if(g===null){var b=new Set;b.add(u),t.updateQueue=b}else g.add(u);break e}else{if(!(t&1)){kS(o,d,t),s0();break e}u=Error(Te(426))}}else if(Gn&&l.mode&1){var k=SS(a);if(k!==null){!(k.flags&65536)&&(k.flags|=256),NS(k,a,l,o,t),Dv(Yu(u,l));break e}}o=u=Yu(u,l),Er!==4&&(Er=2),Af===null?Af=[o]:Af.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var y=O_(o,u,t);gS(o,y);break e;case 1:l=u;var w=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof w.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(ll===null||!ll.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var N=$_(o,l,t);gS(o,N);break e}}o=o.return}while(o!==null)}nP(n)}catch(_){t=_,wr===n&&n!==null&&(wr=n=n.return);continue}break}while(!0)}function eP(){var e=rg.current;return rg.current=ng,e===null?ng:e}function s0(){(Er===0||Er===3||Er===2)&&(Er=4),Fr===null||!(xc&268435455)&&!(iy&268435455)||Ja(Fr,Xr)}function og(e,t){var n=Zt;Zt|=2;var r=eP();(Fr!==e||Xr!==t)&&(ra=null,lc(e,t));do try{pO();break}catch(s){Z_(e,s)}while(!0);if(zv(),Zt=n,rg.current=r,wr!==null)throw Error(Te(261));return Fr=null,Xr=0,Er}function pO(){for(;wr!==null;)tP(wr)}function hO(){for(;wr!==null&&!FM();)tP(wr)}function tP(e){var t=sP(e.alternate,e,ti);e.memoizedProps=e.pendingProps,t===null?nP(e):wr=t,Zv.current=null}function nP(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=aO(n,t),n!==null){n.flags&=32767,wr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Er=6,wr=null;return}}else if(n=oO(n,t,ti),n!==null){wr=n;return}if(t=t.sibling,t!==null){wr=t;return}wr=t=e}while(t!==null);Er===0&&(Er=5)}function Zl(e,t,n){var r=pn,s=Ni.transition;try{Ni.transition=null,pn=1,mO(e,t,n,r)}finally{Ni.transition=s,pn=r}return null}function mO(e,t,n,r){do Lu();while(el!==null);if(Zt&6)throw Error(Te(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(Te(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(GM(e,o),e===Fr&&(wr=Fr=null,Xr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Rh||(Rh=!0,iP(Hm,function(){return Lu(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Ni.transition,Ni.transition=null;var a=pn;pn=1;var l=Zt;Zt|=4,Zv.current=null,cO(e,n),X_(n,e),LL(Hw),Wm=!!zw,Hw=zw=null,e.current=n,uO(n),zM(),Zt=l,pn=a,Ni.transition=o}else e.current=n;if(Rh&&(Rh=!1,el=e,ig=s),o=e.pendingLanes,o===0&&(ll=null),WM(n.stateNode),Ws(e,pr()),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(sg)throw sg=!1,e=ab,ab=null,e;return ig&1&&e.tag!==0&&Lu(),o=e.pendingLanes,o&1?e===lb?If++:(If=0,lb=e):If=0,Cl(),null}function Lu(){if(el!==null){var e=OE(ig),t=Ni.transition,n=pn;try{if(Ni.transition=null,pn=16>e?16:e,el===null)var r=!1;else{if(e=el,el=null,ig=0,Zt&6)throw Error(Te(331));var s=Zt;for(Zt|=4,Xe=e.current;Xe!==null;){var o=Xe,a=o.child;if(Xe.flags&16){var l=o.deletions;if(l!==null){for(var u=0;u<l.length;u++){var d=l[u];for(Xe=d;Xe!==null;){var p=Xe;switch(p.tag){case 0:case 11:case 15:Pf(8,p,o)}var c=p.child;if(c!==null)c.return=p,Xe=c;else for(;Xe!==null;){p=Xe;var f=p.sibling,h=p.return;if(q_(p),p===d){Xe=null;break}if(f!==null){f.return=h,Xe=f;break}Xe=h}}}var g=o.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var k=b.sibling;b.sibling=null,b=k}while(b!==null)}}Xe=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Xe=a;else e:for(;Xe!==null;){if(o=Xe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Pf(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,Xe=y;break e}Xe=o.return}}var w=e.current;for(Xe=w;Xe!==null;){a=Xe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Xe=x;else e:for(a=w;Xe!==null;){if(l=Xe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:sy(9,l)}}catch(_){ar(l,l.return,_)}if(l===a){Xe=null;break e}var N=l.sibling;if(N!==null){N.return=l.return,Xe=N;break e}Xe=l.return}}if(Zt=s,Cl(),Mo&&typeof Mo.onPostCommitFiberRoot=="function")try{Mo.onPostCommitFiberRoot(Xg,e)}catch{}r=!0}return r}finally{pn=n,Ni.transition=t}}return!1}function $S(e,t,n){t=Yu(n,t),t=O_(e,t,1),e=al(e,t,1),t=Ss(),e!==null&&(Pp(e,1,t),Ws(e,t))}function ar(e,t,n){if(e.tag===3)$S(e,e,n);else for(;t!==null;){if(t.tag===3){$S(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ll===null||!ll.has(r))){e=Yu(n,e),e=$_(t,e,1),t=al(t,e,1),e=Ss(),t!==null&&(Pp(t,1,e),Ws(t,e));break}}t=t.return}}function gO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ss(),e.pingedLanes|=e.suspendedLanes&n,Fr===e&&(Xr&n)===n&&(Er===4||Er===3&&(Xr&130023424)===Xr&&500>pr()-t0?lc(e,0):e0|=n),Ws(e,t)}function rP(e,t){t===0&&(e.mode&1?(t=Sh,Sh<<=1,!(Sh&130023424)&&(Sh=4194304)):t=1);var n=Ss();e=ga(e,t),e!==null&&(Pp(e,t,n),Ws(e,n))}function yO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),rP(e,n)}function xO(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(Te(314))}r!==null&&r.delete(t),rP(e,n)}var sP;sP=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Hs.current)Os=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Os=!1,iO(e,t,n);Os=!!(e.flags&131072)}else Os=!1,Gn&&t.flags&1048576&&l_(t,Xm,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;vm(e,t),e=t.pendingProps;var s=Vu(t,us.current);Mu(t,n),s=Yv(null,t,r,e,s,n);var o=Gv();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,Bs(r)?(o=!0,Ym(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Wv(t),s.updater=ry,t.stateNode=s,s._reactInternals=t,Xw(t,r,e,n),t=Zw(null,t,r,!0,o,n)):(t.tag=0,Gn&&o&&Ov(t),bs(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(vm(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=bO(r),e=Ki(r,e),s){case 0:t=Qw(null,t,r,e,n);break e;case 1:t=ES(null,t,r,e,n);break e;case 11:t=jS(null,t,r,e,n);break e;case 14:t=CS(null,t,r,Ki(r.type,e),n);break e}throw Error(Te(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ki(r,s),Qw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ki(r,s),ES(e,t,r,s,n);case 3:e:{if(H_(t),e===null)throw Error(Te(387));r=t.pendingProps,o=t.memoizedState,s=o.element,h_(e,t),Zm(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=Yu(Error(Te(423)),t),t=_S(e,t,r,n,s);break e}else if(r!==s){s=Yu(Error(Te(424)),t),t=_S(e,t,r,n,s);break e}else for(si=ol(t.stateNode.containerInfo.firstChild),oi=t,Gn=!0,Gi=null,n=f_(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ku(),r===s){t=ya(e,t,n);break e}bs(e,t,r,n)}t=t.child}return t;case 5:return m_(t),e===null&&qw(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,Bw(r,s)?a=null:o!==null&&Bw(r,o)&&(t.flags|=32),z_(e,t),bs(e,t,a,n),t.child;case 6:return e===null&&qw(t),null;case 13:return B_(e,t,n);case 4:return Vv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Uu(t,null,r,n):bs(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ki(r,s),jS(e,t,r,s,n);case 7:return bs(e,t,t.pendingProps,n),t.child;case 8:return bs(e,t,t.pendingProps.children,n),t.child;case 12:return bs(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,a=s.value,An(Jm,r._currentValue),r._currentValue=a,o!==null)if(no(o.value,a)){if(o.children===s.children&&!Hs.current){t=ya(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var u=l.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=fa(-1,n&-n),u.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var p=d.pending;p===null?u.next=u:(u.next=p.next,p.next=u),d.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),Yw(o.return,n,t),l.lanes|=n;break}u=u.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Te(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),Yw(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}bs(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Mu(t,n),s=ji(s),r=r(s),t.flags|=1,bs(e,t,r,n),t.child;case 14:return r=t.type,s=Ki(r,t.pendingProps),s=Ki(r.type,s),CS(e,t,r,s,n);case 15:return D_(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ki(r,s),vm(e,t),t.tag=1,Bs(r)?(e=!0,Ym(t)):e=!1,Mu(t,n),L_(t,r,s),Xw(t,r,s,n),Zw(null,t,r,!0,e,n);case 19:return W_(e,t,n);case 22:return F_(e,t,n)}throw Error(Te(156,t.tag))};function iP(e,t){return TE(e,t)}function wO(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 Si(e,t,n,r){return new wO(e,t,n,r)}function i0(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bO(e){if(typeof e=="function")return i0(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Nv)return 11;if(e===jv)return 14}return 2}function ul(e,t){var n=e.alternate;return n===null?(n=Si(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 Nm(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")i0(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case pu:return cc(n.children,s,o,t);case Sv:a=8,s|=8;break;case bw:return e=Si(12,n,t,s|2),e.elementType=bw,e.lanes=o,e;case vw:return e=Si(13,n,t,s),e.elementType=vw,e.lanes=o,e;case kw:return e=Si(19,n,t,s),e.elementType=kw,e.lanes=o,e;case mE:return oy(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pE:a=10;break e;case hE:a=9;break e;case Nv:a=11;break e;case jv:a=14;break e;case qa:a=16,r=null;break e}throw Error(Te(130,e==null?e:typeof e,""))}return t=Si(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function cc(e,t,n,r){return e=Si(7,e,r,t),e.lanes=n,e}function oy(e,t,n,r){return e=Si(22,e,r,t),e.elementType=mE,e.lanes=n,e.stateNode={isHidden:!1},e}function yx(e,t,n){return e=Si(6,e,null,t),e.lanes=n,e}function xx(e,t,n){return t=Si(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function vO(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=Qy(0),this.expirationTimes=Qy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function o0(e,t,n,r,s,o,a,l,u){return e=new vO(e,t,n,l,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Si(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wv(o),e}function kO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:fu,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function oP(e){if(!e)return gl;e=e._reactInternals;e:{if(Ac(e)!==e||e.tag!==1)throw Error(Te(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Bs(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Te(171))}if(e.tag===1){var n=e.type;if(Bs(n))return o_(e,n,t)}return t}function aP(e,t,n,r,s,o,a,l,u){return e=o0(n,r,!0,e,s,o,a,l,u),e.context=oP(null),n=e.current,r=Ss(),s=cl(n),o=fa(r,s),o.callback=t??null,al(n,o,s),e.current.lanes=s,Pp(e,s,r),Ws(e,r),e}function ay(e,t,n,r){var s=t.current,o=Ss(),a=cl(s);return n=oP(n),t.context===null?t.context=n:t.pendingContext=n,t=fa(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=al(s,t,a),e!==null&&(to(e,s,a,o),xm(e,s,a)),a}function ag(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 DS(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function a0(e,t){DS(e,t),(e=e.alternate)&&DS(e,t)}function SO(){return null}var lP=typeof reportError=="function"?reportError:function(e){console.error(e)};function l0(e){this._internalRoot=e}ly.prototype.render=l0.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Te(409));ay(e,t,null,null)};ly.prototype.unmount=l0.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wc(function(){ay(null,e,null,null)}),t[ma]=null}};function ly(e){this._internalRoot=e}ly.prototype.unstable_scheduleHydration=function(e){if(e){var t=FE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Xa.length&&t!==0&&t<Xa[n].priority;n++);Xa.splice(n,0,e),n===0&&HE(e)}};function c0(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function cy(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function FS(){}function NO(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=ag(a);o.call(d)}}var a=aP(t,r,e,0,null,!1,!1,"",FS);return e._reactRootContainer=a,e[ma]=a.current,Qf(e.nodeType===8?e.parentNode:e),wc(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=ag(u);l.call(d)}}var u=o0(e,0,!1,null,null,!1,!1,"",FS);return e._reactRootContainer=u,e[ma]=u.current,Qf(e.nodeType===8?e.parentNode:e),wc(function(){ay(t,u,n,r)}),u}function uy(e,t,n,r,s){var o=n._reactRootContainer;if(o){var a=o;if(typeof s=="function"){var l=s;s=function(){var u=ag(a);l.call(u)}}ay(t,a,e,s)}else a=NO(n,t,e,s,r);return ag(a)}$E=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=hf(t.pendingLanes);n!==0&&(_v(t,n|1),Ws(t,pr()),!(Zt&6)&&(Gu=pr()+500,Cl()))}break;case 13:wc(function(){var r=ga(e,1);if(r!==null){var s=Ss();to(r,e,1,s)}}),a0(e,1)}};Pv=function(e){if(e.tag===13){var t=ga(e,134217728);if(t!==null){var n=Ss();to(t,e,134217728,n)}a0(e,134217728)}};DE=function(e){if(e.tag===13){var t=cl(e),n=ga(e,t);if(n!==null){var r=Ss();to(n,e,t,r)}a0(e,t)}};FE=function(){return pn};zE=function(e,t){var n=pn;try{return pn=e,t()}finally{pn=n}};Tw=function(e,t,n){switch(t){case"input":if(jw(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=ey(r);if(!s)throw Error(Te(90));yE(r),jw(r,s)}}}break;case"textarea":wE(e,n);break;case"select":t=n.value,t!=null&&Au(e,!!n.multiple,t,!1)}};CE=n0;EE=wc;var jO={usingClientEntryPoint:!1,Events:[Ip,yu,ey,NE,jE,n0]},ef={findFiberByHostInstance:rc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},CO={bundleType:ef.bundleType,version:ef.version,rendererPackageName:ef.rendererPackageName,rendererConfig:ef.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:va.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=AE(e),e===null?null:e.stateNode},findFiberByHostInstance:ef.findFiberByHostInstance||SO,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Mh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mh.isDisabled&&Mh.supportsFiber)try{Xg=Mh.inject(CO),Mo=Mh}catch{}}ui.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=jO;ui.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c0(t))throw Error(Te(200));return kO(e,t,null,n)};ui.createRoot=function(e,t){if(!c0(e))throw Error(Te(299));var n=!1,r="",s=lP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=o0(e,1,!1,null,null,n,!1,r,s),e[ma]=t.current,Qf(e.nodeType===8?e.parentNode:e),new l0(t)};ui.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(Te(188)):(e=Object.keys(e).join(","),Error(Te(268,e)));return e=AE(t),e=e===null?null:e.stateNode,e};ui.flushSync=function(e){return wc(e)};ui.hydrate=function(e,t,n){if(!cy(t))throw Error(Te(200));return uy(null,e,t,!0,n)};ui.hydrateRoot=function(e,t,n){if(!c0(e))throw Error(Te(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=lP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=aP(t,null,e,1,n??null,s,!1,o,a),e[ma]=t.current,Qf(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 ly(t)};ui.render=function(e,t,n){if(!cy(t))throw Error(Te(200));return uy(null,e,t,!1,n)};ui.unmountComponentAtNode=function(e){if(!cy(e))throw Error(Te(40));return e._reactRootContainer?(wc(function(){uy(null,null,e,!1,function(){e._reactRootContainer=null,e[ma]=null})}),!0):!1};ui.unstable_batchedUpdates=n0;ui.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!cy(n))throw Error(Te(200));if(e==null||e._reactInternals===void 0)throw Error(Te(38));return uy(e,t,n,!1,r)};ui.version="18.3.1-next-f1338f8080-20240426";function cP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(cP)}catch(e){console.error(e)}}cP(),cE.exports=ui;var $r=cE.exports,zS=$r;xw.createRoot=zS.createRoot,xw.hydrateRoot=zS.hydrateRoot;const uP=m.createContext(null);function db(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function EO(){const e=db(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function _O({children:e}){const[t,n]=m.useState(EO);m.useEffect(()=>{const o=()=>n(db(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=m.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const u=db(l.pathname),d=l.search||"";window.history.pushState({},"",u+d),n(u)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(uP.Provider,{value:s,children:e})}function Bo(){const e=m.useContext(uP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function PO(){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 HS={};function fb(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&HS[t[0]]||(typeof t[0]=="string"&&(HS[t[0]]=new Date),PO(...t))}const dP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function BS(e,t,n){e.loadNamespaces(t,dP(e,n))}function WS(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,dP(e,r))}function AO(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,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=t.services.backendConnector.state[`${l}|${u}`];return d===-1||d===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(o,e)))}function IO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(fb("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,e))return!1}}):AO(e,t,n)}const TO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,RO={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},MO=e=>RO[e],LO=e=>e.replace(TO,MO);let pb={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:LO};function OO(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pb={...pb,...e}}function $O(){return pb}let fP;function DO(e){fP=e}function FO(){return fP}const zO={type:"3rdParty",init(e){OO(e.options.react),DO(e)}},HO=m.createContext();class BO{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const WO=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Tn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(HO)||{},o=n||r||FO();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new BO),!o){fb("You will need to pass in an i18next instance by using initReactI18next");const x=(_,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(_)?_[_.length-1]:_,N=[x,{},!1];return N.t=x,N.i18n={},N.ready=!1,N}o.options.react&&o.options.react.wait!==void 0&&fb("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...$O(),...o.options.react,...t},{useSuspense:l,keyPrefix:u}=a;let d=e||s||o.options&&o.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(d);const p=(o.isInitialized||o.initializedStoreOnce)&&d.every(x=>IO(x,o,a));function c(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],u)}const[f,h]=m.useState(c);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const b=WO(g),k=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:N}=a;k.current=!0,!p&&!l&&(t.lng?WS(o,t.lng,d,()=>{k.current&&h(c)}):BS(o,d,()=>{k.current&&h(c)})),p&&b&&b!==g&&k.current&&h(c);function _(){k.current&&h(c)}return x&&o&&o.on(x,_),N&&o&&o.store.on(N,_),()=>{k.current=!1,x&&o&&x.split(" ").forEach(C=>o.off(C,_)),N&&o&&N.split(" ").forEach(C=>o.store.off(C,_))}},[o,g]);const y=m.useRef(!0);m.useEffect(()=>{k.current&&!y.current&&h(c),y.current=!1},[o,u]);const w=[f,o,p];if(w.t=f,w.i18n=o,w.ready=p,p||!p&&!l)return w;throw new Promise(x=>{t.lng?WS(o,t.lng,d,()=>x()):BS(o,d,()=>x())})}const pP="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",VO=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/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"}],KO=[{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 UO(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function qO({authUser:e,onLogout:t}){const{path:n,navigate:r}=Bo(),{t:s}=Tn(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(u=>u.json()).then(u=>{l||a(!!u.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:pP,alt:"",width:"36",height:"36",decoding:"async"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),i.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),i.jsx("nav",{className:"af-nav",children:VO.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(UO(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[i.jsx("span",{className:"material-symbols-outlined",children:l.icon}),i.jsx("span",{children:l.label||s(l.labelKey)})]},l.to))}),i.jsxs("div",{className:"af-sidebar-footer",children:[i.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[i.jsx("span",{className:"material-symbols-outlined",children:"person"}),i.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?i.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,i.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:i.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!o&&KO.map(l=>{const u=s(l.labelKey);return i.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":u,title:u,children:i.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const hP="agentflow.pipelineRecent",YO=50,GO=15;function XO(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function mP(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(hP);return e?XO(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 Lh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=mP(),o=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,YO);try{localStorage.setItem(hP,JSON.stringify(o))}catch{}}function JO(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 hb(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 o=Math.floor(s/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),u=new Date,d=new Date(u);if(d.setDate(d.getDate()-1),l.toDateString()===d.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 QO(e,t){if(e==null||!Number.isFinite(e)||e<=0)return"--";if(e<1e3)return t("flow:time.milliseconds",{n:Math.max(1,Math.round(e))});const n=e/1e3;return t("flow:time.seconds",{n:n>=10?Math.round(n):n.toFixed(1)})}function ZO(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:JO(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,o)=>o.at-s.at),r.slice(0,GO)}var ni=Uint8Array,Nu=Uint16Array,e$=Int32Array,gP=new ni([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]),yP=new ni([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]),t$=new ni([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xP=function(e,t){for(var n=new Nu(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new e$(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return{b:n,r:s}},wP=xP(gP,2),bP=wP.b,n$=wP.r;bP[28]=258,n$[258]=28;var r$=xP(yP,0),s$=r$.b,mb=new Nu(32768);for(var zn=0;zn<32768;++zn){var Ba=(zn&43690)>>1|(zn&21845)<<1;Ba=(Ba&52428)>>2|(Ba&13107)<<2,Ba=(Ba&61680)>>4|(Ba&3855)<<4,mb[zn]=((Ba&65280)>>8|(Ba&255)<<8)>>1}var Tf=function(e,t,n){for(var r=e.length,s=0,o=new Nu(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new Nu(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new Nu(1<<t);var u=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],p=t-e[s],c=a[e[s]-1]++<<p,f=c|(1<<p)-1;c<=f;++c)l[mb[c]>>u]=d}else for(l=new Nu(r),s=0;s<r;++s)e[s]&&(l[s]=mb[a[e[s]-1]++]>>15-e[s]);return l},Rp=new ni(288);for(var zn=0;zn<144;++zn)Rp[zn]=8;for(var zn=144;zn<256;++zn)Rp[zn]=9;for(var zn=256;zn<280;++zn)Rp[zn]=7;for(var zn=280;zn<288;++zn)Rp[zn]=8;var vP=new ni(32);for(var zn=0;zn<32;++zn)vP[zn]=5;var i$=Tf(Rp,9,1),o$=Tf(vP,5,1),wx=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Bi=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},bx=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},a$=function(e){return(e+7)/8|0},u0=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new ni(e.subarray(t,n))},l$=["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"],xi=function(e,t,n){var r=new Error(t||l$[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,xi),!n)throw r;return r},c$=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new ni(0);var a=!n,l=a||t.i!=2,u=t.i;a&&(n=new ni(s*3));var d=function(ce){var xe=n.length;if(ce>xe){var Se=new ni(Math.max(xe*2,ce));Se.set(n),n=Se}},p=t.f||0,c=t.p||0,f=t.b||0,h=t.l,g=t.d,b=t.m,k=t.n,y=s*8;do{if(!h){p=Bi(e,c,1);var w=Bi(e,c+1,3);if(c+=3,w)if(w==1)h=i$,g=o$,b=9,k=5;else if(w==2){var C=Bi(e,c,31)+257,T=Bi(e,c+10,15)+4,F=C+Bi(e,c+5,31)+1;c+=14;for(var R=new ni(F),H=new ni(19),D=0;D<T;++D)H[t$[D]]=Bi(e,c+D*3,7);c+=T*3;for(var $=wx(H),B=(1<<$)-1,L=Tf(H,$,1),D=0;D<F;){var M=L[Bi(e,c,B)];c+=M&15;var x=M>>4;if(x<16)R[D++]=x;else{var I=0,z=0;for(x==16?(z=3+Bi(e,c,3),c+=2,I=R[D-1]):x==17?(z=3+Bi(e,c,7),c+=3):x==18&&(z=11+Bi(e,c,127),c+=7);z--;)R[D++]=I}}var A=R.subarray(0,C),O=R.subarray(C);b=wx(A),k=wx(O),h=Tf(A,b,1),g=Tf(O,k,1)}else xi(1);else{var x=a$(c)+4,N=e[x-4]|e[x-3]<<8,_=x+N;if(_>s){u&&xi(0);break}l&&d(f+N),n.set(e.subarray(x,_),f),t.b=f+=N,t.p=c=_*8,t.f=p;continue}if(c>y){u&&xi(0);break}}l&&d(f+131072);for(var E=(1<<b)-1,J=(1<<k)-1,Z=c;;Z=c){var I=h[bx(e,c)&E],K=I>>4;if(c+=I&15,c>y){u&&xi(0);break}if(I||xi(2),K<256)n[f++]=K;else if(K==256){Z=c,h=null;break}else{var oe=K-254;if(K>264){var D=K-257,de=gP[D];oe=Bi(e,c,(1<<de)-1)+bP[D],c+=de}var he=g[bx(e,c)&J],we=he>>4;he||xi(3),c+=he&15;var O=s$[we];if(we>3){var de=yP[we];O+=bx(e,c)&(1<<de)-1,c+=de}if(c>y){u&&xi(0);break}l&&d(f+131072);var ue=f+oe;if(f<O){var Ne=o-O,le=Math.min(O,ue);for(Ne+f<0&&xi(3);f<le;++f)n[f]=r[Ne+f]}for(;f<ue;++f)n[f]=n[f-O]}}t.l=h,t.p=Z,t.b=f,t.f=p,h&&(p=1,t.m=b,t.d=g,t.n=k)}while(!p);return f!=n.length&&a?u0(n,0,f):n.subarray(0,f)},u$=new ni(0),Io=function(e,t){return e[t]|e[t+1]<<8},Xi=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},vx=function(e,t){return Xi(e,t)+Xi(e,t+4)*4294967296};function d$(e,t){return c$(e,{i:2},t&&t.out,t&&t.dictionary)}var gb=typeof TextDecoder<"u"&&new TextDecoder,f$=0;try{gb.decode(u$,{stream:!0}),f$=1}catch{}var p$=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:u0(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 h$(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(gb)return gb.decode(e);var s=p$(e),o=s.s,n=s.r;return n.length&&xi(8),o}}var m$=function(e,t){return t+30+Io(e,t+26)+Io(e,t+28)},g$=function(e,t,n){var r=Io(e,t+28),s=h$(e.subarray(t+46,t+46+r),!(Io(e,t+8)&2048)),o=t+46+r,a=Xi(e,t+20),l=n&&a==4294967295?y$(e,o):[a,Xi(e,t+24),Xi(e,t+42)],u=l[0],d=l[1],p=l[2];return[Io(e,t+10),u,d,s,o+Io(e,t+30)+Io(e,t+32),p]},y$=function(e,t){for(;Io(e,t)!=1;t+=4+Io(e,t+2));return[vx(e,t+12),vx(e,t+4),vx(e,t+20)]};function x$(e,t){for(var n={},r=e.length-22;Xi(e,r)!=101010256;--r)(!r||e.length-r>65558)&&xi(13);var s=Io(e,r+8);if(!s)return{};var o=Xi(e,r+16),a=o==4294967295||s==65535;if(a){var l=Xi(e,r-12);a=Xi(e,l)==101075792,a&&(s=Xi(e,l+32),o=Xi(e,l+48))}for(var u=0;u<s;++u){var d=g$(e,o,a),p=d[0],c=d[1],f=d[2],h=d[3],g=d[4],b=d[5],k=m$(e,b);o=g,p?p==8?n[h]=d$(e.subarray(k,k+c),{out:new ni(f)}):xi(14,"unknown compression type "+p):n[h]=u0(e,k,k+c)}return n}const w$=8*1024*1024,b$=500;function v$(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 k$(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function S$(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 N$=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function j$(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=x$(t),r=new Map;let s=0,o=0;for(const[u,d]of Object.entries(n)){if(u.endsWith("/"))continue;const p=v$(u);if(!p||k$(p))continue;const c=(d==null?void 0:d.length)??0;if(s+=c,s>w$||(o+=1,o>b$))return null;r.set(p,c)}if(r.size===0)return null;const a=new Set;for(const u of r.keys()){const d=S$(u);d!==null&&a.add(d)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const u of r.keys())if(!(u===l||u.startsWith(`${l}/`)))return null;return N$.test(l)?l:null}catch{return null}}const kx=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function C$({file:e,onClose:t,onImported:n}){const{t:r}=Tn(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,u]=m.useState(""),[d,p]=m.useState("user"),[c,f]=m.useState(!1),[h,g]=m.useState(""),[b,k]=m.useState(null),y=b??e;m.useEffect(()=>{const _=requestAnimationFrame(()=>{var C;return(C=o.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(_)},[]),m.useEffect(()=>{let _=!1;return(async()=>{const C=y.name||"",T=C.toLowerCase();let F="";if(T.endsWith(".zip")){if(F=await j$(y)||"",!F){const R=C.replace(/\.zip$/i,"");kx.test(R)&&(F=R)}}else if(T.endsWith(".yaml")||T.endsWith(".yml")){const R=C.replace(/\.ya?ml$/i,"");kx.test(R)&&(F=R)}_||u(F)})(),()=>{_=!0}},[y]);const w=l.trim(),x=w.length>0&&kx.test(w);async function N(_){if(_.preventDefault(),!(!x||c)){f(!0),g("");try{const C=new FormData;C.set("flowId",w),C.set("targetSpace",d),C.set("file",y,y.name);const T=await fetch("/api/flows/import",{method:"POST",body:C}),F=await T.json().catch(()=>({}));if(!T.ok){g(typeof F.error=="string"?F.error:r("project:importModal.importFailed"));return}n({id:F.flowId,source:F.flowSource??"user"})}catch(C){g(String((C==null?void 0:C.message)||C))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:N,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),i.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:_=>{var T;const C=(T=_.target.files)==null?void 0:T[0];C&&k(C),_.target.value=""}}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:_=>u(_.target.value),"aria-invalid":w.length>0&&!x}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),i.jsx("div",{className:"af-import-repick",children:i.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var _;return(_=a.current)==null?void 0:_.click()},children:r("project:importModal.changeFile")})}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:c,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||c,children:r(c?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const E$=/^[a-zA-Z][a-zA-Z0-9_-]*$/,VS="af:newPipelineGuide";function _$({open:e,onClose:t,onCreated:n}){const{t:r}=Tn(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[u,d]=m.useState(""),[p,c]=m.useState("user"),[f,h]=m.useState(!1),[g,b]=m.useState(""),[k,y]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),d(""),c("user"),b(""),h(!1),localStorage.getItem(VS)==="true"&&y(!0);const T=requestAnimationFrame(()=>{var F;return(F=o.current)==null?void 0:F.focus()});return()=>cancelAnimationFrame(T)},[e]);const w=()=>{localStorage.removeItem(VS),y(!1)};if(!e)return null;const x=a.trim(),N=x.length>0&&E$.test(x);async function _(C){if(C.preventDefault(),!(!N||f)){h(!0),b(""),w();try{const T=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:u.trim(),targetSpace:p})}),F=await T.json().catch(()=>({}));if(!T.ok){b(typeof F.error=="string"?F.error:r("project:newPipelineModal.createFailed"));return}n({id:F.flowId,source:F.flowSource??"user"})}catch(T){b(String((T==null?void 0:T.message)||T))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&(w(),t())},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{w(),t()},"aria-label":r("project:newPipelineModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),k?i.jsx("div",{className:"af-new-pipeline-guide",children:i.jsxs("div",{className:"af-new-pipeline-guide-content",children:[i.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),i.jsxs("div",{className:"af-new-pipeline-guide-text",children:[i.jsx("p",{children:i.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),i.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),i.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:w,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:_,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:C=>l(C.target.value),"aria-invalid":x.length>0&&!N}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(k?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(k?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:u,onChange:C=>d(C.target.value)}),k?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?i.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{w(),t()},disabled:f,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!N||f,children:r(f?"project:newPipelineModal.creating":k?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const kP="agentflow.pipelineViewPreference";function SP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function NP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(kP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function P$(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(kP,JSON.stringify(e))}catch{}}function lg(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function A$(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function jP(e,t,n,r=!1){if(!e)return;const s=NP();s[SP(e,t,r)]={view:lg(n),at:Date.now()},P$(s)}function I$(e,t="workspace"){if(!(e!=null&&e.id))return lg(t);const r=NP()[SP(e.id,e.source??"user",!!e.archived)],s=lg((r==null?void 0:r.view)||t);return s==="pipeline"&&!A$(e)?"workspace":s}function cg(e,t="workspace"){const n=lg(t);if(!(e!=null&&e.id))return n==="pipeline"?"/flow":n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&r.set(n==="pipeline"?"flowArchived":"archived","1"),n==="display"&&r.set("view","display"),`/${n==="pipeline"?"flow":"workspace"}?${r.toString()}`}function Oh(e,t="workspace"){return cg(e,I$(e,t))}function T$(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),s=Math.max(n.length,r.length);for(let o=0;o<s;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function yb(e){return String((e==null?void 0:e.version)||"").trim()}function R$(e){const t=yb(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 M$({onChanged:e}){const[t,n]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=m.useState([]),[o,a]=m.useState(""),[l,u]=m.useState("keyword"),[d,p]=m.useState([]),[c,f]=m.useState({}),[h,g]=m.useState(""),[b,k]=m.useState(""),[y,w]=m.useState(""),x=m.useCallback(async()=>{k("");try{const[R,H]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),D=await R.json().catch(()=>({}));R.ok&&n({available:!!D.available,version:typeof D.version=="string"?D.version:"",loggedIn:!!D.loggedIn,user:typeof D.user=="string"?D.user:"",error:typeof D.error=="string"?D.error:""});const $=await H.json().catch(()=>({}));if(!H.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+H.status);s(Array.isArray($.skills)?$.skills:[]),f({})}catch(R){k(String(R.message||R))}},[]);m.useEffect(()=>{x()},[x]);const N=m.useCallback(async()=>{const R=o.trim();if(R){g("search"),k(""),w("");try{const H=await fetch(`/api/skillhub/search?q=${encodeURIComponent(R)}&mode=${encodeURIComponent(l)}`),D=await H.json().catch(()=>({}));if(!H.ok)throw new Error(typeof D.error=="string"?D.error:"HTTP "+H.status);p(Array.isArray(D.items)?D.items:[])}catch(H){k(String(H.message||H))}finally{g("")}}},[o,l]),_=m.useCallback(async(R,H=!1)=>{const D=R&&typeof R=="object"?R:null,$=String(D?D.slug||D.name||D.collection||D.skillId||D.id:R||"").trim();if($){g(`install:${$}`),k(""),w("");try{const B=D?{slug:D.slug||"",skillId:D.skillId||"",collection:D.collection||"",collectionName:D.collection&&D.name||"",target:"global",agent:"codex",force:H}:{slug:$,target:"global",agent:"codex",force:H},L=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+L.status);w(H?`已更新 ${$}`:`已安装 ${$}`),await x(),typeof e=="function"&&await e()}catch(B){k(String(B.message||B))}finally{g("")}}},[x,e]),C=m.useCallback(async()=>{if(r.length!==0){g("check-updates"),k(""),w("");try{const R=await Promise.all(r.map(async $=>{const B=String($.name||"").trim();if(!B)return null;try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(B)}&mode=keyword`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+L.status);const I=Array.isArray(M.items)?M.items:[],z=I.find(J=>J.slug===B||J.name===B||J.id===B)||I[0],A=yb($),O=String((z==null?void 0:z.version)||"").trim();let E="unknown";return z?A&&O?E=T$(A,O)<0?"update":"current":O&&(E="remote-only"):E="missing",[B,{state:E,latestVersion:O,installedVersion:A,summary:(z==null?void 0:z.summary)||""}]}catch(L){return[B,{state:"error",error:String(L.message||L),installedVersion:yb($)}]}})),H={};for(const $ of R)$&&(H[$[0]]=$[1]);f(H);const D=Object.values(H).filter($=>$.state==="update").length;w(D>0?`发现 ${D} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[r]),T=m.useCallback(async R=>{const H=String(R||"").trim();if(H){g(`uninstall:${H}`),k(""),w("");try{const D=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:H,target:"global",agent:"codex"})}),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+D.status);w(`已卸载 ${H}`),await x(),typeof e=="function"&&await e()}catch(D){k(String(D.message||D))}finally{g("")}}},[x,e]),F=m.useCallback(async()=>{g("update-cli"),k(""),w("");try{const R=await fetch("/api/skillhub/update",{method:"POST"}),H=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof H.error=="string"?H.error:"HTTP "+R.status);w("SkillHub CLI 已更新"),await x()}catch(R){k(String(R.message||R))}finally{g("")}},[x]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"搜索、安装、更新和卸载 Codex 全局 skills。"})]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:t.loggedIn?`已登录 ${t.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(t.available?" af-set-badge--ok":" af-set-badge--err"),children:t.available?`v${t.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:x,disabled:!!h,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:!!h||r.length===0,children:h==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:F,disabled:!!h,children:h==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),i.jsxs("div",{className:"af-set-skillhub-search",children:[i.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:l,onChange:R=>{u(R.target.value),p([])},children:[i.jsx("option",{value:"keyword",children:"关键词"}),i.jsx("option",{value:"skillId",children:"Skill ID"}),i.jsx("option",{value:"collectionId",children:"Collection ID"})]}),i.jsx("input",{className:"af-set-input af-set-input--sm",value:o,onChange:R=>a(R.target.value),onKeyDown:R=>{R.key==="Enter"&&N()},placeholder:l==="collectionId"?"输入 collection id,例如 1":l==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>N(),disabled:!o.trim()||h==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),h==="search"?"搜索中…":"搜索"]})]}),b?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:b}):null,y?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:y}):null,i.jsxs("div",{className:"af-set-skillhub-grid",children:[i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"已安装"}),i.jsx("span",{children:r.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:r.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 Codex 全局 skills"}):r.map(R=>{const H=c[R.name],D=!H||H.state==="update"||H.state==="remote-only"||H.state==="unknown"||H.state==="error",$=h===`install:${R.name}`?"更新中…":(H==null?void 0:H.state)==="current"?"已最新":(H==null?void 0:H.state)==="update"&&H.latestVersion?`更新到 v${H.latestVersion}`:(H==null?void 0:H.state)==="remote-only"&&H.latestVersion?`安装 v${H.latestVersion}`:"重装";return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:R.displayName||R.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:R$(R)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:H?H.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",H.installedVersion?`v${H.installedVersion} -> `:"","v",H.latestVersion]}):H.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",H.latestVersion||H.installedVersion]}):H.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",H.latestVersion,",本地版本未知"]}):H.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):H.state==="error"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),i.jsxs("div",{className:"af-set-skillhub-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>_(R.name,!0),disabled:!!h||!D,children:$}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>T(R.name),disabled:!!h,children:"卸载"})]})]},`${R.agent}:${R.path}:${R.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:d.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(R=>{const H=R.slug||R.name,D=R.kind==="collection"||R.collection,$=!D&&r.some(B=>B.name===H||B.name===R.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:R.name||H}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[D?`collection:${R.collection}`:H,R.skillId?` · id:${R.skillId}`:"",R.version?` · ${R.version}`:""]}),R.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:R.summary}):null]}),i.jsx("button",{type:"button",className:$?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>_(R,$),disabled:!!h,children:$?"更新":D?"安装合集":"安装"})]},R.id||H)})})]})]})]})}function dl(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 L$(e){return{version:1,collections:dl({collections:e})}}function yl(e,t){const n=new Set((Array.isArray(t)?t:[]).map(r=>r.key).filter(Boolean));return(Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).filter(r=>n.has(r))}function CP(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 EP(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function _P(e,t,n){const r=yl(e,n);if(r.length===0)return"empty";const s=r.filter(o=>t.has(o)).length;return s===0?"none":s===r.length?"all":"partial"}function O$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=dl({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return yl(s,t)}function PP(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),o=String(t||"").trim().toLowerCase(),a=dl({collections:r}),l=O$(t,n,r),u=l.length>0?l:s;if(!e)return u;try{const d=localStorage.getItem(e);if(d!==null){const p=JSON.parse(d);if(Array.isArray(p)){const c=new Set(s),f=p.map(String).filter(y=>c.has(y));if(s.length>0&&f.length===s.length)return u;const h=new Set(f),g=new Set(l),b=l.length>0&&l.every(y=>h.has(y)),k=a.some(y=>{if(!y.builtin||y.id===o||y.name.toLowerCase()===o)return!1;const w=yl(y,n);return w.length>0&&w.every(x=>h.has(x))});return l.length>0&&k&&!b?u:f}}}catch{}return u}function tf(e){return e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function $$(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 xb(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function AP(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 D$="project:defaultCardDesc";function IP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(D$)}function F$(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fr({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return i.jsx("span",{className:t,children:s});const o=new RegExp(`(${F$(r)})`,"gi"),a=s.split(o);return i.jsx("span",{className:t,children:a.map((l,u)=>u%2===1?i.jsx("mark",{className:"af-search-hit",children:l},u):i.jsx("span",{children:l},u))})}function z$(e,t,n){const r=[String(e.id),IP(e,n),AP(e),xb(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function H$(e,t,n){return t?z$(e,t,n).includes(t):!0}function B$(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 Sx(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function KS(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 US(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const W$=["all","agent","control","provide","marketplace"],V$=["all","agent","control","provide"],TP="agentflow.projects.activityPanelOpen",wb="agentflow.projects.activitySelected";function K$(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(TP);return e!=="0"}function qS(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function U$(){return typeof localStorage>"u"?"":localStorage.getItem(wb)||""}function $h(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Yn(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 Wa(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function RP(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 MP(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 bb(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 YS(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||bb(e,t))}function q$(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function GS(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 Y$(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 Nx(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function G$(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 X$(e,t){const n=e.map(p=>p.id),r=new Set(n),s=new Map(n.map(p=>[p,0])),o=new Map(n.map(p=>[p,[]]));t.forEach(p=>{var c;!r.has(p.sourceId)||!r.has(p.targetId)||(s.set(p.targetId,(s.get(p.targetId)||0)+1),(c=o.get(p.sourceId))==null||c.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 c=l[p],f=(a.get(c)||0)+1;for(const h of o.get(c)||[])(!a.has(h)||f>a.get(h))&&(a.set(h,f),l.push(h))}n.forEach((p,c)=>{a.has(p)||a.set(p,c%3)});const u=new Map,d=new Map;return n.forEach(p=>{const c=a.get(p)||0,f=u.get(c)||0;u.set(c,f+1),d.set(p,{x:c*190,y:f*86})}),d}function J$(e){var b,k,y,w;const t=RP(e),n=MP(e),r=new Map(t.map((x,N)=>[bb(x,N),YS(x,N)])),s=t.map((x,N)=>({id:bb(x,N),title:YS(x,N),meta:q$(x)})),o=n.map((x,N)=>{const _=GS(x,"source"),C=GS(x,"target");return{key:(x==null?void 0:x.id)||`${_}-${C}-${N}`,sourceId:_,targetId:C,source:r.get(_)||_||"?",target:r.get(C)||C||"?",label:Y$(x)}}),a=(k=(b=e==null?void 0:e.snippet)==null?void 0:b.ui)!=null&&k.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:{},u=X$(s,o),d=s.map(x=>{const N=G$(a[x.id])||u.get(x.id)||{x:0,y:0},_=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},C=Number(_.width),T=Number(_.height),F=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),R=Math.max(48,Math.min(76,Number.isFinite(T)?T*.46:54));return{...x,x:N.x,y:N.y,width:F,height:R}}),p=new Map(d.map(x=>[x.id,x])),c=o.map(x=>{const N=p.get(x.sourceId),_=p.get(x.targetId);if(!N||!_)return null;const C=N.x+N.width,T=N.y+N.height/2,F=_.x,R=_.y+_.height/2,H=Math.max(48,Math.abs(F-C)*.45);return{...x,path:`M ${C} ${T} C ${C+H} ${T}, ${F-H} ${R}, ${F} ${R}`,labelX:(C+F)/2,labelY:(T+R)/2}}).filter(Boolean),f=d.reduce((x,N)=>({minX:Math.min(x.minX,N.x),minY:Math.min(x.minY,N.y),maxX:Math.max(x.maxX,N.x+N.width),maxY:Math.max(x.maxY,N.y+N.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,g=`${f.minX-h} ${f.minY-h} ${Math.max(360,f.maxX-f.minX+h*2)} ${Math.max(180,f.maxY-f.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:d,edges:c,viewBox:g}}}function nu({resourceKind:e="",authUser:t=null}){var sr,lo,fi,qs,ir,Ys;const{t:n}=Tn(),{navigate:r,path:s}=Bo(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[u,d]=m.useState([]),[p,c]=m.useState([]),[f,h]=m.useState([]),[g,b]=m.useState([]),[k,y]=m.useState([]),[w,x]=m.useState(""),[N,_]=m.useState(!1),[C,T]=m.useState([]),[F,R]=m.useState(""),[H,D]=m.useState(""),[$,B]=m.useState(!1),[L,M]=m.useState(!1),[I,z]=m.useState(!1),[A,O]=m.useState(null),[E,J]=m.useState(!1),[Z,K]=m.useState(""),[oe,de]=m.useState(K$),[he,we]=m.useState(U$),[ue,Ne]=m.useState("all"),[le,ce]=m.useState(""),[xe,Se]=m.useState("overview"),[Ke,et]=m.useState({}),[We,ut]=m.useState(""),[Ve,xt]=m.useState({}),[bt,Jn]=m.useState(""),[Ut,nn]=m.useState(""),[rn,hn]=m.useState({}),[fe,je]=m.useState(""),[He,ot]=m.useState(""),[at,Tt]=m.useState(""),[mt,dn]=m.useState(""),[sn,Rn]=m.useState(""),[on,Mn]=m.useState(!1),[Ln,zr]=m.useState(""),[be,$e]=m.useState({hiddenBuiltins:[],promoted:[]}),ft=m.useRef(0),St=m.useRef(0),mn=m.useRef(0),es=m.useCallback(async()=>{var ge,ze;const U=++St.current;R("");try{const Le=await fetch("/api/flows");if(U!==St.current)return;if(!Le.ok)throw new Error("HTTP "+Le.status);const rt=await Le.json();if(U!==St.current)return;d(Array.isArray(rt)?rt:[])}catch(Le){if(U!==St.current)return;d([]),R(String(Le.message||Le))}try{const Le=await fetch("/api/pipeline-recent-runs");if(U!==St.current)return;if(Le.ok){const rt=await Le.json();if(U!==St.current)return;T(Array.isArray(rt.runs)?rt.runs:[])}else T([])}catch{if(U!==St.current)return;T([])}if(t!=null&&t.isAdmin)try{const Le=await fetch("/api/admin/builtin-flows");if(U!==St.current)return;const rt=await Le.json().catch(()=>({}));Le.ok&&$e({hiddenBuiltins:Array.isArray((ge=rt==null?void 0:rt.config)==null?void 0:ge.hiddenBuiltins)?rt.config.hiddenBuiltins:[],promoted:Array.isArray((ze=rt==null?void 0:rt.config)==null?void 0:ze.promoted)?rt.config.promoted:[]})}catch{if(U!==St.current)return;$e({hiddenBuiltins:[],promoted:[]})}else $e({hiddenBuiltins:[],promoted:[]});B(!0)},[t==null?void 0:t.isAdmin]),Cs=m.useCallback(async(U,ge)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const ze=`${ge}:${U.source}:${U.id}`;zr(ze),R("");try{const Le=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:ge,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),rt=await Le.json().catch(()=>({}));if(!Le.ok)throw new Error(rt.error||"更新内置配置失败");await es()}catch(Le){R(String(Le.message||Le))}finally{zr("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,es]),_r=m.useCallback(async()=>{const U=++mn.current;D(""),M(!1);const ge=e==="my-nodes"?"/api/nodes?scope=owned":"/api/nodes",ze=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";c([]),b([]),ce("");try{const[Le,rt,ln,Rt]=await Promise.all([fetch(ge),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(ze)]),Wn=await Le.json().catch(()=>({})),Pr=await rt.json().catch(()=>({})),_i=await ln.json().catch(()=>({})),On=await Rt.json().catch(()=>({}));if(!Le.ok)throw new Error(Wn.error||"Nodes HTTP "+Le.status);if(!rt.ok)throw new Error(Pr.error||"Skills HTTP "+rt.status);if(!ln.ok)throw new Error(_i.error||"Collections HTTP "+ln.status);if(!Rt.ok)throw new Error(On.error||"Flow snippets HTTP "+Rt.status);if(U!==mn.current)return;c(Array.isArray(Wn.nodes)?Wn.nodes:Array.isArray(Wn)?Wn:[]),h(Array.isArray(Pr.skills)?Pr.skills:[]),y(dl(_i)),b(Array.isArray(On.snippets)?On.snippets:[])}catch(Le){if(U!==mn.current)return;c([]),h([]),b([]),y([]),D(String(Le.message||Le))}finally{if(U!==mn.current)return;M(!0)}},[e]);m.useEffect(()=>{B(!1),es(),_r()},[es,_r]),m.useEffect(()=>{try{localStorage.setItem(TP,oe?"1":"0")}catch{}},[oe]),m.useEffect(()=>{try{he?localStorage.setItem(wb,he):localStorage.removeItem(wb)}catch{}},[he]),m.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(ge=>ge.json()).then(ge=>{U||Mn(!!ge.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const Hr=m.useCallback(async U=>{if(!o)return;const ge=dl({collections:U});_(!0),D("");try{const ze=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L$(ge))}),Le=await ze.json().catch(()=>({}));if(!ze.ok)throw new Error(Le.error||"Collections HTTP "+ze.status);y(dl(Le))}catch(ze){D(String(ze.message||ze))}finally{_(!1)}},[o]),hr=m.useCallback(()=>{if(!o)return;const U=w.trim();if(!U)return;const ge=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",ze=new Set(k.map(Rt=>Rt.id));let Le=ge,rt=2;for(;ze.has(Le);)Le=`${ge}-${rt++}`;const ln=Date.now();Hr([...k,{id:Le,name:U,skillKeys:[],createdAt:ln,updatedAt:ln}]),x(""),Ne(`collection:${Le}`)},[o,w,Hr,k]),kr=m.useCallback(U=>{if(!o)return;const ge=k.find(Le=>Le.id===U);if(ge!=null&&ge.builtin)return;const ze=k.filter(Le=>Le.id!==U);ue===`collection:${U}`&&Ne("all"),Hr(ze)},[o,ue,Hr,k]),hs=m.useCallback((U,ge,ze)=>{if(!o)return;const Le=String(ge||"").trim();if(!Le)return;const rt=Date.now(),ln=k.map(Rt=>{if(Rt.id!==U)return Rt;const Wn=new Set(Rt.skillKeys||[]);return ze?Wn.add(Le):Wn.delete(Le),{...Rt,skillKeys:Array.from(Wn),updatedAt:rt}});Hr(ln)},[o,Hr,k]),Br=m.useCallback(async U=>{const ge=U==null?void 0:U.packageId,ze=U==null?void 0:U.version;if(!ge||!ze||!window.confirm(n("project:deleteMyNodeConfirm",{id:ge,version:ze})))return;const Le=Yn(U);ot(Le),Tt(""),D("");try{const rt=new URLSearchParams({id:ge,version:ze}),ln=await fetch(`/api/marketplace/node?${rt.toString()}`,{method:"DELETE"}),Rt=await ln.json().catch(()=>({}));if(!ln.ok||(Rt==null?void 0:Rt.ok)===!1){const Wn=Array.isArray(Rt==null?void 0:Rt.usage)&&Rt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Rt.usage.length})}`:"";throw new Error(((Rt==null?void 0:Rt.error)||"Delete failed")+Wn)}Tt(n("project:deleteMyNodeSuccess",{id:ge,version:ze})),xt(Wn=>{const Pr={...Wn};return delete Pr[Le],Pr}),hn(Wn=>{const Pr={};for(const[_i,On]of Object.entries(Wn))_i.startsWith(`${Le}:`)||(Pr[_i]=On);return Pr}),ce(""),await _r()}catch(rt){Tt(String(rt.message||rt))}finally{ot("")}},[_r,n]),Ei=m.useCallback(async U=>{const ge=U==null?void 0:U.id,ze=(U==null?void 0:U.version)||"1.0.0";if(!ge||!ze||!window.confirm(n("project:deleteMyFlowConfirm",{id:ge,version:ze})))return;const Le=Wa(U);dn(Le),Rn(""),D("");try{const rt=new URLSearchParams({id:ge,version:ze}),ln=await fetch(`/api/marketplace/flow-snippet?${rt.toString()}`,{method:"DELETE"}),Rt=await ln.json().catch(()=>({}));if(!ln.ok||(Rt==null?void 0:Rt.ok)===!1)throw new Error((Rt==null?void 0:Rt.error)||"Delete failed");Rn(n("project:deleteMyFlowSuccess",{id:ge,version:ze})),ce(""),await _r()}catch(rt){Rn(String(rt.message||rt))}finally{dn("")}},[_r,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),Ne("all"),ce(""),Se("overview");return}l(U=>U==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const U=new URLSearchParams(window.location.search);let ge=!1;if(U.get("tab")==="nodes"){r("/nodes");return}if(U.get("tab")==="my-nodes"){r("/my-nodes");return}if(U.get("tab")==="my-flows"){r("/my-flows");return}if(U.get("tab")==="skills"){r("/skills");return}if(U.get("tab")==="archived"&&(l("archived"),U.delete("tab"),ge=!0),U.get("new")==="1"&&(z(!0),U.delete("new"),ge=!0),ge){const ze=U.toString();window.history.replaceState({},"",ze?`/projects?${ze}`:"/projects")}},[s,r]);const Qn=m.useMemo(()=>ZO(C,mP(),u),[C,u,s]),Wr=m.useMemo(()=>Qn.filter(U=>B$(Z,U)),[Qn,Z]),ae=Z.trim().toLowerCase(),Ce=m.useMemo(()=>a==="archived"?u.filter(U=>U.archived):u.filter(U=>!U.archived),[u,a]),tt=m.useMemo(()=>Ce.filter(U=>H$(U,ae,n)),[Ce,ae,n]),De=m.useMemo(()=>new Set((be.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[be.promoted]),Ae=m.useMemo(()=>(be.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[be.hiddenBuiltins]),Nt=a==="nodes"||a==="my-nodes",mr=a==="my-nodes",it=a==="my-flows",lr=m.useMemo(()=>p.filter(U=>mr&&U.source!=="marketplace"?!1:(ue==="all"||(ue==="marketplace"?U.source==="marketplace":U.type===ue))&&Sx(Z,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[p,mr,Z,ue]),Zn=m.useMemo(()=>{const U=new Map;for(const ge of k)U.set(ge.id,new Set(ge.skillKeys||[]));return U},[k]),Vr=m.useMemo(()=>[{id:"all",label:"全部"},...k.map(U=>({id:`collection:${U.id}`,label:U.name,count:U.skillKeys.length,collection:U})),{id:"ungrouped",label:"未分组"}],[k]),ms=m.useMemo(()=>f.filter(U=>{var Le;const ge=Yn(U);let ze=ue==="all";if(ue.startsWith("collection:")){const rt=ue.slice(11);ze=!!((Le=Zn.get(rt))!=null&&Le.has(ge))}else ue==="ungrouped"&&(ze=!Array.from(Zn.values()).some(rt=>rt.has(ge)));return ze&&Sx(Z,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[f,Z,ue,Zn]),Ie=m.useMemo(()=>g.filter(U=>Sx(Z,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[g,Z]),Us=Nt||it||a==="skills",pt=m.useMemo(()=>lr.find(U=>Yn(U)===le)||lr[0]||null,[lr,le]),xn=m.useMemo(()=>ms.find(U=>Yn(U)===le)||ms[0]||null,[ms,le]),an=m.useMemo(()=>Ie.find(U=>Wa(U)===le)||Ie[0]||null,[Ie,le]),cr=xn?Ke[Yn(xn)]:null,nt=pt?Ve[Yn(pt)]:null,Kr=pt&&Ut?rn[`${Yn(pt)}:${Ut}`]:null,Na=n(Nt?"project:searchNodes":it?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!xn)return;const U=Yn(xn);if(Ke[U])return;let ge=!1;return ut(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then(ze=>ze.json().then(Le=>({ok:ze.ok,json:Le}))).then(({ok:ze,json:Le})=>{ge||ze&&Le.skill&&et(rt=>({...rt,[U]:Le.skill}))}).catch(()=>{}).finally(()=>{ge||ut("")}),()=>{ge=!0}},[a,xn,Ke]),m.useEffect(()=>{if(!Nt||!pt)return;const U=Yn(pt);if(Ve[U])return;let ge=!1;return Jn(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(pt.id)}`).then(ze=>ze.json().then(Le=>({ok:ze.ok,json:Le}))).then(({ok:ze,json:Le})=>{ge||ze&&xt(rt=>({...rt,[U]:Le}))}).catch(()=>{}).finally(()=>{ge||Jn("")}),()=>{ge=!0}},[Nt,pt,Ve]),m.useEffect(()=>{if(!Nt)return;const U=Array.isArray(nt==null?void 0:nt.files)?nt.files:[];nn(ge=>{var ze;return ge&&U.some(Le=>Le.path===ge)?ge:((ze=U[0])==null?void 0:ze.path)||""})},[Nt,nt]),m.useEffect(()=>{if(!Nt||!pt||!Ut)return;const U=`${Yn(pt)}:${Ut}`;if(rn[U])return;let ge=!1;return je(U),fetch(`/api/nodes/file?id=${encodeURIComponent(pt.id)}&path=${encodeURIComponent(Ut)}`).then(ze=>ze.json().then(Le=>({ok:ze.ok,json:Le}))).then(({ok:ze,json:Le})=>{ge||ze&&hn(rt=>({...rt,[U]:Le}))}).catch(()=>{}).finally(()=>{ge||je("")}),()=>{ge=!0}},[Nt,pt,Ut,rn]),m.useEffect(()=>{Tt("")},[le,a]);const Ko=U=>{r(Oh(U,"workspace"))},ao=U=>{we(qS(U)),r(Oh({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},Es=m.useCallback(U=>{var ge,ze;U.preventDefault(),U.stopPropagation(),(ze=(ge=U.dataTransfer)==null?void 0:ge.types)!=null&&ze.includes("Files")&&(ft.current+=1,J(!0))},[]),Uo=m.useCallback(U=>{U.preventDefault(),U.stopPropagation(),ft.current-=1,ft.current<=0&&(ft.current=0,J(!1))},[]),ts=m.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),Nn=m.useCallback(U=>{var Le,rt;U.preventDefault(),U.stopPropagation(),ft.current=0,J(!1);const ge=(rt=(Le=U.dataTransfer)==null?void 0:Le.files)==null?void 0:rt[0];if(!ge)return;const ze=ge.name.toLowerCase();!ze.endsWith(".yaml")&&!ze.endsWith(".yml")&&!ze.endsWith(".zip")||O(ge)},[]);return i.jsxs("div",{className:"af-projects"+(E?" af-projects--drop-target":""),onDragEnter:Es,onDragLeave:Uo,onDragOver:ts,onDrop:Nn,children:[i.jsxs("header",{className:"af-projects-top",children:[e?i.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):i.jsxs("div",{className:"af-projects-tabs",children:[i.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),i.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),i.jsxs("div",{className:"af-projects-top-right",children:[i.jsxs("div",{className:"af-search-wrap",children:[i.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),i.jsx("input",{className:"af-search"+(Z.trim()?" af-search--has-clear":""),type:"search",placeholder:Na,"aria-label":Na,autoComplete:"off",value:Z,onChange:U=>K(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(K(""),U.currentTarget.blur())}}),Z.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>K(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Us?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>_r(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(oe?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":oe,"aria-controls":"af-recent-activity-panel",onClick:()=>de(U=>!U),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>z(!0),children:n("project:createNew")})]})]})]}),i.jsxs("div",{className:"af-projects-body",children:[i.jsxs("section",{className:"af-projects-main",children:[i.jsxs("header",{className:"af-projects-section-head",children:[i.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:globalNodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),i.jsx("p",{className:"af-projects-sub",children:ae?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?lr.length:a==="my-flows"?Ie.length:a==="skills"?ms.length:tt.length}):a==="my-nodes"?n("project:myNodesHint",{count:lr.length}):a==="my-flows"?n("project:myFlowsHint",{count:Ie.length}):a==="nodes"?n("project:nodesHint",{count:p.length}):a==="skills"?n("project:skillsHint",{count:f.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),F?i.jsx("p",{className:"af-err af-projects-api-hint",children:F}):null,H&&Us?i.jsx("p",{className:"af-err af-projects-api-hint",children:H}):null]}),Us?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(M$,{onChanged:_r}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:it?"schema":Nt?mr?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(it?"project:myFlowsPurposeTitle":mr?"project:myNodesPurposeTitle":Nt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(it?"project:myFlowsPurposeDesc":mr?"project:myNodesPurposeDesc":Nt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),it?null:i.jsx("div",{className:"af-resource-filter-row",children:(Nt?(mr?V$:W$).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):Vr).map(U=>U.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(ue===U.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{Ne(U.id),ce("")},children:[U.label,i.jsx("em",{children:U.count}),U.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!U.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${U.collection.name}`,onClick:()=>kr(U.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},U.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(ue===U.id?" af-resource-filter--active":""),onClick:()=>{Ne(U.id),ce("")},children:U.label},U.id))}),a==="skills"&&o?i.jsx("div",{className:"af-skill-collections-manager",children:i.jsxs("div",{className:"af-skill-collections-create",children:[i.jsx("input",{className:"af-set-input af-set-input--sm",value:w,onChange:U=>x(U.target.value),onKeyDown:U=>{U.key==="Enter"&&hr()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!w.trim()||N,onClick:()=>hr(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Nt?i.jsx("div",{className:"af-resource-grid",children:lr.length>0?lr.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(pt&&Yn(U)===Yn(pt)?" af-resource-card--active":""),onClick:()=>ce(Yn(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:tf(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:i.jsx(fr,{query:Z,children:U.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(fr,{query:Z,children:KS(U.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(fr,{query:Z,children:U.label||U.displayName||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(fr,{query:Z,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(fr,{query:Z,children:U.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),i.jsx("span",{className:"af-path-text",children:i.jsx(fr,{query:Z,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):L?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:ae?n("project:noNodeMatch",{query:Z.trim()}):n(mr?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):it?i.jsx("div",{className:"af-resource-grid",children:Ie.length>0?Ie.map(U=>{const ge=RP(U),ze=MP(U),Le=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):ge.length,rt=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):ze.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(an&&Wa(U)===Wa(an)?" af-resource-card--active":""),onClick:()=>ce(Wa(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:tf("primary"),children:i.jsx(fr,{query:Z,children:U.version?`v${U.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(fr,{query:Z,children:U.displayName||U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(fr,{query:Z,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Le,edges:rt})}),i.jsx("span",{children:i.jsx(fr,{query:Z,children:U.id})})]}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),i.jsx("span",{className:"af-path-text",children:i.jsx(fr,{query:Z,children:US(U)})})]})]},Wa(U))}):L?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:ae?n("project:noFlowSnippetMatch",{query:Z.trim()}):n("project:noMyFlows")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?i.jsx("div",{className:"af-resource-grid",children:ms.length>0?ms.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(xn&&Yn(U)===Yn(xn)?" af-resource-card--active":""),onClick:()=>ce(Yn(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:tf(U.source==="builtin"?"muted":"primary"),children:i.jsx(fr,{query:Z,children:U.sourceLabel||U.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(fr,{query:Z,children:U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(fr,{query:Z,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),i.jsx("span",{className:"af-path-text",children:i.jsx(fr,{query:Z,children:U.path||U.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[k.filter(ge=>ge.skillKeys.includes(Yn(U))).slice(0,3).map(ge=>i.jsx("span",{children:ge.name},ge.id)),k.filter(ge=>ge.skillKeys.includes(Yn(U))).length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)):L?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:ae?n("project:noSkillMatch",{query:Z.trim()}):n("project:noSkills")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i.jsxs(i.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&Ae.length>0?i.jsxs("div",{className:"af-project-admin-panel",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"已隐藏内置"}),i.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),i.jsx("div",{className:"af-project-admin-hidden-list",children:Ae.map(U=>{const ge=Ln===`show-builtin:builtin:${U}`;return i.jsxs("button",{type:"button",disabled:ge,onClick:()=>Cs({id:U,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:U}),i.jsx("em",{children:ge?"恢复中":"恢复"})]},U)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[tt.length>0?tt.map(U=>{const ge=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!De.has(U.id),ze=(t==null?void 0:t.isAdmin)&&U.source==="admin",Le=(t==null?void 0:t.isAdmin)&&U.source==="builtin",rt=Ln.endsWith(`:${U.source}:${U.id}`);return i.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>Ko(U),onKeyDown:ln=>{(ln.key==="Enter"||ln.key===" ")&&(ln.preventDefault(),Ko(U))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:tf(xb(U.source,n).tone),children:i.jsx(fr,{query:Z,children:xb(U.source,n).label})}),U.archived?i.jsx("span",{className:tf("muted"),children:i.jsx(fr,{query:Z,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(fr,{query:Z,children:U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(fr,{query:Z,children:IP(U,n)})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),i.jsx("span",{className:"af-path-text",children:i.jsx(fr,{query:Z,children:AP(U)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:ln=>ln.stopPropagation(),onKeyDown:ln=>ln.stopPropagation(),children:[ge?i.jsx("button",{type:"button",disabled:rt,onClick:()=>Cs(U,"promote"),children:"设为内置"}):null,ze?i.jsx("button",{type:"button",disabled:rt,onClick:()=>Cs(U,"unpromote"),children:"取消内置"}):null,Le?i.jsx("button",{type:"button",disabled:rt,onClick:()=>Cs(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}`)}):$?Ce.length===0?i.jsxs("div",{className:"af-projects-empty-block",children:[i.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):u.length>0?n("project:noActive"):n(F?"project:loadFailed":"project:noPipelines")}),!F&&u.length===0&&a==="all"?i.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:Z.trim()})})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),i.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>z(!0),children:[i.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),i.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),on?null:i.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[i.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),i.jsxs("span",{className:"af-hub-card__eyebrow",children:[i.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),i.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),i.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),i.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),i.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),i.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),Us?i.jsx("aside",{className:"af-resource-detail","aria-label":n(Nt?"project:nodeDetail":it?"project:flowDetail":"project:skillDetail"),children:Nt&&pt?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),i.jsxs("div",{children:[i.jsx("h3",{children:pt.label||pt.displayName||pt.id}),i.jsx("p",{children:pt.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(xe===U?" af-resource-detail-tab--active":""),onClick:()=>Se(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),bt===Yn(pt)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):xe==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:pt.description||((sr=nt==null?void 0:nt.node)==null?void 0:sr.description)||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailType")}),i.jsx("dd",{children:pt.type||((lo=nt==null?void 0:nt.node)==null?void 0:lo.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:KS(pt.source,n)})]}),pt.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:pt.packageId})]}):null,pt.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:pt.version})]}):null,pt.packageDir||nt!=null&&nt.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:pt.packageDir||(nt==null?void 0:nt.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(nt==null?void 0:nt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),mr&&pt.source==="marketplace"?i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myNodeManagement")}),i.jsx("p",{children:n("project:deleteMyNodeHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:He===Yn(pt),onClick:()=>Br(pt),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),He===Yn(pt)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),at?i.jsx("p",{className:"af-resource-action-message",children:at}):null]}):null,i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:nodesMeaning")})]})]}):xe==="schema"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeSchema")}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeInputs")}),$h(((fi=nt==null?void 0:nt.node)==null?void 0:fi.inputs)||pt.inputs).length>0?$h(((qs=nt==null?void 0:nt.node)==null?void 0:qs.inputs)||pt.inputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),$h(((ir=nt==null?void 0:nt.node)==null?void 0:ir.outputs)||pt.outputs).length>0?$h(((Ys=nt==null?void 0:nt.node)==null?void 0:Ys.outputs)||pt.outputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):xe==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),nt!=null&&nt.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(nt.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),nt!=null&&nt.body?i.jsxs(i.Fragment,{children:[i.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),i.jsx("pre",{className:"af-resource-skill-preview",children:nt.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):xe==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(nt==null?void 0:nt.files)&&nt.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:nt.files.map(U=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(Ut===U.path?" af-node-file-item--active":""),onClick:()=>nn(U.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:U.path})]},U.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[fe===`${Yn(pt)}:${Ut}`?n("project:loadingResources"):Kr!=null&&Kr.binary?n("project:binaryFile"):(Kr==null?void 0:Kr.content)||n("project:selectNodeFile"),Kr!=null&&Kr.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):i.jsx("p",{children:n("project:noNodeFiles")})]}):i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(nt==null?void 0:nt.usage)&&nt.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:nt.usage.map(U=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:U.flowId}),i.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:U.instances.map(ge=>ge.label||ge.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):it&&an?(()=>{const U=J$(an);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"schema"}),i.jsxs("div",{children:[i.jsx("h3",{children:an.displayName||an.name||an.id}),i.jsx("p",{children:an.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:an.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:an.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:US(an)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(an.nodeCount))?Number(an.nodeCount):U.nodes.length,edges:Number.isFinite(Number(an.edgeCount))?Number(an.edgeCount):U.edges.length})})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:myFlowsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myFlowManagement")}),i.jsx("p",{children:n("project:deleteMyFlowHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:mt===Wa(an),onClick:()=>Ei(an),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),mt===Wa(an)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),sn?i.jsx("p",{className:"af-resource-action-message",children:sn}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:i.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),i.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(ge=>i.jsxs("g",{children:[i.jsx("path",{d:ge.path}),ge.label?i.jsx("text",{x:ge.labelX,y:ge.labelY-5,textAnchor:"middle",children:Nx(ge.label,18)}):null]},ge.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.diagram.nodes.map((ge,ze)=>i.jsxs("g",{transform:`translate(${ge.x} ${ge.y})`,children:[i.jsx("rect",{width:ge.width,height:ge.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:ge.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:ge.height/2+4,textAnchor:"middle",children:ze+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:ge.height/2-3,children:Nx(ge.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:ge.height/2+16,children:Nx(ge.meta||ge.id,20)})]},ge.id))})]})}):i.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),i.jsxs("details",{className:"af-flow-snippet-json",children:[i.jsx("summary",{children:n("project:flowSnippetJson")}),i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(an.snippet||{},null,2)})]})]})]})})():a==="skills"&&xn?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:xn.name||xn.id}),i.jsx("p",{children:xn.sourceLabel||xn.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:xn.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:xn.sourceLabel||xn.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:xn.path||xn.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),k.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:k.map(U=>{const ge=Yn(xn),ze=U.skillKeys.includes(ge);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:ze,disabled:N||!o,onChange:Le=>hs(U.id,ge,Le.target.checked)}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:U.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[U.skillKeys.length," skills"]})]})]},U.id)})})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:skillsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:skillPreview")}),i.jsx("pre",{className:"af-resource-skill-preview",children:We===Yn(xn)?n("project:loadingResources"):(cr==null?void 0:cr.body)||(cr==null?void 0:cr.content)||n("project:skillPreviewEmpty")})]})]}):i.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):i.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(oe?"":" af-activity--hidden"),"aria-hidden":!oe,"aria-label":n("project:recentActivity"),children:[i.jsxs("h2",{className:"af-activity-title",children:[i.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),i.jsx("div",{className:"af-activity-list",children:Wr.length===0?i.jsx("p",{className:"af-activity-empty",children:Qn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Wr.map(U=>{const ge=he===qS(U);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(ge?" af-activity-row--active":""),"aria-current":ge?"page":void 0,onClick:()=>ao(U),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(fr,{query:Z,children:U.flowId})}),i.jsx("span",{className:"af-activity-time",children:hb(U.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:$$(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",hb(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),i.jsx(_$,{open:I,onClose:()=>z(!1),onCreated:async U=>{z(!1),await es();const ge=U.source??"user";r(Oh({id:U.id,source:ge},"workspace"))}}),A?i.jsx(C$,{file:A,onClose:()=>O(null),onImported:async U=>{O(null),await es();const ge=U.source??"user";r(Oh({id:U.id,source:ge},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}function vr(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=vr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Q$={value:()=>{}};function dy(){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 jm(n)}function jm(e){this._=e}function Z$(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}})}jm.prototype=dy.prototype={constructor:jm,on:function(e,t){var n=this._,r=Z$(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=eD(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(s=(e=r[o]).type)n[s]=XS(n[s],e.name,t);else if(t==null)for(s in n)n[s]=XS(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 jm(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[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,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function eD(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function XS(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Q$,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var vb="http://www.w3.org/1999/xhtml";const JS={svg:"http://www.w3.org/2000/svg",xhtml:vb,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fy(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),JS.hasOwnProperty(t)?{space:JS[t],local:e}:e}function tD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===vb&&t.documentElement.namespaceURI===vb?t.createElement(e):t.createElementNS(n,e)}}function nD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function LP(e){var t=fy(e);return(t.local?nD:tD)(t)}function rD(){}function d0(e){return e==null?rD:function(){return this.querySelector(e)}}function sD(e){typeof e!="function"&&(e=d0(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=new Array(a),u,d,p=0;p<a;++p)(u=o[p])&&(d=e.call(u,u.__data__,p,o))&&("__data__"in u&&(d.__data__=u.__data__),l[p]=d);return new ci(r,this._parents)}function iD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function oD(){return[]}function OP(e){return e==null?oD:function(){return this.querySelectorAll(e)}}function aD(e){return function(){return iD(e.apply(this,arguments))}}function lD(e){typeof e=="function"?e=aD(e):e=OP(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var a=t[o],l=a.length,u,d=0;d<l;++d)(u=a[d])&&(r.push(e.call(u,u.__data__,d,a)),s.push(u));return new ci(r,s)}function $P(e){return function(){return this.matches(e)}}function DP(e){return function(t){return t.matches(e)}}var cD=Array.prototype.find;function uD(e){return function(){return cD.call(this.children,e)}}function dD(){return this.firstElementChild}function fD(e){return this.select(e==null?dD:uD(typeof e=="function"?e:DP(e)))}var pD=Array.prototype.filter;function hD(){return Array.from(this.children)}function mD(e){return function(){return pD.call(this.children,e)}}function gD(e){return this.selectAll(e==null?hD:mD(typeof e=="function"?e:DP(e)))}function yD(e){typeof e!="function"&&(e=$P(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],u,d=0;d<a;++d)(u=o[d])&&e.call(u,u.__data__,d,o)&&l.push(u);return new ci(r,this._parents)}function FP(e){return new Array(e.length)}function xD(){return new ci(this._enter||this._groups.map(FP),this._parents)}function ug(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ug.prototype={constructor:ug,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 wD(e){return function(){return e}}function bD(e,t,n,r,s,o){for(var a=0,l,u=t.length,d=o.length;a<d;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new ug(e,o[a]);for(;a<u;++a)(l=t[a])&&(s[a]=l)}function vD(e,t,n,r,s,o,a){var l,u,d=new Map,p=t.length,c=o.length,f=new Array(p),h;for(l=0;l<p;++l)(u=t[l])&&(f[l]=h=a.call(u,u.__data__,l,t)+"",d.has(h)?s[l]=u:d.set(h,u));for(l=0;l<c;++l)h=a.call(e,o[l],l,o)+"",(u=d.get(h))?(r[l]=u,u.__data__=o[l],d.delete(h)):n[l]=new ug(e,o[l]);for(l=0;l<p;++l)(u=t[l])&&d.get(f[l])===u&&(s[l]=u)}function kD(e){return e.__data__}function SD(e,t){if(!arguments.length)return Array.from(this,kD);var n=t?vD:bD,r=this._parents,s=this._groups;typeof e!="function"&&(e=wD(e));for(var o=s.length,a=new Array(o),l=new Array(o),u=new Array(o),d=0;d<o;++d){var p=r[d],c=s[d],f=c.length,h=ND(e.call(p,p&&p.__data__,d,r)),g=h.length,b=l[d]=new Array(g),k=a[d]=new Array(g),y=u[d]=new Array(f);n(p,c,b,k,y,h,t);for(var w=0,x=0,N,_;w<g;++w)if(N=b[w]){for(w>=x&&(x=w+1);!(_=k[x])&&++x<g;);N._next=_||null}}return a=new ci(a,r),a._enter=l,a._exit=u,a}function ND(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function jD(){return new ci(this._exit||this._groups.map(FP),this._parents)}function CD(e,t,n){var r=this.enter(),s=this,o=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?o.remove():n(o),r&&s?r.merge(s).order():s}function ED(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,a=Math.min(s,o),l=new Array(s),u=0;u<a;++u)for(var d=n[u],p=r[u],c=d.length,f=l[u]=new Array(c),h,g=0;g<c;++g)(h=d[g]||p[g])&&(f[g]=h);for(;u<s;++u)l[u]=n[u];return new ci(l,this._parents)}function _D(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],a;--s>=0;)(a=r[s])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function PD(e){e||(e=AD);function t(c,f){return c&&f?e(c.__data__,f.__data__):!c-!f}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,u=s[o]=new Array(l),d,p=0;p<l;++p)(d=a[p])&&(u[p]=d);u.sort(t)}return new ci(s,this._parents).order()}function AD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ID(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function TD(){return Array.from(this)}function RD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var a=r[s];if(a)return a}return null}function MD(){let e=0;for(const t of this)++e;return e}function LD(){return!this.node()}function OD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,a=s.length,l;o<a;++o)(l=s[o])&&e.call(l,l.__data__,o,s);return this}function $D(e){return function(){this.removeAttribute(e)}}function DD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function FD(e,t){return function(){this.setAttribute(e,t)}}function zD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function HD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function BD(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 WD(e,t){var n=fy(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?DD:$D:typeof t=="function"?n.local?BD:HD:n.local?zD:FD)(n,t))}function zP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function VD(e){return function(){this.style.removeProperty(e)}}function KD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function UD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function qD(e,t,n){return arguments.length>1?this.each((t==null?VD:typeof t=="function"?UD:KD)(e,t,n??"")):Xu(this.node(),e)}function Xu(e,t){return e.style.getPropertyValue(t)||zP(e).getComputedStyle(e,null).getPropertyValue(t)}function YD(e){return function(){delete this[e]}}function GD(e,t){return function(){this[e]=t}}function XD(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function JD(e,t){return arguments.length>1?this.each((t==null?YD:typeof t=="function"?XD:GD)(e,t)):this.node()[e]}function HP(e){return e.trim().split(/^|\s+/)}function f0(e){return e.classList||new BP(e)}function BP(e){this._node=e,this._names=HP(e.getAttribute("class")||"")}BP.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 WP(e,t){for(var n=f0(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function VP(e,t){for(var n=f0(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function QD(e){return function(){WP(this,e)}}function ZD(e){return function(){VP(this,e)}}function eF(e,t){return function(){(t.apply(this,arguments)?WP:VP)(this,e)}}function tF(e,t){var n=HP(e+"");if(arguments.length<2){for(var r=f0(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?eF:t?QD:ZD)(n,t))}function nF(){this.textContent=""}function rF(e){return function(){this.textContent=e}}function sF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function iF(e){return arguments.length?this.each(e==null?nF:(typeof e=="function"?sF:rF)(e)):this.node().textContent}function oF(){this.innerHTML=""}function aF(e){return function(){this.innerHTML=e}}function lF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function cF(e){return arguments.length?this.each(e==null?oF:(typeof e=="function"?lF:aF)(e)):this.node().innerHTML}function uF(){this.nextSibling&&this.parentNode.appendChild(this)}function dF(){return this.each(uF)}function fF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function pF(){return this.each(fF)}function hF(e){var t=typeof e=="function"?e:LP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function mF(){return null}function gF(e,t){var n=typeof e=="function"?e:LP(e),r=t==null?mF:typeof t=="function"?t:d0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function yF(){var e=this.parentNode;e&&e.removeChild(this)}function xF(){return this.each(yF)}function wF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vF(e){return this.select(e?bF:wF)}function kF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function SF(e){return function(t){e.call(this,t,this.__data__)}}function NF(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 jF(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function CF(e,t,n){return function(){var r=this.__on,s,o=SF(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=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function EF(e,t,n){var r=NF(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,d=l.length,p;u<d;++u)for(s=0,p=l[u];s<o;++s)if((a=r[s]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?CF:jF,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function KP(e,t,n){var r=zP(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 _F(e,t){return function(){return KP(this,e,t)}}function PF(e,t){return function(){return KP(this,e,t.apply(this,arguments))}}function AF(e,t){return this.each((typeof t=="function"?PF:_F)(e,t))}function*IF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&(yield a)}var UP=[null];function ci(e,t){this._groups=e,this._parents=t}function Mp(){return new ci([[document.documentElement]],UP)}function TF(){return this}ci.prototype=Mp.prototype={constructor:ci,select:sD,selectAll:lD,selectChild:fD,selectChildren:gD,filter:yD,data:SD,enter:xD,exit:jD,join:CD,merge:ED,selection:TF,order:_D,sort:PD,call:ID,nodes:TD,node:RD,size:MD,empty:LD,each:OD,attr:WD,style:qD,property:JD,classed:tF,text:iF,html:cF,raise:dF,lower:pF,append:hF,insert:gF,remove:xF,clone:vF,datum:kF,on:EF,dispatch:AF,[Symbol.iterator]:IF};function ri(e){return typeof e=="string"?new ci([[document.querySelector(e)]],[document.documentElement]):new ci([[e]],UP)}function RF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Yi(e,t){if(e=RF(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 MF={passive:!1},ap={capture:!0,passive:!1};function jx(e){e.stopImmediatePropagation()}function Ou(e){e.preventDefault(),e.stopImmediatePropagation()}function qP(e){var t=e.document.documentElement,n=ri(e).on("dragstart.drag",Ou,ap);"onselectstart"in t?n.on("selectstart.drag",Ou,ap):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function YP(e,t){var n=e.document.documentElement,r=ri(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ou,ap),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 Dh=e=>()=>e;function kb(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:u,dy:d,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:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}kb.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function LF(e){return!e.ctrlKey&&!e.button}function OF(){return this.parentNode}function $F(e,t){return t??{x:e.x,y:e.y}}function DF(){return navigator.maxTouchPoints||"ontouchstart"in this}function GP(){var e=LF,t=OF,n=$F,r=DF,s={},o=dy("start","drag","end"),a=0,l,u,d,p,c=0;function f(N){N.on("mousedown.drag",h).filter(r).on("touchstart.drag",k).on("touchmove.drag",y,MF).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(N,_){if(!(p||!e.call(this,N,_))){var C=x(this,t.call(this,N,_),N,_,"mouse");C&&(ri(N.view).on("mousemove.drag",g,ap).on("mouseup.drag",b,ap),qP(N.view),jx(N),d=!1,l=N.clientX,u=N.clientY,C("start",N))}}function g(N){if(Ou(N),!d){var _=N.clientX-l,C=N.clientY-u;d=_*_+C*C>c}s.mouse("drag",N)}function b(N){ri(N.view).on("mousemove.drag mouseup.drag",null),YP(N.view,d),Ou(N),s.mouse("end",N)}function k(N,_){if(e.call(this,N,_)){var C=N.changedTouches,T=t.call(this,N,_),F=C.length,R,H;for(R=0;R<F;++R)(H=x(this,T,N,_,C[R].identifier,C[R]))&&(jx(N),H("start",N,C[R]))}}function y(N){var _=N.changedTouches,C=_.length,T,F;for(T=0;T<C;++T)(F=s[_[T].identifier])&&(Ou(N),F("drag",N,_[T]))}function w(N){var _=N.changedTouches,C=_.length,T,F;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),T=0;T<C;++T)(F=s[_[T].identifier])&&(jx(N),F("end",N,_[T]))}function x(N,_,C,T,F,R){var H=o.copy(),D=Yi(R||C,_),$,B,L;if((L=n.call(N,new kb("beforestart",{sourceEvent:C,target:f,identifier:F,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:H}),T))!=null)return $=L.x-D[0]||0,B=L.y-D[1]||0,function M(I,z,A){var O=D,E;switch(I){case"start":s[F]=M,E=a++;break;case"end":delete s[F],--a;case"drag":D=Yi(A||z,_),E=a;break}H.call(I,N,new kb(I,{sourceEvent:z,subject:L,target:f,identifier:F,active:E,x:D[0]+$,y:D[1]+B,dx:D[0]-O[0],dy:D[1]-O[1],dispatch:H}),T)}}return f.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Dh(!!N),f):e},f.container=function(N){return arguments.length?(t=typeof N=="function"?N:Dh(N),f):t},f.subject=function(N){return arguments.length?(n=typeof N=="function"?N:Dh(N),f):n},f.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:Dh(!!N),f):r},f.on=function(){var N=o.on.apply(o,arguments);return N===o?f:N},f.clickDistance=function(N){return arguments.length?(c=(N=+N)*N,f):Math.sqrt(c)},f}function p0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function XP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Lp(){}var lp=.7,dg=1/lp,$u="\\s*([+-]?\\d+)\\s*",cp="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",FF=/^#([0-9a-f]{3,8})$/,zF=new RegExp(`^rgb\\(${$u},${$u},${$u}\\)$`),HF=new RegExp(`^rgb\\(${Oo},${Oo},${Oo}\\)$`),BF=new RegExp(`^rgba\\(${$u},${$u},${$u},${cp}\\)$`),WF=new RegExp(`^rgba\\(${Oo},${Oo},${Oo},${cp}\\)$`),VF=new RegExp(`^hsl\\(${cp},${Oo},${Oo}\\)$`),KF=new RegExp(`^hsla\\(${cp},${Oo},${Oo},${cp}\\)$`),QS={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};p0(Lp,bc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ZS,formatHex:ZS,formatHex8:UF,formatHsl:qF,formatRgb:eN,toString:eN});function ZS(){return this.rgb().formatHex()}function UF(){return this.rgb().formatHex8()}function qF(){return JP(this).formatHsl()}function eN(){return this.rgb().formatRgb()}function bc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=FF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?tN(t):n===3?new $s(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Fh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Fh(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=zF.exec(e))?new $s(t[1],t[2],t[3],1):(t=HF.exec(e))?new $s(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=BF.exec(e))?Fh(t[1],t[2],t[3],t[4]):(t=WF.exec(e))?Fh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=VF.exec(e))?sN(t[1],t[2]/100,t[3]/100,1):(t=KF.exec(e))?sN(t[1],t[2]/100,t[3]/100,t[4]):QS.hasOwnProperty(e)?tN(QS[e]):e==="transparent"?new $s(NaN,NaN,NaN,0):null}function tN(e){return new $s(e>>16&255,e>>8&255,e&255,1)}function Fh(e,t,n,r){return r<=0&&(e=t=n=NaN),new $s(e,t,n,r)}function YF(e){return e instanceof Lp||(e=bc(e)),e?(e=e.rgb(),new $s(e.r,e.g,e.b,e.opacity)):new $s}function Sb(e,t,n,r){return arguments.length===1?YF(e):new $s(e,t,n,r??1)}function $s(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}p0($s,Sb,XP(Lp,{brighter(e){return e=e==null?dg:Math.pow(dg,e),new $s(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?lp:Math.pow(lp,e),new $s(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $s(uc(this.r),uc(this.g),uc(this.b),fg(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:nN,formatHex:nN,formatHex8:GF,formatRgb:rN,toString:rN}));function nN(){return`#${oc(this.r)}${oc(this.g)}${oc(this.b)}`}function GF(){return`#${oc(this.r)}${oc(this.g)}${oc(this.b)}${oc((isNaN(this.opacity)?1:this.opacity)*255)}`}function rN(){const e=fg(this.opacity);return`${e===1?"rgb(":"rgba("}${uc(this.r)}, ${uc(this.g)}, ${uc(this.b)}${e===1?")":`, ${e})`}`}function fg(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function uc(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function oc(e){return e=uc(e),(e<16?"0":"")+e.toString(16)}function sN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ji(e,t,n,r)}function JP(e){if(e instanceof Ji)return new Ji(e.h,e.s,e.l,e.opacity);if(e instanceof Lp||(e=bc(e)),!e)return new Ji;if(e instanceof Ji)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,l=o-s,u=(o+s)/2;return l?(t===o?a=(n-r)/l+(n<r)*6:n===o?a=(r-t)/l+2:a=(t-n)/l+4,l/=u<.5?o+s:2-o-s,a*=60):l=u>0&&u<1?0:a,new Ji(a,l,u,e.opacity)}function XF(e,t,n,r){return arguments.length===1?JP(e):new Ji(e,t,n,r??1)}function Ji(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}p0(Ji,XF,XP(Lp,{brighter(e){return e=e==null?dg:Math.pow(dg,e),new Ji(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?lp:Math.pow(lp,e),new Ji(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 $s(Cx(e>=240?e-240:e+120,s,r),Cx(e,s,r),Cx(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ji(iN(this.h),zh(this.s),zh(this.l),fg(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=fg(this.opacity);return`${e===1?"hsl(":"hsla("}${iN(this.h)}, ${zh(this.s)*100}%, ${zh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function iN(e){return e=(e||0)%360,e<0?e+360:e}function zh(e){return Math.max(0,Math.min(1,e||0))}function Cx(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 h0=e=>()=>e;function JF(e,t){return function(n){return e+n*t}}function QF(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 ZF(e){return(e=+e)==1?QP:function(t,n){return n-t?QF(t,n,e):h0(isNaN(t)?n:t)}}function QP(e,t){var n=t-e;return n?JF(e,n):h0(isNaN(e)?t:e)}const pg=function e(t){var n=ZF(t);function r(s,o){var a=n((s=Sb(s)).r,(o=Sb(o)).r),l=n(s.g,o.g),u=n(s.b,o.b),d=QP(s.opacity,o.opacity);return function(p){return s.r=a(p),s.g=l(p),s.b=u(p),s.opacity=d(p),s+""}}return r.gamma=e,r}(1);function ez(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=e[s]*(1-o)+t[s]*o;return r}}function tz(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nz(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),o=new Array(n),a;for(a=0;a<r;++a)s[a]=Rf(e[a],t[a]);for(;a<n;++a)o[a]=t[a];return function(l){for(a=0;a<r;++a)o[a]=s[a](l);return o}}function rz(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function _o(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function sz(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]=Rf(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Nb=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ex=new RegExp(Nb.source,"g");function iz(e){return function(){return e}}function oz(e){return function(t){return e(t)+""}}function ZP(e,t){var n=Nb.lastIndex=Ex.lastIndex=0,r,s,o,a=-1,l=[],u=[];for(e=e+"",t=t+"";(r=Nb.exec(e))&&(s=Ex.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,u.push({i:a,x:_o(r,s)})),n=Ex.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?u[0]?oz(u[0].x):iz(t):(t=u.length,function(d){for(var p=0,c;p<t;++p)l[(c=u[p]).i]=c.x(d);return l.join("")})}function Rf(e,t){var n=typeof t,r;return t==null||n==="boolean"?h0(t):(n==="number"?_o:n==="string"?(r=bc(t))?(t=r,pg):ZP:t instanceof bc?pg:t instanceof Date?rz:tz(t)?ez:Array.isArray(t)?nz:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?sz:_o)(e,t)}var oN=180/Math.PI,jb={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function eA(e,t,n,r,s,o){var a,l,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,u/=l),e*r<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*oN,skewX:Math.atan(u)*oN,scaleX:a,scaleY:l}}var Hh;function az(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?jb:eA(t.a,t.b,t.c,t.d,t.e,t.f)}function lz(e){return e==null||(Hh||(Hh=document.createElementNS("http://www.w3.org/2000/svg","g")),Hh.setAttribute("transform",e),!(e=Hh.transform.baseVal.consolidate()))?jb:(e=e.matrix,eA(e.a,e.b,e.c,e.d,e.e,e.f))}function tA(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function o(d,p,c,f,h,g){if(d!==c||p!==f){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:_o(d,c)},{i:b-2,x:_o(p,f)})}else(c||f)&&h.push("translate("+c+t+f+n)}function a(d,p,c,f){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),f.push({i:c.push(s(c)+"rotate(",null,r)-2,x:_o(d,p)})):p&&c.push(s(c)+"rotate("+p+r)}function l(d,p,c,f){d!==p?f.push({i:c.push(s(c)+"skewX(",null,r)-2,x:_o(d,p)}):p&&c.push(s(c)+"skewX("+p+r)}function u(d,p,c,f,h,g){if(d!==c||p!==f){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:_o(d,c)},{i:b-2,x:_o(p,f)})}else(c!==1||f!==1)&&h.push(s(h)+"scale("+c+","+f+")")}return function(d,p){var c=[],f=[];return d=e(d),p=e(p),o(d.translateX,d.translateY,p.translateX,p.translateY,c,f),a(d.rotate,p.rotate,c,f),l(d.skewX,p.skewX,c,f),u(d.scaleX,d.scaleY,p.scaleX,p.scaleY,c,f),d=p=null,function(h){for(var g=-1,b=f.length,k;++g<b;)c[(k=f[g]).i]=k.x(h);return c.join("")}}}var cz=tA(az,"px, ","px)","deg)"),uz=tA(lz,", ",")",")"),dz=1e-12;function aN(e){return((e=Math.exp(e))+1/e)/2}function fz(e){return((e=Math.exp(e))-1/e)/2}function pz(e){return((e=Math.exp(2*e))-1)/(e+1)}const Cm=function e(t,n,r){function s(o,a){var l=o[0],u=o[1],d=o[2],p=a[0],c=a[1],f=a[2],h=p-l,g=c-u,b=h*h+g*g,k,y;if(b<dz)y=Math.log(f/d)/t,k=function(T){return[l+T*h,u+T*g,d*Math.exp(t*T*y)]};else{var w=Math.sqrt(b),x=(f*f-d*d+r*b)/(2*d*n*w),N=(f*f-d*d-r*b)/(2*f*n*w),_=Math.log(Math.sqrt(x*x+1)-x),C=Math.log(Math.sqrt(N*N+1)-N);y=(C-_)/t,k=function(T){var F=T*y,R=aN(_),H=d/(n*w)*(R*pz(t*F+_)-fz(_));return[l+H*h,u+H*g,d*R/aN(t*F+_)]}}return k.duration=y*1e3*t/Math.SQRT2,k}return s.rho=function(o){var a=Math.max(.001,+o),l=a*a,u=l*l;return e(a,l,u)},s}(Math.SQRT2,2,4);var Ju=0,gf=0,nf=0,nA=1e3,hg,yf,mg=0,vc=0,py=0,up=typeof performance=="object"&&performance.now?performance:Date,rA=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function m0(){return vc||(rA(hz),vc=up.now()+py)}function hz(){vc=0}function gg(){this._call=this._time=this._next=null}gg.prototype=sA.prototype={constructor:gg,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?m0():+n)+(t==null?0:+t),!this._next&&yf!==this&&(yf?yf._next=this:hg=this,yf=this),this._call=e,this._time=n,Cb()},stop:function(){this._call&&(this._call=null,this._time=1/0,Cb())}};function sA(e,t,n){var r=new gg;return r.restart(e,t,n),r}function mz(){m0(),++Ju;for(var e=hg,t;e;)(t=vc-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ju}function lN(){vc=(mg=up.now())+py,Ju=gf=0;try{mz()}finally{Ju=0,yz(),vc=0}}function gz(){var e=up.now(),t=e-mg;t>nA&&(py-=t,mg=e)}function yz(){for(var e,t=hg,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:hg=n);yf=e,Cb(r)}function Cb(e){if(!Ju){gf&&(gf=clearTimeout(gf));var t=e-vc;t>24?(e<1/0&&(gf=setTimeout(lN,e-up.now()-py)),nf&&(nf=clearInterval(nf))):(nf||(mg=up.now(),nf=setInterval(gz,nA)),Ju=1,rA(lN))}}function cN(e,t,n){var r=new gg;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var xz=dy("start","end","cancel","interrupt"),wz=[],iA=0,uN=1,Eb=2,Em=3,dN=4,_b=5,_m=6;function hy(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;bz(e,n,{name:t,index:r,group:s,on:xz,tween:wz,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:iA})}function g0(e,t){var n=io(e,t);if(n.state>iA)throw new Error("too late; already scheduled");return n}function Wo(e,t){var n=io(e,t);if(n.state>Em)throw new Error("too late; already running");return n}function io(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function bz(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=sA(o,0,n.time);function o(d){n.state=uN,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var p,c,f,h;if(n.state!==uN)return u();for(p in r)if(h=r[p],h.name===n.name){if(h.state===Em)return cN(a);h.state===dN?(h.state=_m,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[p]):+p<t&&(h.state=_m,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[p])}if(cN(function(){n.state===Em&&(n.state=dN,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Eb,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Eb){for(n.state=Em,s=new Array(f=n.tween.length),p=0,c=-1;p<f;++p)(h=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++c]=h);s.length=c+1}}function l(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(u),n.state=_b,1),c=-1,f=s.length;++c<f;)s[c].call(e,p);n.state===_b&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=_m,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Pm(e,t){var n=e.__transition,r,s,o=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}s=r.state>Eb&&r.state<_b,r.state=_m,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function vz(e){return this.each(function(){Pm(this,e)})}function kz(e,t){var n,r;return function(){var s=Wo(this,e),o=s.tween;if(o!==n){r=n=o;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 Sz(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Wo(this,e),a=o.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},u=0,d=s.length;u<d;++u)if(s[u].name===t){s[u]=l;break}u===d&&s.push(l)}o.tween=s}}function Nz(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=io(this.node(),n).tween,s=0,o=r.length,a;s<o;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?kz:Sz)(n,e,t))}function y0(e,t,n){var r=e._id;return e.each(function(){var s=Wo(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return io(s,r).value[t]}}function oA(e,t){var n;return(typeof t=="number"?_o:t instanceof bc?pg:(n=bc(t))?(t=n,pg):ZP)(e,t)}function jz(e){return function(){this.removeAttribute(e)}}function Cz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ez(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttribute(e);return a===s?null:a===r?o:o=t(r=a,n)}}function _z(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?o:o=t(r=a,n)}}function Pz(e,t,n){var r,s,o;return function(){var a,l=n(this),u;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=l+"",a===u?null:a===r&&u===s?o:(s=u,o=t(r=a,l)))}}function Az(e,t,n){var r,s,o;return function(){var a,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=l+"",a===u?null:a===r&&u===s?o:(s=u,o=t(r=a,l)))}}function Iz(e,t){var n=fy(e),r=n==="transform"?uz:oA;return this.attrTween(e,typeof t=="function"?(n.local?Az:Pz)(n,r,y0(this,"attr."+e,t)):t==null?(n.local?Cz:jz)(n):(n.local?_z:Ez)(n,r,t))}function Tz(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Rz(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Mz(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Rz(e,o)),n}return s._value=t,s}function Lz(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Tz(e,o)),n}return s._value=t,s}function Oz(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=fy(e);return this.tween(n,(r.local?Mz:Lz)(r,t))}function $z(e,t){return function(){g0(this,e).delay=+t.apply(this,arguments)}}function Dz(e,t){return t=+t,function(){g0(this,e).delay=t}}function Fz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$z:Dz)(t,e)):io(this.node(),t).delay}function zz(e,t){return function(){Wo(this,e).duration=+t.apply(this,arguments)}}function Hz(e,t){return t=+t,function(){Wo(this,e).duration=t}}function Bz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?zz:Hz)(t,e)):io(this.node(),t).duration}function Wz(e,t){if(typeof t!="function")throw new Error;return function(){Wo(this,e).ease=t}}function Vz(e){var t=this._id;return arguments.length?this.each(Wz(t,e)):io(this.node(),t).ease}function Kz(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Wo(this,e).ease=n}}function Uz(e){if(typeof e!="function")throw new Error;return this.each(Kz(this._id,e))}function qz(e){typeof e!="function"&&(e=$P(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],u,d=0;d<a;++d)(u=o[d])&&e.call(u,u.__data__,d,o)&&l.push(u);return new xa(r,this._parents,this._name,this._id)}function Yz(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var u=t[l],d=n[l],p=u.length,c=a[l]=new Array(p),f,h=0;h<p;++h)(f=u[h]||d[h])&&(c[h]=f);for(;l<r;++l)a[l]=t[l];return new xa(a,this._parents,this._name,this._id)}function Gz(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 Xz(e,t,n){var r,s,o=Gz(t)?g0:Wo;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function Jz(e,t){var n=this._id;return arguments.length<2?io(this.node(),n).on.on(e):this.each(Xz(n,e,t))}function Qz(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Zz(){return this.on("end.remove",Qz(this._id))}function e3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=d0(e));for(var r=this._groups,s=r.length,o=new Array(s),a=0;a<s;++a)for(var l=r[a],u=l.length,d=o[a]=new Array(u),p,c,f=0;f<u;++f)(p=l[f])&&(c=e.call(p,p.__data__,f,l))&&("__data__"in p&&(c.__data__=p.__data__),d[f]=c,hy(d[f],t,n,f,d,io(p,n)));return new xa(o,this._parents,t,n)}function t3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=OP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var u=r[l],d=u.length,p,c=0;c<d;++c)if(p=u[c]){for(var f=e.call(p,p.__data__,c,u),h,g=io(p,n),b=0,k=f.length;b<k;++b)(h=f[b])&&hy(h,t,n,b,f,g);o.push(f),a.push(p)}return new xa(o,a,t,n)}var n3=Mp.prototype.constructor;function r3(){return new n3(this._groups,this._parents)}function s3(e,t){var n,r,s;return function(){var o=Xu(this,e),a=(this.style.removeProperty(e),Xu(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function aA(e){return function(){this.style.removeProperty(e)}}function i3(e,t,n){var r,s=n+"",o;return function(){var a=Xu(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function o3(e,t,n){var r,s,o;return function(){var a=Xu(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),Xu(this,e))),a===u?null:a===r&&u===s?o:(s=u,o=t(r=a,l))}}function a3(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var u=Wo(this,e),d=u.on,p=u.value[o]==null?l||(l=aA(t)):void 0;(d!==n||s!==p)&&(r=(n=d).copy()).on(a,s=p),u.on=r}}function l3(e,t,n){var r=(e+="")=="transform"?cz:oA;return t==null?this.styleTween(e,s3(e,r)).on("end.style."+e,aA(e)):typeof t=="function"?this.styleTween(e,o3(e,r,y0(this,"style."+e,t))).each(a3(this._id,e)):this.styleTween(e,i3(e,r,t),n).on("end.style."+e,null)}function c3(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function u3(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&c3(e,a,n)),r}return o._value=t,o}function d3(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,u3(e,t,n??""))}function f3(e){return function(){this.textContent=e}}function p3(e){return function(){var t=e(this);this.textContent=t??""}}function h3(e){return this.tween("text",typeof e=="function"?p3(y0(this,"text",e)):f3(e==null?"":e+""))}function m3(e){return function(t){this.textContent=e.call(this,t)}}function g3(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&m3(s)),t}return r._value=e,r}function y3(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,g3(e))}function x3(){for(var e=this._name,t=this._id,n=lA(),r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,u,d=0;d<l;++d)if(u=a[d]){var p=io(u,t);hy(u,e,n,d,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new xa(r,this._parents,e,n)}function w3(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,a){var l={value:a},u={value:function(){--s===0&&o()}};n.each(function(){var d=Wo(this,r),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),d.on=t}),s===0&&o()})}var b3=0;function xa(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function lA(){return++b3}var ta=Mp.prototype;xa.prototype={constructor:xa,select:e3,selectAll:t3,selectChild:ta.selectChild,selectChildren:ta.selectChildren,filter:qz,merge:Yz,selection:r3,transition:x3,call:ta.call,nodes:ta.nodes,node:ta.node,size:ta.size,empty:ta.empty,each:ta.each,on:Jz,attr:Iz,attrTween:Oz,style:l3,styleTween:d3,text:h3,textTween:y3,remove:Zz,tween:Nz,delay:Fz,duration:Bz,ease:Vz,easeVarying:Uz,end:w3,[Symbol.iterator]:ta[Symbol.iterator]};function v3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var k3={time:null,delay:0,duration:250,ease:v3};function S3(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function N3(e){var t,n;e instanceof xa?(t=e._id,e=e._name):(t=lA(),(n=k3).time=m0(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,u,d=0;d<l;++d)(u=a[d])&&hy(u,e,t,d,a,n||S3(u,t));return new xa(r,this._parents,e,t)}Mp.prototype.interrupt=vz;Mp.prototype.transition=N3;const Bh=e=>()=>e;function j3(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 ca(e,t,n){this.k=e,this.x=t,this.y=n}ca.prototype={constructor:ca,scale:function(e){return e===1?this:new ca(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ca(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 my=new ca(1,0,0);cA.prototype=ca.prototype;function cA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return my;return e.__zoom}function _x(e){e.stopImmediatePropagation()}function rf(e){e.preventDefault(),e.stopImmediatePropagation()}function C3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function E3(){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 fN(){return this.__zoom||my}function _3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function P3(){return navigator.maxTouchPoints||"ontouchstart"in this}function A3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=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>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function uA(){var e=C3,t=E3,n=A3,r=_3,s=P3,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,u=Cm,d=dy("start","zoom","end"),p,c,f,h=500,g=150,b=0,k=10;function y(L){L.property("__zoom",fN).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",H).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(L,M,I,z){var A=L.selection?L.selection():L;A.property("__zoom",fN),L!==A?_(L,M,I,z):A.interrupt().each(function(){C(this,arguments).event(z).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},y.scaleBy=function(L,M,I,z){y.scaleTo(L,function(){var A=this.__zoom.k,O=typeof M=="function"?M.apply(this,arguments):M;return A*O},I,z)},y.scaleTo=function(L,M,I,z){y.transform(L,function(){var A=t.apply(this,arguments),O=this.__zoom,E=I==null?N(A):typeof I=="function"?I.apply(this,arguments):I,J=O.invert(E),Z=typeof M=="function"?M.apply(this,arguments):M;return n(x(w(O,Z),E,J),A,a)},I,z)},y.translateBy=function(L,M,I,z){y.transform(L,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,z)},y.translateTo=function(L,M,I,z,A){y.transform(L,function(){var O=t.apply(this,arguments),E=this.__zoom,J=z==null?N(O):typeof z=="function"?z.apply(this,arguments):z;return n(my.translate(J[0],J[1]).scale(E.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof I=="function"?-I.apply(this,arguments):-I),O,a)},z,A)};function w(L,M){return M=Math.max(o[0],Math.min(o[1],M)),M===L.k?L:new ca(M,L.x,L.y)}function x(L,M,I){var z=M[0]-I[0]*L.k,A=M[1]-I[1]*L.k;return z===L.x&&A===L.y?L:new ca(L.k,z,A)}function N(L){return[(+L[0][0]+ +L[1][0])/2,(+L[0][1]+ +L[1][1])/2]}function _(L,M,I,z){L.on("start.zoom",function(){C(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,O=arguments,E=C(A,O).event(z),J=t.apply(A,O),Z=I==null?N(J):typeof I=="function"?I.apply(A,O):I,K=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),oe=A.__zoom,de=typeof M=="function"?M.apply(A,O):M,he=u(oe.invert(Z).concat(K/oe.k),de.invert(Z).concat(K/de.k));return function(we){if(we===1)we=de;else{var ue=he(we),Ne=K/ue[2];we=new ca(Ne,Z[0]-ue[0]*Ne,Z[1]-ue[1]*Ne)}E.zoom(null,we)}})}function C(L,M,I){return!I&&L.__zooming||new T(L,M)}function T(L,M){this.that=L,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(L,M),this.taps=0}T.prototype={event:function(L){return L&&(this.sourceEvent=L),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(L,M){return this.mouse&&L!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&L!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&L!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(L){var M=ri(this.that).datum();d.call(L,this.that,new j3(L,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),M)}};function F(L,...M){if(!e.apply(this,arguments))return;var I=C(this,M).event(L),z=this.__zoom,A=Math.max(o[0],Math.min(o[1],z.k*Math.pow(2,r.apply(this,arguments)))),O=Yi(L);if(I.wheel)(I.mouse[0][0]!==O[0]||I.mouse[0][1]!==O[1])&&(I.mouse[1]=z.invert(I.mouse[0]=O)),clearTimeout(I.wheel);else{if(z.k===A)return;I.mouse=[O,z.invert(O)],Pm(this),I.start()}rf(L),I.wheel=setTimeout(E,g),I.zoom("mouse",n(x(w(z,A),I.mouse[0],I.mouse[1]),I.extent,a));function E(){I.wheel=null,I.end()}}function R(L,...M){if(f||!e.apply(this,arguments))return;var I=L.currentTarget,z=C(this,M,!0).event(L),A=ri(L.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",K,!0),O=Yi(L,I),E=L.clientX,J=L.clientY;qP(L.view),_x(L),z.mouse=[O,this.__zoom.invert(O)],Pm(this),z.start();function Z(oe){if(rf(oe),!z.moved){var de=oe.clientX-E,he=oe.clientY-J;z.moved=de*de+he*he>b}z.event(oe).zoom("mouse",n(x(z.that.__zoom,z.mouse[0]=Yi(oe,I),z.mouse[1]),z.extent,a))}function K(oe){A.on("mousemove.zoom mouseup.zoom",null),YP(oe.view,z.moved),rf(oe),z.event(oe).end()}}function H(L,...M){if(e.apply(this,arguments)){var I=this.__zoom,z=Yi(L.changedTouches?L.changedTouches[0]:L,this),A=I.invert(z),O=I.k*(L.shiftKey?.5:2),E=n(x(w(I,O),z,A),t.apply(this,M),a);rf(L),l>0?ri(this).transition().duration(l).call(_,E,z,L):ri(this).call(y.transform,E,z,L)}}function D(L,...M){if(e.apply(this,arguments)){var I=L.touches,z=I.length,A=C(this,M,L.changedTouches.length===z).event(L),O,E,J,Z;for(_x(L),E=0;E<z;++E)J=I[E],Z=Yi(J,this),Z=[Z,this.__zoom.invert(Z),J.identifier],A.touch0?!A.touch1&&A.touch0[2]!==Z[2]&&(A.touch1=Z,A.taps=0):(A.touch0=Z,O=!0,A.taps=1+!!p);p&&(p=clearTimeout(p)),O&&(A.taps<2&&(c=Z[0],p=setTimeout(function(){p=null},h)),Pm(this),A.start())}}function $(L,...M){if(this.__zooming){var I=C(this,M).event(L),z=L.changedTouches,A=z.length,O,E,J,Z;for(rf(L),O=0;O<A;++O)E=z[O],J=Yi(E,this),I.touch0&&I.touch0[2]===E.identifier?I.touch0[0]=J:I.touch1&&I.touch1[2]===E.identifier&&(I.touch1[0]=J);if(E=I.that.__zoom,I.touch1){var K=I.touch0[0],oe=I.touch0[1],de=I.touch1[0],he=I.touch1[1],we=(we=de[0]-K[0])*we+(we=de[1]-K[1])*we,ue=(ue=he[0]-oe[0])*ue+(ue=he[1]-oe[1])*ue;E=w(E,Math.sqrt(we/ue)),J=[(K[0]+de[0])/2,(K[1]+de[1])/2],Z=[(oe[0]+he[0])/2,(oe[1]+he[1])/2]}else if(I.touch0)J=I.touch0[0],Z=I.touch0[1];else return;I.zoom("touch",n(x(E,J,Z),I.extent,a))}}function B(L,...M){if(this.__zooming){var I=C(this,M).event(L),z=L.changedTouches,A=z.length,O,E;for(_x(L),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),O=0;O<A;++O)E=z[O],I.touch0&&I.touch0[2]===E.identifier?delete I.touch0:I.touch1&&I.touch1[2]===E.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(E=Yi(E,this),Math.hypot(c[0]-E[0],c[1]-E[1])<k)){var J=ri(this).on("dblclick.zoom");J&&J.apply(this,arguments)}}}return y.wheelDelta=function(L){return arguments.length?(r=typeof L=="function"?L:Bh(+L),y):r},y.filter=function(L){return arguments.length?(e=typeof L=="function"?L:Bh(!!L),y):e},y.touchable=function(L){return arguments.length?(s=typeof L=="function"?L:Bh(!!L),y):s},y.extent=function(L){return arguments.length?(t=typeof L=="function"?L:Bh([[+L[0][0],+L[0][1]],[+L[1][0],+L[1][1]]]),y):t},y.scaleExtent=function(L){return arguments.length?(o[0]=+L[0],o[1]=+L[1],y):[o[0],o[1]]},y.translateExtent=function(L){return arguments.length?(a[0][0]=+L[0][0],a[1][0]=+L[1][0],a[0][1]=+L[0][1],a[1][1]=+L[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(L){return arguments.length?(n=L,y):n},y.duration=function(L){return arguments.length?(l=+L,y):l},y.interpolate=function(L){return arguments.length?(u=L,y):u},y.on=function(){var L=d.on.apply(d,arguments);return L===d?y:L},y.clickDistance=function(L){return arguments.length?(b=(L=+L)*L,y):Math.sqrt(b)},y.tapDistance=function(L){return arguments.length?(k=+L,y):k},y}const zo={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."},dp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],dA=["Enter"," ","Escape"],fA={"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 Qu;(function(e){e.Strict="strict",e.Loose="loose"})(Qu||(Qu={}));var dc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(dc||(dc={}));var fp;(function(e){e.Partial="partial",e.Full="full"})(fp||(fp={}));const pA={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Qa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Qa||(Qa={}));var ks;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ks||(ks={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const pN={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top};function hA(e){return e===null?null:e?"valid":"invalid"}const mA=e=>"id"in e&&"source"in e&&"target"in e,I3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),x0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Op=(e,t=[0,0])=>{const{width:n,height:r}=ka(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},T3=(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 o=typeof s=="string";let a=!t.nodeLookup&&!o?s:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(s):x0(s)?s:t.nodeLookup.get(s.id));const l=a?yg(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return gy(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return yy(n)},$p=(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=gy(n,yg(s)),r=!0)}),r?yy(n):{x:0,y:0,width:0,height:0}},w0=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...Fp(t,[n,r,s]),width:t.width/s,height:t.height/s},u=[];for(const d of e.values()){const{measured:p,selectable:c=!0,hidden:f=!1}=d;if(a&&!c||f)continue;const h=p.width??d.width??d.initialWidth??null,g=p.height??d.height??d.initialHeight??null,b=pp(l,ed(d)),k=(h??0)*(g??0),y=o&&b>0;(!d.internals.handleBounds||y||b>=k||d.dragging)&&u.push(d)}return u},R3=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function M3(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function L3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=M3(e,a),u=$p(l),d=b0(u,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??o,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function gA({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:u,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let c=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",zo.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(c=[[u,d],[u+h,d+g]])}else l&&td(a.extent)&&(c=[[a.extent[0][0]+u,a.extent[0][1]+d],[a.extent[1][0]+u,a.extent[1][1]+d]]);const f=td(c)?kc(t,c,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",zo.error015())),{position:{x:f.x-u+(a.measured.width??0)*p[0],y:f.y-d+(a.measured.height??0)*p[1]},positionAbsolute:f}}async function O3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(f=>f.id)),a=[];for(const f of n){if(f.deletable===!1)continue;const h=o.has(f.id),g=!h&&f.parentId&&a.find(b=>b.id===f.parentId);(h||g)&&a.push(f)}const l=new Set(t.map(f=>f.id)),u=r.filter(f=>f.deletable!==!1),p=R3(a,u);for(const f of u)l.has(f.id)&&!p.find(g=>g.id===f.id)&&p.push(f);if(!s)return{edges:p,nodes:a};const c=await s({nodes:a,edges:p});return typeof c=="boolean"?c?{edges:p,nodes:a}:{edges:[],nodes:[]}:c}const Zu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),kc=(e={x:0,y:0},t,n)=>({x:Zu(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Zu(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function yA(e,t,n){const{width:r,height:s}=ka(n),{x:o,y:a}=n.internals.positionAbsolute;return kc(e,[[o,a],[o+r,a+s]],t)}const hN=(e,t,n)=>e<t?Zu(Math.abs(e-t),1,t)/t:e>n?-Zu(Math.abs(e-n),1,t)/t:0,xA=(e,t,n=15,r=40)=>{const s=hN(e.x,r,t.width-r)*n,o=hN(e.y,r,t.height-r)*n;return[s,o]},gy=(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)}),Pb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),yy=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ed=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=x0(e)?e.internals.positionAbsolute:Op(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},yg=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=x0(e)?e.internals.positionAbsolute:Op(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},wA=(e,t)=>yy(gy(Pb(e),Pb(t))),pp=(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)},mN=e=>Qi(e.width)&&Qi(e.height)&&Qi(e.x)&&Qi(e.y),Qi=e=>!isNaN(e)&&isFinite(e),$3=(e,t)=>{},Dp=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Fp=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?Dp(l,a):l},xg=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function ru(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 D3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ru(e,n),s=ru(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=ru(e.top??e.y??0,n),s=ru(e.bottom??e.y??0,n),o=ru(e.left??e.x??0,t),a=ru(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:o,x:o+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function F3(e,t,n,r,s,o){const{x:a,y:l}=xg(e,[t,n,r]),{x:u,y:d}=xg({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=s-u,c=o-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(c)}}const b0=(e,t,n,r,s,o)=>{const a=D3(o,t,n),l=(t-a.x)/e.width,u=(n-a.y)/e.height,d=Math.min(l,u),p=Zu(d,r,s),c=e.x+e.width/2,f=e.y+e.height/2,h=t/2-c*p,g=n/2-f*p,b=F3(e,h,g,p,t,n),k={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-k.left+k.right,y:g-k.top+k.bottom,zoom:p}},hp=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function td(e){return e!=null&&e!=="parent"}function ka(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 bA(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 vA(e,t={width:0,height:0},n,r,s){const o={...e},a=r.get(n);if(a){const l=a.origin||s;o.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],o.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return o}function gN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function z3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function H3(e){return{...fA,...e||{}}}function Mf(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=Zi(e),l=Fp({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:u,y:d}=n?Dp(l,t):l;return{xSnapped:u,ySnapped:d,...l}}const v0=e=>({width:e.offsetWidth,height:e.offsetHeight}),kA=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},B3=["INPUT","SELECT","TEXTAREA"];function SA(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:B3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const NA=e=>"clientX"in e,Zi=(e,t)=>{var o,a;const n=NA(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[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)}},yN=(e,t,n,r,s)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).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,...v0(a)}})};function jA({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:a,targetControlY:l}){const u=e*.125+s*.375+a*.375+n*.125,d=t*.125+o*.375+l*.375+r*.125,p=Math.abs(u-e),c=Math.abs(d-t);return[u,d,p,c]}function Wh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function xN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Je.Left:return[t-Wh(t-r,o),n];case Je.Right:return[t+Wh(r-t,o),n];case Je.Top:return[t,n-Wh(n-s,o)];case Je.Bottom:return[t,n+Wh(s-n,o)]}}function CA({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:o=Je.Top,curvature:a=.25}){const[l,u]=xN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,p]=xN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[c,f,h,g]=jA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:p});return[`M${e},${t} C${l},${u} ${d},${p} ${r},${s}`,c,f,h,g]}function EA({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[o,l,s,a]}function W3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:o="basic"}){if(o==="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 V3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=gy(yg(e),yg(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return pp(a,yy(o))>0}const K3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,U3=(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)),Du=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||K3;let s;return mA(e)?s={...e}:s={...e,id:r(e)},U3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function _A({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=EA({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const wN={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},q3=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.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},bN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Y3({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:r=Je.Top,center:s,offset:o,stepPosition:a}){const l=wN[t],u=wN[r],d={x:e.x+l.x*o,y:e.y+l.y*o},p={x:n.x+u.x*o,y:n.y+u.y*o},c=q3({source:d,sourcePosition:t,target:p}),f=c.x!==0?"x":"y",h=c[f];let g=[],b,k;const y={x:0,y:0},w={x:0,y:0},[,,x,N]=EA({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[f]*u[f]===-1){f==="x"?(b=s.x??d.x+(p.x-d.x)*a,k=s.y??(d.y+p.y)/2):(b=s.x??(d.x+p.x)/2,k=s.y??d.y+(p.y-d.y)*a);const F=[{x:b,y:d.y},{x:b,y:p.y}],R=[{x:d.x,y:k},{x:p.x,y:k}];l[f]===h?g=f==="x"?F:R:g=f==="x"?R:F}else{const F=[{x:d.x,y:p.y}],R=[{x:p.x,y:d.y}];if(f==="x"?g=l.x===h?R:F:g=l.y===h?F:R,t===r){const L=Math.abs(e[f]-n[f]);if(L<=o){const M=Math.min(o-1,o-L);l[f]===h?y[f]=(d[f]>e[f]?-1:1)*M:w[f]=(p[f]>n[f]?-1:1)*M}}if(t!==r){const L=f==="x"?"y":"x",M=l[f]===u[L],I=d[L]>p[L],z=d[L]<p[L];(l[f]===1&&(!M&&I||M&&z)||l[f]!==1&&(!M&&z||M&&I))&&(g=f==="x"?F:R)}const H={x:d.x+y.x,y:d.y+y.y},D={x:p.x+w.x,y:p.y+w.y},$=Math.max(Math.abs(H.x-g[0].x),Math.abs(D.x-g[0].x)),B=Math.max(Math.abs(H.y-g[0].y),Math.abs(D.y-g[0].y));$>=B?(b=(H.x+D.x)/2,k=g[0].y):(b=g[0].x,k=(H.y+D.y)/2)}const _={x:d.x+y.x,y:d.y+y.y},C={x:p.x+w.x,y:p.y+w.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],b,k,x,N]}function G3(e,t,n,r){const s=Math.min(bN(e,t)/2,bN(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+s*d},${a}Q ${o},${a} ${o},${a+s*p}`}const l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${o},${a+s*u}Q ${o},${a} ${o+s*l},${a}`}function Ab({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:o=Je.Top,borderRadius:a=5,centerX:l,centerY:u,offset:d=20,stepPosition:p=.5}){const[c,f,h,g,b]=Y3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:u},offset:d,stepPosition:p});let k=`M${c[0].x} ${c[0].y}`;for(let y=1;y<c.length-1;y++)k+=G3(c[y-1],c[y],c[y+1],a);return k+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[k,f,h,g,b]}function vN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function X3(e){var c;const{sourceNode:t,targetNode:n}=e;if(!vN(t)||!vN(n))return null;const r=t.internals.handleBounds||kN(t.handles),s=n.internals.handleBounds||kN(n.handles),o=SN((r==null?void 0:r.source)??[],e.sourceHandle),a=SN(e.connectionMode===Qu.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!o||!a)return(c=e.onError)==null||c.call(e,"008",zo.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Je.Bottom,u=(a==null?void 0:a.position)||Je.Top,d=Sc(t,o,l),p=Sc(n,a,u);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:u}}function kN(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 Sc(e,t,n=Je.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ka(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:s+a/2,y:o};case Je.Right:return{x:s+a,y:o+l/2};case Je.Bottom:return{x:s+a/2,y:o+l};case Je.Left:return{x:s,y:o+l/2}}}function SN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ib(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function J3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const o=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const d=Ib(u,t);o.has(d)||(a.push({id:d,color:u.color||n,...u}),o.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const PA=1e3,Q3=10,k0={nodeOrigin:[0,0],nodeExtent:dp,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Z3={...k0,checkEquality:!0};function S0(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function eH(e,t,n){const r=S0(k0,n);for(const s of e.values())if(s.parentId)j0(s,e,t,r);else{const o=Op(s,r.nodeOrigin),a=td(s.extent)?s.extent:r.nodeExtent,l=kc(o,a,ka(s));s.internals.positionAbsolute=l}}function tH(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 o={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(o):s.type==="target"&&r.push(o)}return{source:n,target:r}}function N0(e){return e==="manual"}function Tb(e,t,n,r={}){var p,c;const s=S0(Z3,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!N0(s.zIndexMode)?PA:0;let u=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let h=a.get(f.id);if(s.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Op(f,s.nodeOrigin),b=td(f.extent)?f.extent:s.nodeExtent,k=kc(g,b,ka(f));h={...s.defaults,...f,measured:{width:(p=f.measured)==null?void 0:p.width,height:(c=f.measured)==null?void 0:c.height},internals:{positionAbsolute:k,handleBounds:tH(f,h),z:AA(f,l,s.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(u=!1),f.parentId&&j0(h,t,n,r,o),d||(d=f.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:d}}function nH(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 j0(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:u}=S0(k0,r),d=e.parentId,p=t.get(d);if(!p){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}nH(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&u==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*Q3),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const c=o&&!N0(u)?PA:0,{x:f,y:h,z:g}=rH(e,p,a,l,c,u),{positionAbsolute:b}=e.internals,k=f!==b.x||h!==b.y;(k||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:f,y:h}:b,z:g}})}function AA(e,t,n){const r=Qi(e.zIndex)?e.zIndex:0;return N0(n)?r:r+(e.selected?t:0)}function rH(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,u=ka(e),d=Op(e,n),p=td(e.extent)?kc(d,e.extent,u):d;let c=kc({x:a+p.x,y:l+p.y},r,u);e.extent==="parent"&&(c=yA(c,u,t));const f=AA(e,s,o),h=t.internals.z??0;return{x:c.x,y:c.y,z:h>=f?h+1:f}}function C0(e,t,n,r=[0,0]){var a;const s=[],o=new Map;for(const l of e){const u=t.get(l.parentId);if(!u)continue;const d=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??ed(u),p=wA(d,l.rect);o.set(l.parentId,{expandedRect:p,parent:u})}return o.size>0&&o.forEach(({expandedRect:l,parent:u},d)=>{var x;const p=u.internals.positionAbsolute,c=ka(u),f=u.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(c.width,Math.round(l.width)),k=Math.max(c.height,Math.round(l.height)),y=(b-c.width)*f[0],w=(k-c.height)*f[1];(h>0||g>0||y||w)&&(s.push({id:d,type:"position",position:{x:u.position.x-h+y,y:u.position.y-g+w}}),(x=n.get(d))==null||x.forEach(N=>{e.some(_=>_.id===N.id)||s.push({id:N.id,type:"position",position:{x:N.position.x+h,y:N.position.y+g}})})),(c.width<l.width||c.height<l.height||h||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:b+(h?f[0]*h-y:0),height:k+(g?f[1]*g-w:0)}})}),s}function sH(e,t,n,r,s,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let u=!1;if(!l)return{changes:[],updatedInternals:u};const d=[],p=window.getComputedStyle(l),{m22:c}=new window.DOMMatrixReadOnly(p.transform),f=[];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}}),u=!0;continue}const b=v0(h.nodeElement),k=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(k||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),x=td(g.extent)?g.extent:o;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=yA(N,b,t.get(g.parentId)):x&&(N=kc(N,x,b));const _={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:yN("source",h.nodeElement,w,c,g.id),target:yN("target",h.nodeElement,w,c,g.id)}}};t.set(g.id,_),g.parentId&&j0(_,t,n,{nodeOrigin:s,zIndexMode:a}),u=!0,k&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:ed(_,s)}))}}if(f.length>0){const h=C0(f,t,n,s);d.push(...h)}return{changes:d,updatedInternals:u}}async function iH({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:o}){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,o]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function NN(e,t,n,r,s,o){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const u=r.get(a)||new Map;if(r.set(a,u.set(n,t)),o){a=`${s}-${e}-${o}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function IA(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:o,sourceHandle:a=null,targetHandle:l=null}=r,u={edgeId:r.id,source:s,target:o,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${o}-${l}`,p=`${o}-${l}--${s}-${a}`;NN("source",u,p,e,s,a),NN("target",u,d,e,o,l),t.set(r.id,r)}}function TA(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:TA(n,t):!1}function jN(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 oH(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!TA(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(o);l&&s.set(o,{id:o,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 Px({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,u;const s=[];for(const[d,p]of t){const c=(a=n.get(d))==null?void 0:a.internals.userNode;c&&s.push({...c,position:p.position,dragging:r})}if(!e)return[s[0],s];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((u=t.get(e))==null?void 0:u.position)||o.position,dragging:r}:s[0],s]}function aH({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const o={x:n-s.distance.x,y:r-s.distance.y},a=Dp(o,t);return{x:a.x-o.x,y:a.y-o.y}}function lH({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,u=!1,d={x:0,y:0},p=null,c=!1,f=null,h=!1,g=!1,b=null;function k({noDragClassName:w,handleSelector:x,domNode:N,isSelectable:_,nodeId:C,nodeClickDistance:T=0}){f=ri(N);function F({x:$,y:B}){const{nodeLookup:L,nodeExtent:M,snapGrid:I,snapToGrid:z,nodeOrigin:A,onNodeDrag:O,onSelectionDrag:E,onError:J,updateNodePositions:Z}=t();o={x:$,y:B};let K=!1;const oe=l.size>1,de=oe&&M?Pb($p(l)):null,he=oe&&z?aH({dragItems:l,snapGrid:I,x:$,y:B}):null;for(const[we,ue]of l){if(!L.has(we))continue;let Ne={x:$-ue.distance.x,y:B-ue.distance.y};z&&(Ne=he?{x:Math.round(Ne.x+he.x),y:Math.round(Ne.y+he.y)}:Dp(Ne,I));let le=null;if(oe&&M&&!ue.extent&&de){const{positionAbsolute:Se}=ue.internals,Ke=Se.x-de.x+M[0][0],et=Se.x+ue.measured.width-de.x2+M[1][0],We=Se.y-de.y+M[0][1],ut=Se.y+ue.measured.height-de.y2+M[1][1];le=[[Ke,We],[et,ut]]}const{position:ce,positionAbsolute:xe}=gA({nodeId:we,nextPosition:Ne,nodeLookup:L,nodeExtent:le||M,nodeOrigin:A,onError:J});K=K||ue.position.x!==ce.x||ue.position.y!==ce.y,ue.position=ce,ue.internals.positionAbsolute=xe}if(g=g||K,!!K&&(Z(l,!0),b&&(r||O||!C&&E))){const[we,ue]=Px({nodeId:C,dragItems:l,nodeLookup:L});r==null||r(b,l,we,ue),O==null||O(b,we,ue),C||E==null||E(b,ue)}}async function R(){if(!p)return;const{transform:$,panBy:B,autoPanSpeed:L,autoPanOnNodeDrag:M}=t();if(!M){u=!1,cancelAnimationFrame(a);return}const[I,z]=xA(d,p,L);(I!==0||z!==0)&&(o.x=(o.x??0)-I/$[2],o.y=(o.y??0)-z/$[2],await B({x:I,y:z})&&F(o)),a=requestAnimationFrame(R)}function H($){var oe;const{nodeLookup:B,multiSelectionActive:L,nodesDraggable:M,transform:I,snapGrid:z,snapToGrid:A,selectNodesOnDrag:O,onNodeDragStart:E,onSelectionDragStart:J,unselectNodesAndEdges:Z}=t();c=!0,(!O||!_)&&!L&&C&&((oe=B.get(C))!=null&&oe.selected||Z()),_&&O&&C&&(e==null||e(C));const K=Mf($.sourceEvent,{transform:I,snapGrid:z,snapToGrid:A,containerBounds:p});if(o=K,l=oH(B,M,K,C),l.size>0&&(n||E||!C&&J)){const[de,he]=Px({nodeId:C,dragItems:l,nodeLookup:B});n==null||n($.sourceEvent,l,de,he),E==null||E($.sourceEvent,de,he),C||J==null||J($.sourceEvent,he)}}const D=GP().clickDistance(T).on("start",$=>{const{domNode:B,nodeDragThreshold:L,transform:M,snapGrid:I,snapToGrid:z}=t();p=(B==null?void 0:B.getBoundingClientRect())||null,h=!1,g=!1,b=$.sourceEvent,L===0&&H($),o=Mf($.sourceEvent,{transform:M,snapGrid:I,snapToGrid:z,containerBounds:p}),d=Zi($.sourceEvent,p)}).on("drag",$=>{const{autoPanOnNodeDrag:B,transform:L,snapGrid:M,snapToGrid:I,nodeDragThreshold:z,nodeLookup:A}=t(),O=Mf($.sourceEvent,{transform:L,snapGrid:M,snapToGrid:I,containerBounds:p});if(b=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||C&&!A.has(C))&&(h=!0),!h){if(!u&&B&&c&&(u=!0,R()),!c){const E=Zi($.sourceEvent,p),J=E.x-d.x,Z=E.y-d.y;Math.sqrt(J*J+Z*Z)>z&&H($)}(o.x!==O.xSnapped||o.y!==O.ySnapped)&&l&&c&&(d=Zi($.sourceEvent,p),F(O))}}).on("end",$=>{if(!(!c||h)&&(u=!1,c=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:B,updateNodePositions:L,onNodeDragStop:M,onSelectionDragStop:I}=t();if(g&&(L(l,!1),g=!1),s||M||!C&&I){const[z,A]=Px({nodeId:C,dragItems:l,nodeLookup:B,dragging:!1});s==null||s($.sourceEvent,l,z,A),M==null||M($.sourceEvent,z,A),C||I==null||I($.sourceEvent,A)}}}).filter($=>{const B=$.target;return!$.button&&(!w||!jN(B,`.${w}`,N))&&(!x||jN(B,x,N))});f.call(D)}function y(){f==null||f.on(".drag",null)}return{update:k,destroy:y}}function cH(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())pp(s,ed(o))>0&&r.push(o);return r}const uH=250;function dH(e,t,n,r){var l,u;let s=[],o=1/0;const a=cH(e,n,t+uH);for(const d of a){const p=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((u=d.internals.handleBounds)==null?void 0:u.target)??[]];for(const c of p){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:f,y:h}=Sc(d,c,c.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<o?(s=[{...c,x:f,y:h}],o=g):g===o&&s.push({...c,x:f,y:h}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(p=>p.type===d)??s[0]}return s[0]}function RA(e,t,n,r,s,o=!1){var d,p,c;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((c=a.internals.handleBounds)==null?void 0:c.target)??[]],u=(n?l==null?void 0:l.find(f=>f.id===n):l==null?void 0:l[0])??null;return u&&o?{...u,...Sc(a,u,u.position,!0)}:u}function MA(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function fH(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const LA=()=>!0;function pH(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:u,lib:d,autoPanOnConnect:p,flowId:c,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:k,isValidConnection:y=LA,onReconnectEnd:w,updateConnection:x,getTransform:N,getFromHandle:_,autoPanSpeed:C,dragThreshold:T=1,handleDomNode:F}){const R=kA(e.target);let H=0,D;const{x:$,y:B}=Zi(e),L=MA(o,F),M=l==null?void 0:l.getBoundingClientRect();let I=!1;if(!M||!L)return;const z=RA(s,L,r,u,t);if(!z)return;let A=Zi(e,M),O=!1,E=null,J=!1,Z=null;function K(){if(!p||!M)return;const[ce,xe]=xA(A,M,C);f({x:ce,y:xe}),H=requestAnimationFrame(K)}const oe={...z,nodeId:s,type:L,position:z.position},de=u.get(s);let we={inProgress:!0,isValid:null,from:Sc(de,oe,Je.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:de,to:A,toHandle:null,toPosition:pN[oe.position],toNode:null,pointer:A};function ue(){I=!0,x(we),g==null||g(e,{nodeId:s,handleId:r,handleType:L})}T===0&&ue();function Ne(ce){if(!I){const{x:ut,y:Ve}=Zi(ce),xt=ut-$,bt=Ve-B;if(!(xt*xt+bt*bt>T*T))return;ue()}if(!_()||!oe){le(ce);return}const xe=N();A=Zi(ce,M),D=dH(Fp(A,xe,!1,[1,1]),n,u,oe),O||(K(),O=!0);const Se=OA(ce,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:R,lib:d,flowId:c,nodeLookup:u});Z=Se.handleDomNode,E=Se.connection,J=fH(!!D,Se.isValid);const Ke=u.get(s),et=Ke?Sc(Ke,oe,Je.Left,!0):we.from,We={...we,from:et,isValid:J,to:Se.toHandle&&J?xg({x:Se.toHandle.x,y:Se.toHandle.y},xe):A,toHandle:Se.toHandle,toPosition:J&&Se.toHandle?Se.toHandle.position:pN[oe.position],toNode:Se.toHandle?u.get(Se.toHandle.nodeId):null,pointer:A};x(We),we=We}function le(ce){if(!("touches"in ce&&ce.touches.length>0)){if(I){(D||Z)&&E&&J&&(b==null||b(E));const{inProgress:xe,...Se}=we,Ke={...Se,toPosition:we.toHandle?we.toPosition:null};k==null||k(ce,Ke),o&&(w==null||w(ce,Ke))}h(),cancelAnimationFrame(H),O=!1,J=!1,E=null,Z=null,R.removeEventListener("mousemove",Ne),R.removeEventListener("mouseup",le),R.removeEventListener("touchmove",Ne),R.removeEventListener("touchend",le)}}R.addEventListener("mousemove",Ne),R.addEventListener("mouseup",le),R.addEventListener("touchmove",Ne),R.addEventListener("touchend",le)}function OA(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:u,isValidConnection:d=LA,nodeLookup:p}){const c=o==="target",f=t?a.querySelector(`.${l}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=Zi(e),b=a.elementFromPoint(h,g),k=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:f,y={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const w=MA(void 0,k),x=k.getAttribute("data-nodeid"),N=k.getAttribute("data-handleid"),_=k.classList.contains("connectable"),C=k.classList.contains("connectableend");if(!x||!w)return y;const T={source:c?x:r,sourceHandle:c?N:s,target:c?r:x,targetHandle:c?s:N};y.connection=T;const R=_&&C&&(n===Qu.Strict?c&&w==="source"||!c&&w==="target":x!==r||N!==s);y.isValid=R&&d(T),y.toHandle=RA(x,w,N,p,n,!0)}return y}const Rb={onPointerDown:pH,isValid:OA};function hH({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ri(e);function o({translateExtent:l,width:u,height:d,zoomStep:p=1,pannable:c=!0,zoomable:f=!0,inversePan:h=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const N=n(),_=x.sourceEvent.ctrlKey&&hp()?10:1,C=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*p,T=N[2]*Math.pow(2,C*_);t.scaleTo(T)};let b=[0,0];const k=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 N=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const _=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],C=[_[0]-b[0],_[1]-b[1]];b=_;const T=r()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),F={x:N[0]-C[0]*T,y:N[1]-C[1]*T},R=[[0,0],[u,d]];t.setViewportConstrained({x:F.x,y:F.y,zoom:N[2]},R,l)},w=uA().on("start",k).on("zoom",c?y:null).on("zoom.wheel",f?g:null);s.call(w,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:Yi}}const xy=e=>({x:e.x,y:e.y,zoom:e.k}),Ax=({x:e,y:t,zoom:n})=>my.translate(e,t).scale(n),ju=(e,t)=>e.target.closest(`.${t}`),$A=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),mH=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ix=(e,t=0,n=mH,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},DA=e=>{const t=e.ctrlKey&&hp()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function gH({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:u,onPanZoomEnd:d}){return p=>{if(ju(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(p.ctrlKey&&a){const k=Yi(p),y=DA(p),w=c*Math.pow(2,y);r.scaleTo(n,w,k,p);return}const f=p.deltaMode===1?20:1;let h=s===dc.Vertical?0:p.deltaX*f,g=s===dc.Horizontal?0:p.deltaY*f;!hp()&&p.shiftKey&&s!==dc.Vertical&&(h=p.deltaY*f,g=0),r.translateBy(n,-(h/c)*o,-(g/c)*o,{internal:!0});const b=xy(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(p,b),e.panScrollTimeout=setTimeout(()=>{d==null||d(p,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,b))}}function yH({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=ju(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function xH({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=xy(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 wH({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&$A(t,e.mouseButton??0)),(a=o.sourceEvent)!=null&&a.sync||r([o.transform.x,o.transform.y,o.transform.k]),s&&!((l=o.sourceEvent)!=null&&l.internal)&&(s==null||s(o.sourceEvent,xy(o.transform)))}}function bH({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:o}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,o&&$A(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const u=xy(a.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,u)},n?150:0)}}}function vH({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:u,lib:d,connectionInProgress:p}){return c=>{var k;const f=e||t,h=n&&c.ctrlKey,g=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(ju(c,`${d}-flow__node`)||ju(c,`${d}-flow__edge`)))return!0;if(!r&&!f&&!s&&!o&&!n||a||p&&!g||ju(c,l)&&g||ju(c,u)&&(!g||s&&g&&!e)||!n&&c.ctrlKey&&g)return!1;if(!n&&c.type==="touchstart"&&((k=c.touches)==null?void 0:k.length)>1)return c.preventDefault(),!1;if(!f&&!s&&!h&&g||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||g)&&b}}function kH({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),c=uA().scaleExtent([t,n]).translateExtent(r),f=ri(e).call(c);w({x:s.x,y:s.y,zoom:Zu(s.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");c.wheelDelta(DA);function b(D,$){return f?new Promise(B=>{c==null||c.interpolate(($==null?void 0:$.interpolate)==="linear"?Rf:Cm).transform(Ix(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>B(!0)),D)}):Promise.resolve(!1)}function k({noWheelClassName:D,noPanClassName:$,onPaneContextMenu:B,userSelectionActive:L,panOnScroll:M,panOnDrag:I,panOnScrollMode:z,panOnScrollSpeed:A,preventScrolling:O,zoomOnPinch:E,zoomOnScroll:J,zoomOnDoubleClick:Z,zoomActivationKeyPressed:K,lib:oe,onTransformChange:de,connectionInProgress:he,paneClickDistance:we,selectionOnDrag:ue}){L&&!d.isZoomingOrPanning&&y();const Ne=M&&!K&&!L;c.clickDistance(ue?1/0:!Qi(we)||we<0?0:we);const le=Ne?gH({zoomPanValues:d,noWheelClassName:D,d3Selection:f,d3Zoom:c,panOnScrollMode:z,panOnScrollSpeed:A,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):yH({noWheelClassName:D,preventScrolling:O,d3ZoomHandler:h});if(f.on("wheel.zoom",le,{passive:!1}),!L){const xe=xH({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});c.on("start",xe);const Se=wH({zoomPanValues:d,panOnDrag:I,onPaneContextMenu:!!B,onPanZoom:o,onTransformChange:de});c.on("zoom",Se);const Ke=bH({zoomPanValues:d,panOnDrag:I,panOnScroll:M,onPaneContextMenu:B,onPanZoomEnd:l,onDraggingChange:u});c.on("end",Ke)}const ce=vH({zoomActivationKeyPressed:K,panOnDrag:I,zoomOnScroll:J,panOnScroll:M,zoomOnDoubleClick:Z,zoomOnPinch:E,userSelectionActive:L,noPanClassName:$,noWheelClassName:D,lib:oe,connectionInProgress:he});c.filter(ce),Z?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){c.on("zoom",null)}async function w(D,$,B){const L=Ax(D),M=c==null?void 0:c.constrain()(L,$,B);return M&&await b(M),new Promise(I=>I(M))}async function x(D,$){const B=Ax(D);return await b(B,$),new Promise(L=>L(B))}function N(D){if(f){const $=Ax(D),B=f.property("__zoom");(B.k!==D.zoom||B.x!==D.x||B.y!==D.y)&&(c==null||c.transform(f,$,null,{sync:!0}))}}function _(){const D=f?cA(f.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function C(D,$){return f?new Promise(B=>{c==null||c.interpolate(($==null?void 0:$.interpolate)==="linear"?Rf:Cm).scaleTo(Ix(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>B(!0)),D)}):Promise.resolve(!1)}function T(D,$){return f?new Promise(B=>{c==null||c.interpolate(($==null?void 0:$.interpolate)==="linear"?Rf:Cm).scaleBy(Ix(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>B(!0)),D)}):Promise.resolve(!1)}function F(D){c==null||c.scaleExtent(D)}function R(D){c==null||c.translateExtent(D)}function H(D){const $=!Qi(D)||D<0?0:D;c==null||c.clickDistance($)}return{update:k,destroy:y,setViewport:x,setViewportConstrained:w,getViewport:_,scaleTo:C,scaleBy:T,setScaleExtent:F,setTranslateExtent:R,syncViewport:N,setClickDistance:H}}var nd;(function(e){e.Line="line",e.Handle="handle"})(nd||(nd={}));function SH({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:o}){const a=e-t,l=n-r,u=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(u[0]=u[0]*-1),l&&o&&(u[1]=u[1]*-1),u}function CN(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 Va(e,t){return Math.max(0,t-e)}function Ka(e,t){return Math.max(0,e-t)}function Vh(e,t,n){return Math.max(0,t-e,e-n)}function EN(e,t){return e?!t:t}function NH(e,t,n,r,s,o,a,l){let{affectsX:u,affectsY:d}=t;const{isHorizontal:p,isVertical:c}=t,f=p&&c,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:k,minHeight:y,maxHeight:w}=r,{x,y:N,width:_,height:C,aspectRatio:T}=e;let F=Math.floor(p?h-e.pointerX:0),R=Math.floor(c?g-e.pointerY:0);const H=_+(u?-F:F),D=C+(d?-R:R),$=-o[0]*_,B=-o[1]*C;let L=Vh(H,b,k),M=Vh(D,y,w);if(a){let A=0,O=0;u&&F<0?A=Va(x+F+$,a[0][0]):!u&&F>0&&(A=Ka(x+H+$,a[1][0])),d&&R<0?O=Va(N+R+B,a[0][1]):!d&&R>0&&(O=Ka(N+D+B,a[1][1])),L=Math.max(L,A),M=Math.max(M,O)}if(l){let A=0,O=0;u&&F>0?A=Ka(x+F,l[0][0]):!u&&F<0&&(A=Va(x+H,l[1][0])),d&&R>0?O=Ka(N+R,l[0][1]):!d&&R<0&&(O=Va(N+D,l[1][1])),L=Math.max(L,A),M=Math.max(M,O)}if(s){if(p){const A=Vh(H/T,y,w)*T;if(L=Math.max(L,A),a){let O=0;!u&&!d||u&&!d&&f?O=Ka(N+B+H/T,a[1][1])*T:O=Va(N+B+(u?F:-F)/T,a[0][1])*T,L=Math.max(L,O)}if(l){let O=0;!u&&!d||u&&!d&&f?O=Va(N+H/T,l[1][1])*T:O=Ka(N+(u?F:-F)/T,l[0][1])*T,L=Math.max(L,O)}}if(c){const A=Vh(D*T,b,k)/T;if(M=Math.max(M,A),a){let O=0;!u&&!d||d&&!u&&f?O=Ka(x+D*T+$,a[1][0])/T:O=Va(x+(d?R:-R)*T+$,a[0][0])/T,M=Math.max(M,O)}if(l){let O=0;!u&&!d||d&&!u&&f?O=Va(x+D*T,l[1][0])/T:O=Ka(x+(d?R:-R)*T,l[0][0])/T,M=Math.max(M,O)}}}R=R+(R<0?M:-M),F=F+(F<0?L:-L),s&&(f?H>D*T?R=(EN(u,d)?-F:F)/T:F=(EN(u,d)?-R:R)*T:p?(R=F/T,d=u):(F=R*T,u=d));const I=u?x+F:x,z=d?N+R:N;return{width:_+(u?-F:F),height:C+(d?-R:R),x:o[0]*F*(u?-1:1)+I,y:o[1]*R*(d?-1:1)+z}}const FA={width:0,height:0,x:0,y:0},jH={...FA,pointerX:0,pointerY:0,aspectRatio:1};function CH(e){return[[0,0],[e.measured.width,e.measured.height]]}function EH(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,u=n[1]*a;return[[r-l,s-u],[r+o-l,s+a-u]]}function _H({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=ri(e);let a={controlDirection:CN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:p,keepAspectRatio:c,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:k}){let y={...FA},w={...jH};a={boundaries:p,resizeDirection:f,keepAspectRatio:c,controlDirection:CN(d)};let x,N=null,_=[],C,T,F,R=!1;const H=GP().on("start",D=>{const{nodeLookup:$,transform:B,snapGrid:L,snapToGrid:M,nodeOrigin:I,paneDomNode:z}=n();if(x=$.get(t),!x)return;N=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:O}=Mf(D.sourceEvent,{transform:B,snapGrid:L,snapToGrid:M,containerBounds:N});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:O,aspectRatio:y.width/y.height},C=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(C=$.get(x.parentId),T=C&&x.extent==="parent"?CH(C):void 0),_=[],F=void 0;for(const[E,J]of $)if(J.parentId===t&&(_.push({id:E,position:{...J.position},extent:J.extent}),J.extent==="parent"||J.expandParent)){const Z=EH(J,x,J.origin??I);F?F=[[Math.min(Z[0][0],F[0][0]),Math.min(Z[0][1],F[0][1])],[Math.max(Z[1][0],F[1][0]),Math.max(Z[1][1],F[1][1])]]:F=Z}h==null||h(D,{...y})}).on("drag",D=>{const{transform:$,snapGrid:B,snapToGrid:L,nodeOrigin:M}=n(),I=Mf(D.sourceEvent,{transform:$,snapGrid:B,snapToGrid:L,containerBounds:N}),z=[];if(!x)return;const{x:A,y:O,width:E,height:J}=y,Z={},K=x.origin??M,{width:oe,height:de,x:he,y:we}=NH(w,a.controlDirection,I,a.boundaries,a.keepAspectRatio,K,T,F),ue=oe!==E,Ne=de!==J,le=he!==A&&ue,ce=we!==O&&Ne;if(!le&&!ce&&!ue&&!Ne)return;if((le||ce||K[0]===1||K[1]===1)&&(Z.x=le?he:y.x,Z.y=ce?we:y.y,y.x=Z.x,y.y=Z.y,_.length>0)){const et=he-A,We=we-O;for(const ut of _)ut.position={x:ut.position.x-et+K[0]*(oe-E),y:ut.position.y-We+K[1]*(de-J)},z.push(ut)}if((ue||Ne)&&(Z.width=ue&&(!a.resizeDirection||a.resizeDirection==="horizontal")?oe:y.width,Z.height=Ne&&(!a.resizeDirection||a.resizeDirection==="vertical")?de:y.height,y.width=Z.width,y.height=Z.height),C&&x.expandParent){const et=K[0]*(Z.width??0);Z.x&&Z.x<et&&(y.x=et,w.x=w.x-(Z.x-et));const We=K[1]*(Z.height??0);Z.y&&Z.y<We&&(y.y=We,w.y=w.y-(Z.y-We))}const xe=SH({width:y.width,prevWidth:E,height:y.height,prevHeight:J,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Se={...y,direction:xe};(k==null?void 0:k(D,Se))!==!1&&(R=!0,g==null||g(D,Se),r(Z,z))}).on("end",D=>{R&&(b==null||b(D,{...y}),s==null||s({...y}),R=!1)});o.call(H)}function u(){o.on(".drag",null)}return{update:l,destroy:u}}var zA={exports:{}},HA={},BA={exports:{}},WA={};/**
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 rd=m;function PH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var AH=typeof Object.is=="function"?Object.is:PH,IH=rd.useState,TH=rd.useEffect,RH=rd.useLayoutEffect,MH=rd.useDebugValue;function LH(e,t){var n=t(),r=IH({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return RH(function(){s.value=n,s.getSnapshot=t,Tx(s)&&o({inst:s})},[e,n,t]),TH(function(){return Tx(s)&&o({inst:s}),e(function(){Tx(s)&&o({inst:s})})},[e]),MH(n),n}function Tx(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!AH(e,n)}catch{return!0}}function OH(e,t){return t()}var $H=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?OH:LH;WA.useSyncExternalStore=rd.useSyncExternalStore!==void 0?rd.useSyncExternalStore:$H;BA.exports=WA;var VA=BA.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 wy=m,DH=VA;function FH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zH=typeof Object.is=="function"?Object.is:FH,HH=DH.useSyncExternalStore,BH=wy.useRef,WH=wy.useEffect,VH=wy.useMemo,KH=wy.useDebugValue;HA.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=BH(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=VH(function(){function u(h){if(!d){if(d=!0,p=h,h=r(h),s!==void 0&&a.hasValue){var g=a.value;if(s(g,h))return c=g}return c=h}if(g=c,zH(p,h))return g;var b=r(h);return s!==void 0&&s(g,b)?(p=h,g):(p=h,c=b)}var d=!1,p,c,f=n===void 0?null:n;return[function(){return u(t())},f===null?void 0:function(){return u(f())}]},[t,n,r,s]);var l=HH(e,o[0],o[1]);return WH(function(){a.hasValue=!0,a.value=l},[l]),KH(l),l};zA.exports=HA;var UH=zA.exports;const qH=Sl(UH),YH={},_N=e=>{let t;const n=new Set,r=(p,c)=>{const f=typeof p=="function"?p(t):p;if(!Object.is(f,t)){const h=t;t=c??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>d,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(YH?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,u);return u},GH=e=>e?_N(e):_N,{useDebugValue:XH}=ht,{useSyncExternalStoreWithSelector:JH}=qH,QH=e=>e;function KA(e,t=QH,n){const r=JH(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return XH(r),r}const PN=(e,t)=>{const n=GH(e),r=(s,o=t)=>KA(n,s,o);return Object.assign(r,n),r},ZH=(e,t)=>e?PN(e,t):PN;function Xn(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 by=m.createContext(null),e5=by.Provider,UA=zo.error001();function Jt(e,t){const n=m.useContext(by);if(n===null)throw new Error(UA);return KA(n,e,t)}function Bn(){const e=m.useContext(by);if(e===null)throw new Error(UA);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const AN={display:"none"},t5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qA="react-flow__node-desc",YA="react-flow__edge-desc",n5="react-flow__aria-live",r5=e=>e.ariaLiveMessage,s5=e=>e.ariaLabelConfig;function i5({rfId:e}){const t=Jt(r5);return i.jsx("div",{id:`${n5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:t5,children:t})}function o5({rfId:e,disableKeyboardA11y:t}){const n=Jt(s5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${qA}-${e}`,style:AN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${YA}-${e}`,style:AN,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(i5,{rfId:e})]})}const sd=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:vr(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});sd.displayName="Panel";function a5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(sd,{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:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const l5=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}},Kh=e=>e.id;function c5(e,t){return Xn(e.selectedNodes.map(Kh),t.selectedNodes.map(Kh))&&Xn(e.selectedEdges.map(Kh),t.selectedEdges.map(Kh))}function u5({onSelectionChange:e}){const t=Bn(),{selectedNodes:n,selectedEdges:r}=Jt(l5,c5);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const d5=e=>!!e.onSelectionChangeHandlers;function f5({onSelectionChange:e}){const t=Jt(d5);return e||t?i.jsx(u5,{onSelectionChange:e}):null}const Mb=typeof window<"u"?m.useLayoutEffect:m.useEffect,GA=[0,0],p5={x:0,y:0,zoom:1},h5=["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"],IN=[...h5,"rfId"],m5=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}),TN={translateExtent:dp,nodeOrigin:GA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function g5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:u}=Jt(m5,Xn),d=Bn();Mb(()=>(u(e.defaultNodes,e.defaultEdges),()=>{p.current=TN,l()}),[]);const p=m.useRef(TN);return Mb(()=>{for(const c of IN){const f=e[c],h=p.current[c];f!==h&&(typeof e[c]>"u"||(c==="nodes"?t(f):c==="edges"?n(f):c==="minZoom"?r(f):c==="maxZoom"?s(f):c==="translateExtent"?o(f):c==="nodeExtent"?a(f):c==="ariaLabelConfig"?d.setState({ariaLabelConfig:H3(f)}):c==="fitView"?d.setState({fitViewQueued:f}):c==="fitViewOptions"?d.setState({fitViewOptions:f}):d.setState({[c]:f})))}p.current=e},IN.map(c=>e[c])),null}function RN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function y5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=RN(),o=()=>n(s!=null&&s.matches?"dark":"light");return o(),s==null||s.addEventListener("change",o),()=>{s==null||s.removeEventListener("change",o)}},[e]),t!==null?t:(r=RN())!=null&&r.matches?"dark":"light"}const MN=typeof document<"u"?document:null;function mp(e=null,t={target:MN,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),p=d.reduce((c,f)=>c.concat(...f),[]);return[d,p]}return[[],[]]},[e]);return m.useEffect(()=>{const u=(t==null?void 0:t.target)??MN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=h=>{var k,y;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&SA(h))return!1;const b=ON(h.code,l);if(o.current.add(h[b]),LN(a,o.current,!1)){const w=((y=(k=h.composedPath)==null?void 0:k.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)}},c=h=>{const g=ON(h.code,l);LN(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[g]),h.key==="Meta"&&o.current.clear(),s.current=!1},f=()=>{o.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",p),u==null||u.addEventListener("keyup",c),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{u==null||u.removeEventListener("keydown",p),u==null||u.removeEventListener("keyup",c),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function LN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ON(e,t){return t.includes(e)?"code":"key"}const x5=()=>{const e=Bn();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,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},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:o,maxZoom:a,panZoom:l}=e.getState(),u=b0(t,r,s,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(u,{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:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:u}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-u},p=n.snapGrid??s,c=n.snapToGrid??o;return Fp(d,r,c,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=xg(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function XA(e,t){const n=[],r=new Map,s=[];for(const o of e)if(o.type==="add"){s.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const u of a)w5(u,l);n.push(l)}return s.length&&s.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function w5(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 wg(e,t){return XA(e,t)}function E0(e,t){return XA(e,t)}function ec(e,t){return{id:e,type:"select",selected:t}}function Cu(e,t=new Set,n=!1){const r=[];for(const[s,o]of e){const a=t.has(s);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(ec(o.id,a)))}return r}function $N({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),u=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;u!==void 0&&u!==a&&n.push({id:a.id,item:a,type:"replace"}),u===void 0&&n.push({item:a,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function DN(e){return{id:e.id,type:"remove"}}const FN=e=>I3(e),b5=e=>mA(e);function JA(e){return m.forwardRef(e)}function zN(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>v5(()=>n(s=>s+BigInt(1))));return Mb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function v5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const QA=m.createContext(null);function k5({children:e}){const t=Bn(),n=m.useCallback(l=>{const{nodes:u=[],setNodes:d,hasDefaultNodes:p,onNodesChange:c,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=u;for(const y of l)b=typeof y=="function"?y(b):y;let k=$N({items:b,lookup:f});for(const y of g.values())k=y(k);p&&d(b),k.length>0?c==null||c(k):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:x}=t.getState();y&&x(w)})},[]),r=zN(n),s=m.useCallback(l=>{const{edges:u=[],setEdges:d,hasDefaultEdges:p,onEdgesChange:c,edgeLookup:f}=t.getState();let h=u;for(const g of l)h=typeof g=="function"?g(h):g;p?d(h):c&&c($N({items:h,lookup:f}))},[]),o=zN(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(QA.Provider,{value:a,children:e})}function S5(){const e=m.useContext(QA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const N5=e=>!!e.panZoom;function El(){const e=x5(),t=Bn(),n=S5(),r=Jt(N5),s=m.useMemo(()=>{const o=c=>t.getState().nodeLookup.get(c),a=c=>{n.nodeQueue.push(c)},l=c=>{n.edgeQueue.push(c)},u=c=>{var y,w;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=FN(c)?c:f.get(c.id),b=g.parentId?vA(g.position,g.measured,g.parentId,f,h):g.position,k={...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 ed(k)},d=(c,f,h={replace:!1})=>{a(g=>g.map(b=>{if(b.id===c){const k=typeof f=="function"?f(b):f;return h.replace&&FN(k)?k:{...b,...k}}return b}))},p=(c,f,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===c){const k=typeof f=="function"?f(b):f;return h.replace&&b5(k)?k:{...b,...k}}return b}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var f;return(f=o(c))==null?void 0:f.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(f=>({...f}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:a,setEdges:l,addNodes:c=>{const f=Array.isArray(c)?c:[c];n.nodeQueue.push(h=>[...h,...f])},addEdges:c=>{const f=Array.isArray(c)?c:[c];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:c=[],edges:f=[],transform:h}=t.getState(),[g,b,k]=h;return{nodes:c.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:g,y:b,zoom:k}}},deleteElements:async({nodes:c=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:k,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:x,onBeforeDelete:N}=t.getState(),{nodes:_,edges:C}=await O3({nodesToRemove:c,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:N}),T=C.length>0,F=_.length>0;if(T){const R=C.map(DN);k==null||k(C),w(R)}if(F){const R=_.map(DN);b==null||b(_),y(R)}return(F||T)&&(x==null||x({nodes:_,edges:C})),{deletedNodes:_,deletedEdges:C}},getIntersectingNodes:(c,f=!0,h)=>{const g=mN(c),b=g?c:u(c),k=h!==void 0;return b?(h||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!g&&(y.id===c.id||!w.internals.positionAbsolute))return!1;const x=ed(k?y:w),N=pp(x,b);return f&&N>0||N>=x.width*x.height||N>=b.width*b.height}):[]},isNodeIntersecting:(c,f,h=!0)=>{const b=mN(c)?c:u(c);if(!b)return!1;const k=pp(b,f);return h&&k>0||k>=f.width*f.height||k>=b.width*b.height},updateNode:d,updateNodeData:(c,f,h={replace:!1})=>{d(c,g=>{const b=typeof f=="function"?f(g):f;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:p,updateEdgeData:(c,f,h={replace:!1})=>{p(c,g=>{const b=typeof f=="function"?f(g):f;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:c=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return T3(c,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:c,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${c}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:c,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${c?f?`-${c}-${f}`:`-${c}`:""}`))==null?void 0:g.values())??[])},fitView:async c=>{const f=t.getState().fitViewResolver??z3();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const HN=e=>e.selected,j5=typeof window<"u"?window:void 0;function C5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Bn(),{deleteElements:r}=El(),s=mp(e,{actInsideInputWithModifier:!1}),o=mp(t,{target:j5});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(HN),edges:a.filter(HN)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function E5(e){const t=Bn();m.useEffect(()=>{const n=()=>{var s,o,a,l;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=v0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",zo.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 vy={position:"absolute",width:"100%",height:"100%",top:0,left:0},_5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function P5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=dc.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:d,minZoom:p,maxZoom:c,zoomActivationKeyCode:f,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:k,onViewportChange:y,isControlledViewport:w,paneClickDistance:x,selectionOnDrag:N}){const _=Bn(),C=m.useRef(null),{userSelectionActive:T,lib:F,connectionInProgress:R}=Jt(_5,Xn),H=mp(f),D=m.useRef();E5(C);const $=m.useCallback(B=>{y==null||y({x:B[0],y:B[1],zoom:B[2]}),w||_.setState({transform:B})},[y,w]);return m.useEffect(()=>{if(C.current){D.current=kH({domNode:C.current,minZoom:p,maxZoom:c,translateExtent:d,viewport:u,onDraggingChange:I=>_.setState(z=>z.paneDragging===I?z:{paneDragging:I}),onPanZoomStart:(I,z)=>{const{onViewportChangeStart:A,onMoveStart:O}=_.getState();O==null||O(I,z),A==null||A(z)},onPanZoom:(I,z)=>{const{onViewportChange:A,onMove:O}=_.getState();O==null||O(I,z),A==null||A(z)},onPanZoomEnd:(I,z)=>{const{onViewportChangeEnd:A,onMoveEnd:O}=_.getState();O==null||O(I,z),A==null||A(z)}});const{x:B,y:L,zoom:M}=D.current.getViewport();return _.setState({panZoom:D.current,transform:[B,L,M],domNode:C.current.closest(".react-flow")}),()=>{var I;(I=D.current)==null||I.destroy()}}},[]),m.useEffect(()=>{var B;(B=D.current)==null||B.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:H,preventScrolling:h,noPanClassName:k,userSelectionActive:T,noWheelClassName:b,lib:F,onTransformChange:$,connectionInProgress:R,selectionOnDrag:N,paneClickDistance:x})},[e,t,n,r,s,o,a,l,H,h,k,T,b,F,$,R,N,x]),i.jsx("div",{className:"react-flow__renderer",ref:C,style:vy,children:g})}const A5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function I5(){const{userSelectionActive:e,userSelectionRect:t}=Jt(A5,Xn);return e&&t?i.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 Rx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},T5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function R5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=fp.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:p,onPaneMouseEnter:c,onPaneMouseMove:f,onPaneMouseLeave:h,children:g}){const b=Bn(),{userSelectionActive:k,elementsSelectable:y,dragging:w,connectionInProgress:x}=Jt(T5,Xn),N=y&&(e||k),_=m.useRef(null),C=m.useRef(),T=m.useRef(new Set),F=m.useRef(new Set),R=m.useRef(!1),H=A=>{if(R.current||x){R.current=!1;return}u==null||u(A),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},D=A=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){A.preventDefault();return}d==null||d(A)},$=p?A=>p(A):void 0,B=A=>{R.current&&(A.stopPropagation(),R.current=!1)},L=A=>{var de,he;const{domNode:O}=b.getState();if(C.current=O==null?void 0:O.getBoundingClientRect(),!C.current)return;const E=A.target===_.current;if(!E&&!!A.target.closest(".nokey")||!e||!(o&&E||t)||A.button!==0||!A.isPrimary)return;(he=(de=A.target)==null?void 0:de.setPointerCapture)==null||he.call(de,A.pointerId),R.current=!1;const{x:K,y:oe}=Zi(A.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:K,startY:oe,x:K,y:oe}}),E||(A.stopPropagation(),A.preventDefault())},M=A=>{const{userSelectionRect:O,transform:E,nodeLookup:J,edgeLookup:Z,connectionLookup:K,triggerNodeChanges:oe,triggerEdgeChanges:de,defaultEdgeOptions:he,resetSelectedElements:we}=b.getState();if(!C.current||!O)return;const{x:ue,y:Ne}=Zi(A.nativeEvent,C.current),{startX:le,startY:ce}=O;if(!R.current){const We=t?0:s;if(Math.hypot(ue-le,Ne-ce)<=We)return;we(),a==null||a(A)}R.current=!0;const xe={startX:le,startY:ce,x:ue<le?ue:le,y:Ne<ce?Ne:ce,width:Math.abs(ue-le),height:Math.abs(Ne-ce)},Se=T.current,Ke=F.current;T.current=new Set(w0(J,xe,E,n===fp.Partial,!0).map(We=>We.id)),F.current=new Set;const et=(he==null?void 0:he.selectable)??!0;for(const We of T.current){const ut=K.get(We);if(ut)for(const{edgeId:Ve}of ut.values()){const xt=Z.get(Ve);xt&&(xt.selectable??et)&&F.current.add(Ve)}}if(!gN(Se,T.current)){const We=Cu(J,T.current,!0);oe(We)}if(!gN(Ke,F.current)){const We=Cu(Z,F.current);de(We)}b.setState({userSelectionRect:xe,userSelectionActive:!0,nodesSelectionActive:!1})},I=A=>{var O,E;A.button===0&&((E=(O=A.target)==null?void 0:O.releasePointerCapture)==null||E.call(O,A.pointerId),!k&&A.target===_.current&&b.getState().userSelectionRect&&(H==null||H(A)),b.setState({userSelectionActive:!1,userSelectionRect:null}),R.current&&(l==null||l(A),b.setState({nodesSelectionActive:T.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:vr(["react-flow__pane",{draggable:z,dragging:w,selection:e}]),onClick:N?void 0:Rx(H,_),onContextMenu:Rx(D,_),onWheel:Rx($,_),onPointerEnter:N?void 0:c,onPointerMove:N?M:f,onPointerUp:N?I:void 0,onPointerDownCapture:N?L:void 0,onClickCapture:N?B:void 0,onPointerLeave:h,ref:_,style:vy,children:[g,i.jsx(I5,{})]})}function Lb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:u}=t.getState(),d=l.get(e);if(!d){u==null||u("012",zo.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):s([e])}function ZA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=Bn(),[u,d]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=lH({getStoreItems:()=>l.getState(),onNodeMouseDown:c=>{Lb({id:c,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var c;(c=p.current)==null||c.destroy()}},[n,r,t,o,e,s,a]),u}const M5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function eI(){const e=Bn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:u,nodeLookup:d,nodeOrigin:p}=e.getState(),c=new Map,f=M5(a),h=s?o[0]:5,g=s?o[1]:5,b=n.direction.x*h*n.factor,k=n.direction.y*g*n.factor;for(const[,y]of d){if(!f(y))continue;let w={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+k};s&&(w=Dp(w,o));const{position:x,positionAbsolute:N}=gA({nodeId:y.id,nextPosition:w,nodeLookup:d,nodeExtent:r,nodeOrigin:p,onError:l});y.position=x,y.internals.positionAbsolute=N,c.set(y.id,y)}u(c)},[])}const _0=m.createContext(null),L5=_0.Provider;_0.Consumer;const tI=()=>m.useContext(_0),O5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),$5=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:u,isValid:d}=a,p=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.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:o===Qu.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&&d}};function D5({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:u,className:d,onMouseDown:p,onTouchStart:c,...f},h){var M,I;const g=a||null,b=e==="target",k=Bn(),y=tI(),{connectOnClick:w,noPanClassName:x,rfId:N}=Jt(O5,Xn),{connectingFrom:_,connectingTo:C,clickConnecting:T,isPossibleEndHandle:F,connectionInProcess:R,clickConnectionInProcess:H,valid:D}=Jt($5(y,g,e),Xn);y||(I=(M=k.getState()).onError)==null||I.call(M,"010",zo.error010());const $=z=>{const{defaultEdgeOptions:A,onConnect:O,hasDefaultEdges:E}=k.getState(),J={...A,...z};if(E){const{edges:Z,setEdges:K}=k.getState();K(Du(J,Z))}O==null||O(J),l==null||l(J)},B=z=>{if(!y)return;const A=NA(z.nativeEvent);if(s&&(A&&z.button===0||!A)){const O=k.getState();Rb.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:b,handleId:g,nodeId:y,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(...E)=>{var J,Z;return(Z=(J=k.getState()).onConnectEnd)==null?void 0:Z.call(J,...E)},updateConnection:O.updateConnection,onConnect:$,isValidConnection:n||((...E)=>{var J,Z;return((Z=(J=k.getState()).isValidConnection)==null?void 0:Z.call(J,...E))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}A?p==null||p(z):c==null||c(z)},L=z=>{const{onClickConnectStart:A,onClickConnectEnd:O,connectionClickStartHandle:E,connectionMode:J,isValidConnection:Z,lib:K,rfId:oe,nodeLookup:de,connection:he}=k.getState();if(!y||!E&&!s)return;if(!E){A==null||A(z.nativeEvent,{nodeId:y,handleId:g,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const we=kA(z.target),ue=n||Z,{connection:Ne,isValid:le}=Rb.isValid(z.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:J,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:ue,flowId:oe,doc:we,lib:K,nodeLookup:de});le&&Ne&&$(Ne);const ce=structuredClone(he);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,O==null||O(z,ce),k.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className:vr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:o,clickconnecting:T,connectingfrom:_,connectingto:C,valid:D,connectionindicator:r&&(!R||F)&&(R||H?o:s)}]),onMouseDown:B,onTouchStart:B,onClick:w?L:void 0,ref:h,...f,children:u})}const ds=m.memo(JA(D5));function F5({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(ds,{type:"source",position:n,isConnectable:t})]})}function z5({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:r=Je.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(ds,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(ds,{type:"source",position:r,isConnectable:t})]})}function H5(){return null}function B5({data:e,isConnectable:t,targetPosition:n=Je.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(ds,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const bg={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},BN={input:F5,default:z5,output:B5,group:H5};function W5(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 V5=e=>{const{width:t,height:n,x:r,y:s}=$p(e.nodeLookup,{filter:o=>!!o.selected});return{width:Qi(t)?t:null,height:Qi(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 K5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Bn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Jt(V5,Xn),u=eI(),d=m.useRef(null);m.useEffect(()=>{var h;n||(h=d.current)==null||h.focus({preventScroll:!0})},[n]);const p=!l&&s!==null&&o!==null;if(ZA({nodeRef:d,disabled:!p}),!p)return null;const c=e?h=>{const g=r.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(bg,h.key)&&(h.preventDefault(),u({direction:bg[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:vr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:o}})})}const WN=typeof window<"u"?window:void 0,U5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function nI({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:u,selectionKeyCode:d,selectionOnDrag:p,selectionMode:c,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:N,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:F,defaultViewport:R,translateExtent:H,minZoom:D,maxZoom:$,preventScrolling:B,onSelectionContextMenu:L,noWheelClassName:M,noPanClassName:I,disableKeyboardA11y:z,onViewportChange:A,isControlledViewport:O}){const{nodesSelectionActive:E,userSelectionActive:J}=Jt(U5,Xn),Z=mp(d,{target:WN}),K=mp(b,{target:WN}),oe=K||F,de=K||N,he=p&&oe!==!0,we=Z||J||he;return C5({deleteKeyCode:u,multiSelectionKeyCode:g}),i.jsx(P5,{onPaneContextMenu:o,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:de,panOnScrollSpeed:_,panOnScrollMode:C,zoomOnDoubleClick:T,panOnDrag:!Z&&oe,defaultViewport:R,translateExtent:H,minZoom:D,maxZoom:$,zoomActivationKeyCode:k,preventScrolling:B,noWheelClassName:M,noPanClassName:I,onViewportChange:A,isControlledViewport:O,paneClickDistance:l,selectionOnDrag:he,children:i.jsxs(R5,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:oe,isSelecting:!!we,selectionMode:c,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:he,children:[e,E&&i.jsx(K5,{onSelectionContextMenu:L,noPanClassName:I,disableKeyboardA11y:z})]})})}nI.displayName="FlowRenderer";const q5=m.memo(nI),Y5=e=>t=>e?w0(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 G5(e){return Jt(m.useCallback(Y5(e),[e]),Xn)}const X5=e=>e.updateNodeInternals;function J5(){const e=Jt(X5),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Q5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Bn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),u=m.useRef(e.targetPosition),d=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!p||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const c=d.current!==t,f=l.current!==e.sourcePosition,h=u.current!==e.targetPosition;(c||f||h)&&(d.current=t,l.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function Z5({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:u,nodesConnectable:d,nodesFocusable:p,resizeObserver:c,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:k,nodeClickDistance:y,onError:w}){const{node:x,internals:N,isParent:_}=Jt(ue=>{const Ne=ue.nodeLookup.get(e),le=ue.parentLookup.has(e);return{node:Ne,internals:Ne.internals,isParent:le}},Xn);let C=x.type||"default",T=(k==null?void 0:k[C])||BN[C];T===void 0&&(w==null||w("003",zo.error003(C)),C="default",T=(k==null?void 0:k.default)||BN.default);const F=!!(x.draggable||l&&typeof x.draggable>"u"),R=!!(x.selectable||u&&typeof x.selectable>"u"),H=!!(x.connectable||d&&typeof x.connectable>"u"),D=!!(x.focusable||p&&typeof x.focusable>"u"),$=Bn(),B=bA(x),L=Q5({node:x,nodeType:C,hasDimensions:B,resizeObserver:c}),M=ZA({nodeRef:L,disabled:x.hidden||!F,noDragClassName:f,handleSelector:x.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:y}),I=eI();if(x.hidden)return null;const z=ka(x),A=W5(x),O=R||F||t||n||r||s,E=n?ue=>n(ue,{...N.userNode}):void 0,J=r?ue=>r(ue,{...N.userNode}):void 0,Z=s?ue=>s(ue,{...N.userNode}):void 0,K=o?ue=>o(ue,{...N.userNode}):void 0,oe=a?ue=>a(ue,{...N.userNode}):void 0,de=ue=>{const{selectNodesOnDrag:Ne,nodeDragThreshold:le}=$.getState();R&&(!Ne||!F||le>0)&&Lb({id:e,store:$,nodeRef:L}),t&&t(ue,{...N.userNode})},he=ue=>{if(!(SA(ue.nativeEvent)||g)){if(dA.includes(ue.key)&&R){const Ne=ue.key==="Escape";Lb({id:e,store:$,unselect:Ne,nodeRef:L})}else if(F&&x.selected&&Object.prototype.hasOwnProperty.call(bg,ue.key)){ue.preventDefault();const{ariaLabelConfig:Ne}=$.getState();$.setState({ariaLiveMessage:Ne["node.a11yDescription.ariaLiveMessage"]({direction:ue.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),I({direction:bg[ue.key],factor:ue.shiftKey?4:1})}}},we=()=>{var Ke;if(g||!((Ke=L.current)!=null&&Ke.matches(":focus-visible")))return;const{transform:ue,width:Ne,height:le,autoPanOnNodeFocus:ce,setCenter:xe}=$.getState();if(!ce)return;w0(new Map([[e,x]]),{x:0,y:0,width:Ne,height:le},ue,!0).length>0||xe(x.position.x+z.width/2,x.position.y+z.height/2,{zoom:ue[2]})};return i.jsx("div",{className:vr(["react-flow__node",`react-flow__node-${C}`,{[h]:F},x.className,{selected:x.selected,selectable:R,parent:_,draggable:F,dragging:M}]),ref:L,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:O?"all":"none",visibility:B?"visible":"hidden",...x.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:J,onMouseLeave:Z,onContextMenu:K,onClick:de,onDoubleClick:oe,onKeyDown:D?he:void 0,tabIndex:D?0:void 0,onFocus:D?we:void 0,role:x.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${qA}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(L5,{value:e,children:i.jsx(T,{id:e,data:x.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:x.selected??!1,selectable:R,draggable:F,deletable:x.deletable??!0,isConnectable:H,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:M,dragHandle:x.dragHandle,zIndex:N.z,parentId:x.parentId,...z})})})}var e4=m.memo(Z5);const t4=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function rI(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Jt(t4,Xn),a=G5(e.onlyRenderVisibleElements),l=J5();return i.jsx("div",{className:"react-flow__nodes",style:vy,children:a.map(u=>i.jsx(e4,{id:u,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:o},u))})}rI.displayName="NodeRenderer";const n4=m.memo(rI);function r4(e){return Jt(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 o=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);o&&a&&V3({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Xn)}const s4=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return i.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},i4=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return i.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},VN={[ks.Arrow]:s4,[ks.ArrowClosed]:i4};function o4(e){const t=Bn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(VN,e)?VN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",zo.error009(e)),null)},[e])}const a4=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const u=o4(t);return u?i.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:i.jsx(u,{color:n,strokeWidth:a})}):null},sI=({defaultColor:e,rfId:t})=>{const n=Jt(o=>o.edges),r=Jt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>J3(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?i.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:i.jsx("defs",{children:s.map(o=>i.jsx(a4,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};sI.displayName="MarkerDefinitions";var l4=m.memo(sI);function iI({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:u,className:d,...p}){const[c,f]=m.useState({x:1,y:0,width:0,height:0}),h=vr(["react-flow__edge-textwrapper",d]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const b=g.current.getBBox();f({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:h,visibility:c.width?"visible":"hidden",...p,children:[s&&i.jsx("rect",{width:c.width+2*a[0],x:-a[0],y:-a[1],height:c.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:g,style:r,children:n}),u]}):null}iI.displayName="EdgeText";const c4=m.memo(iI);function ky({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,interactionWidth:d=20,...p}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...p,d:e,fill:"none",className:vr(["react-flow__edge-path",p.className])}),d?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Qi(t)&&Qi(n)?i.jsx(c4,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u}):null]})}function KN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Je.Left||e===Je.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function oI({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:o=Je.Top}){const[a,l]=KN({pos:n,x1:e,y1:t,x2:r,y2:s}),[u,d]=KN({pos:o,x1:r,y1:s,x2:e,y2:t}),[p,c,f,h]=jA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${l} ${u},${d} ${r},${s}`,p,c,f,h]}function aI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:u,labelStyle:d,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:k,interactionWidth:y})=>{const[w,x,N]=oI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),_=e.isInternal?void 0:t;return i.jsx(ky,{id:_,path:w,labelX:x,labelY:N,label:u,labelStyle:d,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:k,interactionWidth:y})})}const u4=aI({isInternal:!1}),lI=aI({isInternal:!0});u4.displayName="SimpleBezierEdge";lI.displayName="SimpleBezierEdgeInternal";function cI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:c,style:f,sourcePosition:h=Je.Bottom,targetPosition:g=Je.Top,markerEnd:b,markerStart:k,pathOptions:y,interactionWidth:w})=>{const[x,N,_]=Ab({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),C=e.isInternal?void 0:t;return i.jsx(ky,{id:C,path:x,labelX:N,labelY:_,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:b,markerStart:k,interactionWidth:w})})}const uI=cI({isInternal:!1}),dI=cI({isInternal:!0});uI.displayName="SmoothStepEdge";dI.displayName="SmoothStepEdgeInternal";function fI(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(uI,{...n,id:r,pathOptions:m.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const d4=fI({isInternal:!1}),pI=fI({isInternal:!0});d4.displayName="StepEdge";pI.displayName="StepEdgeInternal";function hI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[k,y,w]=_A({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(ky,{id:x,path:k,labelX:y,labelY:w,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:h,markerStart:g,interactionWidth:b})})}const f4=hI({isInternal:!1}),mI=hI({isInternal:!0});f4.displayName="StraightEdge";mI.displayName="StraightEdgeInternal";function gI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=Je.Bottom,targetPosition:l=Je.Top,label:u,labelStyle:d,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:k,pathOptions:y,interactionWidth:w})=>{const[x,N,_]=CA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:y==null?void 0:y.curvature}),C=e.isInternal?void 0:t;return i.jsx(ky,{id:C,path:x,labelX:N,labelY:_,label:u,labelStyle:d,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:k,interactionWidth:w})})}const p4=gI({isInternal:!1}),yI=gI({isInternal:!0});p4.displayName="BezierEdge";yI.displayName="BezierEdgeInternal";const UN={default:yI,straight:mI,step:pI,smoothstep:dI,simplebezier:lI},qN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},h4=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,m4=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,YN="react-flow__edgeupdater";function GN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:a,type:l}){return i.jsx("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:a,className:vr([YN,`${YN}-${l}`]),cx:h4(t,r,e),cy:m4(n,r,e),r,stroke:"transparent",fill:"transparent"})}function g4({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:u,onReconnect:d,onReconnectStart:p,onReconnectEnd:c,setReconnecting:f,setUpdateHover:h}){const g=Bn(),b=(N,_)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:T,connectionMode:F,connectionRadius:R,lib:H,onConnectStart:D,cancelConnection:$,nodeLookup:B,rfId:L,panBy:M,updateConnection:I}=g.getState(),z=_.type==="target",A=(J,Z)=>{f(!1),c==null||c(J,n,_.type,Z)},O=J=>d==null?void 0:d(n,J),E=(J,Z)=>{f(!0),p==null||p(N,n,_.type),D==null||D(J,Z)};Rb.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:F,connectionRadius:R,domNode:T,handleId:_.id,nodeId:_.nodeId,nodeLookup:B,isTarget:z,edgeUpdaterType:_.type,lib:H,flowId:L,cancelConnection:$,panBy:M,isValidConnection:(...J)=>{var Z,K;return((K=(Z=g.getState()).isValidConnection)==null?void 0:K.call(Z,...J))??!0},onConnect:O,onConnectStart:E,onConnectEnd:(...J)=>{var Z,K;return(K=(Z=g.getState()).onConnectEnd)==null?void 0:K.call(Z,...J)},onReconnectEnd:A,updateConnection:I,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},k=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),x=()=>h(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(GN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:w,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(GN,{position:u,centerX:o,centerY:a,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:x,type:"target"})]})}function y4({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:d,reconnectRadius:p,onReconnect:c,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:k,onError:y,disableKeyboardA11y:w}){let x=Jt(xe=>xe.edgeLookup.get(e));const N=Jt(xe=>xe.defaultEdgeOptions);x=N?{...N,...x}:x;let _=x.type||"default",C=(b==null?void 0:b[_])||UN[_];C===void 0&&(y==null||y("011",zo.error011(_)),_="default",C=(b==null?void 0:b.default)||UN.default);const T=!!(x.focusable||t&&typeof x.focusable>"u"),F=typeof c<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),R=!!(x.selectable||r&&typeof x.selectable>"u"),H=m.useRef(null),[D,$]=m.useState(!1),[B,L]=m.useState(!1),M=Bn(),{zIndex:I,sourceX:z,sourceY:A,targetX:O,targetY:E,sourcePosition:J,targetPosition:Z}=Jt(m.useCallback(xe=>{const Se=xe.nodeLookup.get(x.source),Ke=xe.nodeLookup.get(x.target);if(!Se||!Ke)return{zIndex:x.zIndex,...qN};const et=X3({id:e,sourceNode:Se,targetNode:Ke,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:xe.connectionMode,onError:y});return{zIndex:W3({selected:x.selected,zIndex:x.zIndex,sourceNode:Se,targetNode:Ke,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode}),...et||qN}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Xn),K=m.useMemo(()=>x.markerStart?`url('#${Ib(x.markerStart,g)}')`:void 0,[x.markerStart,g]),oe=m.useMemo(()=>x.markerEnd?`url('#${Ib(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||z===null||A===null||O===null||E===null)return null;const de=xe=>{var We;const{addSelectedEdges:Se,unselectNodesAndEdges:Ke,multiSelectionActive:et}=M.getState();R&&(M.setState({nodesSelectionActive:!1}),x.selected&&et?(Ke({nodes:[],edges:[x]}),(We=H.current)==null||We.blur()):Se([e])),s&&s(xe,x)},he=o?xe=>{o(xe,{...x})}:void 0,we=a?xe=>{a(xe,{...x})}:void 0,ue=l?xe=>{l(xe,{...x})}:void 0,Ne=u?xe=>{u(xe,{...x})}:void 0,le=d?xe=>{d(xe,{...x})}:void 0,ce=xe=>{var Se;if(!w&&dA.includes(xe.key)&&R){const{unselectNodesAndEdges:Ke,addSelectedEdges:et}=M.getState();xe.key==="Escape"?((Se=H.current)==null||Se.blur(),Ke({edges:[x]})):et([e])}};return i.jsx("svg",{style:{zIndex:I},children:i.jsxs("g",{className:vr(["react-flow__edge",`react-flow__edge-${_}`,x.className,k,{selected:x.selected,animated:x.animated,inactive:!R&&!s,updating:D,selectable:R}]),onClick:de,onDoubleClick:he,onContextMenu:we,onMouseEnter:ue,onMouseMove:Ne,onMouseLeave:le,onKeyDown:T?ce:void 0,tabIndex:T?0:void 0,role:x.ariaRole??(T?"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":T?`${YA}-${g}`:void 0,ref:H,...x.domAttributes,children:[!B&&i.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:R,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:O,targetY:E,sourcePosition:J,targetPosition:Z,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:K,markerEnd:oe,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),F&&i.jsx(g4,{edge:x,isReconnectable:F,reconnectRadius:p,onReconnect:c,onReconnectStart:f,onReconnectEnd:h,sourceX:z,sourceY:A,targetX:O,targetY:E,sourcePosition:J,targetPosition:Z,setUpdateHover:$,setReconnecting:L})]})})}var x4=m.memo(y4);const w4=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function xI({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:p,reconnectRadius:c,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:k,edgesReconnectable:y,elementsSelectable:w,onError:x}=Jt(w4,Xn),N=r4(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(l4,{defaultColor:e,rfId:n}),N.map(_=>i.jsx(x4,{id:_,edgesFocusable:k,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:d,onClick:p,reconnectRadius:c,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:b},_))]})}xI.displayName="EdgeRenderer";const b4=m.memo(xI),v4=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function k4({children:e}){const t=Jt(v4);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function S4(e){const t=El(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const N4=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function j4(e){const t=Jt(N4),n=Bn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function C4(e){return e.connection.inProgress?{...e.connection,to:Fp(e.connection.to,e.transform)}:{...e.connection}}function E4(e){return C4}function _4(e){const t=E4();return Jt(t,Xn)}const P4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function A4({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:u}=Jt(P4,Xn);return!(o&&s&&u)?null:i.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:i.jsx("g",{className:vr(["react-flow__connection",hA(l)]),children:i.jsx(wI,{style:t,type:n,CustomComponent:r,isValid:l})})})}const wI=({style:e,type:t=Qa.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:u,to:d,toNode:p,toHandle:c,toPosition:f,pointer:h}=_4();if(!s)return;if(n)return i.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:u,toPosition:f,connectionStatus:hA(r),toNode:p,toHandle:c,pointer:h});let g="";const b={sourceX:o.x,sourceY:o.y,sourcePosition:u,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case Qa.Bezier:[g]=CA(b);break;case Qa.SimpleBezier:[g]=oI(b);break;case Qa.Step:[g]=Ab({...b,borderRadius:0});break;case Qa.SmoothStep:[g]=Ab(b);break;default:[g]=_A(b)}return i.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};wI.displayName="ConnectionLine";const I4={};function XN(e=I4){m.useRef(e),Bn(),m.useEffect(()=>{},[e])}function T4(){Bn(),m.useRef(!1),m.useEffect(()=>{},[])}function bI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:c,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:k,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:x,selectionMode:N,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,deleteKeyCode:F,onlyRenderVisibleElements:R,elementsSelectable:H,defaultViewport:D,translateExtent:$,minZoom:B,maxZoom:L,preventScrolling:M,defaultMarkerColor:I,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:O,panOnScrollSpeed:E,panOnScrollMode:J,zoomOnDoubleClick:Z,panOnDrag:K,onPaneClick:oe,onPaneMouseEnter:de,onPaneMouseMove:he,onPaneMouseLeave:we,onPaneScroll:ue,onPaneContextMenu:Ne,paneClickDistance:le,nodeClickDistance:ce,onEdgeContextMenu:xe,onEdgeMouseEnter:Se,onEdgeMouseMove:Ke,onEdgeMouseLeave:et,reconnectRadius:We,onReconnect:ut,onReconnectStart:Ve,onReconnectEnd:xt,noDragClassName:bt,noWheelClassName:Jn,noPanClassName:Ut,disableKeyboardA11y:nn,nodeExtent:rn,rfId:hn,viewport:fe,onViewportChange:je}){return XN(e),XN(t),T4(),S4(n),j4(fe),i.jsx(q5,{onPaneClick:oe,onPaneMouseEnter:de,onPaneMouseMove:he,onPaneMouseLeave:we,onPaneContextMenu:Ne,onPaneScroll:ue,paneClickDistance:le,deleteKeyCode:F,selectionKeyCode:w,selectionOnDrag:x,selectionMode:N,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:T,elementsSelectable:H,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:Z,panOnScroll:O,panOnScrollSpeed:E,panOnScrollMode:J,panOnDrag:K,defaultViewport:D,translateExtent:$,minZoom:B,maxZoom:L,onSelectionContextMenu:c,preventScrolling:M,noDragClassName:bt,noWheelClassName:Jn,noPanClassName:Ut,disableKeyboardA11y:nn,onViewportChange:je,isControlledViewport:!!fe,children:i.jsxs(k4,{children:[i.jsx(b4,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:ut,onReconnectStart:Ve,onReconnectEnd:xt,onlyRenderVisibleElements:R,onEdgeContextMenu:xe,onEdgeMouseEnter:Se,onEdgeMouseMove:Ke,onEdgeMouseLeave:et,reconnectRadius:We,defaultMarkerColor:I,noPanClassName:Ut,disableKeyboardA11y:nn,rfId:hn}),i.jsx(A4,{style:b,type:g,component:k,containerStyle:y}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(n4,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:p,nodeClickDistance:ce,onlyRenderVisibleElements:R,noPanClassName:Ut,noDragClassName:bt,disableKeyboardA11y:nn,nodeExtent:rn,rfId:hn}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}bI.displayName="GraphView";const R4=m.memo(bI),JN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:u=.5,maxZoom:d=2,nodeOrigin:p,nodeExtent:c,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,b=new Map,k=new Map,y=r??t??[],w=n??e??[],x=p??[0,0],N=c??dp;IA(b,k,y);const{nodesInitialized:_}=Tb(w,h,g,{nodeOrigin:x,nodeExtent:N,zIndexMode:f});let C=[0,0,1];if(a&&s&&o){const T=$p(h,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:F,y:R,zoom:H}=b0(T,s,o,u,d,(l==null?void 0:l.padding)??.1);C=[F,R,H]}return{rfId:"1",width:s??0,height:o??0,transform:C,nodes:w,nodesInitialized:_,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:k,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:d,translateExtent:dp,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qu.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:{...pA},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:$3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:fA,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},M4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:p,nodeExtent:c,zIndexMode:f})=>ZH((h,g)=>{async function b(){const{nodeLookup:k,panZoom:y,fitViewOptions:w,fitViewResolver:x,width:N,height:_,minZoom:C,maxZoom:T}=g();y&&(await L3({nodes:k,width:N,height:_,panZoom:y,minZoom:C,maxZoom:T},w),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...JN({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:p,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:k=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:x,elevateNodesOnSelect:N,fitViewQueued:_,zIndexMode:C,nodesSelectionActive:T}=g(),{nodesInitialized:F,hasSelectedNodes:R}=Tb(k,y,w,{nodeOrigin:x,nodeExtent:c,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),H=T&&R;_&&F?(b(),h({nodes:k,nodesInitialized:F,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:H})):h({nodes:k,nodesInitialized:F,nodesSelectionActive:H})},setEdges:k=>{const{connectionLookup:y,edgeLookup:w}=g();IA(y,w,k),h({edges:k})},setDefaultNodesAndEdges:(k,y)=>{if(k){const{setNodes:w}=g();w(k),h({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),h({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:x,domNode:N,nodeOrigin:_,nodeExtent:C,debug:T,fitViewQueued:F,zIndexMode:R}=g(),{changes:H,updatedInternals:D}=sH(k,w,x,N,_,C,R);D&&(eH(w,x,{nodeOrigin:_,nodeExtent:C,zIndexMode:R}),F?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(H==null?void 0:H.length)>0&&(T&&console.log("React Flow: trigger node changes",H),y==null||y(H)))},updateNodePositions:(k,y=!1)=>{const w=[];let x=[];const{nodeLookup:N,triggerNodeChanges:_,connection:C,updateConnection:T,onNodesChangeMiddlewareMap:F}=g();for(const[R,H]of k){const D=N.get(R),$=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(H!=null&&H.position)),B={id:R,type:"position",position:$?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:y};if(D&&C.inProgress&&C.fromNode.id===D.id){const L=Sc(D,C.fromHandle,Je.Left,!0);T({...C,from:L})}$&&D.parentId&&w.push({id:R,parentId:D.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),x.push(B)}if(w.length>0){const{parentLookup:R,nodeOrigin:H}=g(),D=C0(w,N,R,H);x.push(...D)}for(const R of F.values())x=R(x);_(x)},triggerNodeChanges:k=>{const{onNodesChange:y,setNodes:w,nodes:x,hasDefaultNodes:N,debug:_}=g();if(k!=null&&k.length){if(N){const C=wg(k,x);w(C)}_&&console.log("React Flow: trigger node changes",k),y==null||y(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:y,setEdges:w,edges:x,hasDefaultEdges:N,debug:_}=g();if(k!=null&&k.length){if(N){const C=E0(k,x);w(C)}_&&console.log("React Flow: trigger edge changes",k),y==null||y(k)}},addSelectedNodes:k=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=g();if(y){const C=k.map(T=>ec(T,!0));N(C);return}N(Cu(x,new Set([...k]),!0)),_(Cu(w))},addSelectedEdges:k=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:_}=g();if(y){const C=k.map(T=>ec(T,!0));_(C);return}_(Cu(w,new Set([...k]))),N(Cu(x,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:y}={})=>{const{edges:w,nodes:x,nodeLookup:N,triggerNodeChanges:_,triggerEdgeChanges:C}=g(),T=k||x,F=y||w,R=[];for(const D of T){if(!D.selected)continue;const $=N.get(D.id);$&&($.selected=!1),R.push(ec(D.id,!1))}const H=[];for(const D of F)D.selected&&H.push(ec(D.id,!1));_(R),C(H)},setMinZoom:k=>{const{panZoom:y,maxZoom:w}=g();y==null||y.setScaleExtent([k,w]),h({minZoom:k})},setMaxZoom:k=>{const{panZoom:y,minZoom:w}=g();y==null||y.setScaleExtent([w,k]),h({maxZoom:k})},setTranslateExtent:k=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(k),h({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:x,elementsSelectable:N}=g();if(!N)return;const _=y.reduce((T,F)=>F.selected?[...T,ec(F.id,!1)]:T,[]),C=k.reduce((T,F)=>F.selected?[...T,ec(F.id,!1)]:T,[]);w(_),x(C)},setNodeExtent:k=>{const{nodes:y,nodeLookup:w,parentLookup:x,nodeOrigin:N,elevateNodesOnSelect:_,nodeExtent:C,zIndexMode:T}=g();k[0][0]===C[0][0]&&k[0][1]===C[0][1]&&k[1][0]===C[1][0]&&k[1][1]===C[1][1]||(Tb(y,w,x,{nodeOrigin:N,nodeExtent:k,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:T}),h({nodeExtent:k}))},panBy:k=>{const{transform:y,width:w,height:x,panZoom:N,translateExtent:_}=g();return iH({delta:k,panZoom:N,transform:y,translateExtent:_,width:w,height:x})},setCenter:async(k,y,w)=>{const{width:x,height:N,maxZoom:_,panZoom:C}=g();if(!C)return Promise.resolve(!1);const T=typeof(w==null?void 0:w.zoom)<"u"?w.zoom:_;return await C.setViewport({x:x/2-k*T,y:N/2-y*T,zoom:T},{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:{...pA}})},updateConnection:k=>{h({connection:k})},reset:()=>h({...JN()})}},Object.is);function Sy({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:u,fitView:d,nodeOrigin:p,nodeExtent:c,zIndexMode:f,children:h}){const[g]=m.useState(()=>M4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:u,nodeOrigin:p,nodeExtent:c,zIndexMode:f}));return i.jsx(e5,{value:g,children:i.jsx(k5,{children:h})})}function L4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:p,nodeOrigin:c,nodeExtent:f,zIndexMode:h}){return m.useContext(by)?i.jsx(i.Fragment,{children:e}):i.jsx(Sy,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:u,initialMinZoom:d,initialMaxZoom:p,nodeOrigin:c,nodeExtent:f,zIndexMode:h,children:e})}const O4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function $4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:u,onInit:d,onMove:p,onMoveStart:c,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,onNodeDragStart:T,onNodeDrag:F,onNodeDragStop:R,onNodesDelete:H,onEdgesDelete:D,onDelete:$,onSelectionChange:B,onSelectionDragStart:L,onSelectionDrag:M,onSelectionDragStop:I,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:O,onBeforeDelete:E,connectionMode:J,connectionLineType:Z=Qa.Bezier,connectionLineStyle:K,connectionLineComponent:oe,connectionLineContainerStyle:de,deleteKeyCode:he="Backspace",selectionKeyCode:we="Shift",selectionOnDrag:ue=!1,selectionMode:Ne=fp.Full,panActivationKeyCode:le="Space",multiSelectionKeyCode:ce=hp()?"Meta":"Control",zoomActivationKeyCode:xe=hp()?"Meta":"Control",snapToGrid:Se,snapGrid:Ke,onlyRenderVisibleElements:et=!1,selectNodesOnDrag:We,nodesDraggable:ut,autoPanOnNodeFocus:Ve,nodesConnectable:xt,nodesFocusable:bt,nodeOrigin:Jn=GA,edgesFocusable:Ut,edgesReconnectable:nn,elementsSelectable:rn=!0,defaultViewport:hn=p5,minZoom:fe=.5,maxZoom:je=2,translateExtent:He=dp,preventScrolling:ot=!0,nodeExtent:at,defaultMarkerColor:Tt="#b1b1b7",zoomOnScroll:mt=!0,zoomOnPinch:dn=!0,panOnScroll:sn=!1,panOnScrollSpeed:Rn=.5,panOnScrollMode:on=dc.Free,zoomOnDoubleClick:Mn=!0,panOnDrag:Ln=!0,onPaneClick:zr,onPaneMouseEnter:be,onPaneMouseMove:$e,onPaneMouseLeave:ft,onPaneScroll:St,onPaneContextMenu:mn,paneClickDistance:es=1,nodeClickDistance:Cs=0,children:_r,onReconnect:Hr,onReconnectStart:hr,onReconnectEnd:kr,onEdgeContextMenu:hs,onEdgeDoubleClick:Br,onEdgeMouseEnter:Ei,onEdgeMouseMove:Qn,onEdgeMouseLeave:Wr,reconnectRadius:ae=10,onNodesChange:Ce,onEdgesChange:tt,noDragClassName:De="nodrag",noWheelClassName:Ae="nowheel",noPanClassName:Nt="nopan",fitView:mr,fitViewOptions:it,connectOnClick:lr,attributionPosition:Zn,proOptions:Vr,defaultEdgeOptions:ms,elevateNodesOnSelect:Ie=!0,elevateEdgesOnSelect:Us=!1,disableKeyboardA11y:pt=!1,autoPanOnConnect:xn,autoPanOnNodeDrag:an,autoPanSpeed:cr,connectionRadius:nt,isValidConnection:Kr,onError:Na,style:Ko,id:ao,nodeDragThreshold:Es,connectionDragThreshold:Uo,viewport:ts,onViewportChange:Nn,width:sr,height:lo,colorMode:fi="light",debug:qs,onScroll:ir,ariaLabelConfig:Ys,zIndexMode:U="basic",...ge},ze){const Le=ao||"1",rt=y5(fi),ln=m.useCallback(Rt=>{Rt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ir==null||ir(Rt)},[ir]);return i.jsx("div",{"data-testid":"rf__wrapper",...ge,onScroll:ln,style:{...Ko,...O4},ref:ze,className:vr(["react-flow",s,rt]),id:ao,role:"application",children:i.jsxs(L4,{nodes:e,edges:t,width:sr,height:lo,fitView:mr,fitViewOptions:it,minZoom:fe,maxZoom:je,nodeOrigin:Jn,nodeExtent:at,zIndexMode:U,children:[i.jsx(g5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:y,nodesDraggable:ut,autoPanOnNodeFocus:Ve,nodesConnectable:xt,nodesFocusable:bt,edgesFocusable:Ut,edgesReconnectable:nn,elementsSelectable:rn,elevateNodesOnSelect:Ie,elevateEdgesOnSelect:Us,minZoom:fe,maxZoom:je,nodeExtent:at,onNodesChange:Ce,onEdgesChange:tt,snapToGrid:Se,snapGrid:Ke,connectionMode:J,translateExtent:He,connectOnClick:lr,defaultEdgeOptions:ms,fitView:mr,fitViewOptions:it,onNodesDelete:H,onEdgesDelete:D,onDelete:$,onNodeDragStart:T,onNodeDrag:F,onNodeDragStop:R,onSelectionDrag:M,onSelectionDragStart:L,onSelectionDragStop:I,onMove:p,onMoveStart:c,onMoveEnd:f,noPanClassName:Nt,nodeOrigin:Jn,rfId:Le,autoPanOnConnect:xn,autoPanOnNodeDrag:an,autoPanSpeed:cr,onError:Na,connectionRadius:nt,isValidConnection:Kr,selectNodesOnDrag:We,nodeDragThreshold:Es,connectionDragThreshold:Uo,onBeforeDelete:E,debug:qs,ariaLabelConfig:Ys,zIndexMode:U}),i.jsx(R4,{onInit:d,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:w,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:_,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:a,connectionLineType:Z,connectionLineStyle:K,connectionLineComponent:oe,connectionLineContainerStyle:de,selectionKeyCode:we,selectionOnDrag:ue,selectionMode:Ne,deleteKeyCode:he,multiSelectionKeyCode:ce,panActivationKeyCode:le,zoomActivationKeyCode:xe,onlyRenderVisibleElements:et,defaultViewport:hn,translateExtent:He,minZoom:fe,maxZoom:je,preventScrolling:ot,zoomOnScroll:mt,zoomOnPinch:dn,zoomOnDoubleClick:Mn,panOnScroll:sn,panOnScrollSpeed:Rn,panOnScrollMode:on,panOnDrag:Ln,onPaneClick:zr,onPaneMouseEnter:be,onPaneMouseMove:$e,onPaneMouseLeave:ft,onPaneScroll:St,onPaneContextMenu:mn,paneClickDistance:es,nodeClickDistance:Cs,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:O,onReconnect:Hr,onReconnectStart:hr,onReconnectEnd:kr,onEdgeContextMenu:hs,onEdgeDoubleClick:Br,onEdgeMouseEnter:Ei,onEdgeMouseMove:Qn,onEdgeMouseLeave:Wr,reconnectRadius:ae,defaultMarkerColor:Tt,noDragClassName:De,noWheelClassName:Ae,noPanClassName:Nt,rfId:Le,disableKeyboardA11y:pt,nodeExtent:at,viewport:ts,onViewportChange:Nn}),i.jsx(f5,{onSelectionChange:B}),_r,i.jsx(a5,{proOptions:Vr,position:Zn}),i.jsx(o5,{rfId:Le,disableKeyboardA11y:pt})]})})}var P0=JA($4);function A0(){const e=Bn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],o=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function vI(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>wg(s,o)),[]);return[t,n,r]}function kI(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>E0(s,o)),[]);return[t,n,r]}function D4({dimensions:e,lineWidth:t,variant:n,className:r}){return i.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:vr(["react-flow__background-pattern",n,r])})}function F4({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:vr(["react-flow__background-pattern","dots",t])})}var fl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(fl||(fl={}));const z4={[fl.Dots]:1,[fl.Lines]:1,[fl.Cross]:6},H4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function SI({id:e,variant:t=fl.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:u,className:d,patternClassName:p}){const c=m.useRef(null),{transform:f,patternId:h}=Jt(H4,Xn),g=r||z4[t],b=t===fl.Dots,k=t===fl.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*f[2]||1,y[1]*f[2]||1],x=g*f[2],N=Array.isArray(o)?o:[o,o],_=k?[x,x]:w,C=[N[0]*f[2]||1+_[0]/2,N[1]*f[2]||1+_[1]/2],T=`${h}${e||""}`;return i.jsxs("svg",{className:vr(["react-flow__background",d]),style:{...u,...vy,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:c,"data-testid":"rf__background",children:[i.jsx("pattern",{id:T,x:f[0]%w[0],y:f[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:b?i.jsx(F4,{radius:x/2,className:p}):i.jsx(D4,{dimensions:_,lineWidth:s,variant:t,className:p})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${T})`})]})}SI.displayName="Background";const I0=m.memo(SI);function B4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:i.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function W4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:i.jsx("path",{d:"M0 0h32v4.2H0z"})})}function V4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:i.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 K4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.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 U4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.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 Uh({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:vr(["react-flow__controls-button",t]),...n,children:e})}const q4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function NI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:u,className:d,children:p,position:c="bottom-left",orientation:f="vertical","aria-label":h}){const g=Bn(),{isInteractive:b,minZoomReached:k,maxZoomReached:y,ariaLabelConfig:w}=Jt(q4,Xn),{zoomIn:x,zoomOut:N,fitView:_}=El(),C=()=>{x(),o==null||o()},T=()=>{N(),a==null||a()},F=()=>{_(s),l==null||l()},R=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),u==null||u(!b)},H=f==="horizontal"?"horizontal":"vertical";return i.jsxs(sd,{className:vr(["react-flow__controls",H,d]),position:c,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Uh,{onClick:C,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:i.jsx(B4,{})}),i.jsx(Uh,{onClick:T,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:k,children:i.jsx(W4,{})})]}),n&&i.jsx(Uh,{className:"react-flow__controls-fitview",onClick:F,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:i.jsx(V4,{})}),r&&i.jsx(Uh,{className:"react-flow__controls-interactive",onClick:R,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?i.jsx(U4,{}):i.jsx(K4,{})}),p]})}NI.displayName="Controls";const Y4=m.memo(NI);function G4({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:u,className:d,borderRadius:p,shapeRendering:c,selected:f,onClick:h}){const{background:g,backgroundColor:b}=o||{},k=a||g||b;return i.jsx("rect",{className:vr(["react-flow__minimap-node",{selected:f},d]),x:t,y:n,rx:p,ry:p,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:u},shapeRendering:c,onClick:h?y=>h(y,e):void 0})}const X4=m.memo(G4),J4=e=>e.nodes.map(t=>t.id),Mx=e=>e instanceof Function?e:()=>e;function Q4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=X4,onClick:a}){const l=Jt(J4,Xn),u=Mx(t),d=Mx(e),p=Mx(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(f=>i.jsx(eB,{id:f,nodeColorFunc:u,nodeStrokeColorFunc:d,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:c},f))})}function Z4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:u}){const{node:d,x:p,y:c,width:f,height:h}=Jt(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const k=b.internals.userNode,{x:y,y:w}=b.internals.positionAbsolute,{width:x,height:N}=ka(k);return{node:k,x:y,y:w,width:x,height:N}},Xn);return!d||d.hidden||!bA(d)?null:i.jsx(l,{x:p,y:c,width:f,height:h,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:o,shapeRendering:a,onClick:u,id:d.id})}const eB=m.memo(Z4);var tB=m.memo(Q4);const nB=200,rB=150,sB=e=>!e.hidden,iB=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?wA($p(e.nodeLookup,{filter:sB}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},oB="react-flow__minimap-desc";function jI({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:u,maskColor:d,maskStrokeColor:p,maskStrokeWidth:c,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:k=!1,ariaLabel:y,inversePan:w,zoomStep:x=1,offsetScale:N=5}){const _=Bn(),C=m.useRef(null),{boundingRect:T,viewBB:F,rfId:R,panZoom:H,translateExtent:D,flowWidth:$,flowHeight:B,ariaLabelConfig:L}=Jt(iB,Xn),M=(e==null?void 0:e.width)??nB,I=(e==null?void 0:e.height)??rB,z=T.width/M,A=T.height/I,O=Math.max(z,A),E=O*M,J=O*I,Z=N*O,K=T.x-(E-T.width)/2-Z,oe=T.y-(J-T.height)/2-Z,de=E+Z*2,he=J+Z*2,we=`${oB}-${R}`,ue=m.useRef(0),Ne=m.useRef();ue.current=O,m.useEffect(()=>{if(C.current&&H)return Ne.current=hH({domNode:C.current,panZoom:H,getTransform:()=>_.getState().transform,getViewScale:()=>ue.current}),()=>{var Se;(Se=Ne.current)==null||Se.destroy()}},[H]),m.useEffect(()=>{var Se;(Se=Ne.current)==null||Se.update({translateExtent:D,width:$,height:B,inversePan:w,pannable:b,zoomStep:x,zoomable:k})},[b,k,w,x,D,$,B]);const le=h?Se=>{var We;const[Ke,et]=((We=Ne.current)==null?void 0:We.pointer(Se))||[0,0];h(Se,{x:Ke,y:et})}:void 0,ce=g?m.useCallback((Se,Ke)=>{const et=_.getState().nodeLookup.get(Ke).internals.userNode;g(Se,et)},[]):void 0,xe=y??L["minimap.ariaLabel"];return i.jsx(sd,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*O: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:vr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:M,height:I,viewBox:`${K} ${oe} ${de} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":we,ref:C,onClick:le,children:[xe&&i.jsx("title",{id:we,children:xe}),i.jsx(tB,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${K-Z},${oe-Z}h${de+Z*2}v${he+Z*2}h${-de-Z*2}z
66
- M${F.x},${F.y}h${F.width}v${F.height}h${-F.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jI.displayName="MiniMap";const aB=m.memo(jI),lB=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,cB={[nd.Line]:"right",[nd.Handle]:"bottom-right"};function uB({nodeId:e,position:t,variant:n=nd.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:u=10,maxWidth:d=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:k,onResizeEnd:y}){const w=tI(),x=typeof e=="string"?e:w,N=Bn(),_=m.useRef(null),C=n===nd.Handle,T=Jt(m.useCallback(lB(C&&h),[C,h]),Xn),F=m.useRef(null),R=t??cB[n];m.useEffect(()=>{if(!(!_.current||!x))return F.current||(F.current=_H({domNode:_.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:D,transform:$,snapGrid:B,snapToGrid:L,nodeOrigin:M,domNode:I}=N.getState();return{nodeLookup:D,transform:$,snapGrid:B,snapToGrid:L,nodeOrigin:M,paneDomNode:I}},onChange:(D,$)=>{const{triggerNodeChanges:B,nodeLookup:L,parentLookup:M,nodeOrigin:I}=N.getState(),z=[],A={x:D.x,y:D.y},O=L.get(x);if(O&&O.expandParent&&O.parentId){const E=O.origin??I,J=D.width??O.measured.width??0,Z=D.height??O.measured.height??0,K={id:O.id,parentId:O.parentId,rect:{width:J,height:Z,...vA({x:D.x??O.position.x,y:D.y??O.position.y},{width:J,height:Z},O.parentId,L,E)}},oe=C0([K],L,M,I);z.push(...oe),A.x=D.x?Math.max(E[0]*J,D.x):void 0,A.y=D.y?Math.max(E[1]*Z,D.y):void 0}if(A.x!==void 0&&A.y!==void 0){const E={id:x,type:"position",position:{...A}};z.push(E)}if(D.width!==void 0&&D.height!==void 0){const J={id:x,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};z.push(J)}for(const E of $){const J={...E,type:"position"};z.push(J)}B(z)},onEnd:({width:D,height:$})=>{const B={id:x,type:"dimensions",resizing:!1,dimensions:{width:D,height:$}};N.getState().triggerNodeChanges([B])}})),F.current.update({controlPosition:R,boundaries:{minWidth:l,minHeight:u,maxWidth:d,maxHeight:p},keepAspectRatio:c,resizeDirection:f,onResizeStart:b,onResize:k,onResizeEnd:y,shouldResize:g}),()=>{var D;(D=F.current)==null||D.destroy()}},[R,l,u,d,p,c,b,k,y,g]);const H=R.split("-");return i.jsx("div",{className:vr(["react-flow__resize-control","nodrag",...H,n,r]),ref:_,style:{...s,scale:T,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:o})}const T0=m.memo(uB);function dB(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fB=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pB=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hB={};function QN(e,t){return(hB.jsx?pB:fB).test(e)}const mB=/[ \t\n\f\r]/g;function gB(e){return typeof e=="object"?e.type==="text"?ZN(e.value):!1:ZN(e)}function ZN(e){return e.replace(mB,"")===""}let zp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};zp.prototype.normal={};zp.prototype.property={};zp.prototype.space=void 0;function CI(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new zp(n,r,t)}function Ob(e){return e.toLowerCase()}class Ks{constructor(t,n){this.attribute=n,this.property=t}}Ks.prototype.attribute="";Ks.prototype.booleanish=!1;Ks.prototype.boolean=!1;Ks.prototype.commaOrSpaceSeparated=!1;Ks.prototype.commaSeparated=!1;Ks.prototype.defined=!1;Ks.prototype.mustUseProperty=!1;Ks.prototype.number=!1;Ks.prototype.overloadedBoolean=!1;Ks.prototype.property="";Ks.prototype.spaceSeparated=!1;Ks.prototype.space=void 0;let yB=0;const Ot=Ic(),xr=Ic(),$b=Ic(),Me=Ic(),_n=Ic(),Fu=Ic(),ei=Ic();function Ic(){return 2**++yB}const Db=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ot,booleanish:xr,commaOrSpaceSeparated:ei,commaSeparated:Fu,number:Me,overloadedBoolean:$b,spaceSeparated:_n},Symbol.toStringTag,{value:"Module"})),Lx=Object.keys(Db);class R0 extends Ks{constructor(t,n,r,s){let o=-1;if(super(t,n),ej(this,"space",s),typeof r=="number")for(;++o<Lx.length;){const a=Lx[o];ej(this,Lx[o],(r&Db[a])===Db[a])}}}R0.prototype.defined=!0;function ej(e,t,n){n&&(e[t]=n)}function hd(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new R0(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Ob(r)]=r,n[Ob(o.attribute)]=r}return new zp(t,n,e.space)}const EI=hd({properties:{ariaActiveDescendant:null,ariaAtomic:xr,ariaAutoComplete:null,ariaBusy:xr,ariaChecked:xr,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:_n,ariaCurrent:null,ariaDescribedBy:_n,ariaDetails:null,ariaDisabled:xr,ariaDropEffect:_n,ariaErrorMessage:null,ariaExpanded:xr,ariaFlowTo:_n,ariaGrabbed:xr,ariaHasPopup:null,ariaHidden:xr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:_n,ariaLevel:Me,ariaLive:null,ariaModal:xr,ariaMultiLine:xr,ariaMultiSelectable:xr,ariaOrientation:null,ariaOwns:_n,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:xr,ariaReadOnly:xr,ariaRelevant:null,ariaRequired:xr,ariaRoleDescription:_n,ariaRowCount:Me,ariaRowIndex:Me,ariaRowSpan:Me,ariaSelected:xr,ariaSetSize:Me,ariaSort:null,ariaValueMax:Me,ariaValueMin:Me,ariaValueNow:Me,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function _I(e,t){return t in e?e[t]:t}function PI(e,t){return _I(e,t.toLowerCase())}const xB=hd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fu,acceptCharset:_n,accessKey:_n,action:null,allow:null,allowFullScreen:Ot,allowPaymentRequest:Ot,allowUserMedia:Ot,alt:null,as:null,async:Ot,autoCapitalize:null,autoComplete:_n,autoFocus:Ot,autoPlay:Ot,blocking:_n,capture:null,charSet:null,checked:Ot,cite:null,className:_n,cols:Me,colSpan:null,content:null,contentEditable:xr,controls:Ot,controlsList:_n,coords:Me|Fu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ot,defer:Ot,dir:null,dirName:null,disabled:Ot,download:$b,draggable:xr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ot,formTarget:null,headers:_n,height:Me,hidden:$b,high:Me,href:null,hrefLang:null,htmlFor:_n,httpEquiv:_n,id:null,imageSizes:null,imageSrcSet:null,inert:Ot,inputMode:null,integrity:null,is:null,isMap:Ot,itemId:null,itemProp:_n,itemRef:_n,itemScope:Ot,itemType:_n,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ot,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:Ot,muted:Ot,name:null,nonce:null,noModule:Ot,noValidate:Ot,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:Ot,optimum:Me,pattern:null,ping:_n,placeholder:null,playsInline:Ot,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ot,referrerPolicy:null,rel:_n,required:Ot,reversed:Ot,rows:Me,rowSpan:Me,sandbox:_n,scope:null,scoped:Ot,seamless:Ot,selected:Ot,shadowRootClonable:Ot,shadowRootDelegatesFocus:Ot,shadowRootMode:null,shape:null,size:Me,sizes:null,slot:null,span:Me,spellCheck:xr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Me,step:null,style:null,tabIndex:Me,target:null,title:null,translate:null,type:null,typeMustMatch:Ot,useMap:null,value:xr,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:_n,axis:null,background:null,bgColor:null,border:Me,borderColor:null,bottomMargin:Me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ot,declare:Ot,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:Ot,noHref:Ot,noShade:Ot,noWrap:Ot,object:null,profile:null,prompt:null,rev:null,rightMargin:Me,rules:null,scheme:null,scrolling:xr,standby:null,summary:null,text:null,topMargin:Me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Me,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ot,disableRemotePlayback:Ot,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:PI}),wB=hd({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:ei,accentHeight:Me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Me,amplitude:Me,arabicForm:null,ascent:Me,attributeName:null,attributeType:null,azimuth:Me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Me,by:null,calcMode:null,capHeight:Me,className:_n,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:Me,diffuseConstant:Me,direction:null,display:null,dur:null,divisor:Me,dominantBaseline:null,download:Ot,dx:null,dy:null,edgeMode:null,editable:null,elevation:Me,enableBackground:null,end:null,event:null,exponent:Me,externalResourcesRequired:null,fill:null,fillOpacity:Me,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:Fu,g2:Fu,glyphName:Fu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Me,horizOriginX:Me,horizOriginY:Me,id:null,ideographic:Me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Me,k:Me,k1:Me,k2:Me,k3:Me,k4:Me,kernelMatrix:ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Me,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:Me,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:Me,overlineThickness:Me,paintOrder:null,panose1:null,path:null,pathLength:Me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:_n,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ei,rev:ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ei,requiredFeatures:ei,requiredFonts:ei,requiredFormats:ei,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:Me,specularExponent:Me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Me,strikethroughThickness:Me,string:null,stroke:null,strokeDashArray:ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Me,strokeOpacity:Me,strokeWidth:null,style:null,surfaceScale:Me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ei,tabIndex:Me,tableValues:null,target:null,targetX:Me,targetY:Me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Me,underlineThickness:Me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Me,values:null,vAlphabetic:Me,vMathematical:Me,vectorEffect:null,vHanging:Me,vIdeographic:Me,version:null,vertAdvY:Me,vertOriginX:Me,vertOriginY:Me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:_I}),AI=hd({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()}}),II=hd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:PI}),TI=hd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),bB={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"},vB=/[A-Z]/g,tj=/-[a-z]/g,kB=/^data[-\w.:]+$/i;function SB(e,t){const n=Ob(t);let r=t,s=Ks;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&kB.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(tj,jB);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!tj.test(o)){let a=o.replace(vB,NB);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=R0}return new s(r,t)}function NB(e){return"-"+e.toLowerCase()}function jB(e){return e.charAt(1).toUpperCase()}const CB=CI([EI,xB,AI,II,TI],"html"),M0=CI([EI,wB,AI,II,TI],"svg");function EB(e){return e.join(" ").trim()}var L0={},nj=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,_B=/\n/g,PB=/^\s*/,AB=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,IB=/^:\s*/,TB=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,RB=/^[;\s]*/,MB=/^\s+|\s+$/g,LB=`
67
- `,rj="/",sj="*",nc="",OB="comment",$B="declaration";function DB(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(_B);b&&(n+=b.length);var k=g.lastIndexOf(LB);r=~k?g.length-k:r+g.length}function o(){var g={line:n,column:r};return function(b){return b.position=new a(g),d(),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 u(g){var b=g.exec(e);if(b){var k=b[0];return s(k),e=e.slice(k.length),b}}function d(){u(PB)}function p(g){var b;for(g=g||[];b=c();)b!==!1&&g.push(b);return g}function c(){var g=o();if(!(rj!=e.charAt(0)||sj!=e.charAt(1))){for(var b=2;nc!=e.charAt(b)&&(sj!=e.charAt(b)||rj!=e.charAt(b+1));)++b;if(b+=2,nc===e.charAt(b-1))return l("End of comment missing");var k=e.slice(2,b-2);return r+=2,s(k),e=e.slice(b),r+=2,g({type:OB,comment:k})}}function f(){var g=o(),b=u(AB);if(b){if(c(),!u(IB))return l("property missing ':'");var k=u(TB),y=g({type:$B,property:ij(b[0].replace(nj,nc)),value:k?ij(k[0].replace(nj,nc)):nc});return u(RB),y}}function h(){var g=[];p(g);for(var b;b=f();)b!==!1&&(g.push(b),p(g));return g}return d(),h()}function ij(e){return e?e.replace(MB,nc):nc}var FB=DB,zB=Wf&&Wf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(L0,"__esModule",{value:!0});L0.default=BB;const HB=zB(FB);function BB(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,HB.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;s?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var Ny={};Object.defineProperty(Ny,"__esModule",{value:!0});Ny.camelCase=void 0;var WB=/^--[a-zA-Z0-9_-]+$/,VB=/-([a-z])/g,KB=/^[^-]+$/,UB=/^-(webkit|moz|ms|o|khtml)-/,qB=/^-(ms)-/,YB=function(e){return!e||KB.test(e)||WB.test(e)},GB=function(e,t){return t.toUpperCase()},oj=function(e,t){return"".concat(t,"-")},XB=function(e,t){return t===void 0&&(t={}),YB(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(qB,oj):e=e.replace(UB,oj),e.replace(VB,GB))};Ny.camelCase=XB;var JB=Wf&&Wf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},QB=JB(L0),ZB=Ny;function Fb(e,t){var n={};return!e||typeof e!="string"||(0,QB.default)(e,function(r,s){r&&s&&(n[(0,ZB.camelCase)(r,t)]=s)}),n}Fb.default=Fb;var e6=Fb;const t6=Sl(e6),RI=MI("end"),O0=MI("start");function MI(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 n6(e){const t=O0(e),n=RI(e);if(t&&n)return{start:t,end:n}}function Lf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?aj(e.position):"start"in e||"end"in e?aj(e):"line"in e||"column"in e?zb(e):""}function zb(e){return lj(e&&e.line)+":"+lj(e&&e.column)}function aj(e){return zb(e&&e.start)+"-"+zb(e&&e.end)}function lj(e){return e&&typeof e=="number"?e:1}class fs extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(a=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.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=Lf(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}fs.prototype.file="";fs.prototype.name="";fs.prototype.reason="";fs.prototype.message="";fs.prototype.stack="";fs.prototype.column=void 0;fs.prototype.line=void 0;fs.prototype.ancestors=void 0;fs.prototype.cause=void 0;fs.prototype.fatal=void 0;fs.prototype.place=void 0;fs.prototype.ruleId=void 0;fs.prototype.source=void 0;const $0={}.hasOwnProperty,r6=new Map,s6=/[A-Z]/g,i6=new Set(["table","tbody","thead","tfoot","tr"]),o6=new Set(["td","th"]),LI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function a6(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=m6(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=h6(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"?M0:CB,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=OI(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function OI(e,t,n){if(t.type==="element")return l6(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return c6(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return d6(e,t,n);if(t.type==="mdxjsEsm")return u6(e,t);if(t.type==="root")return f6(e,t,n);if(t.type==="text")return p6(e,t)}function l6(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=M0,e.schema=s),e.ancestors.push(t);const o=DI(e,t.tagName,!1),a=g6(e,t);let l=F0(e,t);return i6.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!gB(u):!0})),$I(e,a,o,t),D0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function c6(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)}gp(e,t.position)}function u6(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gp(e,t.position)}function d6(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=M0,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:DI(e,t.name,!0),a=y6(e,t),l=F0(e,t);return $I(e,a,o,t),D0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function f6(e,t,n){const r={};return D0(r,F0(e,t)),e.create(t,e.Fragment,r,n)}function p6(e,t){return t.value}function $I(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function D0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function h6(e,t,n){return r;function r(s,o,a,l){const d=Array.isArray(a.children)?n:t;return l?d(o,a,l):d(o,a)}}function m6(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),u=O0(r);return t(s,o,a,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function g6(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&$0.call(t.properties,s)){const o=x6(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&o6.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function y6(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else gp(e,t.position);else{const s=r.name;let o;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,o=e.evaluater.evaluateExpression(l.expression)}else gp(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function F0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:r6;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const d=s.get(u)||0;a=u+"-"+d,s.set(u,d+1)}}const l=OI(e,o,a);l!==void 0&&n.push(l)}return n}function x6(e,t,n){const r=SB(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?dB(n):EB(n)),r.property==="style"){let s=typeof n=="object"?n:w6(e,String(n));return e.stylePropertyNameCase==="css"&&(s=b6(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?bB[r.property]||r.property:r.attribute,n]}}function w6(e,t){try{return t6(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new fs("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=LI+"#cannot-parse-style-attribute",s}}function DI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,a;for(;++o<s.length;){const l=QN(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=QN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return $0.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);gp(e)}function gp(e,t){const n=new fs("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=LI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function b6(e){const t={};let n;for(n in e)$0.call(e,n)&&(t[v6(n)]=e[n]);return t}function v6(e){let t=e.replace(s6,k6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function k6(e){return"-"+e.toLowerCase()}const Ox={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"]},S6={};function N6(e,t){const n=S6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return FI(e,r,s)}function FI(e,t,n){if(j6(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 cj(e.children,t,n)}return Array.isArray(e)?cj(e,t,n):""}function cj(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=FI(e[s],t,n);return r.join("")}function j6(e){return!!(e&&typeof e=="object")}const uj=document.createElement("i");function z0(e){const t="&"+e+";";uj.innerHTML=t;const n=uj.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ho(e,t,n,r){const s=e.length;let o=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);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function vi(e,t){return e.length>0?(Ho(e,e.length,0,t),e):t}const dj={}.hasOwnProperty;function C6(e){const t={};let n=-1;for(;++n<e.length;)E6(t,e[n]);return t}function E6(e,t){let n;for(n in t){const s=(dj.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){dj.call(s,a)||(s[a]=[]);const l=o[a];_6(s[a],Array.isArray(l)?l:l?[l]:[])}}}function _6(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ho(e,0,0,r)}function zI(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 zu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const To=_l(/[A-Za-z]/),ii=_l(/[\dA-Za-z]/),P6=_l(/[#-'*+\--9=?A-Z^-~]/);function Hb(e){return e!==null&&(e<32||e===127)}const Bb=_l(/\d/),A6=_l(/[\dA-Fa-f]/),I6=_l(/[!-/:-@[-`{-~]/);function Ct(e){return e!==null&&e<-2}function Vs(e){return e!==null&&(e<0||e===32)}function un(e){return e===-2||e===-1||e===32}const T6=_l(new RegExp("\\p{P}|\\p{S}","u")),R6=_l(/\s/);function _l(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function md(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&ii(e.charCodeAt(n+1))&&ii(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),s=1):a="�"}else a=String.fromCharCode(o);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 In(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return un(u)?(e.enter(n),l(u)):t(u)}function l(u){return un(u)&&o++<s?(e.consume(u),l):(e.exit(n),t(u))}}const M6={tokenize:L6};function L6(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"),In(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),o(l)}function o(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,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"),o):(e.consume(l),a)}}const O6={tokenize:$6},fj={tokenize:D6};function $6(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,u,d)(x)}return d(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&w();const N=t.events.length;let _=N,C;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){C=t.events[_][1].end;break}y(r);let T=N;for(;T<t.events.length;)t.events[T][1].end={...C},T++;return Ho(t.events,_+1,0,t.events.slice(N)),t.events.length=T,d(x)}return l(x)}function d(x){if(r===n.length){if(!s)return f(x);if(s.currentConstruct&&s.currentConstruct.concrete)return g(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fj,p,c)(x)}function p(x){return s&&w(),y(r),f(x)}function c(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(x)}function f(x){return t.containerState={},e.attempt(fj,h,g)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),f(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:o}),b(x)}function b(x){if(x===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return Ct(x)?(e.consume(x),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),b)}function k(x,N){const _=t.sliceStream(x);if(N&&_.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(_),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const T=t.events.length;let F=T,R,H;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(R){H=t.events[F][1].end;break}R=!0}for(y(r),C=T;C<t.events.length;)t.events[C][1].end={...H},C++;Ho(t.events,F+1,0,t.events.slice(T)),t.events.length=C}}function y(x){let N=n.length;for(;N-- >x;){const _=n[N];t.containerState=_[1],_[0].exit.call(t,e)}n.length=x}function w(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function D6(e,t,n){return In(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pj(e){if(e===null||Vs(e)||R6(e))return 1;if(T6(e))return 2}function H0(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Wb={name:"attention",resolveAll:F6,tokenize:z6};function F6(e,t){let n=-1,r,s,o,a,l,u,d,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;u=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 c={...e[r][1].end},f={...e[n][1].start};hj(c,-u),hj(f,u),a={type:u>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:u>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=vi(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=vi(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=vi(d,H0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=vi(d,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,d=vi(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Ho(e,r-1,n-r+3,d),n=r+d.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function z6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=pj(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===o)return e.consume(u),l;const d=e.exit("attentionSequence"),p=pj(u),c=!p||p===2&&s||n.includes(u),f=!s||s===2&&p||n.includes(r);return d._open=!!(o===42?c:c&&(s||!f)),d._close=!!(o===42?f:f&&(p||!c)),t(u)}}function hj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const H6={name:"autolink",tokenize:B6};function B6(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"),o}function o(h){return To(h)?(e.consume(h),a):h===64?n(h):d(h)}function a(h){return h===43||h===45||h===46||ii(h)?(r=1,l(h)):d(h)}function l(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||ii(h))&&r++<32?(e.consume(h),l):(r=0,d(h))}function u(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||Hb(h)?n(h):(e.consume(h),u)}function d(h){return h===64?(e.consume(h),p):P6(h)?(e.consume(h),d):n(h)}function p(h){return ii(h)?c(h):n(h)}function c(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):f(h)}function f(h){if((h===45||ii(h))&&r++<63){const g=h===45?f:c;return e.consume(h),g}return n(h)}}const jy={partial:!0,tokenize:W6};function W6(e,t,n){return r;function r(o){return un(o)?In(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Ct(o)?t(o):n(o)}}const HI={continuation:{tokenize:K6},exit:U6,name:"blockQuote",tokenize:V6};function V6(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"),o}return n(a)}function o(a){return un(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function K6(e,t,n){const r=this;return s;function s(a){return un(a)?In(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(HI,t,n)(a)}}function U6(e){e.exit("blockQuote")}const BI={name:"characterEscape",tokenize:q6};function q6(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return I6(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const WI={name:"characterReference",tokenize:Y6};function Y6(e,t,n){const r=this;let s=0,o,a;return l;function l(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),u}function u(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,a=ii,p(c))}function d(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=A6,p):(e.enter("characterReferenceValue"),o=7,a=Bb,p(c))}function p(c){if(c===59&&s){const f=e.exit("characterReferenceValue");return a===ii&&!z0(r.sliceSerialize(f))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&s++<o?(e.consume(c),p):n(c)}}const mj={partial:!0,tokenize:X6},gj={concrete:!0,name:"codeFenced",tokenize:G6};function G6(e,t,n){const r=this,s={partial:!0,tokenize:_};let o=0,a=0,l;return u;function u(C){return d(C)}function d(C){const T=r.events[r.events.length-1];return o=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(C)}function p(C){return C===l?(a++,e.consume(C),p):a<3?n(C):(e.exit("codeFencedFenceSequence"),un(C)?In(e,c,"whitespace")(C):c(C))}function c(C){return C===null||Ct(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(mj,b,N)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||Ct(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(C)):un(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),In(e,h,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),f)}function h(C){return C===null||Ct(C)?c(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(C))}function g(C){return C===null||Ct(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(C)):C===96&&C===l?n(C):(e.consume(C),g)}function b(C){return e.attempt(s,N,k)(C)}function k(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),y}function y(C){return o>0&&un(C)?In(e,w,"linePrefix",o+1)(C):w(C)}function w(C){return C===null||Ct(C)?e.check(mj,b,N)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||Ct(C)?(e.exit("codeFlowValue"),w(C)):(e.consume(C),x)}function N(C){return e.exit("codeFenced"),t(C)}function _(C,T,F){let R=0;return H;function H(M){return C.enter("lineEnding"),C.consume(M),C.exit("lineEnding"),D}function D(M){return C.enter("codeFencedFence"),un(M)?In(C,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):$(M)}function $(M){return M===l?(C.enter("codeFencedFenceSequence"),B(M)):F(M)}function B(M){return M===l?(R++,C.consume(M),B):R>=a?(C.exit("codeFencedFenceSequence"),un(M)?In(C,L,"whitespace")(M):L(M)):F(M)}function L(M){return M===null||Ct(M)?(C.exit("codeFencedFence"),T(M)):F(M)}}}function X6(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"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const $x={name:"codeIndented",tokenize:Q6},J6={partial:!0,tokenize:Z6};function Q6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),In(e,o,"linePrefix",5)(d)}function o(d){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):Ct(d)?e.attempt(J6,a,u)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||Ct(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function u(d){return e.exit("codeIndented"),t(d)}}function Z6(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):In(e,o,"linePrefix",5)(a)}function o(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 e8={name:"codeText",previous:n8,resolve:t8,tokenize:r8};function t8(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 n8(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function r8(e,t,n){let r=0,s,o;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),l(c)}function l(c){return c===96?(e.consume(c),r++,l):(e.exit("codeTextSequence"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),u):c===96?(o=e.enter("codeTextSequence"),s=0,p(c)):Ct(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(c))}function d(c){return c===null||c===32||c===96||Ct(c)?(e.exit("codeTextData"),u(c)):(e.consume(c),d)}function p(c){return c===96?(e.consume(c),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(o.type="codeTextData",d(c))}}class s8{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 o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&sf(this.left,r),o.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),sf(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),sf(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);sf(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);sf(this.left,n.reverse())}}}function sf(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 VI(e){const t={};let n=-1,r,s,o,a,l,u,d;const p=new s8(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"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,i8(p,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=p.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);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 Ho(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!d}function i8(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,u=[],d={};let p,c,f=-1,h=n,g=0,b=0;const k=[b];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(p=r.sliceStream(h),h.next||p.push(null),c&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++f<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(b=f+1,k.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):k.pop(),f=k.length;f--;){const y=l.slice(k[f],k[f+1]),w=o.pop();u.push([w,w+y.length-1]),e.splice(w,2,y)}for(u.reverse(),f=-1;++f<u.length;)d[g+u[f][0]]=g+u[f][1],g+=u[f][1]-u[f][0]-1;return d}const o8={resolve:l8,tokenize:c8},a8={partial:!0,tokenize:u8};function l8(e){return VI(e),e}function c8(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?o(l):Ct(l)?e.check(a8,a,o)(l):(e.consume(l),s)}function o(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 u8(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),In(e,o,"linePrefix")}function o(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 KI(e,t,n,r,s,o,a,l,u){const d=u||Number.POSITIVE_INFINITY;let p=0;return c;function c(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),f):y===null||y===32||y===41||Hb(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(y))}function f(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),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),f(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||Vs(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):p<d&&y===40?(e.consume(y),p++,b):y===41?(e.consume(y),p--,b):y===null||y===32||y===40||Hb(y)?n(y):(e.consume(y),y===92?k:b)}function k(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function UI(e,t,n,r,s,o){const a=this;let l=0,u;return d;function d(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(o),p}function p(h){return l>999||h===null||h===91||h===93&&!u||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),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"}),c(h))}function c(h){return h===null||h===91||h===93||Ct(h)||l++>999?(e.exit("chunkString"),p(h)):(e.consume(h),u||(u=!un(h)),h===92?f:c)}function f(h){return h===91||h===92||h===93?(e.consume(h),l++,c):c(h)}}function qI(e,t,n,r,s,o){let a;return l;function l(f){return f===34||f===39||f===40?(e.enter(r),e.enter(s),e.consume(f),e.exit(s),a=f===40?41:f,u):n(f)}function u(f){return f===a?(e.enter(s),e.consume(f),e.exit(s),e.exit(r),t):(e.enter(o),d(f))}function d(f){return f===a?(e.exit(o),u(a)):f===null?n(f):Ct(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),In(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(f))}function p(f){return f===a||f===null||Ct(f)?(e.exit("chunkString"),d(f)):(e.consume(f),f===92?c:p)}function c(f){return f===a||f===92?(e.consume(f),p):p(f)}}function Of(e,t){let n;return r;function r(s){return Ct(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):un(s)?In(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const d8={name:"definition",tokenize:p8},f8={partial:!0,tokenize:h8};function p8(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return UI.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=zu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return Vs(h)?Of(e,d)(h):d(h)}function d(h){return KI(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function p(h){return e.attempt(f8,c,c)(h)}function c(h){return un(h)?In(e,f,"whitespace")(h):f(h)}function f(h){return h===null||Ct(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function h8(e,t,n){return r;function r(l){return Vs(l)?Of(e,s)(l):n(l)}function s(l){return qI(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return un(l)?In(e,a,"whitespace")(l):a(l)}function a(l){return l===null||Ct(l)?t(l):n(l)}}const m8={name:"hardBreakEscape",tokenize:g8};function g8(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Ct(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const y8={name:"headingAtx",resolve:x8,tokenize:w8};function x8(e,t){let n=e.length-2,r=3,s,o;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},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Ho(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function w8(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||Vs(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||Ct(p)?(e.exit("atxHeading"),t(p)):un(p)?In(e,l,"whitespace")(p):(e.enter("atxHeadingText"),d(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),l(p))}function d(p){return p===null||p===35||Vs(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),d)}}const b8=["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"],yj=["pre","script","style","textarea"],v8={concrete:!0,name:"htmlFlow",resolveTo:N8,tokenize:j8},k8={partial:!0,tokenize:E8},S8={partial:!0,tokenize:C8};function N8(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 j8(e,t,n){const r=this;let s,o,a,l,u;return d;function d(K){return p(K)}function p(K){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(K),c}function c(K){return K===33?(e.consume(K),f):K===47?(e.consume(K),o=!0,b):K===63?(e.consume(K),s=3,r.interrupt?t:E):To(K)?(e.consume(K),a=String.fromCharCode(K),k):n(K)}function f(K){return K===45?(e.consume(K),s=2,h):K===91?(e.consume(K),s=5,l=0,g):To(K)?(e.consume(K),s=4,r.interrupt?t:E):n(K)}function h(K){return K===45?(e.consume(K),r.interrupt?t:E):n(K)}function g(K){const oe="CDATA[";return K===oe.charCodeAt(l++)?(e.consume(K),l===oe.length?r.interrupt?t:$:g):n(K)}function b(K){return To(K)?(e.consume(K),a=String.fromCharCode(K),k):n(K)}function k(K){if(K===null||K===47||K===62||Vs(K)){const oe=K===47,de=a.toLowerCase();return!oe&&!o&&yj.includes(de)?(s=1,r.interrupt?t(K):$(K)):b8.includes(a.toLowerCase())?(s=6,oe?(e.consume(K),y):r.interrupt?t(K):$(K)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(K):o?w(K):x(K))}return K===45||ii(K)?(e.consume(K),a+=String.fromCharCode(K),k):n(K)}function y(K){return K===62?(e.consume(K),r.interrupt?t:$):n(K)}function w(K){return un(K)?(e.consume(K),w):H(K)}function x(K){return K===47?(e.consume(K),H):K===58||K===95||To(K)?(e.consume(K),N):un(K)?(e.consume(K),x):H(K)}function N(K){return K===45||K===46||K===58||K===95||ii(K)?(e.consume(K),N):_(K)}function _(K){return K===61?(e.consume(K),C):un(K)?(e.consume(K),_):x(K)}function C(K){return K===null||K===60||K===61||K===62||K===96?n(K):K===34||K===39?(e.consume(K),u=K,T):un(K)?(e.consume(K),C):F(K)}function T(K){return K===u?(e.consume(K),u=null,R):K===null||Ct(K)?n(K):(e.consume(K),T)}function F(K){return K===null||K===34||K===39||K===47||K===60||K===61||K===62||K===96||Vs(K)?_(K):(e.consume(K),F)}function R(K){return K===47||K===62||un(K)?x(K):n(K)}function H(K){return K===62?(e.consume(K),D):n(K)}function D(K){return K===null||Ct(K)?$(K):un(K)?(e.consume(K),D):n(K)}function $(K){return K===45&&s===2?(e.consume(K),I):K===60&&s===1?(e.consume(K),z):K===62&&s===4?(e.consume(K),J):K===63&&s===3?(e.consume(K),E):K===93&&s===5?(e.consume(K),O):Ct(K)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(k8,Z,B)(K)):K===null||Ct(K)?(e.exit("htmlFlowData"),B(K)):(e.consume(K),$)}function B(K){return e.check(S8,L,Z)(K)}function L(K){return e.enter("lineEnding"),e.consume(K),e.exit("lineEnding"),M}function M(K){return K===null||Ct(K)?B(K):(e.enter("htmlFlowData"),$(K))}function I(K){return K===45?(e.consume(K),E):$(K)}function z(K){return K===47?(e.consume(K),a="",A):$(K)}function A(K){if(K===62){const oe=a.toLowerCase();return yj.includes(oe)?(e.consume(K),J):$(K)}return To(K)&&a.length<8?(e.consume(K),a+=String.fromCharCode(K),A):$(K)}function O(K){return K===93?(e.consume(K),E):$(K)}function E(K){return K===62?(e.consume(K),J):K===45&&s===2?(e.consume(K),E):$(K)}function J(K){return K===null||Ct(K)?(e.exit("htmlFlowData"),Z(K)):(e.consume(K),J)}function Z(K){return e.exit("htmlFlow"),t(K)}}function C8(e,t,n){const r=this;return s;function s(a){return Ct(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function E8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(jy,t,n)}}const _8={name:"htmlText",tokenize:P8};function P8(e,t,n){const r=this;let s,o,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),u}function u(E){return E===33?(e.consume(E),d):E===47?(e.consume(E),_):E===63?(e.consume(E),x):To(E)?(e.consume(E),F):n(E)}function d(E){return E===45?(e.consume(E),p):E===91?(e.consume(E),o=0,g):To(E)?(e.consume(E),w):n(E)}function p(E){return E===45?(e.consume(E),h):n(E)}function c(E){return E===null?n(E):E===45?(e.consume(E),f):Ct(E)?(a=c,z(E)):(e.consume(E),c)}function f(E){return E===45?(e.consume(E),h):c(E)}function h(E){return E===62?I(E):E===45?f(E):c(E)}function g(E){const J="CDATA[";return E===J.charCodeAt(o++)?(e.consume(E),o===J.length?b:g):n(E)}function b(E){return E===null?n(E):E===93?(e.consume(E),k):Ct(E)?(a=b,z(E)):(e.consume(E),b)}function k(E){return E===93?(e.consume(E),y):b(E)}function y(E){return E===62?I(E):E===93?(e.consume(E),y):b(E)}function w(E){return E===null||E===62?I(E):Ct(E)?(a=w,z(E)):(e.consume(E),w)}function x(E){return E===null?n(E):E===63?(e.consume(E),N):Ct(E)?(a=x,z(E)):(e.consume(E),x)}function N(E){return E===62?I(E):x(E)}function _(E){return To(E)?(e.consume(E),C):n(E)}function C(E){return E===45||ii(E)?(e.consume(E),C):T(E)}function T(E){return Ct(E)?(a=T,z(E)):un(E)?(e.consume(E),T):I(E)}function F(E){return E===45||ii(E)?(e.consume(E),F):E===47||E===62||Vs(E)?R(E):n(E)}function R(E){return E===47?(e.consume(E),I):E===58||E===95||To(E)?(e.consume(E),H):Ct(E)?(a=R,z(E)):un(E)?(e.consume(E),R):I(E)}function H(E){return E===45||E===46||E===58||E===95||ii(E)?(e.consume(E),H):D(E)}function D(E){return E===61?(e.consume(E),$):Ct(E)?(a=D,z(E)):un(E)?(e.consume(E),D):R(E)}function $(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,B):Ct(E)?(a=$,z(E)):un(E)?(e.consume(E),$):(e.consume(E),L)}function B(E){return E===s?(e.consume(E),s=void 0,M):E===null?n(E):Ct(E)?(a=B,z(E)):(e.consume(E),B)}function L(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Vs(E)?R(E):(e.consume(E),L)}function M(E){return E===47||E===62||Vs(E)?R(E):n(E)}function I(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function z(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),A}function A(E){return un(E)?In(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):O(E)}function O(E){return e.enter("htmlTextData"),a(E)}}const B0={name:"labelEnd",resolveAll:R8,resolveTo:M8,tokenize:L8},A8={tokenize:O8},I8={tokenize:$8},T8={tokenize:D8};function R8(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&&Ho(e,0,e.length,n),e}function M8(e,t){let n=e.length,r=0,s,o,a,l;for(;n--;)if(s=e[n][1],o){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&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",u,t],["enter",d,t]],l=vi(l,e.slice(o+1,o+r+3)),l=vi(l,[["enter",p,t]]),l=vi(l,H0(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=vi(l,[["exit",p,t],e[a-2],e[a-1],["exit",d,t]]),l=vi(l,e.slice(a+1)),l=vi(l,[["exit",u,t]]),Ho(e,o,e.length,l),e}function L8(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return l;function l(f){return o?o._inactive?c(f):(a=r.parser.defined.includes(zu(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),u):n(f)}function u(f){return f===40?e.attempt(A8,p,a?p:c)(f):f===91?e.attempt(I8,p,a?d:c)(f):a?p(f):c(f)}function d(f){return e.attempt(T8,p,c)(f)}function p(f){return t(f)}function c(f){return o._balanced=!0,n(f)}}function O8(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),s}function s(c){return Vs(c)?Of(e,o)(c):o(c)}function o(c){return c===41?p(c):KI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return Vs(c)?Of(e,u)(c):p(c)}function l(c){return n(c)}function u(c){return c===34||c===39||c===40?qI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):p(c)}function d(c){return Vs(c)?Of(e,p)(c):p(c)}function p(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function $8(e,t,n){const r=this;return s;function s(l){return UI.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(zu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function D8(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const F8={name:"labelStartImage",resolveAll:B0.resolveAll,tokenize:z8};function z8(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(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 H8={name:"labelStartLink",resolveAll:B0.resolveAll,tokenize:B8};function B8(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"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Dx={name:"lineEnding",tokenize:W8};function W8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),In(e,t,"linePrefix")}}const Am={name:"thematicBreak",tokenize:V8};function V8(e,t,n){let r=0,s;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Ct(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===s?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),un(d)?In(e,l,"whitespace")(d):l(d))}}const Ms={continuation:{tokenize:Y8},exit:X8,name:"list",tokenize:q8},K8={partial:!0,tokenize:J8},U8={partial:!0,tokenize:G8};function q8(e,t,n){const r=this,s=r.events[r.events.length-1];let o=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:Bb(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(Am,n,d)(h):d(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Bb(h)&&++a<10?(e.consume(h),u):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),d(h)):n(h)}function d(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(jy,r.interrupt?n:p,e.attempt(K8,f,c))}function p(h){return r.containerState.initialBlankLine=!0,o++,f(h)}function c(h){return un(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),f):n(h)}function f(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function Y8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(jy,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,In(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!un(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(U8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,In(e,e.attempt(Ms,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function G8(e,t,n){const r=this;return In(e,s,"listItemIndent",r.containerState.size+1);function s(o){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(o):n(o)}}function X8(e){e.exit(this.containerState.type)}function J8(e,t,n){const r=this;return In(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=r.events[r.events.length-1];return!un(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const xj={name:"setextUnderline",resolveTo:Q8,tokenize:Z8};function Q8(e,t){let n=e.length,r,s,o;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),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function Z8(e,t,n){const r=this;let s;return o;function o(d){let p=r.events.length,c;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){c=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),un(d)?In(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ct(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const eW={tokenize:tW};function tW(e){const t=this,n=e.attempt(jy,r,e.attempt(this.parser.constructs.flowInitial,s,In(e,e.attempt(this.parser.constructs.flow,s,e.attempt(o8,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const nW={resolveAll:GI()},rW=YI("string"),sW=YI("text");function YI(e){return{resolveAll:GI(e==="text"?iW:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,l);return a;function a(p){return d(p)?o(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return d(p)?(n.exit("data"),o(p)):(n.consume(p),u)}function d(p){if(p===null)return!0;const c=s[p];let f=-1;if(c)for(;++f<c.length;){const h=c[f];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function GI(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function iW(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 o=s.length,a=-1,l=0,u;for(;o--;){const d=s[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)u=!0,l++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const oW={42:Ms,43:Ms,45:Ms,48:Ms,49:Ms,50:Ms,51:Ms,52:Ms,53:Ms,54:Ms,55:Ms,56:Ms,57:Ms,62:HI},aW={91:d8},lW={[-2]:$x,[-1]:$x,32:$x},cW={35:y8,42:Am,45:[xj,Am],60:v8,61:xj,95:Am,96:gj,126:gj},uW={38:WI,92:BI},dW={[-5]:Dx,[-4]:Dx,[-3]:Dx,33:F8,38:WI,42:Wb,60:[H6,_8],91:H8,92:[m8,BI],93:B0,95:Wb,96:e8},fW={null:[Wb,nW]},pW={null:[42,95]},hW={null:[]},mW=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:pW,contentInitial:aW,disable:hW,document:oW,flow:cW,flowInitial:lW,insideSpan:fW,string:uW,text:dW},Symbol.toStringTag,{value:"Module"}));function gW(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={},o=[];let a=[],l=[];const u={attempt:T(_),check:T(C),consume:w,enter:x,exit:N,interrupt:T(C,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:f,sliceStream:h,write:c};let p=t.tokenize.call(d,u);return t.resolveAll&&o.push(t),d;function c(D){return a=vi(a,D),k(),a[a.length-1]!==null?[]:(F(t,0),d.events=H0(o,d.events,d),d.events)}function f(D,$){return xW(h(D),$)}function h(D){return yW(a,D)}function g(){const{_bufferIndex:D,_index:$,line:B,column:L,offset:M}=r;return{_bufferIndex:D,_index:$,line:B,column:L,offset:M}}function b(D){s[D.line]=D.column,H()}function k(){let D;for(;r._index<a.length;){const $=a[r._index];if(typeof $=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<$.length;)y($.charCodeAt(r._bufferIndex));else y($)}}function y(D){p=p(D)}function w(D){Ct(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,H()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=D}function x(D,$){const B=$||{};return B.type=D,B.start=g(),d.events.push(["enter",B,d]),l.push(B),B}function N(D){const $=l.pop();return $.end=g(),d.events.push(["exit",$,d]),$}function _(D,$){F(D,$.from)}function C(D,$){$.restore()}function T(D,$){return B;function B(L,M,I){let z,A,O,E;return Array.isArray(L)?Z(L):"tokenize"in L?Z([L]):J(L);function J(he){return we;function we(ue){const Ne=ue!==null&&he[ue],le=ue!==null&&he.null,ce=[...Array.isArray(Ne)?Ne:Ne?[Ne]:[],...Array.isArray(le)?le:le?[le]:[]];return Z(ce)(ue)}}function Z(he){return z=he,A=0,he.length===0?I:K(he[A])}function K(he){return we;function we(ue){return E=R(),O=he,he.partial||(d.currentConstruct=he),he.name&&d.parser.constructs.disable.null.includes(he.name)?de():he.tokenize.call($?Object.assign(Object.create(d),$):d,u,oe,de)(ue)}}function oe(he){return D(O,E),M}function de(he){return E.restore(),++A<z.length?K(z[A]):I}}}function F(D,$){D.resolveAll&&!o.includes(D)&&o.push(D),D.resolve&&Ho(d.events,$,d.events.length-$,D.resolve(d.events.slice($),d)),D.resolveTo&&(d.events=D.resolveTo(d.events,d))}function R(){const D=g(),$=d.previous,B=d.currentConstruct,L=d.events.length,M=Array.from(l);return{from:L,restore:I};function I(){r=D,d.previous=$,d.currentConstruct=B,d.events.length=L,l=M,H()}}function H(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function yW(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,o)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function xW(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){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(o)}s=o===-2,r.push(a)}return r.join("")}function wW(e){const r={constructs:C6([mW,...(e||{}).extensions||[]]),content:s(M6),defined:[],document:s(O6),flow:s(eW),lazy:{},string:s(rW),text:s(sW)};return r;function s(o){return a;function a(l){return gW(r,o,l)}}}function bW(e){for(;!VI(e););return e}const wj=/[\0\t\n\r]/g;function vW(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const u=[];let d,p,c,f,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),c=0,t="",n&&(o.charCodeAt(0)===65279&&c++,n=void 0);c<o.length;){if(wj.lastIndex=c,d=wj.exec(o),f=d&&d.index!==void 0?d.index:o.length,h=o.charCodeAt(f),!d){t=o.slice(c);break}if(h===10&&c===f&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<f&&(u.push(o.slice(c,f)),e+=f-c),h){case 0:{u.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,u.push(-2);e++<p;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=f+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const kW=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function SW(e){return e.replace(kW,NW)}function NW(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return zI(n.slice(o?2:1),o?16:10)}return z0(n)||e}const XI={}.hasOwnProperty;function jW(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),CW(n)(bW(wW(n).document().write(vW()(e,t,!0))))}function CW(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(xt),autolinkProtocol:R,autolinkEmail:R,atxHeading:o(et),blockQuote:o(le),characterEscape:R,characterReference:R,codeFenced:o(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ce,a),codeText:o(xe,a),codeTextData:R,data:R,codeFlowValue:R,definition:o(Se),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Ke),hardBreakEscape:o(We),hardBreakTrailing:o(We),htmlFlow:o(ut,a),htmlFlowData:R,htmlText:o(ut,a),htmlTextData:R,image:o(Ve),label:a,link:o(xt),listItem:o(Jn),listItemValue:f,listOrdered:o(bt,c),listUnordered:o(bt),paragraph:o(Ut),reference:K,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(et),strong:o(nn),thematicBreak:o(hn)},exit:{atxHeading:u(),atxHeadingSequence:_,autolink:u(),autolinkEmail:Ne,autolinkProtocol:ue,blockQuote:u(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:de,characterReferenceMarkerNumeric:de,characterReferenceValue:he,characterReference:we,codeFenced:u(k),codeFencedFence:b,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:H,codeIndented:u(y),codeText:u(M),codeTextData:H,data:H,definition:u(),definitionDestinationString:N,definitionLabelString:w,definitionTitleString:x,emphasis:u(),hardBreakEscape:u($),hardBreakTrailing:u($),htmlFlow:u(B),htmlFlowData:H,htmlText:u(L),htmlTextData:H,image:u(z),label:O,labelText:A,lineEnding:D,link:u(I),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:oe,resourceDestinationString:E,resourceTitleString:J,resource:Z,setextHeading:u(F),setextHeadingLineSequence:T,setextHeadingText:C,strong:u(),thematicBreak:u()}};JI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(fe){let je={type:"root",children:[]};const He={stack:[je],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:p,data:n},ot=[];let at=-1;for(;++at<fe.length;)if(fe[at][1].type==="listOrdered"||fe[at][1].type==="listUnordered")if(fe[at][0]==="enter")ot.push(at);else{const Tt=ot.pop();at=s(fe,Tt,at)}for(at=-1;++at<fe.length;){const Tt=t[fe[at][0]];XI.call(Tt,fe[at][1].type)&&Tt[fe[at][1].type].call(Object.assign({sliceSerialize:fe[at][2].sliceSerialize},He),fe[at][1])}if(He.tokenStack.length>0){const Tt=He.tokenStack[He.tokenStack.length-1];(Tt[1]||bj).call(He,void 0,Tt[0])}for(je.position={start:Ua(fe.length>0?fe[0][1].start:{line:1,column:1,offset:0}),end:Ua(fe.length>0?fe[fe.length-2][1].end:{line:1,column:1,offset:0})},at=-1;++at<t.transforms.length;)je=t.transforms[at](je)||je;return je}function s(fe,je,He){let ot=je-1,at=-1,Tt=!1,mt,dn,sn,Rn;for(;++ot<=He;){const on=fe[ot];switch(on[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{on[0]==="enter"?at++:at--,Rn=void 0;break}case"lineEndingBlank":{on[0]==="enter"&&(mt&&!Rn&&!at&&!sn&&(sn=ot),Rn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Rn=void 0}if(!at&&on[0]==="enter"&&on[1].type==="listItemPrefix"||at===-1&&on[0]==="exit"&&(on[1].type==="listUnordered"||on[1].type==="listOrdered")){if(mt){let Mn=ot;for(dn=void 0;Mn--;){const Ln=fe[Mn];if(Ln[1].type==="lineEnding"||Ln[1].type==="lineEndingBlank"){if(Ln[0]==="exit")continue;dn&&(fe[dn][1].type="lineEndingBlank",Tt=!0),Ln[1].type="lineEnding",dn=Mn}else if(!(Ln[1].type==="linePrefix"||Ln[1].type==="blockQuotePrefix"||Ln[1].type==="blockQuotePrefixWhitespace"||Ln[1].type==="blockQuoteMarker"||Ln[1].type==="listItemIndent"))break}sn&&(!dn||sn<dn)&&(mt._spread=!0),mt.end=Object.assign({},dn?fe[dn][1].start:on[1].end),fe.splice(dn||ot,0,["exit",mt,on[2]]),ot++,He++}if(on[1].type==="listItemPrefix"){const Mn={type:"listItem",_spread:!1,start:Object.assign({},on[1].start),end:void 0};mt=Mn,fe.splice(ot,0,["enter",Mn,on[2]]),ot++,He++,sn=void 0,Rn=!0}}}return fe[je][1]._spread=Tt,He}function o(fe,je){return He;function He(ot){l.call(this,fe(ot),ot),je&&je.call(this,ot)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(fe,je,He){this.stack[this.stack.length-1].children.push(fe),this.stack.push(fe),this.tokenStack.push([je,He||void 0]),fe.position={start:Ua(je.start),end:void 0}}function u(fe){return je;function je(He){fe&&fe.call(this,He),d.call(this,He)}}function d(fe,je){const He=this.stack.pop(),ot=this.tokenStack.pop();if(ot)ot[0].type!==fe.type&&(je?je.call(this,fe,ot[0]):(ot[1]||bj).call(this,fe,ot[0]));else throw new Error("Cannot close `"+fe.type+"` ("+Lf({start:fe.start,end:fe.end})+"): it’s not open");He.position.end=Ua(fe.end)}function p(){return N6(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function f(fe){if(this.data.expectingFirstListItemValue){const je=this.stack[this.stack.length-2];je.start=Number.parseInt(this.sliceSerialize(fe),10),this.data.expectingFirstListItemValue=void 0}}function h(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.lang=fe}function g(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.meta=fe}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.value=fe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.value=fe.replace(/(\r?\n|\r)$/g,"")}function w(fe){const je=this.resume(),He=this.stack[this.stack.length-1];He.label=je,He.identifier=zu(this.sliceSerialize(fe)).toLowerCase()}function x(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.title=fe}function N(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.url=fe}function _(fe){const je=this.stack[this.stack.length-1];if(!je.depth){const He=this.sliceSerialize(fe).length;je.depth=He}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function T(fe){const je=this.stack[this.stack.length-1];je.depth=this.sliceSerialize(fe).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function R(fe){const He=this.stack[this.stack.length-1].children;let ot=He[He.length-1];(!ot||ot.type!=="text")&&(ot=rn(),ot.position={start:Ua(fe.start),end:void 0},He.push(ot)),this.stack.push(ot)}function H(fe){const je=this.stack.pop();je.value+=this.sliceSerialize(fe),je.position.end=Ua(fe.end)}function D(fe){const je=this.stack[this.stack.length-1];if(this.data.atHardBreak){const He=je.children[je.children.length-1];He.position.end=Ua(fe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(je.type)&&(R.call(this,fe),H.call(this,fe))}function $(){this.data.atHardBreak=!0}function B(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.value=fe}function L(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.value=fe}function M(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.value=fe}function I(){const fe=this.stack[this.stack.length-1];if(this.data.inReference){const je=this.data.referenceType||"shortcut";fe.type+="Reference",fe.referenceType=je,delete fe.url,delete fe.title}else delete fe.identifier,delete fe.label;this.data.referenceType=void 0}function z(){const fe=this.stack[this.stack.length-1];if(this.data.inReference){const je=this.data.referenceType||"shortcut";fe.type+="Reference",fe.referenceType=je,delete fe.url,delete fe.title}else delete fe.identifier,delete fe.label;this.data.referenceType=void 0}function A(fe){const je=this.sliceSerialize(fe),He=this.stack[this.stack.length-2];He.label=SW(je),He.identifier=zu(je).toLowerCase()}function O(){const fe=this.stack[this.stack.length-1],je=this.resume(),He=this.stack[this.stack.length-1];if(this.data.inReference=!0,He.type==="link"){const ot=fe.children;He.children=ot}else He.alt=je}function E(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.url=fe}function J(){const fe=this.resume(),je=this.stack[this.stack.length-1];je.title=fe}function Z(){this.data.inReference=void 0}function K(){this.data.referenceType="collapsed"}function oe(fe){const je=this.resume(),He=this.stack[this.stack.length-1];He.label=je,He.identifier=zu(this.sliceSerialize(fe)).toLowerCase(),this.data.referenceType="full"}function de(fe){this.data.characterReferenceType=fe.type}function he(fe){const je=this.sliceSerialize(fe),He=this.data.characterReferenceType;let ot;He?(ot=zI(je,He==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ot=z0(je);const at=this.stack[this.stack.length-1];at.value+=ot}function we(fe){const je=this.stack.pop();je.position.end=Ua(fe.end)}function ue(fe){H.call(this,fe);const je=this.stack[this.stack.length-1];je.url=this.sliceSerialize(fe)}function Ne(fe){H.call(this,fe);const je=this.stack[this.stack.length-1];je.url="mailto:"+this.sliceSerialize(fe)}function le(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function xe(){return{type:"inlineCode",value:""}}function Se(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ke(){return{type:"emphasis",children:[]}}function et(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function ut(){return{type:"html",value:""}}function Ve(){return{type:"image",title:null,url:"",alt:null}}function xt(){return{type:"link",title:null,url:"",children:[]}}function bt(fe){return{type:"list",ordered:fe.type==="listOrdered",start:null,spread:fe._spread,children:[]}}function Jn(fe){return{type:"listItem",spread:fe._spread,checked:null,children:[]}}function Ut(){return{type:"paragraph",children:[]}}function nn(){return{type:"strong",children:[]}}function rn(){return{type:"text",value:""}}function hn(){return{type:"thematicBreak"}}}function Ua(e){return{line:e.line,column:e.column,offset:e.offset}}function JI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?JI(e,r):EW(e,r)}}function EW(e,t){let n;for(n in t)if(XI.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 bj(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Lf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Lf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Lf({start:t.start,end:t.end})+") is still open")}function _W(e){const t=this;t.parser=n;function n(r){return jW(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function PW(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 AW(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function IW(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 o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function TW(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RW(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function MW(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=md(r.toLowerCase()),o=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=o+1,l+=1,e.footnoteCounts.set(r,l);const u={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,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function LW(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 OW(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function QI(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),o=s[0];o&&o.type==="text"?o.value="["+o.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 $W(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return QI(e,t);const s={src:md(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function DW(e,t){const n={src:md(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 FW(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 zW(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return QI(e,t);const s={href:md(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function HW(e,t){const n={href:md(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 BW(e,t,n){const r=e.all(t),s=n?WW(n):ZI(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let c;p&&p.type==="element"&&p.tagName==="p"?c=p:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.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 u=r[r.length-1];u&&(s||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const d={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,d),e.applyData(t,d)}function WW(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=ZI(n[r])}return t}function ZI(e){const t=e.spread;return t??e.children.length>1}function VW(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 o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function KW(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function UW(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function qW(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function YW(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=O0(t.children[1]),u=RI(t.children[t.children.length-1]);l&&u&&(a.position={start:l,end:u}),s.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function GW(e,t,n){const r=n?n.children:void 0,o=(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 u=-1;const d=[];for(;++u<l;){const c=t.children[u],f={},h=a?a[u]:void 0;h&&(f.align=h);let g={type:"element",tagName:o,properties:f,children:[]};c&&(g.children=e.all(c),e.patch(c,g),g=e.applyData(c,g)),d.push(g)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,p),e.applyData(t,p)}function XW(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const vj=9,kj=32;function JW(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(Sj(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(Sj(t.slice(s),s>0,!1)),o.join("")}function Sj(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===vj||o===kj;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===vj||o===kj;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function QW(e,t){const n={type:"text",value:JW(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function ZW(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const e9={blockquote:PW,break:AW,code:IW,delete:TW,emphasis:RW,footnoteReference:MW,heading:LW,html:OW,imageReference:$W,image:DW,inlineCode:FW,linkReference:zW,link:HW,listItem:BW,list:VW,paragraph:KW,root:UW,strong:qW,table:YW,tableCell:XW,tableRow:GW,text:QW,thematicBreak:ZW,toml:qh,yaml:qh,definition:qh,footnoteDefinition:qh};function qh(){}const eT=-1,Cy=0,$f=1,vg=2,W0=3,V0=4,K0=5,U0=6,tT=7,nT=8,Nj=typeof self=="object"?self:globalThis,t9=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,a]=t[s];switch(o){case Cy:case eT:return n(a,s);case $f:{const l=n([],s);for(const u of a)l.push(r(u));return l}case vg:{const l=n({},s);for(const[u,d]of a)l[r(u)]=r(d);return l}case W0:return n(new Date(a),s);case V0:{const{source:l,flags:u}=a;return n(new RegExp(l,u),s)}case K0:{const l=n(new Map,s);for(const[u,d]of a)l.set(r(u),r(d));return l}case U0:{const l=n(new Set,s);for(const u of a)l.add(r(u));return l}case tT:{const{name:l,message:u}=a;return n(new Nj[l](u),s)}case nT: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 Nj[o](a),s)};return r},jj=e=>t9(new Map,e)(0),su="",{toString:n9}={},{keys:r9}=Object,of=e=>{const t=typeof e;if(t!=="object"||!e)return[Cy,t];const n=n9.call(e).slice(8,-1);switch(n){case"Array":return[$f,su];case"Object":return[vg,su];case"Date":return[W0,su];case"RegExp":return[V0,su];case"Map":return[K0,su];case"Set":return[U0,su];case"DataView":return[$f,n]}return n.includes("Array")?[$f,n]:n.includes("Error")?[tT,n]:[vg,n]},Yh=([e,t])=>e===Cy&&(t==="function"||t==="symbol"),s9=(e,t,n,r)=>{const s=(a,l)=>{const u=r.push(a)-1;return n.set(l,u),u},o=a=>{if(n.has(a))return n.get(a);let[l,u]=of(a);switch(l){case Cy:{let p=a;switch(u){case"bigint":l=nT,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);p=null;break;case"undefined":return s([eT],a)}return s([l,p],a)}case $f:{if(u){let f=a;return u==="DataView"?f=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(f=new Uint8Array(a)),s([u,[...f]],a)}const p=[],c=s([l,p],a);for(const f of a)p.push(o(f));return c}case vg:{if(u)switch(u){case"BigInt":return s([u,a.toString()],a);case"Boolean":case"Number":case"String":return s([u,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const p=[],c=s([l,p],a);for(const f of r9(a))(e||!Yh(of(a[f])))&&p.push([o(f),o(a[f])]);return c}case W0:return s([l,a.toISOString()],a);case V0:{const{source:p,flags:c}=a;return s([l,{source:p,flags:c}],a)}case K0:{const p=[],c=s([l,p],a);for(const[f,h]of a)(e||!(Yh(of(f))||Yh(of(h))))&&p.push([o(f),o(h)]);return c}case U0:{const p=[],c=s([l,p],a);for(const f of a)(e||!Yh(of(f)))&&p.push(o(f));return c}}const{message:d}=a;return s([l,{name:u,message:d}],a)};return o},Cj=(e,{json:t,lossy:n}={})=>{const r=[];return s9(!(t||n),!!t,new Map,r)(e),r},kg=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?jj(Cj(e,t)):structuredClone(e):(e,t)=>jj(Cj(e,t));function i9(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 o9(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function a9(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||i9,r=e.options.footnoteBackLabel||o9,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const p=e.all(d),c=String(d.identifier).toUpperCase(),f=md(c.toLowerCase());let h=0;const g=[],b=e.footnoteCounts.get(c);for(;b!==void 0&&++h<=b;){g.length>0&&g.push({type:"text",value:" "});let w=typeof n=="string"?n:n(u,h);typeof w=="string"&&(w={type:"text",value:w}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,h),className:["data-footnote-backref"]},children:Array.isArray(w)?w:[w]})}const k=p[p.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const w=k.children[k.children.length-1];w&&w.type==="text"?w.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else p.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(p,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...kg(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 rT=function(e){if(e==null)return d9;if(typeof e=="function")return Ey(e);if(typeof e=="object")return Array.isArray(e)?l9(e):c9(e);if(typeof e=="string")return u9(e);throw new Error("Expected function, string, or object as test")};function l9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=rT(e[n]);return Ey(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function c9(e){const t=e;return Ey(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function u9(e){return Ey(t);function t(n){return n&&n.type===e}}function Ey(e){return t;function t(n,r,s){return!!(f9(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function d9(){return!0}function f9(e){return e!==null&&typeof e=="object"&&"type"in e}const sT=[],p9=!0,Ej=!1,h9="skip";function m9(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=rT(s),a=r?-1:1;l(e,void 0,[])();function l(u,d,p){const c=u&&typeof u=="object"?u:{};if(typeof c.type=="string"){const h=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(u.type+(h?"<"+h+">":""))+")"})}return f;function f(){let h=sT,g,b,k;if((!t||o(u,d,p[p.length-1]||void 0))&&(h=g9(n(u,p)),h[0]===Ej))return h;if("children"in u&&u.children){const y=u;if(y.children&&h[0]!==h9)for(b=(r?y.children.length:-1)+a,k=p.concat(y);b>-1&&b<y.children.length;){const w=y.children[b];if(g=l(w,b,k)(),g[0]===Ej)return g;b=typeof g[1]=="number"?g[1]:b+a}}return h}}}function g9(e){return Array.isArray(e)?e:typeof e=="number"?[p9,e]:e==null?sT:[e]}function iT(e,t,n,r){let s,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,s=n):(o=t,a=n,s=r),m9(e,o,l,s);function l(u,d){const p=d[d.length-1],c=p?p.children.indexOf(u):void 0;return a(u,c,p)}}const Vb={}.hasOwnProperty,y9={};function x9(e,t){const n=t||y9,r=new Map,s=new Map,o=new Map,a={...e9,...n.handlers},l={all:d,applyData:b9,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:w9,wrap:k9};return iT(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const c=p.type==="definition"?r:s,f=String(p.identifier).toUpperCase();c.has(f)||c.set(f,p)}}),l;function u(p,c){const f=p.type,h=l.handlers[f];if(Vb.call(l.handlers,f)&&h)return h(l,p,c);if(l.options.passThrough&&l.options.passThrough.includes(f)){if("children"in p){const{children:b,...k}=p,y=kg(k);return y.children=l.all(p),y}return kg(p)}return(l.options.unknownHandler||v9)(l,p,c)}function d(p){const c=[];if("children"in p){const f=p.children;let h=-1;for(;++h<f.length;){const g=l.one(f[h],p);if(g){if(h&&f[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=_j(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=_j(b.value))}Array.isArray(g)?c.push(...g):c.push(g)}}}return c}}function w9(e,t){e.position&&(t.position=n6(e))}function b9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=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"&&o&&Object.assign(n.properties,kg(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function v9(e,t){const n=t.data||{},r="value"in t&&!(Vb.call(n,"hProperties")||Vb.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 k9(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 _j(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Pj(e,t){const n=x9(e,t),r=n.one(e,void 0),s=a9(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
79
- `},s),o}function S9(e,t){return e&&"run"in e?async function(n,r){const s=Pj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return Pj(n,{file:r,...e||t})}}function Aj(e){if(e)throw e}var Im=Object.prototype.hasOwnProperty,oT=Object.prototype.toString,Ij=Object.defineProperty,Tj=Object.getOwnPropertyDescriptor,Rj=function(t){return typeof Array.isArray=="function"?Array.isArray(t):oT.call(t)==="[object Array]"},Mj=function(t){if(!t||oT.call(t)!=="[object Object]")return!1;var n=Im.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Im.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Im.call(t,s)},Lj=function(t,n){Ij&&n.name==="__proto__"?Ij(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},Oj=function(t,n){if(n==="__proto__")if(Im.call(t,n)){if(Tj)return Tj(t,n).value}else return;return t[n]},N9=function e(){var t,n,r,s,o,a,l=arguments[0],u=1,d=arguments.length,p=!1;for(typeof l=="boolean"&&(p=l,l=arguments[1]||{},u=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});u<d;++u)if(t=arguments[u],t!=null)for(n in t)r=Oj(l,n),s=Oj(t,n),l!==s&&(p&&s&&(Mj(s)||(o=Rj(s)))?(o?(o=!1,a=r&&Rj(r)?r:[]):a=r&&Mj(r)?r:{},Lj(l,{name:n,newValue:e(p,a,s)})):typeof s<"u"&&Lj(l,{name:n,newValue:s}));return l};const Fx=Sl(N9);function Kb(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 j9(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(u,...d){const p=e[++o];let c=-1;if(u){a(u);return}for(;++c<s.length;)(d[c]===null||d[c]===void 0)&&(d[c]=s[c]);s=d,p?C9(p,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function C9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let u;l&&a.push(s);try{u=e.apply(this,a)}catch(d){const p=d;if(l&&n)throw p;return s(p)}l||(u&&u.then&&typeof u.then=="function"?u.then(o,s):u instanceof Error?s(u):o(u))}function s(a,...l){n||(n=!0,t(a,...l))}function o(a){s(null,a)}}const Eo={basename:E9,dirname:_9,extname:P9,join:A9,sep:"/"};function E9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Hp(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!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(o){n=s+1;break}}else a<0&&(o=!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 _9(e){if(Hp(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 P9(e){Hp(e);let t=e.length,n=-1,r=0,s=-1,o=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:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function A9(...e){let t=-1,n;for(;++t<e.length;)Hp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":I9(n)}function I9(e){Hp(e);const t=e.codePointAt(0)===47;let n=T9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function T9(e,t){let n="",r=0,s=-1,o=0,a=-1,l,u;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||o===1))if(s!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),s=a,o=0;continue}}else if(n.length>0){n="",r=0,s=a,o=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,o=0}else l===46&&o>-1?o++:o=-1}return n}function Hp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const R9={cwd:M9};function M9(){return"/"}function Ub(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function L9(e){if(typeof e=="string")e=new URL(e);else if(!Ub(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 O9(e)}function O9(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 zx=["history","path","basename","stem","extname","dirname"];class aT{constructor(t){let n;t?Ub(t)?n={path:t}:typeof t=="string"||$9(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":R9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<zx.length;){const o=zx[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)zx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Eo.basename(this.path):void 0}set basename(t){Bx(t,"basename"),Hx(t,"basename"),this.path=Eo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Eo.dirname(this.path):void 0}set dirname(t){$j(this.basename,"dirname"),this.path=Eo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Eo.extname(this.path):void 0}set extname(t){if(Hx(t,"extname"),$j(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=Eo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ub(t)&&(t=L9(t)),Bx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Eo.basename(this.path,this.extname):void 0}set stem(t){Bx(t,"stem"),Hx(t,"stem"),this.path=Eo.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 fs(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 Hx(e,t){if(e&&e.includes(Eo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Eo.sep+"`")}function Bx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function $j(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function $9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const D9=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},F9={}.hasOwnProperty;class q0 extends D9{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=j9()}copy(){const t=new q0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Fx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Kx("data",this.frozen),this.namespace[t]=n,this):F9.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Kx("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=Gh(t),r=this.parser||this.Parser;return Wx("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Wx("process",this.parser||this.Parser),Vx("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Gh(t),u=r.parse(l);r.run(u,l,function(p,c,f){if(p||!c||!f)return d(p);const h=c,g=r.stringify(h,f);B9(g)?f.value=g:f.result=g,d(p,f)});function d(p,c){p||!c?a(p):o?o(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),Wx("processSync",this.parser||this.Parser),Vx("processSync",this.compiler||this.Compiler),this.process(t,s),Fj("processSync","process",n),r;function s(o,a){n=!0,Aj(o),r=a}}run(t,n,r){Dj(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const u=Gh(n);s.run(t,u,d);function d(p,c,f){const h=c||t;p?l(p):a?a(h):r(void 0,h,f)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),Fj("runSync","run",r),s;function o(a,l){Aj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Gh(n),s=this.compiler||this.Compiler;return Vx("stringify",s),Dj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Kx("use",this.frozen),t!=null)if(typeof t=="function")u(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 o(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[p,...c]=d;u(p,c)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(s.settings=Fx(!0,s.settings,d.settings))}function l(d){let p=-1;if(d!=null)if(Array.isArray(d))for(;++p<d.length;){const c=d[p];o(c)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,p){let c=-1,f=-1;for(;++c<r.length;)if(r[c][0]===d){f=c;break}if(f===-1)r.push([d,...p]);else if(p.length>0){let[h,...g]=p;const b=r[f][1];Kb(b)&&Kb(h)&&(h=Fx(!0,b,h)),r[f]=[d,h,...g]}}}}const z9=new q0().freeze();function Wx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Vx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Kx(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 Dj(e){if(!Kb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Fj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Gh(e){return H9(e)?e:new aT(e)}function H9(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function B9(e){return typeof e=="string"||W9(e)}function W9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const V9="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",zj=[],Hj={allowDangerousHtml:!0},K9=/^(https?|ircs?|mailto|xmpp)$/i,U9=[{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 Bp(e){const t=q9(e),n=Y9(e);return G9(t.runSync(t.parse(n),n),e)}function q9(e){const t=e.rehypePlugins||zj,n=e.remarkPlugins||zj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Hj}:Hj;return z9().use(_W).use(n).use(S9,r).use(t)}function Y9(e){const t=e.children||"",n=new aT;return typeof t=="string"&&(n.value=t),n}function G9(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||X9;for(const p of U9)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+V9+p.id,void 0);return iT(e,d),a6(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function d(p,c,f){if(p.type==="raw"&&f&&typeof c=="number")return a?f.children.splice(c,1):f.children[c]={type:"text",value:p.value},c;if(p.type==="element"){let h;for(h in Ox)if(Object.hasOwn(Ox,h)&&Object.hasOwn(p.properties,h)){const g=p.properties[h],b=Ox[h];(b===null||b.includes(p.tagName))&&(p.properties[h]=u(String(g||""),h,p))}}if(p.type==="element"){let h=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!h&&r&&typeof c=="number"&&(h=!r(p,c,f)),h&&f&&typeof c=="number")return l&&p.children?f.children.splice(c,1,...p.children):f.children.splice(c,1),c}}}function X9(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||K9.test(e.slice(0,t))?e:""}function J9(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Sg(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Sg(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Sg(t[r])}`).join(",")}}`}function Bj(e){return Sg({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function yp(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function Wj(e){return Sg({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function Vj(e,t){return!J9(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function Kj(e,t=!1){const n=new Map;for(const r of e){const s=yp(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function Q9(e,t,n,r){const s=new Map(e.map(w=>[w.id,w])),o=new Set(n.map(w=>w.id)),a=new Set,l=[],u=[],d=n.map(w=>{const x=s.get(w.id);return x?Bj(x)===Bj(w)?(a.add(w.id),x):(u.push(w.id),Vj(w,x)):(l.push(w.id),w)}),p=Kj(t),c=Kj(r,!0),f=new Set,h=[],g=[],b=r.map(w=>{const x=yp(w),N=p.get(x);return N?Wj(N)===Wj(w)?(f.add(x),N):(g.push(x),Vj(w,N)):(h.push(x),w)}),k=e.filter(w=>!o.has(w.id)).map(w=>w.id),y=t.map(w=>yp(w)).filter(w=>!c.has(w));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:u,removedNodeIds:k,addedEdgeKeys:h,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:h.length,edgeRemoved:y.length,edgeReused:f.size,nextEdgeCount:c.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function lT(e){return typeof e>"u"||e===null}function Z9(e){return typeof e=="object"&&e!==null}function eV(e){return Array.isArray(e)?e:lT(e)?[]:[e]}function tV(e,t){var n,r,s,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n<r;n+=1)s=o[n],e[s]=t[s];return e}function nV(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function rV(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var sV=lT,iV=Z9,oV=eV,aV=nV,lV=rV,cV=tV,Cr={isNothing:sV,isObject:iV,toArray:oV,repeat:aV,isNegativeZero:lV,extend:cV};function cT(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
80
-
81
- `+e.mark.snippet),r+" "+n):r}function xp(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=cT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}xp.prototype=Object.create(Error.prototype);xp.prototype.constructor=xp;xp.prototype.toString=function(t){return this.name+": "+cT(this,t)};var vs=xp;function Ux(e,t,n,r,s){var o="",a="",l=Math.floor(s/2)-1;return r-t>l&&(o=" ... ",t=r-l+o.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+o.length}}function qx(e,t){return Cr.repeat(" ",t-e.length)+e}function uV(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],o,a=-1;o=n.exec(e.buffer);)s.push(o.index),r.push(o.index+o[0].length),e.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",u,d,p=Math.min(e.line+t.linesAfter,s.length).toString().length,c=t.maxLength-(t.indent+p+3);for(u=1;u<=t.linesBefore&&!(a-u<0);u++)d=Ux(e.buffer,r[a-u],s[a-u],e.position-(r[a]-r[a-u]),c),l=Cr.repeat(" ",t.indent)+qx((e.line-u+1).toString(),p)+" | "+d.str+`
82
- `+l;for(d=Ux(e.buffer,r[a],s[a],e.position,c),l+=Cr.repeat(" ",t.indent)+qx((e.line+1).toString(),p)+" | "+d.str+`
83
- `,l+=Cr.repeat("-",t.indent+p+3+d.pos)+`^
84
- `,u=1;u<=t.linesAfter&&!(a+u>=s.length);u++)d=Ux(e.buffer,r[a+u],s[a+u],e.position-(r[a]-r[a+u]),c),l+=Cr.repeat(" ",t.indent)+qx((e.line+u+1).toString(),p)+" | "+d.str+`
85
- `;return l.replace(/\n$/,"")}var dV=uV,fV=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],pV=["scalar","sequence","mapping"];function hV(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function mV(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(fV.indexOf(n)===-1)throw new vs('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=hV(t.styleAliases||null),pV.indexOf(this.kind)===-1)throw new vs('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Jr=mV;function Uj(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(s=a)}),n[s]=r}),n}function gV(){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 qb(e){return this.extend(e)}qb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Jr)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 vs("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Jr))throw new vs("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new vs("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new vs("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof Jr))throw new vs("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(qb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=Uj(s,"implicit"),s.compiledExplicit=Uj(s,"explicit"),s.compiledTypeMap=gV(s.compiledImplicit,s.compiledExplicit),s};var uT=qb,dT=new Jr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),fT=new Jr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),pT=new Jr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),hT=new uT({explicit:[dT,fT,pT]});function yV(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function xV(){return null}function wV(e){return e===null}var mT=new Jr("tag:yaml.org,2002:null",{kind:"scalar",resolve:yV,construct:xV,predicate:wV,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function bV(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 vV(e){return e==="true"||e==="True"||e==="TRUE"}function kV(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var gT=new Jr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:bV,construct:vV,predicate:kV,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 SV(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function NV(e){return 48<=e&&e<=55}function jV(e){return 48<=e&&e<=57}function CV(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(!SV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!NV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!jV(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function EV(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 _V(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Cr.isNegativeZero(e)}var yT=new Jr("tag:yaml.org,2002:int",{kind:"scalar",resolve:CV,construct:EV,predicate:_V,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"]}}),PV=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function AV(e){return!(e===null||!PV.test(e)||e[e.length-1]==="_")}function IV(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 TV=/^[-+]?[0-9]+e/;function RV(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(Cr.isNegativeZero(e))return"-0.0";return n=e.toString(10),TV.test(n)?n.replace("e",".e"):n}function MV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Cr.isNegativeZero(e))}var xT=new Jr("tag:yaml.org,2002:float",{kind:"scalar",resolve:AV,construct:IV,predicate:MV,represent:RV,defaultStyle:"lowercase"}),wT=hT.extend({implicit:[mT,gT,yT,xT]}),bT=wT,vT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),kT=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 LV(e){return e===null?!1:vT.exec(e)!==null||kT.exec(e)!==null}function OV(e){var t,n,r,s,o,a,l,u=0,d=null,p,c,f;if(t=vT.exec(e),t===null&&(t=kT.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(o=+t[4],a=+t[5],l=+t[6],t[7]){for(u=t[7].slice(0,3);u.length<3;)u+="0";u=+u}return t[9]&&(p=+t[10],c=+(t[11]||0),d=(p*60+c)*6e4,t[9]==="-"&&(d=-d)),f=new Date(Date.UTC(n,r,s,o,a,l,u)),d&&f.setTime(f.getTime()-d),f}function $V(e){return e.toISOString()}var ST=new Jr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:LV,construct:OV,instanceOf:Date,represent:$V});function DV(e){return e==="<<"||e===null}var NT=new Jr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:DV}),Y0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
- \r`;function FV(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=Y0;for(n=0;n<s;n++)if(t=o.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function zV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=Y0,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|o.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 HV(e){var t="",n=0,r,s,o=e.length,a=Y0;for(r=0;r<o;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=o%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 BV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var jT=new Jr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:FV,construct:zV,predicate:BV,represent:HV}),WV=Object.prototype.hasOwnProperty,VV=Object.prototype.toString;function KV(e){if(e===null)return!0;var t=[],n,r,s,o,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,VV.call(s)!=="[object Object]")return!1;for(o in s)if(WV.call(s,o))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function UV(e){return e!==null?e:[]}var CT=new Jr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:KV,construct:UV}),qV=Object.prototype.toString;function YV(e){if(e===null)return!0;var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],qV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function GV(e){if(e===null)return[];var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),o[t]=[s[0],r[s[0]]];return o}var ET=new Jr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:YV,construct:GV}),XV=Object.prototype.hasOwnProperty;function JV(e){if(e===null)return!0;var t,n=e;for(t in n)if(XV.call(n,t)&&n[t]!==null)return!1;return!0}function QV(e){return e!==null?e:{}}var _T=new Jr("tag:yaml.org,2002:set",{kind:"mapping",resolve:JV,construct:QV}),G0=bT.extend({implicit:[ST,NT],explicit:[jT,CT,ET,_T]}),xl=Object.prototype.hasOwnProperty,Ng=1,PT=2,AT=3,jg=4,Yx=1,ZV=2,qj=3,eK=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,tK=/[\x85\u2028\u2029]/,nK=/[,\[\]\{\}]/,IT=/^(?:!|!!|![a-z\-]+!)$/i,TT=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Yj(e){return Object.prototype.toString.call(e)}function $o(e){return e===10||e===13}function fc(e){return e===9||e===32}function Ds(e){return e===9||e===32||e===10||e===13}function Eu(e){return e===44||e===91||e===93||e===123||e===125}function rK(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function sK(e){return e===120?2:e===117?4:e===85?8:0}function iK(e){return 48<=e&&e<=57?e-48:-1}function Gj(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
87
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function oK(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function RT(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var MT=new Array(256),LT=new Array(256);for(var iu=0;iu<256;iu++)MT[iu]=Gj(iu)?1:0,LT[iu]=Gj(iu);function aK(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||G0,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function OT(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=dV(n),new vs(t,n)}function ct(e,t){throw OT(e,t)}function Cg(e,t){e.onWarning&&e.onWarning.call(null,OT(e,t))}var Xj={YAML:function(t,n,r){var s,o,a;t.version!==null&&ct(t,"duplication of %YAML directive"),r.length!==1&&ct(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&ct(t,"ill-formed argument of the YAML directive"),o=parseInt(s[1],10),a=parseInt(s[2],10),o!==1&&ct(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&Cg(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,o;r.length!==2&&ct(t,"TAG directive accepts exactly two arguments"),s=r[0],o=r[1],IT.test(s)||ct(t,"ill-formed tag handle (first argument) of the TAG directive"),xl.call(t.tagMap,s)&&ct(t,'there is a previously declared suffix for "'+s+'" tag handle'),TT.test(o)||ct(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{ct(t,"tag prefix is malformed: "+o)}t.tagMap[s]=o}};function pl(e,t,n,r){var s,o,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,o=l.length;s<o;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||ct(e,"expected valid JSON character");else eK.test(l)&&ct(e,"the stream contains non-printable characters");e.result+=l}}function Jj(e,t,n,r){var s,o,a,l;for(Cr.isObject(n)||ct(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)o=s[a],xl.call(t,o)||(RT(t,o,n[o]),r[o]=!0)}function _u(e,t,n,r,s,o,a,l,u){var d,p;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,p=s.length;d<p;d+=1)Array.isArray(s[d])&&ct(e,"nested arrays are not supported inside keys"),typeof s=="object"&&Yj(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&Yj(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(d=0,p=o.length;d<p;d+=1)Jj(e,t,o[d],n);else Jj(e,t,o,n);else!e.json&&!xl.call(n,s)&&xl.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=u||e.position,ct(e,"duplicated mapping key")),RT(t,s,o),delete n[s];return t}function X0(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):ct(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function br(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;fc(s);)s===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),s=e.input.charCodeAt(++e.position);if(t&&s===35)do s=e.input.charCodeAt(++e.position);while(s!==10&&s!==13&&s!==0);if($o(s))for(X0(e),s=e.input.charCodeAt(e.position),r++,e.lineIndent=0;s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&Cg(e,"deficient indentation"),r}function _y(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||Ds(n)))}function J0(e,t){t===1?e.result+=" ":t>1&&(e.result+=Cr.repeat(`
88
- `,t-1))}function lK(e,t,n){var r,s,o,a,l,u,d,p,c=e.kind,f=e.result,h;if(h=e.input.charCodeAt(e.position),Ds(h)||Eu(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(s=e.input.charCodeAt(e.position+1),Ds(s)||n&&Eu(s)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,l=!1;h!==0;){if(h===58){if(s=e.input.charCodeAt(e.position+1),Ds(s)||n&&Eu(s))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),Ds(r))break}else{if(e.position===e.lineStart&&_y(e)||n&&Eu(h))break;if($o(h))if(u=e.line,d=e.lineStart,p=e.lineIndent,br(e,!1,-1),e.lineIndent>=t){l=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=u,e.lineStart=d,e.lineIndent=p;break}}l&&(pl(e,o,a,!1),J0(e,e.line-u),o=a=e.position,l=!1),fc(h)||(a=e.position+1),h=e.input.charCodeAt(++e.position)}return pl(e,o,a,!1),e.result?!0:(e.kind=c,e.result=f,!1)}function cK(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(pl(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,s=e.position;else return!0;else $o(n)?(pl(e,r,s,!0),J0(e,br(e,!1,t)),r=s=e.position):e.position===e.lineStart&&_y(e)?ct(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);ct(e,"unexpected end of the stream within a single quoted scalar")}function uK(e,t){var n,r,s,o,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return pl(e,n,e.position,!0),e.position++,!0;if(l===92){if(pl(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),$o(l))br(e,!1,t);else if(l<256&&MT[l])e.result+=LT[l],e.position++;else if((a=sK(l))>0){for(s=a,o=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=rK(l))>=0?o=(o<<4)+a:ct(e,"expected hexadecimal character");e.result+=oK(o),e.position++}else ct(e,"unknown escape sequence");n=r=e.position}else $o(l)?(pl(e,n,r,!0),J0(e,br(e,!1,t)),n=r=e.position):e.position===e.lineStart&&_y(e)?ct(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}ct(e,"unexpected end of the stream within a double quoted scalar")}function dK(e,t){var n=!0,r,s,o,a=e.tag,l,u=e.anchor,d,p,c,f,h,g=Object.create(null),b,k,y,w;if(w=e.input.charCodeAt(e.position),w===91)p=93,h=!1,l=[];else if(w===123)p=125,h=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(br(e,!0,t),w=e.input.charCodeAt(e.position),w===p)return e.position++,e.tag=a,e.anchor=u,e.kind=h?"mapping":"sequence",e.result=l,!0;n?w===44&&ct(e,"expected the node content, but found ','"):ct(e,"missed comma between flow collection entries"),k=b=y=null,c=f=!1,w===63&&(d=e.input.charCodeAt(e.position+1),Ds(d)&&(c=f=!0,e.position++,br(e,!0,t))),r=e.line,s=e.lineStart,o=e.position,id(e,t,Ng,!1,!0),k=e.tag,b=e.result,br(e,!0,t),w=e.input.charCodeAt(e.position),(f||e.line===r)&&w===58&&(c=!0,w=e.input.charCodeAt(++e.position),br(e,!0,t),id(e,t,Ng,!1,!0),y=e.result),h?_u(e,l,g,k,b,y,r,s,o):c?l.push(_u(e,null,g,k,b,y,r,s,o)):l.push(b),br(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(n=!0,w=e.input.charCodeAt(++e.position)):n=!1}ct(e,"unexpected end of the stream within a flow collection")}function fK(e,t){var n,r,s=Yx,o=!1,a=!1,l=t,u=0,d=!1,p,c;if(c=e.input.charCodeAt(e.position),c===124)r=!1;else if(c===62)r=!0;else return!1;for(e.kind="scalar",e.result="";c!==0;)if(c=e.input.charCodeAt(++e.position),c===43||c===45)Yx===s?s=c===43?qj:ZV:ct(e,"repeat of a chomping mode identifier");else if((p=iK(c))>=0)p===0?ct(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?ct(e,"repeat of an indentation width identifier"):(l=t+p-1,a=!0);else break;if(fc(c)){do c=e.input.charCodeAt(++e.position);while(fc(c));if(c===35)do c=e.input.charCodeAt(++e.position);while(!$o(c)&&c!==0)}for(;c!==0;){for(X0(e),e.lineIndent=0,c=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&c===32;)e.lineIndent++,c=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),$o(c)){u++;continue}if(e.lineIndent<l){s===qj?e.result+=Cr.repeat(`
89
- `,o?1+u:u):s===Yx&&o&&(e.result+=`
90
- `);break}for(r?fc(c)?(d=!0,e.result+=Cr.repeat(`
91
- `,o?1+u:u)):d?(d=!1,e.result+=Cr.repeat(`
92
- `,u+1)):u===0?o&&(e.result+=" "):e.result+=Cr.repeat(`
93
- `,u):e.result+=Cr.repeat(`
94
- `,o?1+u:u),o=!0,a=!0,u=0,n=e.position;!$o(c)&&c!==0;)c=e.input.charCodeAt(++e.position);pl(e,n,e.position,!1)}return!0}function Qj(e,t){var n,r=e.tag,s=e.anchor,o=[],a,l=!1,u;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),u=e.input.charCodeAt(e.position);u!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ct(e,"tab characters must not be used in indentation")),!(u!==45||(a=e.input.charCodeAt(e.position+1),!Ds(a))));){if(l=!0,e.position++,br(e,!0,-1)&&e.lineIndent<=t){o.push(null),u=e.input.charCodeAt(e.position);continue}if(n=e.line,id(e,t,AT,!1,!0),o.push(e.result),br(e,!0,-1),u=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&u!==0)ct(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=o,!0):!1}function pK(e,t,n){var r,s,o,a,l,u,d=e.tag,p=e.anchor,c={},f=Object.create(null),h=null,g=null,b=null,k=!1,y=!1,w;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),w=e.input.charCodeAt(e.position);w!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ct(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),o=e.line,(w===63||w===58)&&Ds(r))w===63?(k&&(_u(e,c,f,h,g,null,a,l,u),h=g=b=null),y=!0,k=!0,s=!0):k?(k=!1,s=!0):ct(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,w=r;else{if(a=e.line,l=e.lineStart,u=e.position,!id(e,n,PT,!1,!0))break;if(e.line===o){for(w=e.input.charCodeAt(e.position);fc(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),Ds(w)||ct(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(_u(e,c,f,h,g,null,a,l,u),h=g=b=null),y=!0,k=!1,s=!1,h=e.tag,g=e.result;else if(y)ct(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=p,!0}else if(y)ct(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=p,!0}if((e.line===o||e.lineIndent>t)&&(k&&(a=e.line,l=e.lineStart,u=e.position),id(e,t,jg,!0,s)&&(k?g=e.result:b=e.result),k||(_u(e,c,f,h,g,b,a,l,u),h=g=b=null),br(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&w!==0)ct(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&_u(e,c,f,h,g,null,a,l,u),y&&(e.tag=d,e.anchor=p,e.kind="mapping",e.result=c),y}function hK(e){var t,n=!1,r=!1,s,o,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&ct(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(o=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):ct(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!Ds(a);)a===33&&(r?ct(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),IT.test(s)||ct(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);o=e.input.slice(t,e.position),nK.test(o)&&ct(e,"tag suffix cannot contain flow indicator characters")}o&&!TT.test(o)&&ct(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{ct(e,"tag name is malformed: "+o)}return n?e.tag=o:xl.call(e.tagMap,s)?e.tag=e.tagMap[s]+o:s==="!"?e.tag="!"+o:s==="!!"?e.tag="tag:yaml.org,2002:"+o:ct(e,'undeclared tag handle "'+s+'"'),!0}function mK(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ct(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Ds(n)&&!Eu(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ct(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function gK(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!Ds(r)&&!Eu(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ct(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),xl.call(e.anchorMap,n)||ct(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],br(e,!0,-1),!0}function id(e,t,n,r,s){var o,a,l,u=1,d=!1,p=!1,c,f,h,g,b,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=jg===n||AT===n,r&&br(e,!0,-1)&&(d=!0,e.lineIndent>t?u=1:e.lineIndent===t?u=0:e.lineIndent<t&&(u=-1)),u===1)for(;hK(e)||mK(e);)br(e,!0,-1)?(d=!0,l=o,e.lineIndent>t?u=1:e.lineIndent===t?u=0:e.lineIndent<t&&(u=-1)):l=!1;if(l&&(l=d||s),(u===1||jg===n)&&(Ng===n||PT===n?b=t:b=t+1,k=e.position-e.lineStart,u===1?l&&(Qj(e,k)||pK(e,k,b))||dK(e,b)?p=!0:(a&&fK(e,b)||cK(e,b)||uK(e,b)?p=!0:gK(e)?(p=!0,(e.tag!==null||e.anchor!==null)&&ct(e,"alias node should not have any properties")):lK(e,b,Ng===n)&&(p=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):u===0&&(p=l&&Qj(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&ct(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),c=0,f=e.implicitTypes.length;c<f;c+=1)if(g=e.implicitTypes[c],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(xl.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,h=e.typeMap.multi[e.kind||"fallback"],c=0,f=h.length;c<f;c+=1)if(e.tag.slice(0,h[c].tag.length)===h[c].tag){g=h[c];break}g||ct(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&ct(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):ct(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||p}function yK(e){var t=e.position,n,r,s,o=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(br(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(o=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!Ds(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&ct(e,"directive name must not be less than one character in length");a!==0;){for(;fc(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!$o(a));break}if($o(a))break;for(n=e.position;a!==0&&!Ds(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&X0(e),xl.call(Xj,r)?Xj[r](e,r,s):Cg(e,'unknown document directive "'+r+'"')}if(br(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,br(e,!0,-1)):o&&ct(e,"directives end mark is expected"),id(e,e.lineIndent-1,jg,!1,!0),br(e,!0,-1),e.checkLineBreaks&&tK.test(e.input.slice(t,e.position))&&Cg(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&_y(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,br(e,!0,-1));return}if(e.position<e.length-1)ct(e,"end of the stream or a document separator is expected");else return}function $T(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
95
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new aK(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ct(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)yK(n);return n.documents}function xK(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=$T(e,n);if(typeof t!="function")return r;for(var s=0,o=r.length;s<o;s+=1)t(r[s])}function wK(e,t){var n=$T(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new vs("expected a single document in the stream, but found more")}}var bK=xK,vK=wK,DT={loadAll:bK,load:vK},FT=Object.prototype.toString,zT=Object.prototype.hasOwnProperty,Q0=65279,kK=9,wp=10,SK=13,NK=32,jK=33,CK=34,Yb=35,EK=37,_K=38,PK=39,AK=42,HT=44,IK=45,Eg=58,TK=61,RK=62,MK=63,LK=64,BT=91,WT=93,OK=96,VT=123,$K=124,KT=125,ps={};ps[0]="\\0";ps[7]="\\a";ps[8]="\\b";ps[9]="\\t";ps[10]="\\n";ps[11]="\\v";ps[12]="\\f";ps[13]="\\r";ps[27]="\\e";ps[34]='\\"';ps[92]="\\\\";ps[133]="\\N";ps[160]="\\_";ps[8232]="\\L";ps[8233]="\\P";var DK=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],FK=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function zK(e,t){var n,r,s,o,a,l,u;if(t===null)return{};for(n={},r=Object.keys(t),s=0,o=r.length;s<o;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),u=e.compiledTypeMap.fallback[a],u&&zT.call(u.styleAliases,l)&&(l=u.styleAliases[l]),n[a]=l;return n}function HK(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new vs("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Cr.repeat("0",r-t.length)+t}var BK=1,bp=2;function WK(e){this.schema=e.schema||G0,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Cr.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=zK(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?bp:BK,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Zj(e,t){for(var n=Cr.repeat(" ",t),r=0,s=-1,o="",a,l=e.length;r<l;)s=e.indexOf(`
96
- `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
- `&&(o+=n),o+=a;return o}function Gb(e,t){return`
98
- `+Cr.repeat(" ",e.indent*t)}function VK(e,t){var n,r,s;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(s=e.implicitTypes[n],s.resolve(t))return!0;return!1}function _g(e){return e===NK||e===kK}function vp(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Q0||65536<=e&&e<=1114111}function e1(e){return vp(e)&&e!==Q0&&e!==SK&&e!==wp}function t1(e,t,n){var r=e1(e),s=r&&!_g(e);return(n?r:r&&e!==HT&&e!==BT&&e!==WT&&e!==VT&&e!==KT)&&e!==Yb&&!(t===Eg&&!s)||e1(t)&&!_g(t)&&e===Yb||t===Eg&&s}function KK(e){return vp(e)&&e!==Q0&&!_g(e)&&e!==IK&&e!==MK&&e!==Eg&&e!==HT&&e!==BT&&e!==WT&&e!==VT&&e!==KT&&e!==Yb&&e!==_K&&e!==AK&&e!==jK&&e!==$K&&e!==TK&&e!==RK&&e!==PK&&e!==CK&&e!==EK&&e!==LK&&e!==OK}function UK(e){return!_g(e)&&e!==Eg}function xf(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function UT(e){var t=/^\n* /;return t.test(e)}var qT=1,Xb=2,YT=3,GT=4,cu=5;function qK(e,t,n,r,s,o,a,l){var u,d=0,p=null,c=!1,f=!1,h=r!==-1,g=-1,b=KK(xf(e,0))&&UK(xf(e,e.length-1));if(t||a)for(u=0;u<e.length;d>=65536?u+=2:u++){if(d=xf(e,u),!vp(d))return cu;b=b&&t1(d,p,l),p=d}else{for(u=0;u<e.length;d>=65536?u+=2:u++){if(d=xf(e,u),d===wp)c=!0,h&&(f=f||u-g-1>r&&e[g+1]!==" ",g=u);else if(!vp(d))return cu;b=b&&t1(d,p,l),p=d}f=f||h&&u-g-1>r&&e[g+1]!==" "}return!c&&!f?b&&!a&&!s(e)?qT:o===bp?cu:Xb:n>9&&UT(e)?cu:a?o===bp?cu:Xb:f?GT:YT}function YK(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===bp?'""':"''";if(!e.noCompatMode&&(DK.indexOf(t)!==-1||FK.test(t)))return e.quotingType===bp?'"'+t+'"':"'"+t+"'";var o=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),l=r||e.flowLevel>-1&&n>=e.flowLevel;function u(d){return VK(e,d)}switch(qK(t,l,e.indent,a,u,e.quotingType,e.forceQuotes&&!r,s)){case qT:return t;case Xb:return"'"+t.replace(/'/g,"''")+"'";case YT:return"|"+n1(t,e.indent)+r1(Zj(t,o));case GT:return">"+n1(t,e.indent)+r1(Zj(GK(t,a),o));case cu:return'"'+XK(t)+'"';default:throw new vs("impossible error: invalid scalar style")}}()}function n1(e,t){var n=UT(e)?String(t):"",r=e[e.length-1]===`
99
- `,s=r&&(e[e.length-2]===`
100
- `||e===`
101
- `),o=s?"+":r?"":"-";return n+o+`
102
- `}function r1(e){return e[e.length-1]===`
103
- `?e.slice(0,-1):e}function GK(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var d=e.indexOf(`
104
- `);return d=d!==-1?d:e.length,n.lastIndex=d,s1(e.slice(0,d),t)}(),s=e[0]===`
105
- `||e[0]===" ",o,a;a=n.exec(e);){var l=a[1],u=a[2];o=u[0]===" ",r+=l+(!s&&!o&&u!==""?`
106
- `:"")+s1(u,t),s=o}return r}function s1(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,o,a=0,l=0,u="";r=n.exec(e);)l=r.index,l-s>t&&(o=a>s?a:l,u+=`
107
- `+e.slice(s,o),s=o+1),a=l;return u+=`
108
- `,e.length-s>t&&a>s?u+=e.slice(s,a)+`
109
- `+e.slice(a+1):u+=e.slice(s),u.slice(1)}function XK(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=xf(e,s),r=ps[n],!r&&vp(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||HK(n);return t}function JK(e,t,n){var r="",s=e.tag,o,a,l;for(o=0,a=n.length;o<a;o+=1)l=n[o],e.replacer&&(l=e.replacer.call(n,String(o),l)),(wa(e,t,l,!1,!1)||typeof l>"u"&&wa(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function i1(e,t,n,r){var s="",o=e.tag,a,l,u;for(a=0,l=n.length;a<l;a+=1)u=n[a],e.replacer&&(u=e.replacer.call(n,String(a),u)),(wa(e,t+1,u,!0,!0,!1,!0)||typeof u>"u"&&wa(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=Gb(e,t)),e.dump&&wp===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=o,e.dump=s||"[]"}function QK(e,t,n){var r="",s=e.tag,o=Object.keys(n),a,l,u,d,p;for(a=0,l=o.length;a<l;a+=1)p="",r!==""&&(p+=", "),e.condenseFlow&&(p+='"'),u=o[a],d=n[u],e.replacer&&(d=e.replacer.call(n,u,d)),wa(e,t,u,!1,!1)&&(e.dump.length>1024&&(p+="? "),p+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),wa(e,t,d,!1,!1)&&(p+=e.dump,r+=p));e.tag=s,e.dump="{"+r+"}"}function ZK(e,t,n,r){var s="",o=e.tag,a=Object.keys(n),l,u,d,p,c,f;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new vs("sortKeys must be a boolean or a function");for(l=0,u=a.length;l<u;l+=1)f="",(!r||s!=="")&&(f+=Gb(e,t)),d=a[l],p=n[d],e.replacer&&(p=e.replacer.call(n,d,p)),wa(e,t+1,d,!0,!0,!0)&&(c=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,c&&(e.dump&&wp===e.dump.charCodeAt(0)?f+="?":f+="? "),f+=e.dump,c&&(f+=Gb(e,t)),wa(e,t+1,p,!0,c)&&(e.dump&&wp===e.dump.charCodeAt(0)?f+=":":f+=": ",f+=e.dump,s+=f));e.tag=o,e.dump=s||"{}"}function o1(e,t,n){var r,s,o,a,l,u;for(s=n?e.explicitTypes:e.implicitTypes,o=0,a=s.length;o<a;o+=1)if(l=s[o],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(u=e.styleMap[l.tag]||l.defaultStyle,FT.call(l.represent)==="[object Function]")r=l.represent(t,u);else if(zT.call(l.represent,u))r=l.represent[u](t,u);else throw new vs("!<"+l.tag+'> tag resolver accepts not "'+u+'" style');e.dump=r}return!0}return!1}function wa(e,t,n,r,s,o,a){e.tag=null,e.dump=n,o1(e,n,!1)||o1(e,n,!0);var l=FT.call(e.dump),u=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var p=l==="[object Object]"||l==="[object Array]",c,f;if(p&&(c=e.duplicates.indexOf(n),f=c!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(s=!1),f&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(p&&f&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(ZK(e,t,e.dump,s),f&&(e.dump="&ref_"+c+e.dump)):(QK(e,t,e.dump),f&&(e.dump="&ref_"+c+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?i1(e,t-1,e.dump,s):i1(e,t,e.dump,s),f&&(e.dump="&ref_"+c+e.dump)):(JK(e,t,e.dump),f&&(e.dump="&ref_"+c+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&YK(e,e.dump,t,o,u);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new vs("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function eU(e,t){var n=[],r=[],s,o;for(Jb(e,n,r),s=0,o=r.length;s<o;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(o)}function Jb(e,t,n){var r,s,o;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,o=e.length;s<o;s+=1)Jb(e[s],t,n);else for(r=Object.keys(e),s=0,o=r.length;s<o;s+=1)Jb(e[r[s]],t,n)}function tU(e,t){t=t||{};var n=new WK(t);n.noRefs||eU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),wa(n,0,r,!0,!0)?n.dump+`
110
- `:""}var nU=tU,rU={dump:nU};function Z0(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var sU=Jr,iU=uT,oU=hT,aU=wT,lU=bT,cU=G0,uU=DT.load,dU=DT.loadAll,fU=rU.dump,pU=vs,hU={binary:jT,float:xT,map:pT,null:mT,pairs:ET,set:_T,timestamp:ST,bool:gT,int:yT,merge:NT,omap:CT,seq:fT,str:dT},mU=Z0("safeLoad","load"),gU=Z0("safeLoadAll","loadAll"),yU=Z0("safeDump","dump"),XT={Type:sU,Schema:iU,FAILSAFE_SCHEMA:oU,JSON_SCHEMA:aU,CORE_SCHEMA:lU,DEFAULT_SCHEMA:cU,load:uU,loadAll:dU,dump:fU,YAMLException:pU,types:hU,safeLoad:mU,safeLoadAll:gU,safeDump:yU};const wl=["requirement","planning","code","test","normal"],Qb={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},xU=["agent","control","provide","condition","jump","condition_jump","start","end"];function wU(e){return xU.includes(e)?e:"agent"}function bU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function vU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=XT.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},o=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},u=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=a.viewport&&typeof a.viewport=="object"?a.viewport:null,p=d&&Number.isFinite(Number(d.x))&&Number.isFinite(Number(d.y))&&Number.isFinite(Number(d.zoom))?{x:Number(d.x),y:Number(d.y),zoom:Math.min(Math.max(Number(d.zoom),.1),4)}:void 0,c=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,f=new Set(Object.keys(s));for(const b of o)b!=null&&b.source&&f.add(String(b.source)),b!=null&&b.target&&f.add(String(b.target));const h=Array.from(f).map(b=>{const k=s[b],y=l[b]&&typeof l[b].x=="number"&&typeof l[b].y=="number"?{x:l[b].x,y:l[b].y}:{x:0,y:0},w=u[b]&&typeof u[b].width=="number"&&typeof u[b].height=="number"?{width:u[b].width,height:u[b].height}:null,x=(k==null?void 0:k.definitionId)??b,N=bU(x),_=(k==null?void 0:k.label)!=null?String(k.label):b,C=(k==null?void 0:k.role)!=null?String(k.role).trim():"",T=Qb[C]||C,F=wl.includes(T)?T:"normal",R=(k==null?void 0:k.model)!=null?String(k.model).trim():void 0,H=(k==null?void 0:k.body)!=null?String(k.body):"",D=(k==null?void 0:k.script)!=null?String(k.script):"",$=(k==null?void 0:k.scriptRef)!=null?String(k.scriptRef):"",B=(k==null?void 0:k.implementationRef)!=null?String(k.implementationRef):"",L=(k==null?void 0:k.implementationMode)!=null?String(k.implementationMode):"",M=Array.isArray(k==null?void 0:k.images)?k.images:[];return{id:b,type:wU(N),position:y,...w?{width:w.width,height:w.height}:{},data:{label:_,definitionId:x,schemaType:N,role:F,model:R||void 0,body:H,images:M,...w?{displaySize:w}:{},...D.trim()!==""?{script:D}:{},...$.trim()!==""?{scriptRef:$}:{},...B.trim()!==""?{implementationRef:B}:{},...L.trim()!==""?{implementationMode:L}:{}}}}),g=o.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).map((b,k)=>({id:`e-${b.source}-${b.target}-${k}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:ks.ArrowClosed}}));return{nodes:h,edges:g,instances:s,description:c,...p?{viewport:p}:{}}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const o=r.match(/\((\d+):/);s=`
111
-
112
- 💡 提示:通常由 ${o?`第 ${o[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
- YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
-
115
- ✅ 正确写法:
116
- \`\`\`yaml
117
- script: |
118
- node -e "console.log('TODO: scripts/x.mjs')"
119
- \`\`\`
120
- ❌ 错误写法(当前文件):
121
- \`\`\`yaml
122
- script: node -e "console.log('TODO: scripts/x.mjs')"
123
- \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function Wp(e,t){var s,o,a,l,u,d,p,c,f,h,g,b,k,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]}:{},N=((o=w.data)==null?void 0:o.definitionId)||w.id,_=((a=w.data)==null?void 0:a.inputs)??[],C=((l=w.data)==null?void 0:l.outputs)??[],T=((u=w.data)==null?void 0:u.role)!=null?String(w.data.role).trim():"",F=x.role!=null?String(x.role).trim():"",R=Qb[T]||T,H=Qb[F]||F,D=wl.includes(R)?R:wl.includes(H)?H:"normal",$=Array.isArray(_)?_.map(n):Array.isArray(x.input)?x.input.map(de=>n(de)):[],B=Array.isArray(C)?C.map(n):Array.isArray(x.output)?x.output.map(de=>n(de)):[],L=((d=w.data)==null?void 0:d.label)!=null?String(w.data.label):x.label!=null?String(x.label):w.id,M=(p=w.data)==null?void 0:p.body,I=M!=null?String(M):x.body!=null?String(x.body):"";let z=((c=w.data)==null?void 0:c.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;(z===""||z==="default")&&(z=void 0);const A={...x,definitionId:N,label:L,role:D,model:z,input:$,output:B},O=((f=w.data)==null?void 0:f.marketplaceRef)||x.marketplaceRef;O?A.marketplaceRef=String(O):delete A.marketplaceRef;const E=((h=w.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;E?A.marketplacePackageId=String(E):delete A.marketplacePackageId;const J=((g=w.data)==null?void 0:g.marketplaceVersion)||x.marketplaceVersion;J?A.marketplaceVersion=String(J):delete A.marketplaceVersion,N.startsWith("provide_")||I.trim()===""?delete A.body:A.body=I;const Z=Array.isArray((b=w.data)==null?void 0:b.images)?w.data.images:Array.isArray(x.images)?x.images:[];Z.length>0?A.images=Z:delete A.images;const K=(k=w.data)==null?void 0:k.script,oe=K!=null?String(K):x.script!=null?String(x.script):"";oe.trim()===""?delete A.script:A.script=oe;for(const de of["scriptRef","implementationRef","implementationMode"]){const he=(y=w.data)==null?void 0:y[de],we=he!=null?String(he):x[de]!=null?String(x[de]):"";we.trim()===""?delete A[de]:A[de]=we.trim()}delete A.temperature,delete A.maxTokens,delete A.description,r[w.id]=A}return r}function Df(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function kU(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 JT(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)),o=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>Df(a)),edges:o.map(a=>Df(a)),instances:Wp(r,n||{})}}function QT(e,t,n,r,s={}){var c;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=s.offset||{x:48,y:48},a=new Set((t||[]).map(f=>f.id)),l=new Map;for(const f of e.nodes)l.set(f.id,kU(f.id,a));const u=e.nodes.map(f=>{var g,b;const h=l.get(f.id);return{...Df(f),id:h,selected:!0,dragging:!1,position:{x:Number(((g=f.position)==null?void 0:g.x)||0)+o.x,y:Number(((b=f.position)==null?void 0:b.y)||0)+o.y}}}),d=(e.edges||[]).filter(f=>l.has(f.source)&&l.has(f.target)).map((f,h)=>{const g=l.get(f.source),b=l.get(f.target);return{...Df(f),id:`e-${g}-${b}-${Date.now()}-${h}`,source:g,target:b,selected:!1}}),p={...r||{}};for(const[f,h]of l.entries()){const g=(c=e.instances)==null?void 0:c[f];g&&(p[h]={...Df(g),label:g.label!=null?String(g.label):h})}return{nodes:[...(t||[]).map(f=>({...f,selected:!1})),...u],edges:[...(n||[]).map(f=>({...f,selected:!1})),...d],instances:p,pastedNodeIds:u.map(f=>f.id)}}function a1(e,t,n,r){var p,c,f,h;const s=Wp(e,n),o=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const b=g.position??{x:0,y:0};a[g.id]={x:b.x,y:b.y};const k=Number(((c=(p=g.data)==null?void 0:p.displaySize)==null?void 0:c.width)||g.width||0),y=Number(((h=(f=g.data)==null?void 0:f.displaySize)==null?void 0:h.height)||g.height||0);k>0&&y>0&&(l[g.id]={width:Math.round(k),height:Math.round(y)})}const u={nodePositions:a};Object.keys(l).length>0&&(u.nodeSizes=l),r!=null&&r.viewport&&Number.isFinite(Number(r.viewport.x))&&Number.isFinite(Number(r.viewport.y))&&Number.isFinite(Number(r.viewport.zoom))&&(u.viewport={x:Number(r.viewport.x),y:Number(r.viewport.y),zoom:Math.min(Math.max(Number(r.viewport.zoom),.1),4)}),(r==null?void 0:r.description)!=null&&String(r.description).trim()!==""&&(u.description=String(r.description).trim());const d={instances:s,edges:o,ui:u};return XT.dump(d,{lineWidth:-1})}function SU(e){var s,o;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((o=e.data)==null?void 0:o.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],u=(l&&l.name!=null?String(l.name).trim():"")||`input-${a}`;t.inputNames.push(u)}for(let a=0;a<r.length;a++){const l=r[a],u=(l&&l.name!=null?String(l.name).trim():"")||`output-${a}`;t.outputNames.push(u)}return t}function NU(e,t,n){var u,d,p;const r=new Set(e.map(c=>c.id)),s={};for(const c of e)s[c.id]=SU(c);const o=new Map,a=new Map;for(const c of t)c.target&&r.has(c.target)&&(o.has(c.target)||o.set(c.target,new Set),c.targetHandle&&o.get(c.target).add(c.targetHandle)),c.source&&r.has(c.source)&&(a.has(c.source)||a.set(c.source,new Set),c.sourceHandle&&a.get(c.source).add(c.sourceHandle));const l=[];for(const c of e){const f=((u=c.data)==null?void 0:u.definitionId)!=null?String(c.data.definitionId):"",h=s[c.id]||{inputNames:[],outputNames:[]},g=h.inputNames.length,b=h.outputNames.length;if(!(f==="control_start"||f.startsWith("provide_"))&&g>0)for(let w=0;w<g;w++){const x=`input-${w}`;if(!((d=o.get(c.id))==null?void 0:d.has(x))){const _=h.inputNames[w]||x;l.push({nodeId:c.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:_,handle:x}),key:`${c.id}-${x}-in`})}}if(!(f==="control_end")&&b>0)for(let w=0;w<b;w++){const x=`output-${w}`;if(!((p=a.get(c.id))==null?void 0:p.has(x))){const _=h.outputNames[w]||x;l.push({nodeId:c.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:_,handle:x}),key:`${c.id}-${x}-out`})}}}return l}const Pg=/\[image\s+(\d+)\]/gi;function Fs(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 jU(e){return`image ${Fs(e).length+1}`}function CU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function EU(e,t){const n=Fs(e),r=String(t||""),s=new Set;Pg.lastIndex=0;let o;for(;o=Pg.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function _U(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 ZT(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 Ag(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 eR({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=Fs(n);for(const a of r){const l=await _U(a),u=jU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:u,...l}),s=CU(s,u)}return{body:s,images:o}}function Zb(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 PU={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_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function AU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(PU[e]||[]).includes(s)?r:s}const IU={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"])},TU={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},RU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function MU(e,t){if(!RU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function LU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function OU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();if(!n)return t;const r=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(r.entry||r.command)&&n==="tool_nodejs"?t:n}function l1(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,p;const o=n[s],l=n.find(c=>(c==null?void 0:c.name)&&c.name===r.name)||o;if(!l)return r;const u=r.showOnNode===!1&&l.showOnNode==null&&((d=IU[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...u?{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&&MU(e,r)?{showOnNode:!0}:{},...(p=TU[e])!=null&&p.has(r.name)?{showOnNode:!1}:{}}})}function tR(e){var s,o;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((o=e==null?void 0:e.data)==null?void 0:o.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const u=Zb(l);return{type:String(u.type||"node"),name:String(u.name??""),default:String(u.default??""),required:!!u.required,description:String(u.description??""),showOnNode:u.showOnNode!=null?u.showOnNode!==!1:!!u.required||String(u.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function kp(e,t,n,r,s){var z,A,O,E,J,Z,K,oe,de,he,we,ue,Ne,le,ce,xe,Se,Ke,et,We,ut;const o=((z=e.data)==null?void 0:z.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ve=>Ve.id===o),l=t[e.id];let u=[],d=[],p=((A=e.data)==null?void 0:A.label)??e.id,c,f,h,g,b;const k=!!l;l&&(Array.isArray(l.input)&&(u=l.input.map(Zb)),Array.isArray(l.output)&&(d=l.output.map(Zb)),l.label&&(p=String(l.label)),l.role&&typeof l.role=="string"&&(c=l.role),l.model!=null&&(f=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=c??(typeof((O=e.data)==null?void 0:O.role)=="string"?e.data.role:"普通"),w=f??((E=e.data)==null?void 0:E.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",N=x!==""?x:void 0,_=h??((J=e.data)==null?void 0:J.body)??"",C=Array.isArray(g)?g:Array.isArray((Z=e.data)==null?void 0:Z.images)?e.data.images:[],T=b!==void 0?b:((K=e.data)==null?void 0:K.script)!=null?String(e.data.script):"",F=String(e.id),R=(oe=r==null?void 0:r[s])==null?void 0:oe[F],H=(de=R==null?void 0:R.label)==null?void 0:de.label,D=R==null?void 0:R.body,$=R==null?void 0:R.description;k||(u.length===0&&((he=a==null?void 0:a.inputs)!=null&&he.length)&&(u=a.inputs.map(Ve=>({...Ve}))),d.length===0&&((we=a==null?void 0:a.outputs)!=null&&we.length)&&(d=a.outputs.map(Ve=>({...Ve}))));const B=OU(a,(a==null?void 0:a.id)??o),L=(l==null?void 0:l.marketplaceRef)||((ue=e.data)==null?void 0:ue.marketplaceRef)||LU(a);if(B==="agent_subAgent"&&!d.some(Ve=>(Ve==null?void 0:Ve.name)==="result")){const Ve=(Ne=a==null?void 0:a.outputs)==null?void 0:Ne.find(xt=>(xt==null?void 0:xt.name)==="result");d=[...d,Ve?{...Ve}:{type:"text",name:"result",default:""}]}if((B==="display_markdown"||B==="display_mermaid"||B==="display_ascii"||B==="display_chart"||B==="display_table")&&!d.some(Ve=>(Ve==null?void 0:Ve.name)==="next")){const Ve=(le=a==null?void 0:a.outputs)==null?void 0:le.find(xt=>(xt==null?void 0:xt.name)==="next");d=[...d,Ve?{...Ve}:{type:"node",name:"next",default:""}]}if(B==="workspace_run"){if(!u.some(Ve=>(Ve==null?void 0:Ve.name)==="prev")){const Ve=(ce=a==null?void 0:a.inputs)==null?void 0:ce.find(xt=>(xt==null?void 0:xt.name)==="prev");u=[Ve?{...Ve}:{type:"node",name:"prev",default:""},...u]}if(!d.some(Ve=>(Ve==null?void 0:Ve.name)==="next")){const Ve=(xe=a==null?void 0:a.outputs)==null?void 0:xe.find(xt=>(xt==null?void 0:xt.name)==="next");d=[...d,Ve?{...Ve}:{type:"node",name:"next",default:""}]}}u=l1(B,u,a==null?void 0:a.inputs),d=l1(B,d,a==null?void 0:a.outputs),B.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(_).trim()!==""&&(d=d.map((Ve,xt)=>xt===0?{...Ve,default:_,value:_}:Ve));const M=AU(B,H||p,a),I=B==="tool_nodejs"||String(T).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:H||p,displayLabel:M,definitionDisplayName:a==null?void 0:a.displayName,definitionId:B,...L?{marketplaceRef:L}:{},...l!=null&&l.marketplacePackageId||(Se=e.data)!=null&&Se.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Ke=e.data)==null?void 0:Ke.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(et=e.data)!=null&&et.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((We=e.data)==null?void 0:We.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((ut=e.data)==null?void 0:ut.schemaType)??e.type??"agent",role:y,model:w,body:D||_,images:C,script:T,inputs:u,outputs:d,description:$||N,originalLabel:p,originalBody:_,...I?{script:T}:{}}}}function nR(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var p,c,f,h;const s=n.get(r.source),o=n.get(r.target),a=((c=(p=s==null?void 0:s.data)==null?void 0:p.outputs)==null?void 0:c.length)??0,l=((h=(f=o==null?void 0:o.data)==null?void 0:f.inputs)==null?void 0:h.length)??0,u=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,d=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&u>=0&&u<a&&d>=0&&d<l})}function c1(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 u1(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function Ff(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=c1(t==null?void 0:t.sourceHandle,"output"),o=c1(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(u=>{var d,p,c,f;if(u.id===n){const h=u1((d=u.data)==null?void 0:d.outputs,s);if(h!==((p=u.data)==null?void 0:p.outputs))return a=!0,{...u,data:{...u.data,outputs:h}}}if(u.id===r){const h=u1((c=u.data)==null?void 0:c.inputs,o);if(h!==((f=u.data)==null?void 0:f.inputs))return a=!0,{...u,data:{...u.data,inputs:h}}}return u});return a?l:e}const d1=80,$U=220;function DU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:o,measured:a,internals:l,...u}=e;return u}function FU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Xh(e,t,n){const r={nodes:Array.isArray(e)?e.map(DU):[],edges:Array.isArray(t)?t.map(FU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function Gx(e,t){const n=[...e,t];return n.length>d1?n.slice(n.length-d1):n}function rR({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),u=m.useRef([]),d=m.useRef(null),p=m.useRef(null),c=m.useRef(null),f=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(_=>_+1),[]),b=m.useCallback(()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},[]),k=m.useCallback(()=>{b();const _=p.current,C=c.current;return p.current=null,c.current=null,!_||!C||_.signature===C.signature?(C&&(d.current=C),!1):(l.current=Gx(l.current,_),u.current=[],d.current=C,g(),!0)},[g,b]),y=m.useCallback((_=[],C=[],T={})=>{b(),l.current=[],u.current=[],p.current=null,c.current=null,d.current=Xh(_,C,T),h.current=!1,g()},[g,b]),w=m.useCallback(_=>{h.current=!0,d.current=_,p.current=null,c.current=null,b(),s==null||s(_.value),g()},[g,b,s]),x=m.useCallback(()=>{k();const _=d.current||Xh(e,t,n),C=l.current.pop();return C?(u.current=Gx(u.current,_),w(C),!0):(g(),!1)},[g,t,n,k,e,w]),N=m.useCallback(()=>{k();const _=d.current||Xh(e,t,n),C=u.current.pop();return C?(l.current=Gx(l.current,_),w(C),!0):(g(),!1)},[g,t,n,k,e,w]);return m.useEffect(()=>()=>b(),[b]),m.useEffect(()=>{if(!r)return;const _=Xh(e,t,n);if(!d.current){d.current=_;return}if(h.current){h.current=!1,d.current=_;return}_.signature!==d.current.signature&&(p.current||(p.current=d.current),c.current=_,b(),f.current=window.setTimeout(()=>{k()},$U))},[b,t,r,n,k,e]),{canUndo:l.current.length>0||!!p.current,canRedo:u.current.length>0,resetHistory:y,undo:x,redo:N,version:o}}function Fn(e){switch(Ig(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Ig(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 zU(e,t){const n=Ig(e),r=Ig(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const HU=new Set(["workspaceContext","skillsContext","mcpContext"]);function ev(e){const t=Ig(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&HU.has(n)?`${t}+${n}`:t}function sR(e){return ev(e)}function bl(e,t){if(!e||!t||!zU(e.type,t.type))return!1;const n=ev(e),r=ev(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function BU(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 od(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=BU(t,n==="source"?"output":"input");return o<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[o]||null}function na(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function WU(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 VU(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function KU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Yr(e){e.stopPropagation()}function UU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qU(e,t){const n=`\\[${UU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
- `).replace(/\n{3,}/g,`
125
-
126
- `).trimEnd()}function Xx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YU(e){const t=String(e||"");let n="",r=0;Pg.lastIndex=0;let s;for(;s=Pg.exec(t);)n+=Xx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Xx(s[0])}</span>`,r=s.index+s[0].length;return n+=Xx(t.slice(r)),n||" "}function GU(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,u=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(u,2),8);return Math.ceil(d*r+s+o+a+l)}function iR({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:u,onModelChange:d}){var Ln,zr;const{t:p}=Tn(),c=(e==null?void 0:e.inputs)??[],f=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=WU(e),b=VU(g),k=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),w=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,N=(e==null?void 0:e.nodeStatus)??null,_=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",T=C.startsWith("provide_"),F=C==="provide_bool",R=C==="provide_str",H=C==="provide_file",D=C==="agent_subAgent",$=D&&!k,B=F?KU(f[0]):!1,L=T?String(((Ln=f[0])==null?void 0:Ln.value)??((zr=f[0])==null?void 0:zr.default)??(e==null?void 0:e.body)??""):"",M=String((e==null?void 0:e.body)||""),I=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||p("flow:node.fallbackLabel"),z=!T&&!$&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",A=Fs(e==null?void 0:e.images),O=m.useRef(!1),E=m.useRef(!1),J=m.useRef(null),Z=m.useRef(null),K=m.useRef(null),[oe,de]=m.useState(L),[he,we]=m.useState(M);m.useEffect(()=>{O.current||de(L)},[n,L]),m.useEffect(()=>{E.current||we(M)},[n,M]),m.useEffect(()=>{const be=Z.current;if(!be)return;const $e=GU(be,he);be.style.minHeight=`${$e}px`,be.style.height="",K.current&&(K.current.style.minHeight=`${$e}px`,K.current.style.height="")},[he]),m.useEffect(()=>{const be=J.current,$e=e==null?void 0:e.onNodeContentResize;if(!$||!be||!$e||typeof ResizeObserver>"u")return;let ft=0;const St=()=>{window.cancelAnimationFrame(ft),ft=window.requestAnimationFrame(()=>$e(n))},mn=new ResizeObserver(St);return mn.observe(be),St(),()=>{window.cancelAnimationFrame(ft),mn.disconnect()}},[e==null?void 0:e.onNodeContentResize,$,n]);const ue=Array.isArray(u==null?void 0:u.cursor)?u.cursor:[],Ne=Array.isArray(u==null?void 0:u.opencode)?u.opencode:[],le=Array.isArray(u==null?void 0:u.claudeCode)?u.claudeCode:[],ce=((e==null?void 0:e.model)??"").trim(),xe=h==="agent"&&!C.startsWith("tool_nodejs"),Se=new Set(ue.map(na)),Ke=new Set(Ne.map(na)),et=new Set(le.map(na)),We=ce?ce.startsWith("cursor:")||ce.startsWith("opencode:")||ce.startsWith("claude-code:")?ce:et.has(ce)?`claude-code:${ce}`:Ke.has(ce)?`opencode:${ce}`:Se.has(ce)?`cursor:${ce}`:ce:"",ut=ce&&!We.startsWith("cursor:")&&!We.startsWith("opencode:")&&!We.startsWith("claude-code:")&&!Se.has(ce)&&!Ke.has(ce)&&!et.has(ce),Ve=ce.startsWith("cursor:")?ce.slice(7):ce.startsWith("opencode:")?ce.slice(9):ce.startsWith("claude-code:")?ce.slice(12):ce,xt=be=>{if(y)return;const $e=be.target.value;d&&d(n,$e)},bt=be=>{be.stopPropagation(),!y&&r&&r(n)},Jn=be=>{be.stopPropagation(),s&&s()},Ut=be=>{be.stopPropagation(),!y&&(o==null||o(n,be.target.value==="true"?"true":"false"))},nn=be=>{if(be.stopPropagation(),y)return;const $e=be.target.value;de($e),O.current||o==null||o(n,$e)},rn=be=>{be.stopPropagation(),O.current=!0},hn=be=>{if(be.stopPropagation(),y)return;O.current=!1;const $e=be.currentTarget.value;de($e),o==null||o(n,$e)},fe=()=>{y||o==null||o(n,oe)},je=be=>{if(be.stopPropagation(),y)return;const $e=window.prompt("文件路径",oe);$e!=null&&(de($e),o==null||o(n,$e))},He=be=>{if(we(be),a==null||a(n,be),l){const $e=EU(A,be);($e.length!==A.length||$e.some((ft,St)=>{var mn;return ft.id!==((mn=A[St])==null?void 0:mn.id)}))&&l(n,$e)}},ot=be=>{if(be.stopPropagation(),y)return;const $e=be.target.value;E.current?we($e):He($e)},at=be=>{be.stopPropagation(),!y&&(E.current=!0)},Tt=be=>{if(be.stopPropagation(),y)return;E.current=!1;const $e=be.currentTarget.value;He($e)},mt=()=>{y||He(he)},dn=async be=>{if(y)return;const $e=await eR({files:be,body:he,images:A});$e&&(we($e.body),a==null||a(n,$e.body),l==null||l(n,$e.images))},sn=(be,$e)=>{if(be.stopPropagation(),y)return;const ft=A.filter(mn=>mn.id!==$e.id),St=qU(he,$e.label);we(St),a==null||a(n,St),l==null||l(n,ft)},Rn=be=>{if(y)return;const $e=ZT(be);$e.length!==0&&(be.preventDefault(),be.stopPropagation(),dn($e).catch(()=>{}))},on=be=>{if(y)return;const $e=Ag(be);$e.length!==0&&(be.preventDefault(),be.stopPropagation(),dn($e).catch(()=>{}))},Mn=()=>{const be=Z.current,$e=K.current;!be||!$e||($e.scrollTop=be.scrollTop,$e.scrollLeft=be.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(w?" af-flow-node--executing":"")+(N==="success"?" af-flow-node--done":"")+(N==="failed"?" af-flow-node--failed":"")+(N==="running"&&!w?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+($?" af-flow-node--inline-body-editor":"")+(R?" af-flow-node--provide-text":"")+" af-flow-node--"+h.replace(/[^a-z0-9_-]/g,""),"data-schema":h,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!k&&xe&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Yr,onMouseDown:Yr,onClick:Yr,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:We,onChange:xt,onPointerDown:Yr,onMouseDown:Yr,onClick:Yr,"aria-label":p("flow:node.model"),title:Ve||p("flow:node.defaultModel"),disabled:y,children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),ut&&i.jsx("option",{value:ce,children:ce}),ue.length>0&&i.jsx("optgroup",{label:"Cursor",children:ue.map(be=>i.jsx("option",{value:`cursor:${na(be)}`,children:na(be)},`c-${be}`))}),Ne.length>0&&i.jsx("optgroup",{label:"OpenCode",children:Ne.map(be=>i.jsx("option",{value:`opencode:${na(be)}`,children:na(be)},`o-${be}`))}),le.length>0&&i.jsx("optgroup",{label:"Claude Code",children:le.map(be=>i.jsx("option",{value:`claude-code:${na(be)}`,children:na(be)},`cc-${be}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),w&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),N==="running"&&!w&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),N==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:_!=null&&String(_).trim()!==""?_:"--"}),N==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&T&&!F&&!R&&!H&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Jn,"aria-label":p("flow:node.expandProvide"),title:p("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:bt,"aria-label":p("flow:node.deleteNode"),title:p("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:c.map((be,$e)=>{if(be.showOnNode===!1)return null;const ft=p("flow:node.inputTooltip",{name:be.name||`#${$e}`,type:be.type})+(be.default!=null&&be.default!==""?p("flow:node.defaultSuffix",{value:be.default}):""),St=be.name||`#${$e+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:ft,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[St,be.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${$e}`,className:"af-flow-node__handle",style:{background:Fn(be.type)},title:ft})]},`in-${$e}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[i.jsx("span",{className:"af-flow-node__title",children:I}),n?i.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,F?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(B?" af-flow-node__bool-select--true":""),value:B?"true":"false",onChange:Ut,onPointerDown:Yr,onMouseDown:Yr,onClick:Yr,"aria-label":"Boolean value",title:B?"true":"false",disabled:y,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):R?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:oe,onChange:nn,onCompositionStart:rn,onCompositionEnd:hn,onBlur:fe,onPointerDown:Yr,onMouseDown:Yr,onClick:Yr,placeholder:"输入文本",rows:2,readOnly:y}):H?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Yr,onMouseDown:Yr,onClick:Yr,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:oe,onChange:nn,onCompositionStart:rn,onCompositionEnd:hn,onBlur:fe,placeholder:"选择或输入文件路径",title:oe||"选择或输入文件路径",readOnly:y}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:je,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):D&&!k?i.jsxs("div",{ref:J,className:"af-flow-node__prompt-stack nodrag",children:[i.jsx("pre",{ref:K,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:YU(he)+`
127
- `}}),i.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:he,onChange:ot,onCompositionStart:at,onCompositionEnd:Tt,onBlur:mt,onPaste:Rn,onDrop:on,onScroll:Mn,onDragOver:be=>{Ag(be).length>0&&be.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,D&&A.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:A.map((be,$e)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:be.name,children:[i.jsx("img",{src:be.dataUrl,alt:""}),i.jsxs("span",{children:["[",be.label||`image ${$e+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:ft=>sn(ft,be),onPointerDown:Yr,onMouseDown:Yr,"aria-label":`删除 ${be.label||`image ${$e+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},be.id||$e))}):null,z?i.jsx("span",{className:"af-flow-node__prompt-preview",title:z,children:z}):null]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:f.map((be,$e)=>{if(be.showOnNode===!1)return null;const ft=p("flow:node.outputTooltip",{name:be.name||`#${$e}`,type:be.type})+(be.default!=null&&be.default!==""?p("flow:node.defaultSuffix",{value:be.default}):""),St=be.name||`#${$e+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:ft,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[St,be.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${$e}`,className:"af-flow-node__handle",style:{background:Fn(be.type)},title:ft})]},`out-${$e}`)})})]})]})}const Nc="flowNode";function oR(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 Tg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function XU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function aR({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Tn(),a=m.useId(),l=m.useRef(null),[u,d]=m.useState(""),[p,c]=m.useState(!1),[f,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),h(""),c(!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=u.trim(),b=g===n;async function k(y){if(y.preventDefault(),!(!b||p)){c(!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:o("project:archiveModal.archiveFailed"));return}s()}catch(w){h(String((w==null?void 0:w.message)||w))}finally{c(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.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:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:u,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),f?i.jsx("p",{className:"af-err af-new-pipeline-err",children:f}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function f1({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:o=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:u,onConfirm:d,onCancel:p}){const{t:c}=Tn(),f=m.useId(),h=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var x;return(x=h.current)==null?void 0:x.focus()});function w(x){x.key==="Escape"&&p(),x.key==="Enter"&&d()}return window.addEventListener("keydown",w),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",w)}},[e,p,d]),!e)return null;const g=r??c("common:common.confirm","确定"),b=s??c("common:common.cancel","取消"),k=t??c("common:common.confirmTitle","请确认");return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&p()},children:i.jsxs("div",{ref:h,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:k}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:p,"aria-label":b,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[i.jsx("p",{className:"af-new-pipeline-lead",children:n}),i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:p,children:b}),a&&u?i.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:u,children:a}):null,i.jsx("button",{type:"button",className:o?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function lR({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:o}){const{t:a}=Tn(),l=m.useId(),u=m.useRef(null),[d,p]=m.useState(""),[c,f]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),g(""),f(!1);const w=requestAnimationFrame(()=>{var x;return(x=u.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(w)},[e,n]),!e)return null;const b=d.trim(),k=b===n;async function y(w){if(w.preventDefault(),!k||c)return;f(!0),g("");let x=null;try{const N=new AbortController;x=setTimeout(()=>N.abort(),15e3);const _=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:b,flowArchived:s}),signal:N.signal}),C=await _.json().catch(()=>({}));if(!_.ok){g(typeof C.error=="string"?C.error:a("project:deleteModal.deleteFailed"));return}try{for(let T=localStorage.length-1;T>=0;T--){const F=localStorage.key(T);F&&(F.startsWith(`af:composer-sessions:${n}:${r}`)||F.startsWith(`af:composer-active-session:${n}:${r}`)||F.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(F)}}catch{}await o()}catch(N){if((N==null?void 0:N.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((N==null?void 0:N.message)||N))}finally{x&&clearTimeout(x),f(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:w=>{w.target===w.currentTarget&&t()},children:i.jsxs("div",{ref:u,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:w=>w.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:w=>p(w.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!k})]}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:c,children:a("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||c,children:a(c?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function JU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Wi({keys:e}){return i.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>i.jsxs("span",{children:[n>0?i.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,i.jsx(JU,{children:t})]},n))})}function cR({open:e,onClose:t}){const{t:n}=Tn(),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 o=XU()?"⌘":"Ctrl";return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:i.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:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body",children:[i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),i.jsx(Wi,{keys:[o,"S"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),i.jsx(Wi,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Wi,{keys:[o,"K"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),i.jsx(Wi,{keys:["A"]})]})]})]}),i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),i.jsx(Wi,{keys:["V"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),i.jsx(Wi,{keys:["H"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),i.jsx(Wi,{keys:["Space"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),i.jsx(Wi,{keys:["F"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),i.jsx(Wi,{keys:[o,"A"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),i.jsx(Wi,{keys:[o,"Z"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),i.jsx(Wi,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function QU(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:o.includes(n)?15:0}function uR({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Tn(),[o,a]=m.useState(""),[l,u]=m.useState(0),d=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),u(0);const g=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const c=m.useMemo(()=>{const g=(r||[]).map(y=>{var w,x,N;return{id:y.id,label:((w=y.data)==null?void 0:w.label)||"",definitionId:((x=y.data)==null?void 0:x.definitionId)||"",schemaType:((N=y.data)==null?void 0:N.schemaType)||""}}),b=o.trim(),k=g.map(y=>({e:y,s:QU(y,b)})).filter(y=>y.s>0);return k.sort((y,w)=>w.s-y.s||y.e.id.localeCompare(w.e.id)),k.slice(0,50).map(y=>y.e)},[r,o]);if(m.useEffect(()=>{l>=c.length&&u(0)},[c.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 f=g=>{const b=c[g];b&&(n(b.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),u(b=>Math.min(c.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),u(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),f(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-jump-panel__input-wrap",children:[i.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:g=>{a(g.target.value),u(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:c.length})]}),c.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:p,className:"af-jump-panel__list",role:"listbox",children:c.map((g,b)=>i.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>u(b),onMouseDown:k=>{k.preventDefault(),f(b)},children:[i.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&i.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),i.jsxs("div",{className:"af-jump-panel__hint",children:[i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"↑"}),i.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function ZU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:o,fileName:a,onSaved:l,onAiEdit:u}){const{t:d}=Tn(),p=m.useId(),c=m.useRef(null),f=m.useRef(null),[h,g]=m.useState(""),[b,k]=m.useState(""),[y,w]=m.useState(!1),[x,N]=m.useState(!1),[_,C]=m.useState(!1),[T,F]=m.useState(""),[R,H]=m.useState("");if(m.useEffect(()=>{if(!e||!o)return;g(""),k(""),F(""),H(""),w(!0),N(!1),C(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o});(async()=>{try{const A=await fetch(`/api/pipeline-file-content?${I}`),O=await A.json();if(!A.ok)throw new Error(O.error||"HTTP "+A.status);g(O.content||""),k(O.content||"")}catch(A){F(A.message||String(A))}finally{w(!1)}})();const z=requestAnimationFrame(()=>{var A;return(A=c.current)==null?void 0:A.focus()});return()=>cancelAnimationFrame(z)},[e,o,n,r,s]),!e)return null;const D=h!==b;async function $(I){if(I.preventDefault(),!x){N(!0),F(""),H("");try{const z=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o}),A=await fetch(`/api/pipeline-file-save?${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),O=await A.json();if(!A.ok)throw new Error(O.error||"HTTP "+A.status);k(h),H(d("flow:fileEdit.saved")),l&&l()}catch(z){F(z.message||String(z))}finally{N(!1)}}}async function B(){if(!(!u||_||!h)){C(!0),F("");try{const I=await u(h);typeof I=="string"&&I&&g(I)}catch(I){F(I.message||String(I))}finally{C(!1)}}}function L(){g(b),F(""),H("")}const M=h.length>1e5;return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:i.jsxs("div",{ref:c,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:a||o}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-file-edit-body",children:y?i.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):T&&!h?i.jsx("div",{className:"af-file-edit-error",children:T}):i.jsxs(i.Fragment,{children:[M&&i.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),i.jsx("textarea",{ref:f,className:"af-file-edit-textarea",value:h,onChange:I=>g(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(T||R)&&!y&&i.jsx("div",{className:`af-file-edit-status${R?" af-file-edit-status--success":""}`,children:R||T}),i.jsxs("div",{className:"af-file-edit-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:L,disabled:!D||x||_,children:d("flow:fileEdit.reset")}),u&&i.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:B,disabled:_||x||!h,children:d(_?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),i.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:!D||x||_,children:d(x?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const dR=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),e7=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function t7(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 n7(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 p1(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 fR(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(dR.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 pR(e){return{inputNames:p1(e==null?void 0:e.inputs),outputNames:p1(e==null?void 0:e.outputs)}}function r7(e,t,n){const r=pR(t),s=n7(e),o=[];for(const a of s)if(!fR(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function s7(e,t){const n=pR(t),r=/\$\{([^}]*)\}/g,s=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&s.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],u=fR(a[1],n);s.push({kind:u?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&s.push({kind:"plain",text:e.slice(o)}),s}function i7(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function o7(e){return e.map(t=>{const n=i7(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 a7(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 o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):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 o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of e7)dR.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function l7(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function c7(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 o=e.clientWidth;if(o<=0)return null;s.style.width=`${o}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(),u=parseFloat(r.lineHeight),d=Number.isFinite(u)&&u>0?u:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function Jh({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:u,onImagesChange:d}){const{t:p}=Tn(),c=m.useId(),f=m.useRef(null),h=m.useRef(null),[g,b]=m.useState(0),[k,y]=m.useState(0),[w,x]=m.useState(null),N=m.useMemo(()=>Fs(u),[u]),_=m.useMemo(()=>r7(e,a,p),[e,a,p]),C=_.length>0,T=m.useMemo(()=>s7(e,a),[e,a]),F=m.useMemo(()=>o7(T),[T]),R=m.useMemo(()=>n?null:t7(e,g),[e,g,n]),H=m.useMemo(()=>{if(!R)return[];const I=a7(a,p);return l7(I,R.query)},[R,a,p]);m.useEffect(()=>{y(I=>{const z=Math.max(0,H.length-1);return Math.min(Math.max(0,I),z)})},[H.length]);const D=m.useCallback(()=>{const I=f.current;if(!I||!R||H.length===0){x(null);return}const z=c7(I,g);if(!z){x(null);return}const A=4,O=44,E=13.5*16,J=Math.min(H.length*O+8,E);let Z=z.bottom+A;Z+J>window.innerHeight-8&&(Z=Math.max(8,z.top-J-A));const K=288;let oe=z.left;oe=Math.max(8,Math.min(oe,window.innerWidth-K-8)),x({top:Z,left:oe})},[R,H.length,g]);m.useLayoutEffect(()=>{if(!R||H.length===0){x(null);return}const I=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(I)},[R,H.length,g,e,D]),m.useEffect(()=>{if(!R||H.length===0)return;const I=()=>D();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[R,H.length,D]);const $=m.useCallback(I=>{if(!R)return;const{atIndex:z}=R,A=e.slice(0,z)+"${"+I+"}"+e.slice(g);t(A);const O=z+I.length+3;queueMicrotask(()=>{const E=f.current;E&&(E.focus(),E.setSelectionRange(O,O)),b(O)})},[R,e,g,t]),B=m.useCallback(()=>{const I=f.current,z=h.current;!I||!z||(z.scrollTop=I.scrollTop,z.scrollLeft=I.scrollLeft,R&&H.length>0&&queueMicrotask(()=>D()))},[R,H.length,D]),L=m.useCallback(I=>{if(!n&&R&&H.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),y(z=>(z+1)%H.length);else if(I.key==="ArrowUp")I.preventDefault(),y(z=>(z-1+H.length)%H.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const z=H[k];z&&$(z.insert)}}},[n,R,H,k,$]),M=m.useCallback(async I=>{if(n||typeof d!="function")return!1;const z=await eR({files:I,body:e,images:N});return z?(t(z.body),d(z.images),queueMicrotask(()=>{const A=f.current;if(!A)return;A.focus();const O=z.body.length;A.setSelectionRange(O,O),b(O)}),!0):!1},[n,N,t,d,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[N.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:N.map((I,z)=>i.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[i.jsx("img",{src:I.dataUrl,alt:""}),i.jsxs("span",{children:["[",I.label||`image ${z+1}`,"]"]})]},I.id||z))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:F+`
128
- `}}),i.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?c:void 0,onChange:I=>{t(I.target.value),b(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:L,onPaste:I=>{const z=ZT(I);z.length!==0&&(I.preventDefault(),M(z).catch(()=>{}))},onDragOver:I=>{Ag(I).length>0&&I.preventDefault()},onDrop:I=>{const z=Ag(I);z.length!==0&&(I.preventDefault(),M(z).catch(()=>{}))},onScroll:B})]}),R&&H.length>0&&w?$r.createPortal(i.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:H.map((I,z)=>i.jsx("li",{role:"option","aria-selected":z===k,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===k?" af-composer-mention-item--active":""),onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>y(z),onClick:()=>$(I.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,C?i.jsx("p",{id:c,className:"af-body-ph-issues",role:"status",children:_.map(I=>I.message).join(" · ")}):null]})}const hR=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Qh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function h1({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Tn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),u=c=>r(n.filter((f,h)=>h!==c)),d=(c,f,h)=>{const g=n.map((b,k)=>{if(k!==c)return b;const y={...b,[f]:h};return f==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.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")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((c,f)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:c.type,onChange:h=>d(f,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.name,onChange:h=>d(f,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.default,onChange:h=>d(f,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.description||"",onChange:h=>d(f,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!c.required,onChange:h=>{o||d(f,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:c.showOnNode!==!1,onChange:h=>d(f,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>u(f),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:f}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function mR({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:u,allowEditRequiredPins:d=!1,error:p,ioSlots:c}){const{t:f}=Tn(),[h,g]=m.useState(!1),[b,k]=m.useState(!1),[y,w]=m.useState({status:"idle",message:""}),x=m.useCallback($=>{t(B=>B&&{...B,...$})},[t]),{cursorList:N,opencodeList:_,claudeCodeList:C,currentNotInLists:T}=m.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],B=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],L=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],M=new Set([...$,...B,...L].map(Qh)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,A=I&&!M.has(z)?I:"";return{cursorList:$,opencodeList:B,claudeCodeList:L,currentNotInLists:A}},[s,e==null?void 0:e.model]);if(!e)return null;const F=String(e.script??""),R=n==="tool_nodejs"||F.trim()!=="",H=typeof u=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(H){w({status:"running",message:f("flow:nodeProps.publishRunning")});try{const $=await u(e,n);w({status:"success",message:$!=null&&$.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):f("flow:nodeProps.publishSuccess")})}catch($){w({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!H||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?i.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:wl.includes(e.role)?e.role:f("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:o,children:wl.map($=>i.jsx("option",{value:$,children:$},$))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?T||$:""})(),onChange:$=>x({model:$.target.value}),disabled:o,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),T?i.jsxs("option",{value:T,children:[T,f("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?i.jsx("optgroup",{label:"Cursor",children:N.map($=>i.jsx("option",{value:Qh($),children:$},`c-${$}`))}):null,_.length>0?i.jsx("optgroup",{label:"OpenCode",children:_.map($=>i.jsx("option",{value:Qh($),children:$},`o-${$}`))}):null,C.length>0?i.jsx("optgroup",{label:"Claude Code",children:C.map($=>i.jsx("option",{value:`claude-code:${Qh($)}`,children:$},`cc-${$}`))}):null]})]}),i.jsx(h1,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:o,requiredReadonly:!d}),i.jsx(h1,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:o,requiredReadonly:!d}),R?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Jh,{value:F,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:c,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":f("flow:nodeProps.expandEdit"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Jh,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:c,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&k(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Jh,{value:F,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editUserPrompt"),onMouseDown:$=>{$.target===$.currentTarget&&g(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Jh,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null]})}function ek(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function u7(e){const t=ek(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function gR(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function m1({text:e}){const{t}=Tn(),n=e||"";return n.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(Bp,{children:n})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function g1({o:e}){var r;const{t}=Tn(),n=ek(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return i.jsxs("div",{className:"af-run-ctx-media",children:[i.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return i.jsx("pre",{className:"af-run-ctx-pre",children:gR(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(Bp,{children:s})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return i.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function y1(e){return u7(e)}function x1(e){var r;if(!e)return null;const t=ek(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?gR(String(n)):String(n)}function w1({text:e,title:t,copiedLabel:n}){const[r,s]=m.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:i.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const b1=2e4,yR="af:run-node-ctx-width";function Tm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function tl(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):tl(Tm())}function d7(){try{const e=localStorage.getItem(yR);if(e==null)return tl(Tm());const t=parseInt(e,10);return Number.isFinite(t)?tl(t):tl(Tm())}catch{return tl(Tm())}}async function v1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await o.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(l.error||"HTTP "+o.status);return l}function f7(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function p7({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:o}=Tn(),[a,l]=m.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[u,d]=m.useState(d7),p=m.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[c,f]=m.useState(!0),[h,g]=m.useState(""),[b,k]=m.useState([]),[y,w]=m.useState(null),[x,N]=m.useState(null),_=m.useRef(null),C=m.useRef(null),T=m.useRef(0),F=m.useRef(0);m.useLayoutEffect(()=>{const A=window.matchMedia("(max-width: 960px)"),O=()=>l(A.matches);return A.addEventListener("change",O),()=>A.removeEventListener("change",O)},[]),m.useEffect(()=>{function A(){d(O=>tl(O))}return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const R=m.useCallback(()=>{d(A=>{const O=tl(A);try{localStorage.setItem(yR,String(O))}catch{}return O})},[]),H=m.useCallback(A=>{if(a||A.button!==0)return;A.preventDefault();const O=A.currentTarget;p.current={active:!0,pointerId:A.pointerId,startX:A.clientX,startW:u},O.setPointerCapture(A.pointerId)},[a,u]),D=m.useCallback(A=>{const O=p.current;if(!O.active||A.pointerId!==O.pointerId)return;const E=O.startX-A.clientX;d(tl(O.startW+E))},[]),$=m.useCallback(A=>{const O=p.current;if(!(!O.active||A.pointerId!==O.pointerId)){O.active=!1;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}R()}},[R]),B=m.useCallback(()=>{const A=p.current;A.active&&(A.active=!1,R())},[R]),L=m.useCallback(A=>{const O=Array.isArray(A)?A:[];k(O),w(E=>E&&O.some(J=>J.execId===E)?E:O.length>0?O[O.length-1].execId:null)},[]),M=m.useCallback(()=>{if(!e||!t)return;const A=++T.current,O=new AbortController,E=window.setTimeout(()=>O.abort(),b1);(async()=>{try{const J=await v1(t,e,n,O.signal);if(A!==T.current)return;L(Array.isArray(J.rounds)?J.rounds:[])}catch{}finally{window.clearTimeout(E)}})()},[e,t,n,L]);m.useEffect(()=>{if(!e||!t){f(!1),g(""),k([]);return}const A=++F.current;f(!0),g(""),k([]),w(null);const O=new AbortController,E=window.setTimeout(()=>O.abort(),b1);return(async()=>{try{const J=await v1(t,e,n,O.signal);if(A!==F.current)return;L(Array.isArray(J.rounds)?J.rounds:[])}catch(J){if(A!==F.current)return;const Z=(J==null?void 0:J.name)==="AbortError"?"requestTimeout":J.message||String(J);g(Z)}finally{window.clearTimeout(E),A===F.current&&f(!1)}})(),()=>{O.abort(),F.current++,T.current++}},[e,t,n,L]),m.useEffect(()=>{r&&M()},[r,M]),m.useEffect(()=>{clearInterval(C.current);const A=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(A&&A.status==="running"))&&e&&t&&(C.current=setInterval(()=>M(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,M]),m.useEffect(()=>{_.current&&(_.current.scrollTop=0)},[y]);const I=b.find(A=>A.execId===y),z=a?void 0:{width:`${u}px`};return i.jsxs("aside",{className:"af-run-ctx-panel",style:z,"aria-label":o("flow:runContext.title"),children:[a?null:i.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:H,onPointerMove:D,onPointerUp:$,onPointerCancel:$,onLostPointerCapture:B}),i.jsxs("div",{className:"af-run-ctx-panel__main",children:[i.jsxs("div",{className:"af-run-ctx-head",children:[i.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),h&&i.jsx("div",{className:"af-run-ctx-error",children:f7(o,h)}),!c&&!h&&b.length===0&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+m7((I==null?void 0:I.status)||""),children:[i.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),i.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:A=>{const O=A.target.value;w(O==="latest"?"latest":Number(O))},children:[...b].reverse().map(A=>{const O=A.execId==="latest"?o("flow:runContext.latest"):`#${A.execId}`,E=g7(o,A.status),J=A.finishedAt?` · ${h7(A.finishedAt)}`:"";return i.jsx("option",{value:String(A.execId),children:`${O} · ${E}${J}`},A.execId)})})]}),I&&i.jsxs("div",{className:"af-run-ctx-body",ref:_,children:[I.inputs&&I.inputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((A,O)=>i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsx("div",{className:"af-run-ctx-slot-head",children:i.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot})}),i.jsx("pre",{className:"af-run-ctx-slot-text",children:A.value})]},`${A.slot}-${O}`))]}),I.prompt!=null&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("prompt"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(m1,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>N("output"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((A,O)=>{const E=y1(A),J=x1(A);return i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot}),E?i.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:E}):null,i.jsx(w1,{text:J,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(g1,{o:A})]},`${A.slot}-${O}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),x&&I&&i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:A=>{A.target===A.currentTarget&&N(null)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>N(null),"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&i.jsx(m1,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((A,O)=>{const E=y1(A),J=x1(A);return i.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot}),E?i.jsx("span",{className:"af-run-ctx-format-badge",children:E}):null,i.jsx(w1,{text:J,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(g1,{o:A})]},`${A.slot}-${O}`)})]})]})})]})}function h7(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function m7(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function g7(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function y7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:o,onCliInputsChange:a,onBackToEdit:l}){const{t:u}=Tn(),[d,p]=m.useState({}),[c,f]=m.useState(null),[h,g]=m.useState({}),[b,k]=m.useState(!0),[y,w]=m.useState(!1),[x,N]=m.useState(""),[_,C]=m.useState(!1),[T,F]=m.useState(null),R=m.useRef(null),H=m.useRef(!0),D=m.useRef({});m.useMemo(()=>{var E,J,Z;const O={};for(const K of r){const oe=(Z=(J=(E=K.data)==null?void 0:E.outputs)==null?void 0:J[0])==null?void 0:Z.default;oe!=null&&oe!==""&&(O[K.id]=String(oe))}return D.current=O,O},[r]);const $=m.useMemo(()=>{var E;const O={};for(const J of o){if(!((E=J.data)!=null&&E.inputs))continue;const Z=J.data.inputs;for(let K=0;K<Z.length;K++){const oe=Z[K];if(!(oe!=null&&oe.name))continue;const de=s.find(we=>we.target===J.id&&we.targetHandle===`input-${K}`);if(!(de!=null&&de.source))continue;r.find(we=>we.id===de.source)&&(O[de.source]=oe.name)}}return O},[o,s,r]);m.useEffect(()=>(H.current=!0,()=>{H.current=!1}),[]),m.useEffect(()=>{if(!e){k(!1);return}k(!0);const O=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&O.set("archived","1"),fetch(`/api/flow/run-config?${O.toString()}`).then(E=>{if(!E.ok)throw new Error(`HTTP ${E.status}`);return E.json()}).then(E=>{var Z;if(!H.current)return;p(E.presets||{}),f(E.activePreset||null);const J=E.activePreset&&((Z=E.presets)!=null&&Z[E.activePreset])?E.presets[E.activePreset]:{};g({...D.current,...J}),k(!1)}).catch(()=>{H.current&&(g(D.current),k(!1))})},[e,t,n]),m.useEffect(()=>{var E;if(!a)return;const O={};for(const[J,Z]of Object.entries(h)){const K=$[J];if(!K)continue;const oe=r.find(he=>he.id===J);if(!oe)continue;(((E=oe.data)==null?void 0:E.definitionId)||"").startsWith("provide_file")?O[K]={type:"file",path:Z}:O[K]={type:"str",value:Z}}a(O)},[h,$,r,a]);const B=m.useCallback((O,E)=>{g(J=>({...J,[O]:E}))},[]),L=m.useCallback(O=>{O!==c&&(f(O),O&&d[O]?g({...D.current,...d[O]}):g(D.current))},[c,d]),M=m.useCallback(async()=>{if(x.trim()){w(!0);try{const O={...d,[x.trim()]:h},E={flowId:e,flowSource:t,archived:n,presets:O,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&(p(O),f(x.trim()),N(""),C(!1))}finally{w(!1)}}},[e,t,n,d,h,x]),I=m.useCallback(async()=>{if(c){w(!0);try{const O={...d};delete O[c];const E=Object.keys(O)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:E})})).ok&&(p(O),f(E),E&&O[E]?g({...D.current,...O[E]}):g(D.current))}finally{w(!1)}}},[e,t,n,d,c]),z=m.useCallback(async()=>{if(c){w(!0);try{const O={...d,[c]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:c})})).ok&&p(O)}finally{w(!1)}}},[e,t,n,d,c,h]),A=Object.keys(d);return A.length>0,b?i.jsx("aside",{className:"af-run-config-panel",children:i.jsx("div",{className:"af-run-config-loading",children:u("common.loading")})}):i.jsxs("aside",{className:"af-run-config-panel",children:[i.jsxs("div",{className:"af-run-config-preset",children:[i.jsx("label",{className:"af-run-config-preset-label",children:u("flow:runConfig.preset")}),i.jsxs("div",{className:"af-run-config-preset-row",children:[i.jsxs("select",{className:"af-run-config-preset-select",value:c||"",onChange:O=>L(O.target.value||null),disabled:y,children:[i.jsx("option",{value:"",children:u("flow:runConfig.default")}),A.map(O=>i.jsx("option",{value:O,children:O},O))]}),i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:y,title:u("flow:runConfig.newPreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),c&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:y,title:u("flow:runConfig.savePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),c&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:u("flow:runConfig.deletePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),_&&i.jsxs("div",{className:"af-run-config-save-dialog",children:[i.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:u("flow:runConfig.presetNamePlaceholder"),value:x,onChange:O=>N(O.target.value),disabled:y}),i.jsxs("div",{className:"af-run-config-save-actions",children:[i.jsx("button",{type:"button",className:"af-btn-primary",onClick:M,disabled:y||!x.trim(),children:u(y?"common.saving":"common.save")}),i.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),N("")},disabled:y,children:u("common.cancel")})]})]}),i.jsxs("div",{className:"af-run-config-inputs",children:[i.jsx("div",{className:"af-run-config-inputs-header",children:u("flow:runConfig.inputParams")}),r.length===0?i.jsx("div",{className:"af-run-config-empty",children:u("flow:runConfig.noProvideNodes")}):i.jsx("div",{className:"af-run-config-input-list",children:r.map(O=>{var we,ue;const E=((we=O.data)==null?void 0:we.definitionId)||"",J=E.startsWith("provide_file"),Z=E==="provide_bool",K=((ue=O.data)==null?void 0:ue.label)||O.id,oe=O.id,de=h[oe]||"",he=["true","1","yes","on"].includes(String(de).trim().toLowerCase());return i.jsxs("div",{className:"af-run-config-input-item",children:[i.jsxs("div",{className:"af-run-config-input-head",children:[i.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(J?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:J?"description":Z?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-config-input-label",children:K}),Z?null:i.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>F({instanceId:oe,label:K,content:de}),"aria-label":u("flow:runConfig.expandInput"),title:u("flow:runConfig.expandInput"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx("div",{className:"af-run-config-input-id",children:oe}),Z?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(he?" af-run-config-bool-toggle--true":""),onClick:()=>B(oe,he?"false":"true"),"aria-pressed":he,children:he?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-config-input-field",value:de,onChange:Ne=>B(oe,Ne.target.value),placeholder:u(J?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},oe)})})]}),T&&$r.createPortal(i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>F(null),"aria-label":u("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:R,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!R.current||(B(T.instanceId,R.current.value),F(null))},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),u("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>F(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),u("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const xR={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},x7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function w7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function b7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function v7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function k1(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(xR))if(r.includes(e))return n;return"other"}function k7({event:e,defaultExpanded:t}){const[n,r]=m.useState(!!t),s=x7[e.tag]||"#a8a8a8",o=e.payload,a=o&&typeof o=="object",l=a?typeof o.text=="string"?o.text:"":String(o||""),u=a?o.meta:null,d=m.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(o).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const g=o[h];return g==null?`${h}:null`:typeof g=="object"?`${h}:{…}`:`${h}:${String(g).slice(0,30)}`}).join(" "):"",[o,l,a]),p=m.useCallback(c=>{c.stopPropagation();const f=a?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(f)}catch{}},[o,a]);return i.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(c=>!c),children:[i.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[i.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:b7(e.ts)}),i.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),i.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&i.jsx("button",{type:"button",onClick:p,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&i.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[u&&Object.keys(u).length>0&&i.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(u,null,2)}),l?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(o,null,2)}):null]})]})}function S7({open:e,onClose:t,flowId:n}){var F;const[r,s]=m.useState([]),[o,a]=m.useState(!1),[l,u]=m.useState(null),[d,p]=m.useState(null),[c,f]=m.useState(!1),[h,g]=m.useState(!0),[b,k]=m.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,w]=m.useState(""),x=m.useRef(null),N=m.useCallback(async()=>{a(!0);try{const R=h&&n?`?flowId=${encodeURIComponent(n)}`:"",D=await(await fetch(`/api/composer-logs${R}`)).json();s(Array.isArray(D.sessions)?D.sessions:[])}catch{s([])}finally{a(!1)}},[n,h]),_=m.useCallback(async R=>{if(!R){p(null);return}f(!0);try{const D=await(await fetch(`/api/composer-logs/${encodeURIComponent(R)}`)).json();p(D)}catch{p(null)}finally{f(!1)}},[]);m.useEffect(()=>{e&&N()},[e,N]),m.useEffect(()=>{if(!(!e||!l))return _(l),x.current=setInterval(()=>_(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,_]);const C=m.useMemo(()=>{const R=(d==null?void 0:d.events)||[],H=y.trim().toLowerCase();return R.filter(D=>{const $=k1(D.tag,D.payload);return!b[$]&&$!=="other"?!1:H?[D.tag,JSON.stringify(D.payload||"")].join(" ").toLowerCase().includes(H):!0})},[d,b,y]),T=m.useMemo(()=>{const R=(d==null?void 0:d.events)||[],H={};for(const D of R){const $=k1(D.tag,D.payload);H[$]=(H[$]||0)+1}return H},[d]);return e?i.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[i.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),i.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),i.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:h,onChange:R=>g(R.target.checked),disabled:!n}),"仅显示当前 flow"]}),i.jsx("button",{type:"button",onClick:N,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(R=>{const H=l===R.sessionId;return i.jsxs("div",{onClick:()=>u(R.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:H?"rgba(124,77,255,0.18)":"transparent",borderLeft:H?"3px solid #7c4dff":"3px solid transparent"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:v7(R.mtime)}),i.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:R.flowId||"(no flow)"}),R.promptPreview&&i.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:R.promptPreview}),i.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[w7(R.size)," · ",R.model||"default"]})]},R.sessionId)})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(xR).map(R=>i.jsxs("button",{type:"button",onClick:()=>k(H=>({...H,[R]:!H[R]})),style:{background:b[R]?"rgba(124,77,255,0.25)":"transparent",color:b[R]?"#e8deff":"#6a6a6a",border:`1px solid ${b[R]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[R," ",T[R]!=null?`(${T[R]})`:""]},R)),i.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:R=>w(R.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),c&&!d&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&i.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((F=d.events)==null?void 0:F.length)||0," total)"]}),C.map((R,H)=>i.jsx(k7,{event:R,defaultExpanded:R.tag==="error"},`${R.ts}_${H}`))]})]})]})]}):null}const N7="0.1.71";function S1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Jx(e,t){return t==="running"?S1(e):e==null||!Number.isFinite(e)||e<=0?"--":S1(e)}const wR=m.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function j7(e){var w,x,N,_,C,T,F,R,H,D,$;const{setNodes:t}=El(),n=A0(),{modelLists:r,onModelChange:s}=m.useContext(wR),o=m.useRef(null),a=!!((w=e.data)!=null&&w.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,u=((N=e.data)==null?void 0:N.definitionId)==="agent_subAgent"&&!((_=e.data)!=null&&_.isRunMode)&&!a,d=m.useCallback(B=>{const L=()=>n(B);window.requestAnimationFrame(L),window.setTimeout(L,80)},[n]),p=m.useCallback((B,L)=>{const M=I1(L);M&&(t(I=>I.map(z=>{var E,J,Z,K,oe,de;if(z.id!==B)return z;const A=Number(((J=(E=z.data)==null?void 0:E.displaySize)==null?void 0:J.width)||z.width||((Z=z.measured)==null?void 0:Z.width)||0),O=Number(((oe=(K=z.data)==null?void 0:K.displaySize)==null?void 0:oe.height)||z.height||((de=z.measured)==null?void 0:de.height)||0);return Math.abs(A-M.width)<2&&Math.abs(O-M.height)<2?z:{...z,width:M.width,height:M.height,data:{...z.data,displaySize:M}}})),d(B))},[d,t]),c=m.useCallback(B=>{if(a)return;const L=o.current;if(!L)return;const M=L.getBoundingClientRect();p(B,{width:Math.max(M.width,L.scrollWidth),height:Math.max(M.height,L.scrollHeight)})},[p,a]),f=m.useCallback(B=>{var oe,de,he,we,ue,Ne;if(!u)return;B.preventDefault(),B.stopPropagation();const L=o.current,M=L==null?void 0:L.getBoundingClientRect(),I=Number(((de=(oe=e.data)==null?void 0:oe.displaySize)==null?void 0:de.width)||e.width||((he=e.measured)==null?void 0:he.width)||(M==null?void 0:M.width)||SR),z=Number(((ue=(we=e.data)==null?void 0:we.displaySize)==null?void 0:ue.height)||e.height||((Ne=e.measured)==null?void 0:Ne.height)||(M==null?void 0:M.height)||tv),A=B.clientX,O=B.clientY,E=e.id;let J=0;const Z=le=>{const ce=I1({width:I+le.clientX-A,height:z+le.clientY-O});ce&&(window.cancelAnimationFrame(J),J=window.requestAnimationFrame(()=>p(E,ce)))},K=()=>{window.cancelAnimationFrame(J),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K),d(E)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",K,{once:!0}),window.addEventListener("pointercancel",K,{once:!0})},[p,(T=(C=e.data)==null?void 0:C.displaySize)==null?void 0:T.height,(R=(F=e.data)==null?void 0:F.displaySize)==null?void 0:R.width,e.height,e.id,(H=e.measured)==null?void 0:H.height,(D=e.measured)==null?void 0:D.width,e.width,d,u]),h=m.useCallback(B=>{t(L=>L.filter(M=>M.id!==B))},[t]),g=m.useCallback(()=>{var I,z,A,O,E,J,Z,K;const B=((I=e.data)==null?void 0:I.definitionId)||"",L=((z=e.data)==null?void 0:z.label)||e.id,M=((E=(O=(A=e.data)==null?void 0:A.outputs)==null?void 0:O[0])==null?void 0:E.value)||((K=(Z=(J=e.data)==null?void 0:J.outputs)==null?void 0:Z[0])==null?void 0:K.default)||"";window.__provideEditContent={instanceId:e.id,label:L,definitionId:B,content:M},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=m.useCallback((B,L)=>{t(M=>M.map(I=>{var A;if(I.id!==B)return I;const z=Array.isArray((A=I.data)==null?void 0:A.outputs)&&I.data.outputs.length?I.data.outputs.map((O,E)=>E===0?{...O,default:L,value:L}:O):[{type:"bool",name:"value",default:L,value:L}];return{...I,data:{...I.data,body:"",outputs:z}}}))},[t]),k=m.useCallback((B,L)=>{t(M=>M.map(I=>I.id===B?{...I,data:{...I.data,body:L}}:I))},[t]),y=m.useCallback((B,L)=>{t(M=>M.map(I=>I.id===B?{...I,data:{...I.data,images:Fs(L)}}:I))},[t]);return i.jsxs("div",{ref:o,className:"af-flow-node-shell"+(u?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[i.jsx(iR,{...e,data:{...e.data,onNodeContentResize:c},deleteNode:h,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:k,onNodeImagesChange:y,modelLists:r,onModelChange:s}),u?i.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":(($=e.data)==null?void 0:$.resizeLabel)||"Resize node",role:"separator",onPointerDown:f}):null]})}const C7={[Nc]:j7},wf=["CONTROL","TOOL","PROVIDE","AGENT"],E7=1200,N1="af-flow-node--sync-flash",j1="af-flow-edge--sync-flash";function C1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function E1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function tk(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function _7(e){const t=tk(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Zh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function bR(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function vR(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Qx(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 _1(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(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function P1(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 P7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function A7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function kR(e,t,n,r,s){const o=_7(e),a={id:t,type:Nc,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:o,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return kp(a,r,s)}const SR=320,I7=220,T7=1600,tv=104,R7=900;function A1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function I1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:A1(t,I7,T7)||SR,height:A1(n,tv,R7)||tv}}function M7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,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 T1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),o=s.get(n),a=s.get(r),l=od(o,e.sourceHandle||"output-0","source"),u=od(a,e.targetHandle||"input-0","target");return!l||!u?!1:bl(l,u)}function L7(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 o=t.find(l=>l.id===n),a=od(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:sR(a)}:null}function O7(e,t,n){var a;const r=kR(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",o=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<o.length;l+=1){const u=o[l];if(n.handleType==="source"?bl(n.slot,u):bl(u,n.slot))return{slot:u,slotIndex:l,hydrated:r}}return null}function $7(e,t){return t?e.map((n,r)=>{const s=O7(n,e,t);if(!s)return null;const o=tk(n);return{def:n,order:r,category:o,categoryRank:wf.indexOf(o),slot:s.slot,slotIndex:s.slotIndex,displayLabel:bR(s.hydrated.data||n),description:vR(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const D7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function F7(e){const t=new Set,n=[];let r;const s=new RegExp(D7.source,"g");for(;(r=s.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function R1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function ia(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function em(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const o=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],u=o.map(ia),d=a.map(ia);return l.map(ia).includes(s)&&!u.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!u.includes(s)?`opencode:${s}`:s}function z7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Zx(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function H7({steps:e}){const{t}=Tn();return!e||e.length===0?null:i.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
- `),a=n.status||"pending";return i.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:o,children:[i.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),i.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?i.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?i.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?i.jsx("span",{className:"af-composer-step-chip-model",children:z7(s)}):null]}):null})]},n.index)})})}function B7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function W7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",o=t[t.length-1];o&&o.kind===s?o.text+=s==="error"||s==="result"?`
130
- ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function V7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function K7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function M1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:o}=Tn(),a=m.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return m.useEffect(()=>{if(!s||!a.current)return;const u=a.current;requestAnimationFrame(()=>{u.scrollTop=u.scrollHeight})},[e,t,s]),i.jsxs("div",{ref:a,className:l,children:[e.map((u,d)=>u.type==="user"?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:o("flow:composer.yourQuestion")}),i.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`composer-u-${d}-${u.text.slice(0,48)}`):i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(L1,{segments:u.segments,running:!1})},`composer-a-${d}`)),i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(L1,{segments:t,running:n})})]})}function L1({segments:e,running:t=!1}){const{t:n}=Tn(),r=e.filter(c=>c.kind==="assistant").map(c=>c.text).join(""),s=e.filter(c=>c.kind==="result").map(c=>c.text).join(""),o=B7(r,s),a=e.filter(c=>c.kind==="error").map(c=>c.text).join(`
131
- `),l=e.filter(c=>c.kind!=="error"),u=o?l.filter(c=>c.kind!=="result"):l,d=W7(u),p=!!(d.length>0||a);return i.jsxs(i.Fragment,{children:[d.map((c,f)=>i.jsxs("section",{className:K7(c.kind),children:[i.jsx("div",{className:"af-composer-ai-block-label",children:V7(c.kind,n)}),i.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`${c.kind}-${f}`)),t&&!p?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),i.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),i.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function U7({fitViewEpoch:e}){const{fitView:t}=El(),n=m.useRef(t);return n.current=t,m.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function q7({onReady:e}){const t=A0();return m.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function O1(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function $1(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)}}const Rm=1500,D1=500,Y7=262144,G7=2e3;function ew(e){return typeof e!="string"?"":e.length<=G7?e:`[log line truncated, ${e.length} chars]`}const X7=Rm;function J7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const o=JSON.parse(s);return o&&o.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${o.instanceId||""}${o.label?` · ${o.label}`:""} 开始`}:o&&o.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${o.instanceId||""} 完成${o.elapsed?` (${o.elapsed})`:""}`}:o&&o.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${o.instanceId||""} 失败${o.error?`: ${o.error}`:""}`}:o&&o.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${o.uuid||""}`}:{ts:n,type:"info",text:ew(s)}}catch{return{ts:n,type:"info",text:ew(s)}}return{ts:n,type:"log",text:ew(`[${r}] ${s}`)}}function F1(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<X7;r--){const s=n[r];if(!s)continue;const o=J7(s);o&&t.push(o)}return t.reverse(),t}function Q7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const o=e[s],a=t[s];if(!a)return!1;if(o!==a&&(o.status!==a.status||(o.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function Z7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function eq({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:o,onConnect:a,onConnectStart:l,onConnectEnd:u,isValidConnection:d,onNodesDelete:p,onNodeClick:c,onNodeDoubleClick:f,onEdgeClick:h,onFlowInit:g,onDrop:b,onDragOver:k,hideMinimapAndControls:y,bottomSlot:w}){const{t:x}=Tn(),N=!s,_=N||t==="pan"?!0:[1,2],C=N?!1:t==="select",T="af-flow-canvas"+(N?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),F=m.useCallback(()=>{},[]),R=m.useMemo(()=>{const H=new Map(n.map(M=>[M.id,M])),D=new Set(n.filter(M=>M.selected).map(M=>M.id)),$=D.size>0,B=(M,I)=>{const z=/^#([0-9a-f]{6})$/i.exec(M);if(!z)return M;const A=parseInt(z[1],16);return`rgba(${A>>16&255}, ${A>>8&255}, ${A&255}, ${I})`},L="#ff5169";return r.map(M=>{var ce,xe,Se,Ke;const I=H.get(M.source),z=H.get(M.target),A=/^output-(\d+)$/.exec(M.sourceHandle||""),O=/^input-(\d+)$/.exec(M.targetHandle||""),E=I&&A?(xe=(ce=I.data)==null?void 0:ce.outputs)==null?void 0:xe[parseInt(A[1],10)]:null,J=z&&O?(Ke=(Se=z.data)==null?void 0:Se.inputs)==null?void 0:Ke[parseInt(O[1],10)]:null,Z=E!=null&&E.type?Fn(E.type):null,K=J!=null&&J.type?Fn(J.type):null,oe=Z&&K&&Z!==K,de=$&&(D.has(M.source)||D.has(M.target)),he=M.style||{};if(oe){const et=M.selected?.95:de?.85:.78,We=B(L,et);return{...M,className:((M.className||"")+" af-flow-edge--type-mismatch"+(de?" af-flow-edge--adjacent":"")).trim(),style:{...he,stroke:We,strokeWidth:de?2.75:2.5,strokeDasharray:"6 4"},markerEnd:M.markerEnd&&typeof M.markerEnd=="object"?{...M.markerEnd,color:We}:{type:ks.ArrowClosed,color:We}}}const we=Z||K;if(!we)return de?{...M,className:((M.className||"")+" af-flow-edge--adjacent").trim(),style:{...he,strokeWidth:2.5}}:M;const ue=de||M.selected?.7:.38,Ne=B(we,ue),le=de?2.5:he.strokeWidth??2;return{...M,className:((M.className||"")+(de?" af-flow-edge--adjacent":"")).trim(),style:{...he,stroke:Ne,strokeWidth:le},markerEnd:M.markerEnd&&typeof M.markerEnd=="object"?{...M.markerEnd,color:Ne}:{type:ks.ArrowClosed,color:Ne}}})},[n,r]);return i.jsxs(P0,{className:T,nodes:n,edges:R,onNodesChange:s||F,onEdgesChange:o||F,onConnect:N?void 0:a,onConnectStart:N?void 0:l,onConnectEnd:N?void 0:u,isValidConnection:N?void 0:d,onNodesDelete:N?void 0:p,onNodeClick:c,onNodeDoubleClick:N?void 0:f,onEdgeClick:N?void 0:h,onInit:g,onDrop:N?void 0:b,onDragOver:N?void 0:k,nodeTypes:C7,selectionOnDrag:C,panOnDrag:_,nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N,edgesFocusable:!N,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[i.jsx(I0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),i.jsx(sd,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:i.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:i.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:i.jsx(aB,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:H=>{var $;const D=((($=H.data)==null?void 0:$.schemaType)??"agent").toLowerCase();return D==="control"?"rgba(237, 108, 2, 0.85)":D==="provide"?"rgba(0, 228, 117, 0.35)":D==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),i.jsx("div",{className:"af-flow-bottom-unified__center",children:w}),y?null:i.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:i.jsx(Y4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&i.jsx(sd,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:H,color:D})=>i.jsxs("span",{className:"af-pin-legend__item",children:[i.jsx("span",{className:"af-pin-legend__dot",style:{background:D}}),i.jsx("span",{className:"af-pin-legend__label",children:H})]},H))}),i.jsx(U7,{fitViewEpoch:e}),!N&&n.length===0?i.jsxs("div",{className:"af-flow-empty-hint",children:[i.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),i.jsx("p",{className:"af-flow-empty-hint-text",children:x("flow:emptyCanvas.composerHint")}),i.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:x("flow:emptyCanvas.composerSub")}})]}):null]})}function z1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams(window.location.search),n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&n.set("flowArchived","1"),t.get("panel")==="settings"&&n.set("panel","settings"),window.history.replaceState({},"","/flow?"+n.toString())}function tq(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function yi(e){return e==="builtin"||e==="admin"}function ou(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function nq(e){var r,s,o,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const NR="af:run-console-height",zf=230,af={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},tm={};function Mm(e){if(!Number.isFinite(e))return zf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function rq(){try{const e=localStorage.getItem(NR);if(e==null)return zf;const t=parseInt(e,10);return Number.isFinite(t)?Mm(t):zf}catch{return zf}}function sq(){var Pk,Ak;const{t:e,i18n:t}=Tn(),{navigate:n,path:r}=Bo(),s=m.useRef(null),o=m.useRef(new Map),a=m.useCallback(v=>{s.current=typeof v=="function"?v:null},[]),[l,u]=m.useState([]),[d,p]=m.useState(""),[c,f]=m.useState(null),[h,g]=m.useState(0),[b,k]=m.useState(""),[y,w]=m.useState(""),[x,N]=m.useState(""),[_,C]=m.useState(""),[T,F]=m.useState(!1),[R,H]=m.useState(""),[D,$]=m.useState(!1),[B,L]=m.useState(""),[M,I]=m.useState(!1),[z,A]=m.useState(!1),[O,E]=m.useState(!1),[J,Z]=m.useState(null),[K,oe]=m.useState(!1),[de,he]=m.useState(!1),we=m.useRef(!1),[ue,Ne]=m.useState([]),[le,ce]=m.useState(""),[xe,Se]=m.useState("nodes"),Ke=m.useRef(null),[et,We]=m.useState([]),[ut,Ve]=m.useState(!1),[xt,bt]=m.useState(""),[Jn,Ut]=m.useState(!1),[nn,rn]=m.useState({name:"",id:"",description:""}),[hn,fe]=m.useState(!1),[je,He]=m.useState(""),[ot,at]=m.useState(""),Tt=m.useRef(null),[mt,dn]=m.useState([]),[sn,Rn]=m.useState(!1),[on,Mn]=m.useState(""),[Ln,zr]=m.useState(""),[be,$e]=m.useState(null),[ft,St]=m.useState(null),[mn,es]=m.useState([]),[Cs,_r]=m.useState(""),[Hr,hr]=m.useState(!1),kr=m.useCallback(v=>{Tt.current&&window.clearTimeout(Tt.current),at(v),Tt.current=window.setTimeout(()=>{at(""),Tt.current=null},3800)},[]),hs=m.useCallback(v=>{const j=String(v||"").trim();if(!j)return;const W=()=>{var Y;return(Y=s.current)==null?void 0:Y.call(s,j)};window.requestAnimationFrame(W),window.setTimeout(W,80)},[]);m.useEffect(()=>()=>{Tt.current&&window.clearTimeout(Tt.current)},[]);const[Br,Ei]=m.useState(!1),[Qn,Wr]=m.useState({files:[]}),[ae,Ce]=m.useState(!1),[tt,De]=m.useState(!0);m.useEffect(()=>{let v=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(Y=>{v||De(Y.ok)}).catch(()=>{v||De(!1)})};j();const W=window.setInterval(j,5e3);return()=>{v=!0,window.clearInterval(W)}},[]),m.useEffect(()=>{let v=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{v||Na(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{v=!0}},[]),m.useEffect(()=>{c!=null&&c.id&&jP(c.id,c.source??"user","pipeline",!!c.archived)},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived]);const[Ae,Nt]=m.useState("edit"),[mr,it]=m.useState([]),lr=m.useRef(0),[Zn,Vr]=m.useState(new Set),[ms,Ie]=m.useState({}),[Us,pt]=m.useState(null),[xn,an]=m.useState(0),[cr,nt]=m.useState(!1),[Kr,Na]=m.useState(!1),[Ko,ao]=m.useState(!1),[Es,Uo]=m.useState(rq),ts=m.useRef({active:!1,pointerId:-1,startY:0,startH:zf}),[Nn,sr]=m.useState(null),[lo,fi]=m.useState(null),[qs,ir]=m.useState({}),Ys=m.useRef(qs);m.useEffect(()=>{Ys.current=qs},[qs]);const[U,ge]=m.useState(!1),[ze,Le]=m.useState(!1),[rt,ln]=m.useState({}),[Rt,Wn]=m.useState({}),[Pr,_i]=m.useState(null),[On,ja]=m.useState(af),[Pl,Tc]=m.useState(!1),[Gs,kd]=m.useState(!1),[Al,Il]=m.useState(""),[Rc,co]=m.useState(""),[cn,ns]=m.useState(tm),[Vn,Mc]=m.useState(null),qo=m.useRef(0),Pi=m.useRef(null),Ur=m.useRef(null),Tl=m.useRef(!0),Ai=m.useRef(!1),[gr,Yo]=m.useState(null),[Rl,Ca]=m.useState(null),[Sd,Ea]=m.useState(!1),[Ii,Ti]=m.useState(""),[Ml,_a]=m.useState(!1),Nd=m.useRef(null),[_s,Ll]=m.useState(null),[jd,Go]=m.useState(!1),[Lc,rs]=m.useState(null),[Ol,Ri]=m.useState(!1),[Mi,Oc]=m.useState(null),$c=m.useRef(null),[Sr,pi]=m.useState(""),[Ps,Pa]=m.useState(0),[gs,Xo]=m.useState(0),[uo,Cd]=m.useState("pan"),[_e,ys]=m.useState(!1),[Dc,Ed]=m.useState(!1),fo=m.useRef(null),Fc=m.useRef(null),$l=m.useRef(null),[ur,zc]=m.useState(0),[qe,_d]=m.useState(null),[Oy,Hc]=m.useState(""),[Et,Gp]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[po,Jo]=m.useState(""),[Pd,$y]=m.useState(""),[hi,Xp]=m.useState([]),[ho,mo]=m.useState([]),[Dl,Fl]=m.useState(!1),[Bc,Jp]=m.useState([]),[Ad,Qp]=m.useState(!1),[Zp,eh]=m.useState(()=>new Set),[Ar,Aa]=m.useState(!1),Wc=m.useRef(null),Id=m.useRef(null),[th,nh]=m.useState({}),zl=m.useCallback(v=>{if(!v)return null;const j=v.id,W=v.source??"user",Y=v.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${W}${Y?":"+Y:""}`,activeKey:`af:composer-active-session:${j}:${W}${Y?":"+Y:""}`}},[]),Td=m.useCallback(v=>{if(!v)return"";const j=v.id,W=v.source??"user",Y=v.archived?"archived":"";return`af:composer-skills:pipeline:${j}:${W}${Y?":"+Y:""}`},[]),As=m.useCallback(v=>{const j=zl(v);if(!j)return{sessions:[],activeSessionId:null};try{const W=localStorage.getItem(j.sessionsKey);if(!W)return{sessions:[],activeSessionId:null};const Y=JSON.parse(W);if(!Array.isArray(Y))return{sessions:[],activeSessionId:null};const G=Y.filter(ne=>ne&&typeof ne.id=="string").map(ne=>({...ne,running:!1,statusLine:ne.running?e("flow:composer.pageRefreshReset"):ne.statusLine,steps:[]}));let X=null;try{X=localStorage.getItem(j.activeKey),X&&!G.some(ne=>ne.id===X)&&(X=null)}catch{X=null}return{sessions:G,activeSessionId:X}}catch{return{sessions:[],activeSessionId:null}}},[zl]),Ia=m.useCallback((v,j,W)=>{const Y=zl(v);if(Y)try{localStorage.setItem(Y.sessionsKey,JSON.stringify(j)),W?localStorage.setItem(Y.activeKey,W):localStorage.removeItem(Y.activeKey)}catch{}},[zl]),go=m.useRef(0),yo=m.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Ir,st]=m.useState([]),[_t,mi]=m.useState(null),xo=m.useMemo(()=>Td(c),[Td,c]),[Vc,rh]=m.useState(""),Kc=m.useMemo(()=>{if(!c)return null;const v=c.id,j=c.source??"user",W=c.archived?"archived":"";return`${v}:${j}${W?":"+W:""}`},[c]),Rd=m.useRef(!1);m.useEffect(()=>{if(!Kc){st([]),mi(null),yo.current={sessions:[],activeSessionId:null,flowKey:null};return}const v=yo.current;if(v.flowKey===Kc)return;v.flowKey=Kc,Rd.current&&v.sessions.length>0&&Ia(c,v.sessions,v.activeSessionId);const{sessions:j,activeSessionId:W}=As(c);if(j.length===0){const Y=`session-1-${Date.now()}`,G={id:Y,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};v.sessions=[G],v.activeSessionId=Y,st([G]),mi(Y)}else{const Y=j[j.length-1];if(Y&&(!Y.thread||Y.thread.length===0))go.current=Zx(j),v.sessions=j,v.activeSessionId=Y.id,st(j),mi(Y.id);else{const X=Zx(j)+1;go.current=X;const ne=`session-${X}-${Date.now()}`,se={id:ne,label:e("flow:composer.conversationLabel",{n:X}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},ye=[...j,se];v.sessions=ye,v.activeSessionId=ne,st(ye),mi(ne)}}Rd.current=!0},[Kc,c,As,Ia]);const er=m.useMemo(()=>Ir.find(v=>v.id===_t)||null,[Ir,_t]),Kn=(er==null?void 0:er.running)??!1,Ta=(er==null?void 0:er.statusLine)??"",Qo=(er==null?void 0:er.segments)??[],Li=(er==null?void 0:er.thread)??[],Ra=(er==null?void 0:er.steps)??[];er==null||er.outputDismissed;const Mt=(er==null?void 0:er.phaseContext)??null,sh=m.useRef([]),[Hl,Oi]=m.useState(!1),Un=m.useRef(null),Bl=m.useRef(null);m.useEffect(()=>{const v=Bl.current;v&&requestAnimationFrame(()=>{v.scrollTop=v.scrollHeight})},[Li,Qo]);const Uc=m.useRef(null),Ma=m.useRef(!1),Md=m.useRef(null),ih=m.useCallback(v=>{const j=++go.current,W=`session-${j}-${Date.now()}`,Y={id:W,label:v||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return st(G=>[...G,Y]),mi(W),W},[]);m.useEffect(()=>{!c||!Rd.current||(yo.current.sessions=Ir,yo.current.activeSessionId=_t,Ia(c,Ir,_t))},[Ir,_t,c,Ia]),m.useEffect(()=>{go.current=Math.max(go.current,Zx(Ir))},[Ir]);const qc=m.useCallback(v=>{var j;Uc.current===v&&((j=Un.current)==null||j.abort()),st(W=>{const Y=W.filter(X=>X.id!==v);if(W.some((X,ne)=>X.id===v&&W.findIndex(se=>se.id===_t)===ne)||_t===v){const X=Y;X.length>0?mi(X[X.length-1].id):setTimeout(()=>{go.current=0;const ne=++go.current,se=`session-${ne}-${Date.now()}`,ye={id:se,label:e("flow:composer.conversationLabel",{n:ne}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};st(ve=>[...ve,ye]),mi(se)},0)}return Y})},[_t]),Nr=m.useCallback(v=>{st(j=>{const W=j.findIndex(X=>X.id===_t);if(W<0)return j;const Y={...j[W]};v(Y);const G=[...j];return G[W]=Y,G})},[_t]),Ld=m.useCallback(v=>{Nr(j=>{j.running=v})},[Nr]),Xs=m.useCallback(v=>{Nr(j=>{j.statusLine=v})},[Nr]),Js=m.useCallback(v=>{Nr(j=>{typeof v=="function"?j.segments=v(j.segments):j.segments=v})},[Nr]),Od=m.useCallback(v=>{Nr(j=>{typeof v=="function"?j.thread=v(j.thread):j.thread=v})},[Nr]),wo=m.useCallback(v=>{Nr(j=>{typeof v=="function"?j.steps=v(j.steps):j.steps=v})},[Nr]),$d=m.useCallback(v=>{Nr(j=>{j.outputDismissed=v})},[Nr]),Wl=m.useCallback(v=>{Nr(j=>{j.phaseContext=typeof v=="function"?v(j.phaseContext):v})},[Nr]),Dd=m.useCallback(v=>{mi(v),st(j=>{const W=j.findIndex(G=>G.id===v);if(W<0||!j[W].outputDismissed)return j;const Y=[...j];return Y[W]={...j[W],outputDismissed:!1},Y})},[]);m.useEffect(()=>{sh.current=Qo},[Qo]);const yr=m.useRef({}),La=m.useRef(!1),$i=m.useRef(null),Yc=m.useRef(null),bo=m.useRef(null),Oa=m.useRef(!1),Gc=m.useRef(0),Vl=m.useRef(""),[Dt,wt,Dy]=vI([]),[wn,Gt,Xc]=kI([]),dr=m.useRef(Dt),Zo=m.useRef(wn),oh=m.useRef(null),Fd=m.useRef(null),ah=m.useRef(null),Jc=m.useRef(null),[ss,gi]=m.useState(null),lh=m.useCallback(v=>{var j;yr.current=(j=v==null?void 0:v.extra)!=null&&j.instances&&typeof v.extra.instances=="object"?v.extra.instances:{},wt(Array.isArray(v==null?void 0:v.nodes)?v.nodes:[]),Gt(Array.isArray(v==null?void 0:v.edges)?v.edges:[]),gi(null)},[Gt,wt]),Fy=m.useMemo(()=>({instances:yr.current}),[wn,Dt]),{resetHistory:ch,undo:uh,redo:Kl}=rR({nodes:Dt,edges:wn,extra:Fy,enabled:!!c&&Oa.current&&Ae==="edit",onRestore:lh}),Qs=m.useMemo(()=>Dt.filter(v=>{var j;return(((j=v.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[Dt]),$a=m.useMemo(()=>{var j;const v={};for(const W of Dt){if(!((j=W.data)!=null&&j.inputs))continue;const Y=W.data.inputs;for(let G=0;G<Y.length;G++){const X=Y[G];if(!(X!=null&&X.name))continue;const ne=wn.find(ye=>ye.target===W.id&&ye.targetHandle===`input-${G}`);if(!(ne!=null&&ne.source))continue;Qs.find(ye=>ye.id===ne.source)&&(v[ne.source]=X.name)}}return v},[Dt,wn,Qs]),Ul=m.useMemo(()=>{if(Ae==="edit"||Zn.size===0)return null;const v=new Set(Zn);for(const j of wn)Zn.has(j.source)&&v.add(j.target),Zn.has(j.target)&&v.add(j.source);return v},[Ae,Zn,wn]),dh=m.useMemo(()=>Ae==="edit"?Dt:Dt.map(v=>{var j,W;return{...v,draggable:!1,connectable:!1,data:{...v.data,isRunMode:!0,isExecuting:Zn.has(v.id),nodeStatus:((j=ms[v.id])==null?void 0:j.status)??null,nodeElapsed:((W=ms[v.id])==null?void 0:W.elapsed)??null,isDim:Ul?!Ul.has(v.id):!1}}}),[Ae,Dt,Zn,ms,Ul]),fh=m.useMemo(()=>Ul?wn.map(v=>{const j=Zn.has(v.source)||Zn.has(v.target),W=v.className?v.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",Y=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...v,className:(W?W+" ":"")+Y}}):wn,[wn,Zn,Ul]);m.useEffect(()=>{if(!c){Wn({}),_i(null),ja(af),ns(tm),Mc(null),Il(""),co("");return}const v=new URLSearchParams({flowId:c.id,flowSource:c.source||"user"});c.archived&&v.set("archived","1"),fetch(`/api/flow/run-config?${v.toString()}`).then(j=>j.json()).then(j=>{Wn(j.presets||{}),_i(j.activePreset||null)}).catch(()=>{Wn({}),_i(null)})},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived]);const vo=m.useCallback(v=>{qo.current+=1,ja(v)},[]),Di=m.useCallback(async(v,j={})=>{if(!v)return;const W=!!j.quiet,Y=!!j.force,G=qo.current;W||(Tc(!0),Il(""),co(""));const X=new URLSearchParams({flowId:v.id,flowSource:v.source||"user"});v.archived&&X.set("archived","1");try{const ne=await fetch(`/api/flow/schedule?${X.toString()}`),se=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(se.error||`HTTP ${ne.status}`);if(!Y&&qo.current!==G)return;ja({...af,...se.schedule||{}}),ns(se.state&&typeof se.state=="object"?se.state:tm),Mc(se.status||null)}catch(ne){if(!Y&&qo.current!==G)return;ja(af),ns(tm),Mc(null),Il(String(ne.message||ne))}finally{Tc(!1)}},[]);m.useEffect(()=>{if(!c)return;let v=!1;return(async()=>{await Di(c)})(),()=>{v=!0}},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,Di]),m.useEffect(()=>{var W,Y,G,X;if(!Pr||!Rt[Pr]||Qs.length===0)return;const v=Rt[Pr],j={};for(const ne of Qs){const se=$a[ne.id];if(!se)continue;const ye=((W=ne.data)==null?void 0:W.definitionId)||"",ve=v[ne.id]??((X=(G=(Y=ne.data)==null?void 0:Y.outputs)==null?void 0:G[0])==null?void 0:X.default)??"";ye.startsWith("provide_file")?j[se]={type:"file",path:ve}:j[se]={type:"str",value:ve}}Object.keys(j).length>0&&ir(j)},[Pr,Rt,Qs,$a]);const is=m.useCallback(()=>{if(!Mi||!$c.current)return;const v=$c.current.value;wt(j=>j.map(W=>{var Y,G;return W.id!==Mi.instanceId?W:{...W,data:{...W.data,outputs:((G=(Y=W.data)==null?void 0:Y.outputs)==null?void 0:G.map((X,ne)=>ne===0?{...X,default:v}:X))||[{type:"text",name:"value",default:v}]}}})),Oc(null)},[Mi,wt]),gt=m.useMemo(()=>{const v=Dt.filter(j=>j.selected);return v.length===1?v[0]:null},[Dt]),Zs=m.useMemo(()=>c?NU(Dt,wn,e):[],[c,Dt,wn,e]),zy=m.useMemo(()=>Zs.map(v=>v.key).join("|"),[Zs]),zd=m.useMemo(()=>Zs.some(v=>String((v==null?void 0:v.level)||"warning").toLowerCase()==="error"),[Zs]);m.useLayoutEffect(()=>{oe(Zs.length>0&&!zd)},[zy,c==null?void 0:c.id,c==null?void 0:c.source,Zs.length,zd]),$l.current=gt,m.useEffect(()=>{dr.current=Dt},[Dt]),m.useEffect(()=>{const v=o.current,j=new Map,W=[];for(const ne of Dt){const se=M7(ne);j.set(ne.id,se),v.get(ne.id)!==se&&W.push(ne.id)}if(o.current=j,W.length===0)return;const Y=()=>W.forEach(ne=>{var se;return(se=s.current)==null?void 0:se.call(s,ne)}),G=window.requestAnimationFrame(Y),X=window.setTimeout(Y,80);return()=>{window.cancelAnimationFrame(G),window.clearTimeout(X)}},[Dt]),m.useEffect(()=>{Zo.current=wn},[wn]),m.useEffect(()=>{ah.current=ss},[ss]),m.useEffect(()=>{if(!ss)return;const v=W=>{W.key==="Escape"&&gi(null)},j=W=>{var Y,G;(G=(Y=W.target)==null?void 0:Y.closest)!=null&&G.call(Y,".af-connect-node-menu")||gi(null)};return document.addEventListener("keydown",v),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",v),document.removeEventListener("pointerdown",j)}},[ss]),m.useEffect(()=>()=>{bo.current!=null&&(clearTimeout(bo.current),bo.current=null)},[]);const Qc=m.useMemo(()=>{var j;if(!gt)return null;const v=(j=gt.data)==null?void 0:j.definitionId;return ue.find(W=>W.id===v)??null},[gt,ue]),S=m.useMemo(()=>{const v={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of ue){const W=tk(j);v[W].push(j)}for(const j of wf)v[j].sort((W,Y)=>W.id.localeCompare(Y.id));return v},[ue]),P=m.useMemo(()=>{const v=le.trim().toLowerCase();if(!v)return S;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const W of wf)j[W]=S[W].filter(Y=>A7(Y,v));return j},[S,le]),V=m.useMemo(()=>wf.reduce((v,j)=>v+P[j].length,0),[P]),q=m.useMemo(()=>ue.filter(v=>{const j=String(v.id??""),W=String(v.source??"");return j.startsWith("marketplace:")||W==="marketplace"||W==="collection"}),[ue]),Q=m.useMemo(()=>{const v=new Set;for(const j of q){const W=String(j.id??"");if(W&&(v.add(W),W.startsWith("marketplace:"))){const Y=W.slice(12),[G]=Y.split("@");G&&v.add(`marketplace:${G}`)}}return v},[q]),re=m.useCallback(async()=>{p("");try{const v=await fetch("/api/flows");if(!v.ok)throw new Error("HTTP "+v.status);u(await v.json())}catch(v){p(String(v.message||v))}},[]);m.useEffect(()=>{re()},[re]),m.useEffect(()=>{if(r!=="/flow")return;const v=new URLSearchParams(window.location.search);v.get("new")==="1"&&!v.get("flowId")&&n("/projects?new=1")},[r,n]),m.useEffect(()=>{if(r!=="/flow"||!c)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&St("settings")},[r,c==null?void 0:c.id,c==null?void 0:c.source]),m.useEffect(()=>{let v=!1;const j=()=>{fetch("/api/model-lists").then(Y=>Y.json()).then(Y=>{v||Gp({cursor:Array.isArray(Y.cursor)?Y.cursor.map(String):[],opencode:Array.isArray(Y.opencode)?Y.opencode.map(String):[],claudeCode:Array.isArray(Y.claudeCode)?Y.claudeCode.map(String):[]})}).catch(()=>{})};j();const W=setTimeout(j,4e3);return()=>{v=!0,clearTimeout(W)}},[]),m.useEffect(()=>{let v=!1;return fetch("/api/skills").then(j=>j.json()).then(j=>{if(v)return;const W=Array.isArray(j.skills)?j.skills.filter(Y=>Y&&typeof Y.key=="string"&&Y.key.trim()).map(Y=>({key:String(Y.key),name:String(Y.name||Y.id||Y.key),description:Y.description?String(Y.description):"",sourceLabel:Y.sourceLabel?String(Y.sourceLabel):""})):[];Xp(W),Fl(!0)}).catch(()=>{}),()=>{v=!0}},[]),m.useEffect(()=>{let v=!1;return fetch("/api/skill-collections").then(j=>j.json()).then(j=>{v||(Jp(dl(j)),Qp(!0))}).catch(()=>{}),()=>{v=!0}},[]),m.useEffect(()=>{if(rh(""),!(!Dl||!Ad)){if(!xo){mo([]);return}mo(PP(xo,"pipeline",hi,Bc)),rh(xo)}},[Bc,Ad,hi,Dl,xo]),m.useEffect(()=>{if(!(Vc!==xo||!xo))try{localStorage.setItem(xo,JSON.stringify(ho))}catch{}},[ho,xo,Vc]);const ie=m.useCallback(async v=>{const j=v.source??"user",W=!!v.archived,Y=new URLSearchParams({flowId:v.id,flowSource:j});W&&Y.set("archived","1");const G=new URLSearchParams({flowId:v.id,flowSource:j});W&&G.set("archived","1"),G.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[X,ne]=await Promise.all([fetch("/api/flow?"+Y.toString()),fetch("/api/nodes?"+G.toString())]),se=await X.json();if(!X.ok||se.error)throw new Error(se.error||e("flow:nodePropsError.loadFlowFailed"));const ye=await ne.json();if(!ne.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const ve=Array.isArray(ye)?ye:Array.isArray(ye==null?void 0:ye.nodes)?ye.nodes:[],Be=!Array.isArray(ye)&&(ye==null?void 0:ye.pipelineTranslations)||{},pe=vU(se.flowYaml||"");if(pe.error)throw new Error(pe.error);const Fe={...pe.instances||{}},Pe=pe.nodes.map(bn=>kp(bn,Fe,ve,Be,v.id)),vt=nR(pe.edges,Pe);return{flowSource:j,paletteList:ve,instances:Fe,flowDescriptionText:pe.description??"",viewport:$1(pe.viewport),nodes:Pe,edges:vt}},[t.language,e]),te=m.useCallback(async(v,j={})=>{const W=!!j.preserveComposer,Y=W&&!!j.incrementalSync;Oa.current=!1,Gc.current+=1,f(v),w(""),W||(N(""),ce(""),St(null),k(""),H(""),L(""),pi(""),Od([]),Js([]),wo([]),$d(!1),Wl(null),Cd("pan")),Y||(yr.current={},wt([]),Gt([])),z1(v);try{const G=await ie(v);if(Ne(G.paletteList),yr.current=G.instances,k(G.flowDescriptionText),H(v.id||""),Y){const X=dr.current,ne=Zo.current;try{const se=Q9(X,ne,G.nodes,G.edges),ye=new Set([...se.changes.addedNodeIds,...se.changes.updatedNodeIds]),ve=new Set([...se.changes.addedEdgeKeys,...se.changes.updatedEdgeKeys]),Be=ye.size>0?se.nodes.map(Fe=>ye.has(Fe.id)?{...Fe,className:C1(Fe.className,N1)}:Fe):se.nodes,pe=ve.size>0?se.edges.map(Fe=>ve.has(yp(Fe))?{...Fe,className:C1(Fe.className,j1)}:Fe):se.edges;wt(Be),Gt(pe),bo.current!=null&&(clearTimeout(bo.current),bo.current=null),(ye.size>0||ve.size>0)&&(bo.current=window.setTimeout(()=>{bo.current=null,ye.size>0&&wt(Fe=>Fe.map(Pe=>{if(!ye.has(Pe.id))return Pe;const vt=E1(Pe.className,N1);return vt===String(Pe.className||"")?Pe:{...Pe,className:vt}})),ve.size>0&&Gt(Fe=>Fe.map(Pe=>{if(!ve.has(yp(Pe)))return Pe;const vt=E1(Pe.className,j1);return vt===String(Pe.className||"")?Pe:{...Pe,className:vt}}))},E7))}catch{wt(G.nodes),Gt(G.edges)}}else if(wt(G.nodes),Gt(G.edges),Yc.current=G.viewport||null,G.viewport){const X=()=>{var ne;try{(ne=$i.current)==null||ne.setViewport(G.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(X))}else g(X=>X+1);Lh(v.id,G.flowSource),zc(X=>X+1),ch(G.nodes,G.edges,{instances:G.instances});try{Vl.current=a1(G.nodes,G.edges,G.instances,{description:G.flowDescriptionText,viewport:Yc.current})}catch{Vl.current=""}Oa.current=!0}catch(G){w(String(G.message||G))}},[ie,ch,wt,Gt]),ee=m.useCallback(async()=>{if(!(c!=null&&c.id))return;const v=c.source??"user",j=new URLSearchParams({flowId:c.id,flowSource:v});c.archived&&j.set("archived","1"),j.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const W=await fetch("/api/nodes?"+j.toString()),Y=await W.json();if(!W.ok)throw new Error((Y==null?void 0:Y.error)||e("flow:nodePropsError.loadNodesFailed"));const G=Array.isArray(Y)?Y:Array.isArray(Y==null?void 0:Y.nodes)?Y.nodes:[];Ne(G)},[c,e,t.language]),me=m.useCallback(async()=>{Rn(!0),Mn("");try{const v=await fetch("/api/marketplace/nodes"),j=await v.json().catch(()=>({}));if(!v.ok)throw new Error((j==null?void 0:j.error)||"Failed to load marketplace nodes");dn(Array.isArray(j==null?void 0:j.nodes)?j.nodes:[])}catch(v){Mn(String(v.message||v)),dn([])}finally{Rn(!1)}},[]),ke=m.useCallback(async()=>{Ve(!0),bt("");try{const v=await fetch("/api/marketplace/flow-snippets"),j=await v.json().catch(()=>({}));if(!v.ok)throw new Error((j==null?void 0:j.error)||"Failed to load flow snippets");We(Array.isArray(j==null?void 0:j.snippets)?j.snippets:[])}catch(v){bt(String(v.message||v)),We([])}finally{Ve(!1)}},[]);m.useEffect(()=>{c&&(me(),ke())},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,me,ke]);const Re=m.useCallback(async v=>{if(!c||!v)return;const j=v.definitionId||`marketplace:${v.id}${v.version?`@${v.version}`:""}`;if(j){zr(j),Mn("");try{const W=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",archived:!!c.archived,nodeSpec:j})}),Y=await W.json().catch(()=>({}));if(!W.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Failed to install marketplace node");await ee()}catch(W){Mn(String(W.message||W))}finally{zr("")}}},[c,ee]),dt=m.useCallback(async(v,j)=>{const W={packageId:(v==null?void 0:v.newId)||(v==null?void 0:v.id)||(v==null?void 0:v.label),label:(v==null?void 0:v.label)||(v==null?void 0:v.newId)||(v==null?void 0:v.id),version:"1.0.0",definitionId:j,body:(v==null?void 0:v.body)||"",script:(v==null?void 0:v.script)||"",inputs:Array.isArray(v==null?void 0:v.inputs)?v.inputs:[],outputs:Array.isArray(v==null?void 0:v.outputs)?v.outputs:[],flowId:c==null?void 0:c.id,flowSource:(c==null?void 0:c.source)||"user"},Y=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),G=await Y.json();if(!Y.ok||(G==null?void 0:G.ok)===!1)throw new Error((G==null?void 0:G.error)||"Publish failed");return await ee(),G},[ee,c]),Ye=m.useCallback(async()=>{var Y;if(!c||we.current)return;const v=c.id,j=c.source??"user",W=((Y=$l.current)==null?void 0:Y.id)??null;we.current=!0,he(!0);try{await te({id:v,source:j,archived:c.archived},{preserveComposer:!0,incrementalSync:!0}),W&&wt(G=>G.map(X=>({...X,selected:X.id===W})))}finally{we.current=!1,he(!1)}},[c,c==null?void 0:c.archived,te,wt]);m.useEffect(()=>{if(La.current||l.length===0)return;const v=new URLSearchParams(window.location.search),j=v.get("flowId");if(!j)return;const W=v.get("flowSource")??"user",Y=v.get("flowArchived")==="1",G=l.find(X=>X.id===j&&(X.source??"user")===W&&!!X.archived===Y);G&&(La.current=!0,te(G))},[l,te]);const It=m.useRef(0);m.useEffect(()=>{if(!c)return;const v=c.id,j=c.source??"user",W=!!c.archived;It.current=0;let Y=!1;const G=async()=>{var se;if(Y)return;const ne=new URLSearchParams({flowId:v,flowSource:j,v:String(It.current)});W&&ne.set("archived","1");try{const ye=await fetch("/api/flow-editor-sync-poll?"+ne.toString());if(!ye.ok||Y)return;const ve=await ye.json();if(Y)return;if(ve.changed){It.current=ve.version;const Be=((se=$l.current)==null?void 0:se.id)??null;await te({id:v,source:j,archived:W},{preserveComposer:!0,incrementalSync:!0}),await Di({id:v,source:j,archived:W},{quiet:!0,force:!0}),Be&&wt(pe=>pe.map(Fe=>({...Fe,selected:Fe.id===Be})))}else It.current=ve.version}catch{}},X=window.setInterval(G,2e3);return G(),()=>{Y=!0,window.clearInterval(X)}},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,te,Di,wt]);const jn=m.useMemo(()=>x?x.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":x===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[x]);m.useEffect(()=>{if(!x)return;x===e("flow:status.saved")||x.startsWith(e("flow:status.runInTerminal"));const v=x.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>N(""),v);return()=>clearTimeout(j)},[x,e]),m.useEffect(()=>{C("")},[c==null?void 0:c.id,c==null?void 0:c.source]),m.useEffect(()=>{const v=()=>{window.__provideEditContent&&(Oc(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",v),()=>window.removeEventListener("provide-expand",v)},[]),m.useEffect(()=>{var se,ye,ve,Be,pe,Fe,Pe;if(!gt){_d(null);return}const v=yr.current[gt.id]||{},{inputs:j,outputs:W}=tR(gt),Y=String(((se=gt.data)==null?void 0:se.definitionId)??gt.id??""),G=((ye=gt.data)==null?void 0:ye.script)!=null?String(gt.data.script):void 0,X=v.script!=null?String(v.script):void 0,ne=Y==="tool_nodejs"||G&&G.trim()!==""||X&&X.trim()!==""?String(G??X??""):"";_d({id:gt.id,newId:gt.id,label:String(((ve=gt.data)==null?void 0:ve.label)??gt.id),role:((Be=gt.data)==null?void 0:Be.role)??"普通",model:String(((pe=gt.data)==null?void 0:pe.model)??v.model??""),body:String(((Fe=gt.data)==null?void 0:Fe.body)??v.body??""),images:Fs(((Pe=gt.data)==null?void 0:Pe.images)??v.images),script:ne,inputs:j,outputs:W})},[gt==null?void 0:gt.id,ur]),m.useEffect(()=>{c&&(gt||(Fc.current=null,St(v=>v==="node"?null:v)))},[c,gt==null?void 0:gt.id]);const qn=m.useCallback(()=>{Fc.current=null,St(v=>v==="settings"||v==="history"?v:"node")},[]),Qt=m.useCallback((v,j)=>{v.metaKey||v.ctrlKey||v.shiftKey||Ae!=="edit"&&fi((j==null?void 0:j.id)??null)},[Ae]),Xt=m.useCallback((v,j)=>{Ae==="edit"&&(v.preventDefault(),wt(W=>W.map(Y=>({...Y,selected:Y.id===j.id}))),Gt(W=>W.map(Y=>({...Y,selected:!1}))),qn())},[qn,Ae,Gt,wt]),$n=m.useCallback((v,j)=>{if(Ae!=="edit")return;const W=v.metaKey||v.ctrlKey||v.shiftKey;Gt(Y=>Y.map(G=>G.id===j.id?{...G,selected:!G.selected||!W}:W?G:{...G,selected:!1})),W||wt(Y=>Y.map(G=>({...G,selected:!1})))},[Ae,Gt,wt]),Ft=m.useCallback(v=>T1(v,dr.current),[]),gn=m.useCallback(v=>{if(!T1(v,dr.current)){N("端口类型不匹配,已取消连线");return}gi(null),wt(j=>Ff(j,v)),Gt(j=>{const W=j.filter(Y=>!(Y.target===v.target&&Y.targetHandle===v.targetHandle));return Du({...v,markerEnd:{type:ks.ArrowClosed}},W)})},[Gt,wt]),Ue=m.useCallback((v,j)=>{Fd.current=L7(j,dr.current),gi(null)},[]),Pt=m.useCallback((v,j)=>{var Pe,vt,bn,vn;const W=Fd.current;if(Fd.current=null,!c||!W||j!=null&&j.toNode)return;const Y=$7(ue,W);if(Y.length===0){N(`没有匹配 ${W.slotType} 端口的节点`);return}const G=((vt=(Pe=v==null?void 0:v.changedTouches)==null?void 0:Pe[0])==null?void 0:vt.clientX)??(v==null?void 0:v.clientX),X=((vn=(bn=v==null?void 0:v.changedTouches)==null?void 0:bn[0])==null?void 0:vn.clientY)??(v==null?void 0:v.clientY);if(!Number.isFinite(G)||!Number.isFinite(X))return;const ne=$i.current,se=document.querySelector(".af-pipeline-flow .react-flow");if(!ne||!se)return;const ye=se.getBoundingClientRect(),ve=320,Be=Math.min(440,104+Y.length*58),pe=Math.max(12,Math.min(G-ye.left,ye.width-ve-12)),Fe=Math.max(12,Math.min(X-ye.top,ye.height-Be-12));gi({left:pe,top:Fe,flowPosition:ne.screenToFlowPosition({x:G,y:X}),draft:W,candidates:Y,query:""})},[ue,c]),Tr=m.useCallback(v=>{for(const j of v)delete yr.current[j.id]},[]),Da=m.useCallback(v=>{$i.current=v},[]),ql=m.useCallback(v=>{wt(W=>W.map(Y=>({...Y,selected:Y.id===v}))),Gt(W=>W.map(Y=>({...Y,selected:!1}))),qn();const j=()=>{var ye,ve,Be;const W=$i.current;if(!(W!=null&&W.getNode))return;const Y=W.getNode(v);if(!Y)return;const G=(ye=W.getInternalNode)==null?void 0:ye.call(W,v),X=((ve=G==null?void 0:G.measured)==null?void 0:ve.width)??(G==null?void 0:G.width)??Y.width??200,ne=((Be=G==null?void 0:G.measured)==null?void 0:Be.height)??(G==null?void 0:G.height)??Y.height??88,{zoom:se}=W.getViewport();W.setCenter(Y.position.x+X/2,Y.position.y+ne/2,{zoom:O1(se),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[wt,Gt,qn]),Ee=m.useCallback(v=>{wt(W=>W.map(Y=>({...Y,selected:Y.id===v}))),Gt(W=>W.map(Y=>({...Y,selected:!1})));const j=()=>{var ve,Be,pe;const W=$i.current;if(!(W!=null&&W.getNode))return;const Y=W.getNode(v);if(!Y)return;const G=(ve=W.getInternalNode)==null?void 0:ve.call(W,v),X=((Be=G==null?void 0:G.measured)==null?void 0:Be.width)??(G==null?void 0:G.width)??Y.width??200,ne=((pe=G==null?void 0:G.measured)==null?void 0:pe.height)??(G==null?void 0:G.height)??Y.height??88,{zoom:se}=W.getViewport(),ye=O1(se);W.setCenter(Y.position.x+X/2,Y.position.y+ne/2,{zoom:ye,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[wt,Gt]),lt=m.useCallback((v,j)=>{const W=`node-${Date.now()}`;return kR(v,W,j,yr.current,ue)},[ue]),yt=m.useCallback(v=>{if(!c||!v)return;let j={x:180,y:160};const W=$i.current,Y=document.querySelector(".af-pipeline-flow .react-flow");if(W&&Y){const G=Y.getBoundingClientRect();j=W.screenToFlowPosition({x:G.left+G.width*.45,y:G.top+G.height*.38})}wt(G=>[...G,lt(v,j)])},[c,wt,lt]),jt=m.useCallback(v=>{const j=ah.current;if(!c||!j||!(v!=null&&v.def))return;const W=lt(v.def,j.flowPosition),Y=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:W.id,targetHandle:`input-${v.slotIndex}`}:{source:W.id,sourceHandle:`output-${v.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};wt(G=>Ff([...G,W],Y)),Gt(G=>{const X=G.filter(ne=>!(ne.target===Y.target&&ne.targetHandle===Y.targetHandle));return Du({...Y,markerEnd:{type:ks.ArrowClosed}},X)}),gi(null)},[c,lt,wt,Gt]),Oe=m.useCallback(v=>{v.preventDefault(),v.dataTransfer.dropEffect="move"},[]),zt=m.useCallback(v=>{var ne;if(v.preventDefault(),!c)return;const j=$i.current;if(!j)return;const W=j.screenToFlowPosition({x:v.clientX,y:v.clientY}),Y=v.dataTransfer.getData("application/agentflow-snippet");if(Y){const se=et.find(ye=>`${ye.id}@${ye.version}`===Y);se&&((ne=Jc.current)==null||ne.call(Jc,se,W));return}const G=v.dataTransfer.getData("application/agentflow-node");if(!G)return;const X=ue.find(se=>se.id===G);X&&wt(se=>[...se,lt(X,W)])},[c,ue,et,wt,lt]),Bt=m.useCallback(async(v,j)=>{if(!c)return;const W=a1(v,j,yr.current,{description:b,viewport:Yc.current});if(W!==Vl.current){N(e("flow:status.saving"));try{const Y=tq(c.source),G=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:Y,flowYaml:W,...c.archived?{flowArchived:!0}:{}})}),X=await G.json();if(!G.ok||!X.success)throw new Error(X.error||e("flow:status.saveFailed"));if(Vl.current=W,N(e("flow:status.saved")),yi(c.source)&&Y==="workspace"){const ne={id:c.id,source:"workspace",path:void 0};f(ne),z1(ne),Lh(c.id,"workspace")}}catch(Y){N(e("flow:status.saveFailed")+": "+(Y.message||Y))}}},[c,b]);m.useEffect(()=>{if(!c||!Oa.current||Ae!=="edit"||c.archived)return;const v=Gc.current,j=setTimeout(()=>{v===Gc.current&&Oa.current&&Bt(dr.current,Zo.current)},400);return()=>clearTimeout(j)},[Dt,wn,b,Ae,c,Bt]);const Yt=m.useCallback(async v=>{if(!c||c.archived)return;const j=c.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==v){F(!0),C("");try{const W=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,fromSource:j,toSource:v})}),Y=await W.json().catch(()=>({}));if(!W.ok)throw new Error(typeof Y.error=="string"?Y.error:e("flow:composer.requestFailed"));const G=Y.flowSource==="workspace"||Y.flowSource==="user"?Y.flowSource:v;let X={id:c.id,source:G,archived:c.archived};try{const ne=await fetch("/api/flows");if(ne.ok){const se=await ne.json(),ye=Array.isArray(se)?se.find(ve=>ve.id===c.id&&(ve.source??"user")===G&&!!ve.archived==!!c.archived):null;ye&&(X=ye)}}catch{}await te(X,{preserveComposer:!0}),Lh(c.id,G)}catch(W){C(String(W.message||W))}finally{F(!1)}}},[c,te]),Wt=m.useCallback(async()=>{if(c){kd(!0),Il(""),co("");try{const v=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",archived:!!c.archived,schedule:On})}),j=await v.json().catch(()=>({}));if(!v.ok||!j.success)throw new Error(j.error||"Failed to save schedule");ja({...af,...j.schedule||{}}),co(e("flow:schedule.saved")),await Di(c,{quiet:!0,force:!0})}catch(v){Il(String(v.message||v))}finally{kd(!1)}}},[c,On,Di,e]),Lt=m.useCallback(async()=>{c&&(await Bt(dr.current,Zo.current),!c.archived&&c.source!=="builtin"&&await Wt())},[c,Bt,Wt]),fn=m.useCallback(async()=>{if(!c||!R.trim())return;const v=R.trim();if(v===c.id){L("");return}$(!0),L("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",newFlowId:v})}),W=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof W.error=="string"?W.error:e("flow:composer.requestFailed"));let Y={id:W.flowId,source:W.flowSource??c.source,archived:c.archived};try{const G=await fetch("/api/flows");if(G.ok){const X=await G.json(),ne=Array.isArray(X)?X.find(se=>se.id===W.flowId&&(se.source??"user")===(W.flowSource??c.source)):null;ne&&(Y=ne)}}catch{}await te(Y,{preserveComposer:!0}),Lh(W.flowId,W.flowSource??c.source)}catch(j){L(String(j.message||j))}finally{$(!1)}},[c,R,te]),en=m.useCallback(v=>{navigator.clipboard.writeText(v).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(()=>{})},[]),yn=m.useCallback(()=>{Bt(Dt,wn)},[Bt,Dt,wn]),Cn=m.useCallback(()=>{var j,W;if(!c)return;const v=$1((W=(j=$i.current)==null?void 0:j.getViewport)==null?void 0:W.call(j));v&&(Yc.current=v,N("已固定 Pipeline 进入视角"),Bt(dr.current,Zo.current))},[Bt,c]),Rr=m.useCallback((v,j)=>{const W=j.trim()===""||j==="default"?void 0:j.trim(),Y=Dt.map(G=>G.id===v?{...G,data:{...G.data,model:W}}:G);wt(Y),Bt(Y,wn)},[Dt,wn,wt,Bt]),Mr=m.useCallback(()=>{var vt,bn;if(!qe||!c||!gt)return!1;const v=gt.id,j=qe.newId.trim();if(Hc(""),!hR.test(j))return Hc(e("flow:nodePropsError.invalidInstanceId")),!1;if(Dt.some(vn=>vn.id===j&&vn.id!==v))return Hc(e("flow:nodePropsError.duplicateInstanceId")),!1;const W=qe.role.trim(),Y=wl.includes(W)?W:"普通",G=qe.model.trim(),X=vn=>(Array.isArray(vn)?vn:[]).map(Vt=>({type:String((Vt==null?void 0:Vt.type)??"节点").trim()||"节点",name:String((Vt==null?void 0:Vt.name)??""),default:String((Vt==null?void 0:Vt.default)??""),description:String((Vt==null?void 0:Vt.description)??""),required:!!(Vt!=null&&Vt.required),showOnNode:(Vt==null?void 0:Vt.showOnNode)!=null?Vt.showOnNode!==!1:!!(Vt!=null&&Vt.required)||String((Vt==null?void 0:Vt.type)??"节点").trim().toLowerCase()==="node"})),ne=X(qe.inputs),se=X(qe.outputs),ye=String(((vt=gt.data)==null?void 0:vt.definitionId)??j),ve=ye.startsWith("provide_"),Be={...gt.data,label:qe.label.trim()||j,displayLabel:qe.label.trim()||j,role:Y,model:G===""||G==="default"?void 0:G,body:ve?"":qe.body,images:ve?[]:Fs(qe.images),inputs:ne,outputs:ve&&Array.isArray((bn=gt.data)==null?void 0:bn.outputs)?gt.data.outputs:se},pe=String(qe.script??"").trim();ye==="tool_nodejs"||pe!==""?Be.script=String(qe.script??""):delete Be.script;let Fe,Pe=wn;if(j!==v){const vn={...yr.current},Vt={...vn[v]||{}};delete vn[v],vn[j]=Vt,yr.current=vn,Fe=Dt.map(kt=>kt.id!==v?kt:{...kt,id:j,selected:!0,data:Be}),Pe=wn.map((kt,tn)=>({...kt,source:kt.source===v?j:kt.source,target:kt.target===v?j:kt.target,id:`e-${kt.source===v?j:kt.source}-${kt.target===v?j:kt.target}-${tn}`}))}else Fe=Dt.map(vn=>vn.id===v?{...vn,data:Be}:vn);return wt(Fe),Gt(Pe),hs(j),Bt(Fe,Pe),!0},[qe,c,gt,Dt,wn,wt,Gt,hs,Bt]),Fa=m.useCallback(()=>{var bn,vn;if(!qe||!c||!gt)return!1;const v=gt.id,j=qe.role.trim(),W=wl.includes(j)?j:"普通",Y=qe.model.trim(),G=Vt=>(Array.isArray(Vt)?Vt:[]).map(kt=>({type:String((kt==null?void 0:kt.type)??"节点").trim()||"节点",name:String((kt==null?void 0:kt.name)??""),default:String((kt==null?void 0:kt.default)??""),description:String((kt==null?void 0:kt.description)??""),required:!!(kt!=null&&kt.required),showOnNode:(kt==null?void 0:kt.showOnNode)!=null?kt.showOnNode!==!1:!!(kt!=null&&kt.required)||String((kt==null?void 0:kt.type)??"节点").trim().toLowerCase()==="node"})),X=G(qe.inputs),ne=G(qe.outputs),se=String(((bn=gt.data)==null?void 0:bn.definitionId)??v),ye=se.startsWith("provide_"),ve=qe.label.trim()||v,Be=Y===""||Y==="default"?void 0:Y,pe={...gt.data,label:ve,displayLabel:ve,role:W,model:Be,body:ye?"":qe.body,images:ye?[]:Fs(qe.images),inputs:X,outputs:ye&&Array.isArray((vn=gt.data)==null?void 0:vn.outputs)?gt.data.outputs:ne},Fe=String(qe.script??"").trim();se==="tool_nodejs"||Fe!==""?pe.script=String(qe.script??""):delete pe.script;const Pe=gt.data||{};return(Pe.label!==pe.label||Pe.role!==pe.role||Pe.model!==pe.model||Pe.body!==pe.body||JSON.stringify(Fs(Pe.images))!==JSON.stringify(pe.images)||(Pe.script??void 0)!==(pe.script??void 0)||JSON.stringify(Pe.inputs||[])!==JSON.stringify(X)||JSON.stringify(Pe.outputs||[])!==JSON.stringify(ne))&&(wt(Vt=>Vt.map(kt=>kt.id===v?{...kt,data:pe}:kt)),hs(v)),!0},[qe,c,gt,wt,hs]),ea=m.useRef(Fa);m.useEffect(()=>{ea.current=Fa},[Fa]),m.useEffect(()=>{if(!qe||!c||!Oa.current||Ae!=="edit")return;const v=setTimeout(()=>{ea.current()},400);return()=>clearTimeout(v)},[qe,c,Ae]);const za=m.useCallback(()=>{if(!(!qe||!gt)){if(qe.newId.trim()===gt.id){Hc("");return}Mr()}},[qe,gt,Mr]);m.useEffect(()=>{const v=j=>{var ne,se,ye;if(Ae!=="edit")return;const W=oR(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(ft==="node"&&gt&&qe){j.preventDefault(),j.stopPropagation(),Mr()||yn();return}if(W)return;j.preventDefault(),j.stopPropagation(),yn();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),Ed(ve=>!ve);return}if(Dc)return;if(_e){if(j.key==="Escape"){j.preventDefault(),ys(!1);return}if(Tg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ys(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(W)return;const Y=j.key.toLowerCase(),G=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&Y==="z",X=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&Y==="z"||Y==="y");if(G||X){j.preventDefault(),j.stopPropagation();const ve=G?uh():Kl();N(ve?G?"Undo canvas change":"Redo canvas change":G?"Nothing to undo":"Nothing to redo");return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="c"){const ve=JT(dr.current,Zo.current,yr.current);ve&&(j.preventDefault(),j.stopPropagation(),oh.current=ve,N(`Copied ${ve.nodes.length} node${ve.nodes.length>1?"s":""}`));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="v"){const ve=QT(oh.current,dr.current,Zo.current,yr.current);ve&&(j.preventDefault(),j.stopPropagation(),yr.current=ve.instances,wt(ve.nodes),Gt(ve.edges),N(`Pasted ${ve.pastedNodeIds.length} node${ve.pastedNodeIds.length>1?"s":""}`));return}if((j.key==="a"||j.key==="A")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),j.stopPropagation(),(ne=Ke.current)==null||ne.focus(),(ye=(se=Ke.current)==null?void 0:se.select)==null||ye.call(se);return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),wt(ve=>ve.map(Be=>({...Be,selected:!0}))),Gt(ve=>ve.map(Be=>({...Be,selected:!1})));return}if(Tg(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),ys(ve=>!ve);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Cd("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Cd("pan");return}if((j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Cn();return}};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[yn,Cn,_e,Dc,ft,gt,qe,Mr,Ae,uh,Kl]),m.useEffect(()=>{if(Ae!=="running"||Us==null)return;let v=Math.floor((Date.now()-Us)/1e3);const j=setInterval(()=>{const W=Date.now()-Us,Y=Math.floor(W/1e3);Y!==v&&(v=Y,an(W))},500);return()=>clearInterval(j)},[Ae,Us]),m.useEffect(()=>{const v=Ur.current;!v||!v.parentElement||Tl.current&&(Ai.current=!0,v.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ai.current=!1}))},[mr]),m.useEffect(()=>{const v=Ur.current;if(!v)return;const j=v.parentElement;if(!j)return;const W=()=>{if(Ai.current)return;const Y=j.scrollHeight-j.scrollTop-j.clientHeight;Tl.current=Y<40};return j.addEventListener("scroll",W,{passive:!0}),()=>j.removeEventListener("scroll",W)},[cr,Ae]),m.useEffect(()=>{if(Ae==="edit"||!cr)return;Tl.current=!0;const v=Ur.current;v&&(Ai.current=!0,v.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ai.current=!1}))},[Ae,cr]),m.useEffect(()=>{mr.length>Rm+D1&&it(v=>v.length>Rm+D1?v.slice(-Rm):v)},[mr]);const Hd=m.useCallback(v=>{if(v.button!==0)return;v.preventDefault();const j=v.currentTarget;ts.current={active:!0,pointerId:v.pointerId,startY:v.clientY,startH:Es},j.setPointerCapture(v.pointerId)},[Es]),O2=m.useCallback(v=>{const j=ts.current;if(!j.active||v.pointerId!==j.pointerId)return;const W=j.startY-v.clientY;Uo(Mm(j.startH+W))},[]),ph=m.useCallback(()=>{Uo(v=>{const j=Mm(v);try{localStorage.setItem(NR,String(j))}catch{}return j})},[]),bk=m.useCallback(v=>{const j=ts.current;if(!(!j.active||v.pointerId!==j.pointerId)){j.active=!1;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}ph()}},[ph]),$2=m.useCallback(()=>{const v=ts.current;v.active&&(v.active=!1,ph())},[ph]);m.useEffect(()=>{function v(){Uo(j=>Mm(j))}return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]);const ko=m.useCallback(async(v={})=>{if(!c)return;const j=v.runUuid!=null&&String(v.runUuid).trim()?String(v.runUuid).trim():null,W=v.cliInputsOverride??Ys.current,Y=!!v.prepareOnly;if(Nt(Y?"ready":"running"),it(Y?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),Vr(new Set),Ie({}),nt(!Y),St(null),j||sr(null),Y)return;if(!j){const X=Date.now();pt(X),an(0)}const G=new AbortController;Pi.current=G;try{const X=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",...j?{uuid:j}:{},cliInputs:W}),signal:G.signal});if(!X.ok){const pe=await X.json().catch(()=>({error:e("flow:composer.requestFailed")}));it(Fe=>[...Fe,{ts:new Date().toISOString(),type:"error",text:pe.error||e("flow:composer.requestFailed")}]),Nt("error");return}if(it(pe=>[...pe,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!X.body){it(pe=>[...pe,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),Nt("error");return}const ne=X.body.getReader(),se=new TextDecoder;let ye="";const ve=pe=>{const Fe=pe.ts||new Date().toISOString();if(pe.type==="event")if(pe.event==="node-start")Vr(Pe=>new Set(Pe).add(pe.instanceId)),Ie(Pe=>({...Pe,[pe.instanceId]:{status:"running",startMs:Date.now()}})),it(Pe=>[...Pe,{ts:Fe,type:"node-start",text:pe.label?e("flow:run.nodeStartWithLabel",{instanceId:pe.instanceId,label:pe.label}):e("flow:run.nodeStart",{instanceId:pe.instanceId})}]);else if(pe.event==="node-done"){Vr(vt=>{const bn=new Set(vt);return bn.delete(pe.instanceId),bn});const Pe=pe.elapsed??null;Ie(vt=>({...vt,[pe.instanceId]:{status:"success",elapsed:Pe}})),it(vt=>[...vt,{ts:Fe,type:"node-done",text:Pe?e("flow:run.nodeDoneWithElapsed",{instanceId:pe.instanceId,elapsed:Pe}):e("flow:run.nodeDone",{instanceId:pe.instanceId})}])}else if(pe.event==="node-failed")Vr(Pe=>{const vt=new Set(Pe);return vt.delete(pe.instanceId),vt}),Ie(Pe=>({...Pe,[pe.instanceId]:{status:"failed",elapsed:pe.elapsed??null}})),it(Pe=>[...Pe,{ts:Fe,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:pe.instanceId})}]);else if(pe.event==="apply-start"){if(pe.uuid&&sr(String(pe.uuid)),typeof pe.runStartTime=="number"&&pe.runStartTime>0)pt(pe.runStartTime),an(Math.max(0,Date.now()-pe.runStartTime));else if(typeof pe.totalExecutedMs=="number"&&pe.totalExecutedMs>0){const Pe=Date.now()-pe.totalExecutedMs;pt(Pe),an(pe.totalExecutedMs)}it(Pe=>[...Pe,{ts:Fe,type:"info",text:e("flow:run.pipelineStart",{uuid:pe.uuid||"?"})}])}else pe.event==="apply-done"?it(Pe=>[...Pe,{ts:Fe,type:"info",text:pe.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:pe.totalElapsed}):e("flow:run.pipelineDone")}]):pe.event==="apply-paused"?it(Pe=>[...Pe,{ts:Fe,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(pe.pendingNodes||[]).join(", ")})}]):it(Pe=>[...Pe,{ts:Fe,type:"event",text:`[${pe.event}] ${JSON.stringify(pe)}`}]);else pe.type==="user-check-content"?(Yo({instanceId:pe.instanceId,execId:pe.execId??1,inputPath:pe.inputPath,outputPath:pe.outputPath,content:pe.content||""}),Ca(pe.content||""),Ea(!1),Ti(""),_a(!1),it(Pe=>[...Pe,{ts:Fe,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:pe.instanceId})}])):pe.type==="user-ask-prompt"?(Ll({instanceId:pe.instanceId,execId:pe.execId??1,question:pe.question||"",options:Array.isArray(pe.options)?pe.options:[]}),Go(!1),it(Pe=>[...Pe,{ts:Fe,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:pe.instanceId,defaultValue:`等待用户选择 (${pe.instanceId})`})}])):pe.type==="tool-print-content"?(rs({instanceId:pe.instanceId,execId:pe.execId??1,content:pe.content||"",createdAt:Date.now()}),Ri(!1)):pe.type==="log"?it(Pe=>[...Pe,{ts:Fe,type:"log",text:pe.text!=null?String(pe.text):""}]):pe.type==="error"?it(Pe=>[...Pe,{ts:Fe,type:"error",text:pe.message||e("flow:run.unknownError")}]):pe.type==="done"?it(Pe=>[...Pe,{ts:Fe,type:"done",text:e("flow:run.executionEnd",{exitCode:pe.exitCode??"?"})}]):it(Pe=>[...Pe,{ts:Fe,type:"log",text:JSON.stringify(pe)}])},Be=pe=>{if(pe.trim())try{ve(JSON.parse(pe))}catch{it(Fe=>[...Fe,{ts:new Date().toISOString(),type:"log",text:pe}])}};for(;;){const{done:pe,value:Fe}=await ne.read();ye+=se.decode(Fe??new Uint8Array,{stream:!pe});const Pe=ye.split(`
133
- `);ye=Pe.pop()??"";for(const vt of Pe)Be(vt);if(pe)break}ye.trim()&&Be(ye),Nt("done")}catch(X){X.name==="AbortError"?(it(ne=>[...ne,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),Nt("stopped")):(it(ne=>[...ne,{ts:new Date().toISOString(),type:"error",text:X.message||e("flow:run.unknownError")}]),Nt("error"))}finally{Pi.current=null,Vr(new Set)}},[c]),[D2,Hy]=m.useState(!1),F2=m.useCallback(()=>{Hy(!0)},[]),z2=m.useCallback(async()=>{if(Hy(!1),Pi.current&&(Pi.current.abort(),Pi.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}Nt("stopped"),Vr(new Set)},[c]),Yl=m.useCallback(()=>{Nt("edit"),Vr(new Set),Ie({}),fi(null),sr(null)},[]),[H2,hh]=m.useState(!1),B2=m.useCallback(async()=>{if(hh(!1),Pi.current&&(Pi.current.abort(),Pi.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}Yl()},[c,Yl]),W2=m.useCallback(()=>{hh(!1),n("/projects")},[n]),V2=m.useCallback(v=>{const j=v.runId!=null&&String(v.runId).trim()?String(v.runId).trim():null,W=v.flowId!=null&&String(v.flowId).trim()?String(v.flowId).trim():(c==null?void 0:c.id)!=null?String(c.id):null;sr(j);const Y=v.status||"unknown";let G="stopped";Y==="success"?G="done":Y==="failed"?G="error":Y==="running"?G="running":G="stopped",Nt(G);const X=typeof v.at=="number"?v.at:null;if(G==="running"&&X!=null?(pt(X),an(Math.max(0,Date.now()-X))):X!=null&&typeof v.endedAt=="number"&&v.endedAt>X?(pt(null),an(v.endedAt-X)):(pt(null),an(Math.max(0,v.durationMs??0))),it([]),Vr(new Set),Ie({}),fi(null),St(null),nt(!1),j&&W){const ne=new URLSearchParams({flowId:W,runId:j});fetch(`/api/run-node-statuses?${ne}`).then(se=>se.json()).then(se=>{const ye=se.statuses&&typeof se.statuses=="object"?se.statuses:{},ve={};for(const[Be,pe]of Object.entries(ye))pe&&typeof pe=="object"&&typeof pe.status=="string"&&(ve[Be]={status:pe.status,...pe.elapsed!=null&&String(pe.elapsed).trim()!==""?{elapsed:String(pe.elapsed)}:{}});Ie(ve)}).catch(()=>{})}},[c==null?void 0:c.id]);m.useEffect(()=>{if(!(c!=null&&c.id)||Ae!=="edit")return;let v=!1;return(async()=>{try{const j=await fetch("/api/pipeline-recent-runs"),W=await j.json();if(v||!j.ok)return;const G=(Array.isArray(W.runs)?W.runs:[]).find(se=>se.flowId===c.id&&se.status==="running");if(!G||v)return;const X=G.runId||null;sr(X),Nt("running"),nt(!0),pt(G.at||Date.now()),lr.current=0;const ne=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${X},已恢复运行视图`}];if(X){const se=new URLSearchParams({flowId:c.id,runId:X}),ve=await(await fetch(`/api/run-node-statuses?${se}`)).json();if(v)return;const Be=ve.statuses&&typeof ve.statuses=="object"?ve.statuses:{},pe={},Fe=new Set;for(const[Pe,vt]of Object.entries(Be))vt&&typeof vt=="object"&&typeof vt.status=="string"&&(pe[Pe]={status:vt.status,...vt.elapsed!=null&&String(vt.elapsed).trim()!==""?{elapsed:String(vt.elapsed)}:{}},vt.status==="running"&&Fe.add(Pe));Ie(pe),Vr(Fe);try{const Pe=new URLSearchParams({flowId:c.id,runId:X,sinceBytes:"0",tailBytes:"262144"}),vt=await fetch(`/api/run-log?${Pe}`);if(vt.ok){const bn=await vt.json();if(!v){lr.current=Number(bn.bytes||0);const vn=F1(typeof bn.text=="string"?bn.text:"");it([...vn,...ne]);return}}}catch{}}it(ne)}catch{}})(),()=>{v=!0}},[c==null?void 0:c.id]),m.useEffect(()=>{if(Ae==="edit"||!(c!=null&&c.id)||!Nn)return;let v=!1,j=null;const W=async()=>{try{const Y=new URLSearchParams({flowId:c.id,runId:Nn}),G=await fetch(`/api/run-node-statuses?${Y}`);if(!G.ok)return;const X=await G.json();if(v)return;const ne=X.statuses&&typeof X.statuses=="object"?X.statuses:{},se={},ye=new Set;for(const[ve,Be]of Object.entries(ne))Be&&typeof Be=="object"&&typeof Be.status=="string"&&(se[ve]={status:Be.status,...Be.elapsed!=null&&String(Be.elapsed).trim()!==""?{elapsed:String(Be.elapsed)}:{}},Be.status==="running"&&ye.add(ve));Ie(ve=>Q7(ve,se)?ve:se),Vr(ve=>Z7(ve,ye)?ve:ye);try{const ve=new URLSearchParams({flowId:c.id,runId:Nn,sinceBytes:String(lr.current||0),tailBytes:String(Y7)}),Be=await fetch(`/api/run-log?${ve}`);if(Be.ok){const pe=await Be.json();if(v)return;const Fe=Number(pe.bytes||0),Pe=typeof pe.text=="string"?pe.text:"";if(Pe){const vt=F1(Pe);vt.length>0&&it(bn=>[...bn,...vt])}lr.current=Fe}}catch{}try{const ve=await fetch("/api/pipeline-recent-runs");if(!ve.ok)return;const Be=await ve.json();if(v)return;const Fe=(Array.isArray(Be.runs)?Be.runs:[]).find(Pe=>Pe.flowId===c.id&&Pe.runId===Nn);if(Fe&&Fe.status){const Pe=Fe.status;Pe==="running"?Nt(vt=>vt==="running"?vt:"running"):Pe==="success"?Nt("done"):Pe==="failed"?Nt("error"):(Pe==="stopped"||Pe==="interrupted")&&Nt("stopped")}}catch{}}catch{}};return W(),j=window.setInterval(W,2500),()=>{v=!0,j&&window.clearInterval(j)}},[Ae,c==null?void 0:c.id,Nn]),m.useEffect(()=>{if(ft!=="history"||!c)return;let v=!1;return(async()=>{hr(!0),_r("");try{const j=await fetch("/api/pipeline-recent-runs"),W=await j.json();if(!j.ok)throw new Error(W.error||"HTTP "+j.status);v||es(Array.isArray(W.runs)?W.runs:[])}catch(j){v||(_r(String(j.message||j)),es([]))}finally{v||hr(!1)}})(),()=>{v=!0}},[ft,c]),m.useEffect(()=>{if(!c){Wr({files:[]});return}let v=!1;return(async()=>{Ce(!0);try{const j=new URLSearchParams({flowId:c.id,flowSource:c.source||"user",archived:c.archived?"1":"0"}),W=await fetch(`/api/pipeline-files?${j}`),Y=await W.json();if(!W.ok)throw new Error(Y.error||"HTTP "+W.status);v||Wr({files:Array.isArray(Y.files)?Y.files:[],path:Y.path,error:Y.error})}catch(j){v||Wr({files:[],error:j.message||String(j)})}finally{v||Ce(!1)}})(),()=>{v=!0}},[c]);const Bd=m.useMemo(()=>c?mn.filter(v=>v&&v.flowId===c.id).sort((v,j)=>j.at-v.at):[],[mn,c]),xs=m.useMemo(()=>{let v=0,j=0,W=0,Y=0,G=0;for(const X of Bd){const ne=X.status||"unknown";ne==="success"?v+=1:ne==="failed"?j+=1:ne==="running"?W+=1:ne==="stopped"?Y+=1:ne==="interrupted"&&(G+=1)}return{success:v,failed:j,running:W,stopped:Y,interrupted:G}},[Bd]),Wd=m.useMemo(()=>c?R1(Sr,Ps):null,[c,Sr,Ps]),Fi=m.useMemo(()=>{if(!Wd||!c)return[];const v=Wd.query.toLowerCase(),j=G=>v?G.some(X=>X&&String(X).toLowerCase().includes(v)):!0,W=Dt.map(G=>{var ve,Be;const X=G.id,ne=String(((ve=G.data)==null?void 0:ve.label)??X),se=(Be=G.data)!=null&&Be.definitionId?String(G.data.definitionId):"",ye=[ne!==X?ne:"",se&&se!==X?se:""].filter(Boolean);return{id:X,label:ne,defId:se,subs:ye}}).filter(({id:G,label:X,defId:ne})=>j([G,X,ne])).sort((G,X)=>G.id.localeCompare(X.id)).slice(0,18).map(({id:G,label:X,defId:ne})=>{const se=[X!==G?X:null,ne||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:G,title:G,subtitle:se}}),Y=ue.filter(G=>G&&G.id&&j([G.id,G.label,G.description])).sort((G,X)=>G.id.localeCompare(X.id)).slice(0,22).map(G=>({kind:"definition",id:G.id,title:G.id,subtitle:G.label&&G.label!==G.id?String(G.label):String(G.type||"")}));return[...W,...Y]},[Wd,Dt,ue,c]),Vd=m.useMemo(()=>{const v=Fi.filter(W=>W.kind==="instance"),j=Fi.filter(W=>W.kind==="definition");return{instances:v,definitions:j}},[Fi]);m.useEffect(()=>{Xo(v=>{const j=Math.max(0,Fi.length-1);return Math.min(Math.max(0,v),j)})},[Fi]);const vk=m.useMemo(()=>F7(Sr),[Sr]),qr=m.useMemo(()=>Dt.filter(v=>v.selected),[Dt]),By=m.useMemo(()=>new Set(qr.map(v=>v.id)),[qr]),mh=m.useMemo(()=>wn.filter(v=>By.has(v.source)&&By.has(v.target)),[wn,By]),kk=m.useMemo(()=>{const v=le.trim().toLowerCase();return v?et.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(W=>String(W).toLowerCase().includes(v))):et},[et,le]),Sk=m.useCallback((v,j)=>{const W=String(v||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",Y=Date.now().toString(36);let G=`${W}-${Y}`,X=2;for(;j.has(G);)G=`${W}-${Y}-${X}`,X+=1;return j.add(G),G},[]),Nk=m.useCallback((v,j)=>{var tn,ws;if(!c||!v)return;const W=v.snippet&&typeof v.snippet=="object"?v.snippet:{},Y=W.instances&&typeof W.instances=="object"?W.instances:{},G=Object.keys(Y);if(G.length===0)return;const X=new Set(dr.current.map(Qe=>Qe.id)),ne={};for(const Qe of G)ne[Qe]=Sk(Qe,X);const se=(tn=W.ui)!=null&&tn.nodePositions&&typeof W.ui.nodePositions=="object"?W.ui.nodePositions:{},ye=(ws=W.ui)!=null&&ws.nodeSizes&&typeof W.ui.nodeSizes=="object"?W.ui.nodeSizes:{},ve=G.map(Qe=>{const kn=se[Qe];return{id:Qe,x:typeof(kn==null?void 0:kn.x)=="number"?kn.x:0,y:typeof(kn==null?void 0:kn.y)=="number"?kn.y:0}}),Be=Math.min(...ve.map(Qe=>Qe.x)),pe=Math.min(...ve.map(Qe=>Qe.y));let Fe=j||{x:180,y:160};const Pe=$i.current,vt=document.querySelector(".af-pipeline-flow .react-flow");if(!j&&Pe&&vt){const Qe=vt.getBoundingClientRect();Fe=Pe.screenToFlowPosition({x:Qe.left+Qe.width*.48,y:Qe.top+Qe.height*.32})}const bn={};for(const Qe of G)bn[ne[Qe]]={...Y[Qe]||{}};yr.current={...yr.current,...bn};const vn=G.map(Qe=>{const kn=Y[Qe]||{},So=ve.find(Ud=>Ud.id===Qe)||{x:0,y:0},zi=ye[Qe]&&typeof ye[Qe].width=="number"&&typeof ye[Qe].height=="number"?{width:ye[Qe].width,height:ye[Qe].height}:null,Xl={id:ne[Qe],type:"flowNode",selected:!0,position:{x:Fe.x+(So.x-Be),y:Fe.y+(So.y-pe)},...zi?{width:zi.width,height:zi.height}:{},data:{label:kn.label||ne[Qe],definitionId:kn.definitionId||Qe,role:kn.role||"normal",body:kn.body||"",script:kn.script||"",...zi?{displaySize:zi}:{}}};return kp(Xl,yr.current,ue,{},c.id)}),Vt=new Set(G),kt=(Array.isArray(W.edges)?W.edges:[]).filter(Qe=>Vt.has(Qe==null?void 0:Qe.source)&&Vt.has(Qe==null?void 0:Qe.target)).map((Qe,kn)=>({id:`e-${ne[Qe.source]}-${ne[Qe.target]}-${Date.now()}-${kn}`,source:ne[Qe.source],target:ne[Qe.target],sourceHandle:Qe.sourceHandle??void 0,targetHandle:Qe.targetHandle??void 0,markerEnd:{type:ks.ArrowClosed}}));wt(Qe=>[...Qe.map(kn=>({...kn,selected:!1})),...vn]),Gt(Qe=>[...Qe.map(kn=>({...kn,selected:!1})),...kt]),N(`已添加流程片段:${v.displayName||v.id}`)},[Sk,ue,c,Gt,wt]);Jc.current=Nk;const K2=m.useCallback(()=>{var W,Y;if(qr.length<2){bt("请先在画布上选择至少两个节点。"),Se("flows");return}const v=qr[0],j=qr.length===2?`${((W=v.data)==null?void 0:W.label)||v.id} 片段`:`${((Y=v.data)==null?void 0:Y.label)||v.id} 等 ${qr.length} 个节点`;rn({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),He(""),Ut(!0),Se("flows")},[qr]),U2=m.useCallback(async()=>{var X,ne;if(!c||qr.length<2)return;const v=nn.name.trim();if(!v){He("请填写片段名称。");return}const j=Wp(qr,yr.current),W={},Y={};for(const se of qr){W[se.id]={x:((X=se.position)==null?void 0:X.x)||0,y:((ne=se.position)==null?void 0:ne.y)||0};const ye=nq(se);ye&&(Y[se.id]=ye)}const G=mh.map(se=>({source:se.source,target:se.target,sourceHandle:se.sourceHandle??null,targetHandle:se.targetHandle??null}));fe(!0),He("");try{const se=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:nn.id,name:v,displayName:v,version:"1.0.0",description:nn.description,snippet:{instances:j,edges:G,ui:{nodePositions:W,nodeSizes:Y}}})}),ye=await se.json().catch(()=>({}));if(!se.ok||(ye==null?void 0:ye.ok)===!1)throw new Error((ye==null?void 0:ye.error)||"Publish failed");Ut(!1),N(`流程片段已发布:${ye.id||v}`),kr(`流程片段已发布:${ye.id||v}`),await ke(),Se("flows")}catch(se){He(String(se.message||se))}finally{fe(!1)}},[c,qr,mh,nn,ke,kr]),gh=m.useMemo(()=>{const v=[],j=new Set;for(const G of qr)j.add(G.id),v.push({node:G,kind:"canvas"});const W=new Map(Dt.map(G=>[G.id,G])),Y=new Map(ue.map(G=>[G.id,G]));for(const G of vk){if(j.has(G))continue;const X=W.get(G);if(X){j.add(G),v.push({node:X,kind:"mention"});continue}const ne=Y.get(G);ne&&(j.add(G),v.push({definition:ne,kind:"definition"}))}return v},[qr,vk,Dt,ue]),Is=m.useMemo(()=>{const v=Array.isArray(Et==null?void 0:Et.cursor)?Et.cursor:[],j=Array.isArray(Et==null?void 0:Et.opencode)?Et.opencode:[],W=Array.isArray(Et==null?void 0:Et.claudeCode)?Et.claudeCode:[],Y=j.map(ve=>`opencode:${ia(ve)}`),G=W.map(ve=>`claude-code:${ia(ve)}`),X=new Set([...v,...j,...W].map(ia).concat(Y).concat(G)),ne=(po||"").trim(),se=em(po,v,j,W),ye=se&&!X.has(se)&&!X.has(ne)?ne:"";return{cursorList:v,opencodeList:j,claudeCodeList:W,currentNotInLists:ye}},[Et,po]),Wy=m.useMemo(()=>new Set(ho),[ho]),Vy=ho.length,yh=m.useMemo(()=>{const v=new Map(hi.map(X=>[X.key,X])),j=new Set,W=new Set,Y=Bc.map(X=>{const ne=yl(X,hi).map(se=>v.get(se)).filter(Boolean);for(const se of ne)j.add(se.key),W.add(String(se.name||se.id||se.key||"").trim());return{...X,skills:ne}}).filter(X=>X.skills.length>0),G=hi.filter(X=>{const ne=String(X.name||X.id||X.key||"").trim();return!j.has(X.key)&&!W.has(ne)});return{groups:Y,ungrouped:G}},[Bc,hi]),Zc=m.useCallback(()=>{const v=Wc.current;if(!v)return;const j=v.getBoundingClientRect(),W=Math.min(400,Math.max(300,window.innerWidth-24)),Y=Math.min(Math.max(12,j.right-W),window.innerWidth-W-12),G=Math.max(140,j.top-22),X=Math.min(360,G);nh({position:"fixed",left:`${Y}px`,top:`${Math.max(12,j.top-X-10)}px`,width:`${W}px`,maxHeight:`${X}px`})},[]);m.useEffect(()=>{const v=Array.isArray(Et==null?void 0:Et.cursor)?Et.cursor:[],j=Array.isArray(Et==null?void 0:Et.opencode)?Et.opencode:[],W=Array.isArray(Et==null?void 0:Et.claudeCode)?Et.claudeCode:[];Jo(Y=>{const G=em(Y,v,j,W);return G===Y?Y:G})},[Et.cursor,Et.opencode,Et.claudeCode]),m.useEffect(()=>{if(!Ar)return;Zc();const v=W=>{var G,X;const Y=W.target;(G=Wc.current)!=null&&G.contains(Y)||(X=Id.current)!=null&&X.contains(Y)||Aa(!1)},j=W=>{W.key==="Escape"&&Aa(!1)};return window.addEventListener("resize",Zc),window.addEventListener("scroll",Zc,!0),document.addEventListener("pointerdown",v),document.addEventListener("keydown",j),()=>{window.removeEventListener("resize",Zc),window.removeEventListener("scroll",Zc,!0),document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",j)}},[Ar,Zc]);const Gl=m.useCallback(async(v,j={})=>{var kt;if(!c||Ma.current)return;const W=j.phaseContextSnapshot,Y=(typeof v=="string"?v:Sr).trim();if(!Y)return;const G=sh.current;Ma.current=!0,Ld(!0),Xs(e("flow:composer.connecting")),St(tn=>tn!=="composer"?"composer":tn);const X=[...Li];if(G.length>0&&X.push({type:"assistant",segments:[...G]}),Od([...X,{type:"user",text:Y}]),X.filter(tn=>tn.type==="user").length===0){const tn=Y.replace(/\s+/g," ").slice(0,30)+(Y.length>30?"…":"");st(ws=>ws.map(Qe=>Qe.id===_t?{...Qe,label:tn}:Qe))}const ne=X.map(tn=>tn.type==="user"?{role:"user",text:tn.text}:{role:"assistant",text:(tn.segments||[]).filter(Qe=>Qe.kind==="assistant"||Qe.kind==="result").map(Qe=>Qe.text).join(`
134
- `)}).filter(tn=>tn.text),se=W??Mt;pi(""),Js([]),wo([]),$d(!1);const ye=new AbortController;Un.current=ye,Uc.current=_t;let ve=null;const Be=Array.isArray(Et==null?void 0:Et.cursor)?Et.cursor:[],pe=Array.isArray(Et==null?void 0:Et.opencode)?Et.opencode:[],Fe=Array.isArray(Et==null?void 0:Et.claudeCode)?Et.claudeCode:[],Pe=em(po,Be,pe,Fe),vt=gh.filter(tn=>tn.kind!=="definition"&&tn.node).map(tn=>tn.node.id),bn=c;let vn=!1,Vt=!1;try{ve=setTimeout(()=>ye.abort(),12e4);const tn={prompt:Y,model:Pe,flowId:c.id,flowSource:c.source??"user",...c.archived?{flowArchived:!0}:{},contextInstanceIds:vt,thread:ne,selectedSkills:ho};se&&se.nextPhase&&!se.isLastPhase&&(tn.phaseContext={phaseIndex:se.nextPhase.index,phases:se.phases,userPromptOriginal:se.userPromptOriginal||Y}),Pd&&(tn.phaseRole=Pd);const ws=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(tn),signal:ye.signal});if(ve&&(clearTimeout(ve),ve=null),!ws.ok){let zi=ws.statusText||e("flow:composer.requestFailed");try{const Xl=await ws.json();Xl&&Xl.error&&(zi=String(Xl.error))}catch{}Xs(zi),Js([{kind:"error",text:zi}]);return}const Qe=(kt=ws.body)==null?void 0:kt.getReader();if(!Qe){Xs(e("flow:composer.cannotReadStream"));return}const kn=new TextDecoder;let So="";for(;;){const{done:zi,value:Xl}=await Qe.read();if(zi)break;for(So+=kn.decode(Xl,{stream:!0});;){const Ud=So.indexOf(`
135
- `);if(Ud<0)break;const Ik=So.slice(0,Ud).trim();if(So=So.slice(Ud+1),!Ik)continue;let Ze;try{Ze=JSON.parse(Ik)}catch{continue}if(Ze.type==="status"&&typeof Ze.line=="string"&&Xs(Ze.line),Ze.type==="natural"&&typeof Ze.text=="string"&&Ze.text){const En=typeof Ze.kind=="string"&&Ze.kind?Ze.kind:"assistant";Js(Sn=>[...Sn,{kind:En,text:Ze.text}])}if(Ze.type==="error"&&Ze.message){Vt=!0;const En=Ze.code?` [${Ze.code}]`:"",Sn=String(Ze.message)+En;Xs(Sn),Js(Ts=>[...Ts,{kind:"error",text:Sn}])}if(Ze.type==="plan"&&Array.isArray(Ze.steps)){wo(Ze.steps.map(Sn=>({...Sn,status:"pending"})));const En=Ze.steps.map((Sn,Ts)=>`${Ts+1}. ${Sn.description||Sn.type}`).join(`
136
- `);Js(Sn=>[...Sn,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ze.steps.length,summary:En})}])}if(Ze.type==="step-start"){const En=Ze.index??0,Sn=Ze.total??0,Ts=Ze.tier?` [${Ze.tier}]`:"",Q2=Ze.model?` (${Ze.model})`:"";Xs(e("flow:composer.step",{current:En+1,total:Sn,description:(Ze.description||"")+Ts+Q2})),wo(Z2=>Z2.map(eu=>eu.index===En?{...eu,status:"running",model:Ze.model,tier:Ze.tier,nodeRole:Ze.nodeRole??eu.nodeRole,instanceId:Ze.instanceId??eu.instanceId,instanceLabel:Ze.instanceLabel??eu.instanceLabel}:eu))}if(Ze.type==="step-progress"){const En=Ze.index??0,Sn=Ze.total??0;Xs(e("flow:composer.step",{current:En+1,total:Sn,description:Ze.description||""}))}if(Ze.type==="step-done"){const En=Ze.index??0;wo(Sn=>Sn.map(Ts=>Ts.index===En?{...Ts,status:Ze.success?"done":"error"}:Ts))}if(Ze.type==="phase-plan"&&Array.isArray(Ze.phases)){Wl(Sn=>({...Sn||{},phases:Ze.phases,currentPhase:Ze.currentPhase??0,phaseTotal:Ze.phaseTotal??Ze.phases.length,phaseName:Ze.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(Sn==null?void 0:Sn.userPromptOriginal)||Y}));const En=Ze.phases.map((Sn,Ts)=>`${Ts+1}. ${Sn.label}`).join(" → ");Js(Sn=>[...Sn,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ze.phases.length,labels:En,current:Ze.phaseName||""})}])}Ze.type==="phase-complete"&&(Wl(En=>{var Ts;return{...En||{},phases:Ze.phases||(En==null?void 0:En.phases)||[],currentPhase:Ze.phaseIndex??0,phaseTotal:Ze.phaseTotal??((Ts=Ze.phases)==null?void 0:Ts.length)??0,phaseName:Ze.phaseName||"",isLastPhase:!!Ze.isLastPhase,nextPhase:Ze.nextPhase||null,userPromptOriginal:Ze.userPromptOriginal||(En==null?void 0:En.userPromptOriginal)||Y}}),!Ze.isLastPhase&&Ze.nextPhase&&Js(En=>[...En,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ze.phaseName||e("flow:composer.nextPhase"),nextPhase:Ze.nextPhase.label})}])),Ze.type==="done"&&(vn=!0,Xs(En=>En||e("flow:composer.done")))}}}catch(tn){const ws=tn;if(ws.name==="AbortError"){const Qe=e(ve?"flow:composer.connectTimeout":"flow:composer.aborted");Xs(Qe),Js(kn=>[...kn,{kind:"error",text:Qe}])}else{const Qe=ws.code||ws.name||"UNKNOWN",kn=`${ws.message||String(tn)} [${Qe}]`;Xs(kn),Js(So=>[...So,{kind:"error",text:kn}])}}finally{if(Ma.current=!1,Ld(!1),Un.current=null,Uc.current=null,ve&&clearTimeout(ve),vn&&bn){const tn={id:bn.id,source:bn.source??"user",archived:bn.archived};(async()=>(await te(tn,{preserveComposer:!0,incrementalSync:!0}),await Di(tn,{quiet:!0,force:!0})))()}}},[c,Sr,po,Et,gh,te,Di,Li,_t,Mt,Pd,ho]);Md.current=Gl;const jk=m.useCallback(()=>{!Mt||Mt.isLastPhase||(Wl(null),Gl(e("flow:composer.skipRemainingPhases")))},[Mt,Gl]),Ck=m.useCallback(()=>{if(!Mt||Mt.isLastPhase||!Mt.nextPhase)return;const v=String(Mt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Gl(e("flow:composer.continuePhase",{label:v}),{phaseContextSnapshot:Mt})},[Mt,Gl]);m.useEffect(()=>{if(!Hl)return;const v=j=>{j.key==="Escape"&&Oi(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Hl]),m.useEffect(()=>{Ae!=="edit"&&Oi(!1)},[Ae]),m.useLayoutEffect(()=>{const v=fo.current;if(!v)return;if(!c){v.style.height="";return}v.style.height="0px";const j=getComputedStyle(v),W=parseFloat(j.lineHeight),Y=(parseFloat(j.paddingTop)||0)+(parseFloat(j.paddingBottom)||0),G=Number.isFinite(W)&&W>0?W:13*1.45,X=Y+G*2,ne=Y+G*10,se=Math.min(Math.max(v.scrollHeight,X),ne);v.style.height=`${se}px`},[Sr,c]);const Ky=m.useCallback(v=>{const j=Sr,W=Ps,Y=R1(j,W);if(!Y)return;const G=j.slice(0,Y.atIndex)+`@${v} `+j.slice(W);pi(G);const X=Y.atIndex+v.length+2;queueMicrotask(()=>{const ne=fo.current;ne&&(ne.focus(),ne.setSelectionRange(X,X)),Pa(X)})},[Sr,Ps]),Uy=m.useCallback(v=>{pi(j=>{const W=`@${v}`,Y=j.indexOf(W);return Y<0?j:j.slice(0,Y)+j.slice(Y+W.length)})},[]),Ek=m.useCallback(v=>{v.kind==="canvas"?wt(j=>j.map(W=>W.id===v.node.id?{...W,selected:!1}:W)):v.kind==="mention"?Uy(v.node.id):Uy(v.definition.id)},[wt,Uy]),q2=m.useCallback(()=>{St(v=>v==="history"?null:"history")},[]),Y2=m.useCallback(()=>{St(v=>v==="settings"?null:"settings")},[]),G2=m.useCallback(()=>{St(v=>v==="composer"?null:"composer")},[]),Kd=m.useCallback(()=>{St(v=>(v==="node"&&$l.current&&(Fc.current=$l.current.id),null))},[]),_k=m.useCallback(()=>{ys(v=>!v)},[]),X2=()=>{if(!c)return null;const v=Gs||c.archived||yi(c.source),j=Vn!=null&&Vn.running?e("flow:schedule.running"):On.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),W=Vn!=null&&Vn.running?"running":On.enabled?"waiting":"disabled",Y=mt.slice(0,12),G=c.archived||yi(c.source);return i.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[i.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[i.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),i.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),i.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),i.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),i.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),i.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),i.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),i.jsxs("main",{className:"af-pipeline-settings-main",children:[i.jsxs("div",{className:"af-pipeline-settings-main-head",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),i.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),i.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Kd,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),i.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),i.jsx("h2",{children:e("flow:settings.basicInfo")})]}),i.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?i.jsxs("div",{className:"af-pipeline-rename-row",children:[i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:R,onChange:X=>{H(X.target.value),L("")},onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),fn())},onBlur:()=>{R.trim()&&R.trim()!==c.id&&fn()},placeholder:c.id,disabled:D,spellCheck:!1}),i.jsx("span",{className:"af-pipeline-drawer-badge",children:ou(c.source??"user",e)})]}):i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,i.jsx("span",{className:"af-pipeline-drawer-badge",children:ou(c.source??"user",e)}),c.archived?i.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),B?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:B}):null]}),i.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),c.owner||"bigo"]})]})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:b,onChange:X=>k(X.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),i.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),i.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof c.path=="string"&&c.path?i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[i.jsx("span",{className:"af-pipeline-path-text",children:c.path}),i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>en(c.path),title:e("flow:settings.copyPath"),children:i.jsx("span",{className:"material-symbols-outlined",children:M?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),i.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>Yt("workspace"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>Yt("user"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),_?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:_}):null]}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),i.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),i.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),i.jsxs("div",{className:"af-pipeline-market-row",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-pipeline-market-count",children:[mt.length," ",e("flow:settings.marketNodesUnit")]}),i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),i.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:me,disabled:sn,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(sn?"common:common.loading":"common:common.refresh")]})]}),on?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:on}):null,sn?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Y.length>0?i.jsx("div",{className:"af-pipeline-market-list",children:Y.map(X=>{const ne=X.definitionId||`marketplace:${X.id}${X.version?`@${X.version}`:""}`,se=Q.has(ne)||Q.has(`marketplace:${X.id}`),ye=q.find(Fe=>String(Fe.id)===ne||String(Fe.id)===`marketplace:${X.id}`),ve=Ln===ne,Be=Zh(X.inputs||X.input),pe=Zh(X.outputs||X.output);return i.jsxs("div",{className:"af-pipeline-market-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:se?"check_circle":"extension"}),i.jsxs("div",{className:"af-pipeline-market-main",children:[i.jsxs("div",{className:"af-pipeline-market-title-row",children:[i.jsx("strong",{children:X.displayName||X.label||X.id}),i.jsx("span",{children:X.version?`v${X.version}`:ne})]}),i.jsx("p",{className:"af-pipeline-market-purpose",children:X.description||e("flow:settings.marketplaceNoDescription")}),i.jsxs("div",{className:"af-pipeline-market-io",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),i.jsx("div",{className:"af-pipeline-market-chips",children:Be.length>0?Be.map(Fe=>i.jsx("span",{className:"af-pipeline-market-chip",children:Fe},`in-${ne}-${Fe}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),i.jsx("div",{className:"af-pipeline-market-chips",children:pe.length>0?pe.map(Fe=>i.jsx("span",{className:"af-pipeline-market-chip",children:Fe},`out-${ne}-${Fe}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),i.jsxs("div",{className:"af-pipeline-market-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>$e(X),children:e("flow:settings.previewNode")}),i.jsx("button",{type:"button",className:se?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:G||ve,onClick:()=>{se&&ye?(yt(ye),St(null)):Re(X)},children:e(ve?"flow:settings.installingNode":se?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},ne)})}):i.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),i.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),i.jsx("h2",{children:e("flow:schedule.title")})]}),Pl?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[i.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[i.jsx("input",{type:"checkbox",checked:!!On.enabled,disabled:v,onChange:X=>vo(ne=>({...ne,enabled:X.target.checked}))}),i.jsx("span",{children:e("flow:schedule.enabled")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:On.cron||"",disabled:v,onChange:X=>vo(ne=>({...ne,cron:X.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:On.timezone||"",disabled:v,onChange:X=>vo(ne=>({...ne,timezone:X.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),i.jsxs("select",{className:"af-pipeline-flow-select",value:On.preset||"",disabled:v,onChange:X=>vo(ne=>({...ne,preset:X.target.value})),children:[i.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Rt).map(X=>i.jsx("option",{value:X,children:X},X))]})]})]}),i.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[i.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${W}`}),i.jsx("span",{children:On.nextRunAt?e("flow:schedule.nextRun",{time:new Date(On.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),i.jsxs("span",{children:[e("flow:schedule.runtime"),":",j]})]}),i.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[cn.lastTriggeredAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),i.jsx("dd",{children:new Date(cn.lastTriggeredAt).toLocaleString()})]}):null,cn.lastSkippedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),i.jsxs("dd",{children:[new Date(cn.lastSkippedAt).toLocaleString(),cn.lastSkipReason?` · ${cn.lastSkipReason}`:""]})]}):null,cn.lastRunUuid?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastRun")}),i.jsx("dd",{children:cn.lastRunUuid})]}):null,cn.lastExitCode!=null?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastExit")}),i.jsx("dd",{children:String(cn.lastExitCode)})]}):null,cn.lastFinishedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),i.jsx("dd",{children:new Date(cn.lastFinishedAt).toLocaleString()})]}):null]}),Vn!=null&&Vn.lastError||cn.lastError?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Vn==null?void 0:Vn.lastError)||cn.lastError}):null,c.archived||yi(c.source)?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Al?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Al}):null,Rc?i.jsx("p",{className:"af-pipeline-drawer-muted",children:Rc}):null]})]}),i.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),i.jsx("h2",{children:e("flow:pipeline.metadata")})]}),i.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsxs("dd",{children:[Dt.length," ",e("flow:pipeline.nodesUnit")]})]}),i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),i.jsx("dd",{children:q.length})]}),i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:settings.source")}),i.jsx("dd",{children:ou(c.source??"user",e)})]})]})]})]}),i.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[i.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),i.jsxs("div",{children:[i.jsx("h2",{children:c.id}),i.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${W}`,children:j})]})]}),i.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsx("dd",{children:Dt.length})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.owner")}),i.jsx("dd",{children:c.owner||"bigo"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.source")}),i.jsx("dd",{children:ou(c.source??"user",e)})]})]})]}),i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsx("h2",{children:e("flow:settings.quickActions")}),i.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void Lt(),disabled:Gs,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(Gs?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:Kd,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsx("h2",{children:e("flow:settings.help")}),i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},J2=()=>{const v=be;if(!v)return null;const j=v.definitionId||`marketplace:${v.id}${v.version?`@${v.version}`:""}`,W=v.displayName||v.label||v.id,Y=Zh(v.inputs||v.input),G=Zh(v.outputs||v.output);return $r.createPortal(i.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:X=>{X.target===X.currentTarget&&$e(null)},children:i.jsxs("div",{className:"af-market-preview-dialog",children:[i.jsxs("div",{className:"af-market-preview-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),i.jsx("h2",{children:W})]}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>$e(null),"aria-label":e("flow:settings.closePreview"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-market-preview-body",children:[i.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:i.jsxs("div",{className:"af-market-preview-node",children:[i.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(Y.length>0?Y:[""]).slice(0,4).map((X,ne)=>i.jsx("span",{title:X},`preview-in-${ne}`))}),i.jsxs("div",{className:"af-market-preview-node-main",children:[i.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("strong",{children:W}),i.jsx("span",{children:j})]}),i.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(G.length>0?G:[""]).slice(0,4).map((X,ne)=>i.jsx("span",{title:X},`preview-out-${ne}`))})]})}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:e("flow:settings.nodeFunction")}),i.jsx("p",{children:v.description||e("flow:settings.marketplaceNoDescription")})]}),i.jsxs("div",{className:"af-market-preview-io-grid",children:[i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:"Inputs"}),i.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:Y.length>0?Y.map(X=>i.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-input-${X}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:"Outputs"}),i.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:G.length>0?G.map(X=>i.jsx("span",{className:"af-pipeline-market-chip",children:X},`preview-output-${X}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),i.jsxs("dl",{className:"af-market-preview-dl",children:[i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.definitionId")}),i.jsx("dd",{children:j})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.version")}),i.jsx("dd",{children:v.version||"-"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.packagePath")}),i.jsx("dd",{children:v.packageDir||"-"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.packagedFiles")}),i.jsx("dd",{children:Array.isArray(v.packagedFiles)&&v.packagedFiles.length>0?v.packagedFiles.map(X=>X.to||X).join(", "):"-"})]})]})]})]})]})}),document.body)};return i.jsxs(Sy,{children:[i.jsx(q7,{onReady:a}),i.jsxs(wR.Provider,{value:{modelLists:Et,onModelChange:Rr},children:[i.jsxs("div",{className:"af-pipeline-page"+(Ae!=="edit"?" af-pipeline-page--run-mode":""),children:[i.jsxs("header",{className:"af-pipeline-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Ae==="running"?hh(!0):Ae!=="edit"?Yl():n("/projects")},"aria-label":e(Ae!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Ae!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",N7,"-STABLE"]})]}),i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),i.jsx("button",{type:"button",onClick:()=>n(cg(c,"workspace")),children:"Workspace"}),i.jsx("button",{type:"button",onClick:()=>n(cg(c,"display")),children:"Display"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[Kr&&i.jsx("button",{type:"button",className:"af-icon-btn"+(Ko?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>ao(v=>!v),children:i.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Ae==="running"&&i.jsxs("div",{className:"af-run-timer",children:[i.jsx("span",{className:"af-run-timer__dot"}),i.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),i.jsx("span",{className:"af-run-timer__value",children:Jx(xn,"running")})]}),Ae==="stopped"&&i.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[i.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),i.jsx("span",{className:"af-run-timer__value",children:Jx(xn,"stopped")})]}),(Ae==="done"||Ae==="error")&&i.jsxs("div",{className:"af-run-timer"+(Ae==="error"?" af-run-timer--error":" af-run-timer--done"),children:[i.jsx("span",{className:"af-run-timer__label",children:Ae==="error"?"FAILED":"COMPLETED"}),i.jsx("span",{className:"af-run-timer__value",children:Jx(xn,Ae)})]}),Ae!=="edit"&&i.jsx("button",{type:"button",className:"af-icon-btn"+(cr?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>nt(v=>!v),children:i.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Ae==="edit"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(ft==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!c,onClick:q2,children:i.jsx("span",{className:"material-symbols-outlined",children:"history"})}),i.jsx("button",{type:"button",className:"af-icon-btn"+(ft==="settings"?" af-icon-btn--active":""),onClick:Y2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!c,children:i.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ft==="composer"?" af-composer-topbar-btn--active":"")+(Kn?" af-composer-topbar-btn--running":""),onClick:G2,"aria-label":"AI Composer",title:"AI Composer",disabled:!c,children:"AI"}),i.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(_e?" af-icon-btn--active":""),onClick:_k,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!c,children:i.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!c||yi(c.source)||c.source!=="user"&&c.source!=="workspace",onClick:()=>E(!0),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),i.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!c||yi(c.source)||c.archived||c.source!=="user"&&c.source!=="workspace",onClick:()=>A(!0),children:"Archive"})]}),Ae==="running"?i.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:F2,title:e("flow:run.pauseRun"),children:[i.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Ae==="ready"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void ko(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Yl,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Ae==="stopped"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void ko({runUuid:Nn}),title:Nn?e("flow:topbar.resumeTitle",{uuid:Nn}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Yl,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Ae==="done"||Ae==="error"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void ko(),title:e("flow:topbar.rerunTitle"),children:"Run"}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Yl,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):i.jsxs("div",{className:"af-run-btn-group",children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!c,onClick:()=>void ko(),children:"Run"}),i.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!c,onClick:()=>ge(v=>!v),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":U,children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),U&&c&&i.jsxs("div",{className:"af-run-dropdown-menu",children:[i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var j,W,Y,G,X;ge(!1);const v={};for(const ne of Qs){const se=$a[ne.id];se&&(v[se]=((j=qs[se])==null?void 0:j.value)??((W=qs[se])==null?void 0:W.path)??((X=(G=(Y=ne.data)==null?void 0:Y.outputs)==null?void 0:G[0])==null?void 0:X.default)??"")}ln(v),Le(!0)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{ge(!1),ko({prepareOnly:!0})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),i.jsx("div",{className:"af-run-dropdown-divider"}),i.jsxs("div",{className:"af-run-dropdown-section",children:[i.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{ge(!1),ko()},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Rt).map(v=>i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var Y;ge(!1);const j=Rt[v]||{},W={};for(const G of Qs){const X=$a[G.id];if(!X)continue;const ne=((Y=G.data)==null?void 0:Y.definitionId)||"",se=j[G.id]??"";ne.startsWith("provide_file")?W[X]={type:"file",path:se}:W[X]={type:"str",value:se}}ko({cliInputsOverride:W})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),v]},v))]})]})]})]})]}),ot?i.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsx("span",{children:ot}),i.jsx("button",{type:"button",onClick:()=>at(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-pipeline-body"+(Ae!=="edit"?" af-pipeline-body--run-mode":""),children:[Ae==="edit"&&ft!=="settings"?i.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[i.jsxs("div",{className:`af-palette-workspace${Br?" af-palette-workspace--expanded":""}`,children:[i.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Ei(v=>!v),"aria-expanded":Br,children:[i.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),i.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),i.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Br?"expand_less":"expand_more"})]}),i.jsx("div",{className:"af-palette-workspace-path",title:c&&(c.path||Qn.path)||"",children:c?c.id:e("flow:palette2.noPipelineSelected")}),Br&&i.jsx("div",{className:"af-palette-workspace-tree",children:ae?i.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Qn.error?i.jsx("div",{className:"af-palette-workspace-empty",children:Qn.error}):c?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-palette-workspace-group",children:[i.jsxs("div",{className:"af-palette-workspace-group-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),i.jsx("span",{children:c.id}),i.jsxs("span",{className:"af-palette-workspace-count",children:["(",Qn.files.length,")"]})]}),Qn.files.length>0?i.jsx("ul",{className:"af-palette-workspace-list",children:Qn.files.filter(v=>v.type==="file").map(v=>i.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:v.path,onClick:()=>Z({filePath:v.path,fileName:v.name}),children:[i.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:v.icon}),i.jsx("span",{className:"af-palette-workspace-item-label",children:v.name}),v.size!=null&&i.jsx("span",{className:"af-palette-workspace-item-size",children:v.size<1024?`${v.size}B`:v.size<1024*1024?`${(v.size/1024).toFixed(1)}KB`:`${(v.size/1024/1024).toFixed(1)}MB`})]},v.path))}):Qn.files.filter(v=>v.type==="directory").length===0?i.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Qn.files.filter(v=>{var j;return v.type==="directory"&&((j=v.children)==null?void 0:j.length)>0}).map(v=>i.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[i.jsxs("div",{className:"af-palette-workspace-group-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:v.icon}),i.jsxs("span",{children:[v.name,"/"]}),i.jsxs("span",{className:"af-palette-workspace-count",children:["(",v.children.length,")"]})]}),i.jsx("ul",{className:"af-palette-workspace-list",children:v.children.map(j=>i.jsxs("li",{className:`af-palette-workspace-item${j.type==="file"?" af-palette-workspace-item--clickable":""}`,title:j.path,onClick:j.type==="file"?()=>Z({filePath:j.path,fileName:j.name}):void 0,children:[i.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:j.icon}),i.jsx("span",{className:"af-palette-workspace-item-label",children:j.name}),j.type==="file"&&j.size!=null&&i.jsx("span",{className:"af-palette-workspace-item-size",children:j.size<1024?`${j.size}B`:j.size<1024*1024?`${(j.size/1024).toFixed(1)}KB`:`${(j.size/1024/1024).toFixed(1)}MB`})]},j.path))})]},v.path))]}):i.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),i.jsxs("div",{className:"af-node-palette-head",children:[i.jsxs("h2",{className:"af-node-palette-title",children:[i.jsx("span",{children:"Palette"}),i.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),i.jsxs("label",{className:"af-palette-search-wrap",children:[i.jsx("span",{className:"af-visually-hidden",children:xe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),i.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:Ke,type:"search",className:"af-palette-search-input",value:le,onChange:v=>ce(v.target.value),placeholder:(xe==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":xe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":xe==="nodes",className:"af-palette-tab"+(xe==="nodes"?" af-palette-tab--active":""),onClick:()=>Se("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":xe==="flows",className:"af-palette-tab"+(xe==="flows"?" af-palette-tab--active":""),onClick:()=>Se("flows"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?i.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,i.jsx("div",{className:"af-node-palette-scroll",children:xe==="flows"?i.jsxs(i.Fragment,{children:[i.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:i.jsxs("div",{className:"af-flow-snippet-actions",children:[i.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:K2,disabled:!c||qr.length<2,title:qr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",qr.length," 节点 / ",mh.length," 连线"]})]})}),xt?i.jsx("p",{className:"af-err af-palette-list-err",children:xt}):null,ut?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):kk.length>0?i.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[i.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),i.jsx("div",{className:"af-palette-cards",children:kk.map(v=>{const j=`${v.id}@${v.version}`,W=v.displayName||v.name||v.id,Y=v.description||`${v.nodeCount||0} 个节点,${v.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>Nk(v),draggable:!!c,onDragStart:G=>{G.dataTransfer.setData("application/agentflow-snippet",j),G.dataTransfer.effectAllowed="move"},disabled:!c,title:Y,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:W}),i.jsxs("span",{className:"af-palette-card-id",children:[v.id,"@",v.version]})]})]}),Y?i.jsx("span",{className:"af-palette-card-desc",children:Y}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[v.nodeCount||0," nodes"]}),i.jsxs("span",{children:[v.edgeCount||0," edges"]})]})]},j)})})]}):i.jsx("p",{className:"af-palette-empty",children:le.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[wf.filter(v=>P[v].length>0).map(v=>i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${v}`,children:[i.jsx("h3",{className:"af-palette-cat",children:v}),i.jsx("div",{className:"af-palette-cards",children:P[v].map(j=>{const W=P1(j.inputs,"input"),Y=P1(j.outputs,"output"),X=j.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":vR(j),ne=bR(j);return i.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>yt(j),draggable:!!c,onDragStart:se=>{se.dataTransfer.setData("application/agentflow-node",j.id),se.dataTransfer.effectAllowed="move"},disabled:!c,title:X||j.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:P7(v)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:ne}),ne!==j.id?i.jsx("span",{className:"af-palette-card-id",children:j.id}):null]})]}),X?i.jsx("span",{className:"af-palette-card-desc",children:X}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[W.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[W.shown.map((se,ye)=>i.jsxs("span",{className:"af-palette-card-port",title:_1("input",se,ye),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Fn(se==null?void 0:se.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Qx(se,ye)})]},`in-${ye}`)),W.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",W.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[Y.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[Y.shown.map((se,ye)=>i.jsxs("span",{className:"af-palette-card-port",title:_1("output",se,ye),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Qx(se,ye)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Fn(se==null?void 0:se.type)}})]},`out-${ye}`)),Y.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",Y.hidden]}):null]})]})]})]},j.id)})})]},v)),c&&ue.length===0?i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,c&&ue.length>0&&le.trim()&&V===0?i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,c?null:i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),i.jsxs("footer",{className:"af-palette-engine",children:[i.jsxs("div",{className:"af-palette-engine-head",children:[i.jsx("span",{className:"af-palette-engine-dot"+(tt?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),i.jsx("span",{className:"af-palette-engine-label",children:e(tt?"common:engine.online":"common:engine.offline")})]}),x?i.jsx("div",{className:"af-palette-tip"+jn,role:"status","aria-live":"polite",children:x}):null]})]}):Ae!=="edit"&&c?i.jsx(y7,{flowId:c.id,flowSource:c.source||"user",flowArchived:c.archived,provideNodes:Qs,edges:wn,nodes:Dt,onCliInputsChange:ir,onBackToEdit:Yl}):null,i.jsxs("div",{className:"af-pipeline-main-stack",children:[i.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?i.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,c&&Zs.length>0&&!K?i.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[i.jsxs("div",{className:"af-flow-slot-warnings-head",children:[i.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),i.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",disabled:de,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void Ye(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),i.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>oe(!0),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),i.jsx("ul",{className:"af-flow-slot-warnings-list",children:Zs.map(v=>i.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',i.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:v.nodeId}),onClick:j=>{j.preventDefault(),ql(v.nodeId)},children:v.nodeId}),'"',v.suffix]},v.key))})]}):null,c&&Zs.length>0&&K?i.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Zs.length})}),i.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:_k,title:e("flow:validation.shortcutHint"),children:[i.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),i.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[i.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>oe(!1),children:e("flow:validation.show")}),i.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:de,onClick:()=>void Ye(),children:e("common:common.refresh")})]})]}):null,ft==="settings"&&c&&Ae==="edit"?X2():i.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:c?i.jsxs(i.Fragment,{children:[i.jsx(eq,{fitViewEpoch:h,canvasTool:uo,nodes:dh,edges:fh,onNodesChange:Ae!=="edit"?void 0:Dy,onEdgesChange:Ae!=="edit"?void 0:Xc,onConnect:Ae!=="edit"?void 0:gn,onConnectStart:Ae!=="edit"?void 0:Ue,onConnectEnd:Ae!=="edit"?void 0:Pt,isValidConnection:Ae!=="edit"?void 0:Ft,onNodesDelete:Ae!=="edit"?void 0:Tr,onNodeClick:Qt,onNodeDoubleClick:Xt,onEdgeClick:$n,onFlowInit:Da,onDrop:zt,onDragOver:Oe,hideMinimapAndControls:!!(c&&ft),bottomSlot:Ae==="edit"?i.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:i.jsxs("div",{className:"af-pipeline-composer-inner",children:[i.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:gh.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):gh.map((v,j)=>{var ye,ve;if(v.kind==="definition"){const Be=v.definition,pe=String(Be.label??Be.id),Fe=[Be.id,Be.description?String(Be.description).slice(0,120):""].filter(Boolean).join(" — ");return i.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Fe,children:[i.jsx("span",{className:"af-composer-node-chip-label",children:pe}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Ek(v),"aria-label":e("flow:composer.removeFromInput",{id:Be.id}),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Be.id}`)}const W=v.node,Y=v.kind,G=String(((ye=W.data)==null?void 0:ye.label)??W.id),X=(ve=W.data)!=null&&ve.definitionId?String(W.data.definitionId):"",ne=X&&X!==G?`${G} · ${W.id} · ${X}`:`${G} · ${W.id}`,se=Y==="canvas"?e("flow:composer.deselectNode",{id:W.id}):e("flow:composer.removeFromInput",{id:W.id});return i.jsxs("div",{className:"af-composer-node-chip"+(Y==="mention"?" af-composer-node-chip--mention":""),title:ne,children:[i.jsx("span",{className:"af-composer-node-chip-label",children:G}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Ek(v),"aria-label":se,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},W.id)})}),i.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[i.jsxs("div",{className:"af-composer-input-wrap",children:[i.jsx("textarea",{ref:fo,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!c,value:Sr,rows:2,onChange:v=>{pi(v.target.value),Pa(v.target.selectionStart??v.target.value.length)},onSelect:v=>{const j=v.target;j instanceof HTMLTextAreaElement&&Pa(j.selectionStart??0)},onKeyDown:v=>{if((v.metaKey||v.ctrlKey)&&v.key==="Enter"){v.preventDefault(),Gl();return}if(Wd&&Fi.length>0&&(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")){if(v.key==="ArrowDown")v.preventDefault(),Xo(j=>(j+1)%Fi.length);else if(v.key==="ArrowUp")v.preventDefault(),Xo(j=>(j-1+Fi.length)%Fi.length);else if(v.key==="Enter"){v.preventDefault();const j=Fi[gs];j&&Ky(j.id)}}},onKeyUp:v=>{const j=v.target;j instanceof HTMLTextAreaElement&&Pa(j.selectionStart??j.value.length)},onClick:v=>{const j=v.target;j instanceof HTMLTextAreaElement&&Pa(j.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Wd&&c&&Fi.length>0?i.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Vd.instances.length>0?i.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:i.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Vd.instances.map((v,j)=>{const W=j;return i.jsx("li",{role:"option","aria-selected":W===gs,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(W===gs?" af-composer-mention-item--active":""),onMouseDown:Y=>Y.preventDefault(),onMouseEnter:()=>Xo(W),onClick:()=>Ky(v.id),children:[i.jsx("span",{className:"af-composer-mention-id",children:v.title}),v.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:v.subtitle}):null]})},`i-${v.id}`)}),Vd.definitions.length>0?i.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:i.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Vd.definitions.map((v,j)=>{const W=Vd.instances.length+j;return i.jsx("li",{role:"option","aria-selected":W===gs,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(W===gs?" af-composer-mention-item--active":""),onMouseDown:Y=>Y.preventDefault(),onMouseEnter:()=>Xo(W),onClick:()=>Ky(v.id),children:[i.jsx("span",{className:"af-composer-mention-id",children:v.title}),v.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:v.subtitle}):null]})},`d-${v.id}`)})]}):null]}),i.jsxs("div",{className:"af-composer-toolbar",children:[Ir.length>0&&i.jsx("label",{className:"af-composer-session-field",children:i.jsxs("select",{className:"af-composer-session-select",value:_t||"",onChange:v=>{v.target.value==="__new__"?ih():Dd(v.target.value)},disabled:Kn,"aria-label":e("flow:composer.switchConversation"),children:[Ir.map(v=>i.jsxs("option",{value:v.id,children:[v.label,v.running?" ⏳":""]},v.id)),i.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Wc,type:"button",className:"af-composer-skills-button"+(Vy>0?" af-composer-skills-button--active":""),disabled:!c||Kn,"aria-haspopup":"listbox","aria-expanded":Ar,onClick:()=>Aa(v=>!v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Vy>0?`Skills ${Vy}`:"Skills"})]}),Ar&&!Kn?$r.createPortal(i.jsx("div",{ref:Id,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:th,children:hi.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[yh.groups.map(v=>{const j=yl(v,hi),W=_P(v,Wy,hi),Y=Zp.has(v.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(Y?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:W==="all",disabled:j.length===0,onChange:G=>{const X=G.target.checked;mo(ne=>X?CP(ne,j):EP(ne,j))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:v.name}),v.builtin?i.jsx("em",{children:"built-in"}):null,W==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":Y?`展开 ${v.name}`:`收起 ${v.name}`,onClick:()=>{eh(G=>{const X=new Set(G);return X.has(v.id)?X.delete(v.id):X.add(v.id),X})},children:[i.jsx("span",{children:v.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Y?"expand_more":"expand_less"})]})]}),Y?null:i.jsx("div",{className:"af-composer-skill-group-items",children:v.skills.map(G=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Wy.has(G.key),onChange:X=>{const ne=X.target.checked;mo(se=>ne?se.includes(G.key)?se:[...se,G.key]:se.filter(ye=>ye!==G.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:G.name}),G.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:G.description}):null]})]},`${v.id}:${G.key}`))})]},v.id)}),yh.ungrouped.length>0?i.jsxs("div",{className:"af-composer-skill-group",children:[i.jsxs("div",{className:"af-composer-skill-group-title",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("span",{children:yh.ungrouped.length})]}),yh.ungrouped.map(v=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Wy.has(v.key),onChange:j=>{const W=j.target.checked;mo(Y=>W?Y.includes(v.key)?Y:[...Y,v.key]:Y.filter(G=>G!==v.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:v.name}),v.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:v.description}):null]})]},`ungrouped:${v.key}`))]}):null]})}),document.body):null]}),i.jsxs("label",{className:"af-composer-model-field",children:[i.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),i.jsxs("select",{className:"af-composer-model-select",value:(po||"").trim()?Is.currentNotInLists?Is.currentNotInLists:em(po,Is.cursorList,Is.opencodeList,Is.claudeCodeList):"",onChange:v=>Jo(v.target.value),disabled:!c||Kn,"aria-label":e("flow:composer.modelAriaLabel"),children:[i.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Is.currentNotInLists?i.jsxs("option",{value:Is.currentNotInLists,children:[Is.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Is.cursorList.length>0?i.jsx("optgroup",{label:"Cursor",children:Is.cursorList.map(v=>i.jsx("option",{value:ia(v),children:v},`composer-c-${v}`))}):null,Is.opencodeList.length>0?i.jsx("optgroup",{label:"OpenCode",children:Is.opencodeList.map(v=>i.jsx("option",{value:`opencode:${ia(v)}`,children:v},`composer-o-${v}`))}):null,Is.claudeCodeList.length>0?i.jsx("optgroup",{label:"Claude Code",children:Is.claudeCodeList.map(v=>i.jsx("option",{value:`claude-code:${ia(v)}`,children:v},`composer-cc-${v}`))}):null]})]}),i.jsx("button",{type:"button",className:"af-composer-send"+(c&&Sr.trim()&&!Kn?" af-composer-send--active":"")+(Kn?" af-composer-send--stop":""),disabled:!c||!Kn&&!Sr.trim(),"aria-label":e(Kn?"flow:composer.stopGeneration":"flow:composer.send"),title:Kn?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var v;if(Kn){(v=Un.current)==null||v.abort();return}Gl()},children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Kn?"stop":"arrow_upward"})})]})]}),Hl?$r.createPortal(i.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:v=>{v.target===v.currentTarget&&Oi(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[i.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[i.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),i.jsx("div",{className:"af-composer-thread-dialog-status"+(Kn?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:Ta||void 0,children:Kn&&!Ta?e("flow:composer.executing"):Ta||e("flow:composer.ready")})]}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Oi(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ra.length>1&&!(Mt&&Array.isArray(Mt.phases)&&Mt.phases.length>1)?i.jsx("div",{className:"af-composer-steps-track-wrap",children:i.jsx(H7,{steps:Ra})}):null,Mt&&Array.isArray(Mt.phases)&&Mt.phases.length>1?i.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Mt.phases.map((v,j)=>{const W=v.status||(j<(Mt.currentPhase??0)?"done":j===(Mt.currentPhase??0)?Kn?"running":Mt.nextPhase||Mt.isLastPhase?"done":"running":"pending");return i.jsxs("div",{className:"af-composer-phase-item"+(W==="done"?" af-composer-phase-item--done":"")+(W==="running"?" af-composer-phase-item--running":"")+(W==="pending"?" af-composer-phase-item--pending":""),title:`${v.label}${v.description?":"+v.description:""}`,children:[i.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:W==="done"?i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):i.jsx("span",{children:j+1})}),i.jsx("span",{className:"af-composer-phase-label",children:v.label})]},v.name||j)})}):null,i.jsx("div",{className:"af-composer-thread-dialog-scroll",children:i.jsx(M1,{thread:Li,liveSegments:Qo,running:Kn})}),Mt&&!Mt.isLastPhase&&Mt.nextPhase&&!Kn?i.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[i.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Mt.nextPhase.label})}),i.jsxs("div",{className:"af-composer-phase-review-buttons",children:[i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Ck,children:e("flow:composer.phaseReviewContinue",{label:Mt.nextPhase.label})}),i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:jk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),ss&&Ae==="edit"?(()=>{var Y;const v=String(ss.query||"").trim().toLowerCase(),j=v?ss.candidates.filter(G=>{var X,ne,se;return[(X=G.def)==null?void 0:X.id,G.displayLabel,G.description,(ne=G.slot)==null?void 0:ne.name,(se=G.slot)==null?void 0:se.type].filter(Boolean).some(ye=>String(ye).toLowerCase().includes(v))}):ss.candidates,W=ss.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:ss.left,top:ss.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Fn((Y=ss.draft.slot)==null?void 0:Y.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",ss.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>gi(null),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:ss.query,onChange:G=>gi(X=>X&&{...X,query:G.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[j.map(G=>{var se,ye;const X=G.displayLabel||((se=G.def)==null?void 0:se.id),ne=Qx(G.slot,G.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>jt(G),title:G.description||G.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:X}),X!==G.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:G.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:W}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Fn((ye=G.slot)==null?void 0:ye.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ne})]})]},`${G.def.id}-${G.slotIndex}`)}),j.length===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):i.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Ae!=="edit"&&cr&&i.jsxs("div",{className:"af-run-console",style:{height:Es},children:[i.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:Hd,onPointerMove:O2,onPointerUp:bk,onPointerCancel:bk,onLostPointerCapture:$2}),i.jsxs("div",{className:"af-run-console__head",children:[i.jsxs("span",{className:"af-run-console__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),i.jsxs("div",{className:"af-run-console__head-right",children:[Ae==="running"&&i.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),i.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>nt(!1),"aria-label":e("flow:run.closeLog"),children:i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),i.jsxs("div",{className:"af-run-console__body",children:[mr.map((v,j)=>i.jsxs("div",{className:"af-run-console__line"+(v.type==="error"?" af-run-console__line--error":"")+(v.type==="warn"?" af-run-console__line--warn":"")+(v.type==="node-start"?" af-run-console__line--start":"")+(v.type==="node-done"?" af-run-console__line--done":"")+(v.type==="node-failed"?" af-run-console__line--error":"")+(v.type==="done"?" af-run-console__line--done":""),children:[i.jsxs("span",{className:"af-run-console__ts",children:["[",v.ts?new Date(v.ts).toLocaleTimeString():"--:--:--","]"]}),i.jsx("span",{className:"af-run-console__text",children:v.text!=null?String(v.text):""})]},j)),i.jsx("div",{ref:Ur})]})]})]}),Ae!=="edit"&&lo&&c?i.jsx(p7,{instanceId:lo,flowId:c.id,runId:Nn,nodeStatus:((Pk=ms[lo])==null?void 0:Pk.status)??null,onClose:()=>fi(null)}):null,ft&&ft!=="settings"&&c&&Ae==="edit"?i.jsx("aside",{className:"af-pipeline-drawer"+(ft==="node"?" af-pipeline-drawer--wide":"")+(ft==="composer"?" af-pipeline-drawer--wide":""),"aria-label":ft==="settings"?e("flow:settings.title"):ft==="history"?e("flow:history.title"):ft==="composer"?"AI Composer":e("flow:nodeProps.title"),children:ft==="composer"?i.jsxs("div",{className:"af-composer-sidebar",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Kd,"aria-label":e("flow:composer.closeSidebar"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ir.length>0&&i.jsxs("div",{className:"af-composer-session-tabs",children:[Ir.map(v=>i.jsxs("button",{type:"button",ref:j=>{j&&v.id===_t&&j.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",v.id===_t?"af-composer-session-tab--active":"",v.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Dd(v.id),title:v.label,children:[i.jsx("span",{className:"af-composer-session-label",children:v.label}),i.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:j=>{j.stopPropagation(),qc(v.id)},onKeyDown:j=>{j.key!=="Enter"&&j.key!==" "||(j.preventDefault(),j.stopPropagation(),qc(v.id))},title:v.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},v.id)),i.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>ih(),title:e("flow:composer.newConversation"),children:i.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),i.jsx("div",{className:"af-composer-sidebar-status"+(Kn?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Kn&&!Ta?e("flow:composer.executing"):Ta||e("flow:composer.ready")}),Mt&&Array.isArray(Mt.phases)&&Mt.phases.length>1?i.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Mt.phases.map((v,j)=>{const W=v.status||(j<(Mt.currentPhase??0)?"done":j===(Mt.currentPhase??0)?Kn?"running":Mt.isLastPhase&&j===Mt.phases.length-1||Mt.nextPhase?"done":"running":"pending");return i.jsxs("div",{className:"af-composer-phase-item"+(W==="done"?" af-composer-phase-item--done":"")+(W==="running"?" af-composer-phase-item--running":"")+(W==="pending"?" af-composer-phase-item--pending":""),title:`${v.label}${v.description?":"+v.description:""}`,children:[i.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:W==="done"?i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):i.jsx("span",{children:j+1})}),i.jsx("span",{className:"af-composer-phase-label",children:v.label})]},v.name||j)})}):null,i.jsx("div",{className:"af-composer-sidebar-thread",ref:Bl,children:i.jsx(M1,{thread:Li,liveSegments:Qo,running:Kn})}),Mt&&!Mt.isLastPhase&&Mt.nextPhase&&!Kn?i.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[i.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Mt.nextPhase.label})}),i.jsxs("div",{className:"af-composer-phase-review-buttons",children:[i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Ck,children:e("flow:composer.phaseReviewContinue",{label:Mt.nextPhase.label})}),i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:jk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):ft==="node"&&gt?qe?i.jsx(mR,{draft:qe,setDraft:_d,definitionId:String(((Ak=gt.data)==null?void 0:Ak.definitionId)??gt.id),systemPromptReadonly:String((Qc==null?void 0:Qc.description)??""),modelLists:Et,disabled:!c,onIdBlur:za,onClose:Kd,onPublishToMarketplace:dt,error:Oy,ioSlots:{inputs:Array.isArray(qe==null?void 0:qe.inputs)?qe.inputs:[],outputs:Array.isArray(qe==null?void 0:qe.outputs)?qe.outputs:[]}}):i.jsx("div",{className:"af-pipeline-drawer-body",children:i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:e(ft==="settings"?"flow:settings.title":"flow:history.title")}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:Kd,"aria-label":e("flow:composer.closeSidebar"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-pipeline-drawer-body",children:ft==="settings"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?i.jsxs("div",{className:"af-pipeline-rename-row",children:[i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:R,onChange:v=>{H(v.target.value),L("")},onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),fn())},onBlur:()=>{R.trim()&&R.trim()!==c.id&&fn()},placeholder:c.id,disabled:D,spellCheck:!1}),i.jsx("span",{className:"af-pipeline-drawer-badge",children:ou(c.source??"user",e)})]}):i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,i.jsx("span",{className:"af-pipeline-drawer-badge",children:ou(c.source??"user",e)}),c.archived?i.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),B?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:B}):null]}),typeof c.path=="string"&&c.path?i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[i.jsx("span",{className:"af-pipeline-path-text",children:c.path}),i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>en(c.path),title:e("flow:settings.copyPath"),children:i.jsx("span",{className:"material-symbols-outlined",children:M?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),i.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>Yt("workspace"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>Yt("user"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),_?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:_}):null]}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:b,onChange:v=>k(v.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),i.jsxs("div",{className:"af-pipeline-meta-card",children:[i.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),Pl?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-new-pipeline-radio",children:[i.jsx("input",{type:"checkbox",checked:!!On.enabled,disabled:Gs||c.archived||yi(c.source),onChange:v=>vo(j=>({...j,enabled:v.target.checked}))}),i.jsx("span",{children:e("flow:schedule.enabled")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:On.cron||"",disabled:Gs||c.archived||yi(c.source),onChange:v=>vo(j=>({...j,cron:v.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:On.timezone||"",disabled:Gs||c.archived||yi(c.source),onChange:v=>vo(j=>({...j,timezone:v.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),i.jsxs("select",{className:"af-pipeline-flow-select",value:On.preset||"",disabled:Gs||c.archived||yi(c.source),onChange:v=>vo(j=>({...j,preset:v.target.value})),children:[i.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Rt).map(v=>i.jsx("option",{value:v,children:v},v))]})]}),i.jsx("div",{className:"af-pipeline-drawer-readonly",children:i.jsx("span",{children:e("flow:schedule.overlapSkip")})}),On.nextRunAt?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(On.nextRunAt).toLocaleString()})}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),i.jsxs("dl",{className:"af-pipeline-meta-dl",children:[i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.runtime")}),i.jsx("dd",{children:Vn!=null&&Vn.running?e("flow:schedule.running"):On.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),cn.lastTriggeredAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),i.jsx("dd",{children:new Date(cn.lastTriggeredAt).toLocaleString()})]}):null,cn.lastSkippedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),i.jsxs("dd",{children:[new Date(cn.lastSkippedAt).toLocaleString(),cn.lastSkipReason?` · ${cn.lastSkipReason}`:""]})]}):null,cn.lastRunUuid?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastRun")}),i.jsx("dd",{children:cn.lastRunUuid})]}):null,cn.lastExitCode!=null?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastExit")}),i.jsx("dd",{children:String(cn.lastExitCode)})]}):null,cn.lastFinishedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),i.jsx("dd",{children:new Date(cn.lastFinishedAt).toLocaleString()})]}):null]}),Vn!=null&&Vn.lastError||cn.lastError?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Vn==null?void 0:Vn.lastError)||cn.lastError}):null,c.archived||yi(c.source)?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Al?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Al}):null,Rc?i.jsx("p",{className:"af-pipeline-drawer-muted",children:Rc}):null,i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:Gs||c.archived||yi(c.source),onClick:Wt,children:e(Gs?"flow:schedule.saving":"flow:schedule.save")})]})]}),i.jsxs("div",{className:"af-pipeline-meta-card",children:[i.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),i.jsx("dl",{className:"af-pipeline-meta-dl",children:i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsxs("dd",{children:[Dt.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),i.jsx("strong",{children:c.id})]}),Hr?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Cs?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Cs}):Bd.length===0?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):i.jsxs(i.Fragment,{children:[xs.success+xs.failed+xs.running+xs.stopped+xs.interrupted>0?i.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[xs.success>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:xs.success})}):null,xs.failed>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:xs.failed})}):null,xs.stopped>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:xs.stopped})}):null,xs.interrupted>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:xs.interrupted})}):null,xs.running>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:xs.running})}):null]}):null,i.jsx("ul",{className:"af-exec-history-list",children:Bd.map((v,j)=>{const W=v.status||"unknown",Y=W==="success"?"af-exec-history-card--success":W==="failed"?"af-exec-history-card--failed":W==="stopped"?"af-exec-history-card--stopped":W==="interrupted"?"af-exec-history-card--interrupted":W==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",G=e(W==="success"?"flow:history.success":W==="failed"?"flow:history.failed":W==="stopped"?"flow:history.stopped":W==="interrupted"?"flow:history.interrupted":W==="running"?"flow:history.running":"flow:history.unknown"),X=W==="success"?"check_circle":W==="failed"?"error":W==="stopped"?"stop_circle":W==="interrupted"?"sync_disabled":W==="running"?"progress_activity":"help",ne=v.runId||`${v.at}-${j}`,se=v.runId!=null&&v.runId.length>=6?e("flow:history.runLabel",{id:v.runId.length>8?v.runId.slice(-8):v.runId}):e("flow:history.runLabel",{id:Bd.length-j});return i.jsx("li",{className:"af-exec-history-list-item",children:i.jsxs("button",{type:"button",className:`af-exec-history-card ${Y}`,onClick:()=>V2(v),title:e("flow:history.enterRunView"),children:[i.jsxs("div",{className:"af-exec-history-card-top",children:[i.jsx("span",{className:"af-exec-history-card-title",children:se}),i.jsx("span",{className:"af-exec-history-card-time",children:hb(v.at,e)})]}),i.jsxs("div",{className:"af-exec-history-card-bottom",children:[i.jsxs("span",{className:"af-exec-history-card-status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X}),G]}),i.jsxs("span",{className:"af-exec-history-card-duration",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),QO(v.durationMs,e)]})]})]})},`${c.id}-${ne}`)})})]})]})})]})}):null]}),i.jsx(f1,{open:D2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:z2,onCancel:()=>Hy(!1)}),i.jsx(f1,{open:H2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:W2,onSecondary:B2,onCancel:()=>hh(!1)}),i.jsx(cR,{open:_e,onClose:()=>ys(!1)}),J2(),i.jsx(uR,{open:Dc,onClose:()=>Ed(!1),onJump:Ee,nodes:Dt}),i.jsx(S7,{open:Ko,onClose:()=>ao(!1),flowId:(c==null?void 0:c.id)??""}),i.jsx(aR,{open:z,onClose:()=>A(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",onArchived:async()=>{A(!1),await re(),n("/projects?tab=archived")}}),i.jsx(lR,{open:O&&!!(c!=null&&c.id),onClose:()=>E(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),onDeleted:async()=>{E(!1),f(null),wt([]),Gt([]),Wl(null),await re(),n("/projects")}}),Jn&&$r.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Ut(!1),"aria-label":e("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"名称"}),i.jsx("input",{type:"text",value:nn.name,onChange:v=>{const j=v.target.value;rn(W=>({...W,name:j,id:W.id?W.id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"ID"}),i.jsx("input",{type:"text",value:nn.id,onChange:v=>rn(j=>({...j,id:v.target.value})),placeholder:"pr-check-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:nn.description,onChange:v=>rn(j=>({...j,description:v.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",qr.length," 个节点和 ",mh.length," 条内部连线。"]}),je?i.jsx("div",{className:"af-flow-snippet-error",children:je}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Ut(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:hn||!nn.name.trim(),onClick:()=>void U2(),children:hn?"发布中…":"发布"})]})]})}),document.body),i.jsx(ZU,{open:!!J,onClose:()=>Z(null),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),filePath:(J==null?void 0:J.filePath)??"",fileName:(J==null?void 0:J.fileName)??"",onSaved:()=>{Wr(v=>({...v}))}})]}),gr&&Ae!=="edit"&&$r.createPortal(i.jsx("div",{className:"af-user-check-modal-overlay",children:i.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-user-check-modal__head",children:[i.jsxs("span",{className:"af-user-check-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:gr.instanceId})]}),i.jsx("div",{className:"af-user-check-modal__actions",children:Sd?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!gr||!c||!Nn)return;const v=Rl||gr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Nn,instanceId:gr.instanceId,content:v})})).ok?(Yo(W=>W&&{...W,content:v}),Ea(!1),it(W=>[...W,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):it(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{it(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Ca(gr.content),Ea(!1)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Ea(!0),children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),i.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Yo(null),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),i.jsx("div",{className:"af-user-check-modal__body",children:Sd?i.jsx("textarea",{ref:Nd,className:"af-user-check-modal__textarea",value:Rl||gr.content,onChange:v=>Ca(v.target.value)}):i.jsx("div",{className:"af-user-check-modal__preview",children:i.jsx("pre",{children:Rl||gr.content})})}),i.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[i.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:Ii,onChange:v=>Ti(v.target.value),disabled:Ml}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Ml||!Ii.trim(),onClick:()=>{!gr||!c||!Nn||!Ii.trim()||(_a(!0),it(v=>[...v,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"ai-edit-user-check-content",runUuid:Nn,instanceId:gr.instanceId,content:Rl||gr.content,prompt:Ii})}).then(v=>v.json()).then(v=>{_a(!1),v.ok&&v.content?(Ca(v.content),Ea(!0),Ti(""),it(j=>[...j,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):it(j=>[...j,{ts:new Date().toISOString(),type:"error",text:v.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{_a(!1),it(v=>[...v,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Ml?i.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):i.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),i.jsxs("div",{className:"af-user-check-modal__foot",children:[i.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!gr||!c||!Nn)return;const v=Rl||gr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:Nn,instanceId:gr.instanceId,content:v})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-check",runUuid:Nn,instanceId:gr.instanceId,execId:gr.execId})}),Yo(null),Ti(""),ko({runUuid:Nn})):it(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{it(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),_s&&Ae!=="edit"&&$r.createPortal(i.jsx("div",{className:"af-user-ask-modal-overlay",children:i.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-user-ask-modal__head",children:[i.jsxs("span",{className:"af-user-ask-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:_s.instanceId})]}),i.jsx("div",{className:"af-user-ask-modal__actions",children:i.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Ll(null),"aria-label":e("flow:userAsk.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),i.jsxs("div",{className:"af-user-ask-modal__body",children:[_s.question.trim()?i.jsx("div",{className:"af-user-ask-modal__question",children:i.jsx("pre",{children:_s.question})}):null,_s.options.length===0?i.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):i.jsx("div",{className:"af-user-ask-modal__options",children:_s.options.map(v=>i.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:jd,onClick:async()=>{if(!(!_s||!c||!Nn)){Go(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-ask",runUuid:Nn,instanceId:_s.instanceId,execId:_s.execId,branch:v.name,selectedIndex:v.index,selectedLabel:v.label})})).ok?(Ll(null),Go(!1),ko({runUuid:Nn})):(Go(!1),it(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{Go(!1),it(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[i.jsxs("span",{className:"af-user-ask-option__index",children:["[",v.index,"]"]}),i.jsx("span",{className:"af-user-ask-option__label",children:v.label})]},v.name))})]}),i.jsx("div",{className:"af-user-ask-modal__foot",children:i.jsx("span",{className:"af-user-ask-modal__hint",children:e(jd?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),Lc&&Ae!=="edit"&&i.jsxs("div",{className:"af-tool-print-toast"+(Ol?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[i.jsxs("div",{className:"af-tool-print-toast__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"print"}),i.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:Lc.instanceId})}),i.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Ri(v=>!v),"aria-label":e(Ol?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(Ol?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:Ol?"close_fullscreen":"open_in_full"})}),i.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>rs(null),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-tool-print-toast__body",children:i.jsx("div",{className:"af-tool-print-toast__markdown",children:i.jsx(Bp,{children:Lc.content})})})]}),Mi&&i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:Mi.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Oc(null),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:$c,className:"af-provide-edit-modal__textarea",defaultValue:Mi.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:is,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Oc(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),ze&&i.jsx("div",{className:"af-run-params-overlay",children:i.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-run-params-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),i.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),i.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Le(!1),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-run-params-modal__body",children:Qs.length===0?i.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):i.jsx("div",{className:"af-run-params-list",children:Qs.map(v=>{var ye,ve;const j=$a[v.id];if(!j)return null;const W=((ye=v.data)==null?void 0:ye.definitionId)||"",Y=W.startsWith("provide_file"),G=W==="provide_bool",X=((ve=v.data)==null?void 0:ve.label)||v.id,ne=rt[j]??"",se=["true","1","yes","on"].includes(String(ne).trim().toLowerCase());return i.jsxs("div",{className:"af-run-params-item",children:[i.jsxs("div",{className:"af-run-params-item__head",children:[i.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(Y?" af-run-params-item__icon--file":""),children:Y?"description":G?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-params-item__label",children:X}),i.jsx("span",{className:"af-run-params-item__slot",children:j})]}),G?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(se?" af-run-config-bool-toggle--true":""),onClick:()=>ln(Be=>({...Be,[j]:se?"false":"true"})),"aria-pressed":se,children:se?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-params-item__input",value:ne,onChange:Be=>ln(pe=>({...pe,[j]:Be.target.value})),placeholder:e(Y?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},v.id)})})}),i.jsxs("div",{className:"af-run-params-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var j;const v={};for(const W of Qs){const Y=$a[W.id];if(!Y)continue;const G=((j=W.data)==null?void 0:j.definitionId)||"",X=rt[Y]??"";G.startsWith("provide_file")?v[Y]={type:"file",path:X}:v[Y]={type:"str",value:X}}Le(!1),ge(!1),ko({cliInputsOverride:v})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),i.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Le(!1),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const iq="modulepreload",oq=function(e){return"/"+e},H1={},aq=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(u=>{if(u=oq(u),u in H1)return;H1[u]=!0;const d=u.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const c=document.createElement("link");if(c.rel=d?"stylesheet":iq,d||(c.as="script"),c.crossOrigin="",c.href=u,l&&c.setAttribute("nonce",l),document.head.appendChild(c),d)return new Promise((f,h)=>{c.addEventListener("load",f),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(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"&&o(l.reason);return t().catch(o)})},lq=new Set(["echarts"]),cq=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),uq=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),dq=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function hl(e){return e&&typeof e=="object"&&!Array.isArray(e)}function jc(e,t){if(!hl(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:hl(n[r])&&hl(s)&&(n[r]=jc(n[r],s));return n}function Py(e,t){return e==null?e:Array.isArray(e)?e.map(n=>hl(n)?jc(n,t):n):hl(e)?jc(e,t):e}function fq(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 nv(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)=>nv(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||uq.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);nv(r,`${t}.${n}`)}}}function pq(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(!cq.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function hq(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:jc(e,t)}function mq(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(!hl(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return jc(o,n)}):hl(e)?jc(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function gq(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Py(e,n)}function B1(e,t="rgba(255, 255, 255, 0.62)"){return Py(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 yq(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Py(e,n)}function xq(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:Py(e,t)}function wq(e,t,n){const r=mq(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>hl(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??dq,textStyle:jc(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:hq(e.tooltip),legend:gq(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?yq(e.grid,s||o):e.grid,xAxis:B1(e.xAxis),yAxis:B1(e.yAxis),radar:xq(e.radar),series:t}}function bq(e){const t=fq(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(!lq.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");nv(n);const r=pq(n.option.series),s=n.title==null?"":String(n.title),o=wq(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function ua(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 jR(e){const t=ua(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function CR(e){return ua(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function vq(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function kq(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,u="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?u&&(n.get(d).label=u):n.set(d,{id:d,label:u||d}),d},a=l=>{const u=String(l||"").trim().replace(/[;,]+$/,""),d=u.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?o(d[1],d[2]||d[3]||d[4]||d[1]):o(u.replace(/[^A-Za-z0-9_]/g,"_"),u)};for(const l of t){const u=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(u){s=u[2].toUpperCase();continue}const d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function Sq({code:e}){const t=m.useMemo(()=>kq(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((p,c)=>{l.set(p.id,{x:28+(n?c*(r+o):c%3*(r+o)),y:28+(n?c%3*(s+a):c*(s+a))})});const u=Math.max(520,...Array.from(l.values()).map(p=>p.x+r+28)),d=Math.max(220,...Array.from(l.values()).map(p=>p.y+s+28));return i.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,role:"img","aria-label":"Mermaid flowchart preview",children:[i.jsx("defs",{children:i.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:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,c)=>{const f=l.get(p.from),h=l.get(p.to);if(!f||!h)return null;const g=n?`M ${f.x+r} ${f.y+s/2} C ${(f.x+h.x+r)/2} ${f.y+s/2}, ${(f.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${f.x+r/2} ${f.y+s} C ${f.x+r/2} ${f.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:g,markerEnd:"url(#af-md-mermaid-arrow)"},`${p.from}-${p.to}-${c}`)}),t.nodes.map(p=>{const c=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:c.x,y:c.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:c.x+r/2,y:c.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,24)})]},p.id)})]})}function Nq(e){const t=String(e||"").split(/\r?\n/).map(o=>o.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],s=(o,a="")=>{const l=String(o||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const o of t){if(/^sequenceDiagram\b/i.test(o))continue;const a=o.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){s(a[2],a[3]||a[2]);continue}const l=o.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 u=o.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:u?u[2]:o})}return{participants:Array.from(n,([o,a])=>({id:o,label:a})),rows:r}}function jq({code:e}){const t=m.useMemo(()=>Nq(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,o=26,a=44,l=48,u=Math.max(620,s*2+n.length*r),d=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),p=c=>{const f=Math.max(0,n.findIndex(h=>h.id===c));return s+f*r+r/2};return i.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[i.jsx("defs",{children:i.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:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((c,f)=>{const h=s+f*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:c.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:d-18})]},c.id)}),t.rows.map((c,f)=>{const h=o+a+f*l+24;if(c.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:u-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:c.text.slice(0,120)})]},`note-${f}`);const g=p(c.from),b=p(c.to),k=(g+b)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:g,y1:h,x2:b,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:k,y:h-8,textAnchor:"middle",children:c.text.slice(0,72)})]},`msg-${f}`)})]})}function ER({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return i.jsx("div",{className:"af-md-mermaid-preview",children:n?i.jsx(jq,{code:t}):i.jsx(Sq,{code:t})})}function Cq(e){const t=String(e||"").replace(/\r\n/g,`
137
- `).split(`
138
- `),n=[];let r=[],s=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",u=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&u){o();const d=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)d.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:d.join(`
140
- `)});continue}if(!s&&vq(l)){o();const d=[];for(;a<t.length;){const p=t[a]||"";if(d.length>0&&(!p.trim()||/^-{3,}\s*$/.test(p)||/^#{1,6}\s+/.test(p)))break;d.push(p),a++}n.push({type:"mermaid",text:d.join(`
141
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&ua(l).length>1&&jR(t[a+1])){o();const d=ua(l),p=CR(t[a+1]),c=[];for(a+=2;a<t.length&&t[a].trim()&&ua(t[a]).length>1;)c.push(ua(t[a])),a++;n.push({type:"table",headers:d,align:p,rows:c});continue}r.push(l),a++}return o(),n}function W1(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),o=[];for(const a of s)if(a!=="."){if(a===".."){if(o.length===0)return n;o.pop();continue}o.push(a)}return o.join("/")}function _R(e){const t=String(e||"").replace(/\r\n/g,`
142
- `).split(`
143
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,s+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){s+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){s+=l,o+=1;continue}let p=o;for(;p<r.length&&!/\s|<|>/.test(r[p]);)p+=1;let c=r.slice(o,p),f="";for(;/[.,;:!?)}\]]$/.test(c);)f=c.slice(-1)+f,c=c.slice(0,-1);c?s+=`[${c}](${c})${f}`:s+=r.slice(o,p),o=p}return s}).join(`
144
- `)}function PR(e,t=!1,n=""){const r=s=>{const o=String(s||"").trim();if(!o)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(o)||o.startsWith("#"))return o;const a=W1(o,n);return e?e(a,{kind:"link",download:!0}):a};return{...t?{p:({children:s})=>i.jsx(i.Fragment,{children:s})}:{},code:({inline:s,className:o,children:a})=>{var d;const l=((d=String(o||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",u=String(a||"").replace(/\n$/,"");return!s&&/^(mermaid|mmd)$/i.test(l)?i.jsx(ER,{code:u}):s?i.jsx("code",{className:o,children:a}):i.jsx("code",{className:o,children:a})},img:({src:s,alt:o})=>i.jsx("img",{src:e?e(W1(s,n)):s||"",alt:o||"",loading:"lazy"}),a:({href:s,children:o})=>i.jsx("a",{href:r(s),target:"_blank",rel:"noopener noreferrer",children:o})}}function V1({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(Bp,{components:PR(t,!0,n),children:_R(e)})}function nk({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>Cq(e),[e]),s=m.useMemo(()=>PR(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(ER,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(Bp,{components:s,children:_R(o.text)},`md-${a}`):i.jsx("div",{className:"af-work-display-table-wrap",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:o.headers.map((l,u)=>i.jsx("th",{style:{textAlign:o.align[u]||"left"},children:i.jsx(V1,{resolveSrc:t,basePath:n,children:l})},u))})}),i.jsx("tbody",{children:o.rows.map((l,u)=>i.jsx("tr",{children:o.headers.map((d,p)=>i.jsx("td",{style:{textAlign:o.align[p]||"left"},children:i.jsx(V1,{resolveSrc:t,basePath:n,children:l[p]||""})},p))},u))})]})},`table-${a}`))})}function Eq(e,t=","){const n=[];let r=[],s="",o=!1;const a=String(e||"").replace(/\r\n/g,`
145
- `);for(let l=0;l<a.length;l+=1){const u=a[l],d=a[l+1];if(o){u==='"'&&d==='"'?(s+='"',l+=1):u==='"'?o=!1:s+=u;continue}u==='"'?o=!0:u===t?(r.push(s.trim()),s=""):u===`
146
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=u}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(u=>String(u||"").trim()))}function jo(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 _q(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:s.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>s.map(a=>jo(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>jo(o)||`Column ${a+1}`);return{columns:s.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>s.map((a,l)=>jo(o[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,o)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||o),label:String(s.label||s.title||s.name||s.key||`Column ${o+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(o),label:jo(s)||`Column ${o+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,o)=>({key:String(o),label:jo(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>jo(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>jo(s[a])):s&&typeof s=="object"?r.map(o=>jo(s[o.key])):r.map((o,a)=>a===0?jo(s):""))}}function Pq(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=_q(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
147
- `).split(`
148
- `).filter(l=>l.trim());if(s.length>=2&&ua(s[0]).length>1&&jR(s[1])){const l=ua(s[0]),u=CR(s[1]);return{columns:l.map((d,p)=>({key:String(p),label:d,align:u[p]||"left"})),rows:s.slice(2).map(d=>ua(d)),error:""}}const o=r.includes(" ")?" ":",",a=Eq(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((u,d)=>u||`Column ${d+1}`).map((u,d)=>({key:String(d),label:u,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function rk({content:e}){const t=m.useMemo(()=>Pq(e),[e]);return t.error||t.columns.length===0?i.jsxs("div",{className:"af-work-display-table-empty",children:[i.jsx("strong",{children:"Table data error"}),i.jsx("span",{children:t.error||"No columns found"})]}):i.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:t.columns.map((n,r)=>i.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),i.jsx("tbody",{children:t.rows.map((n,r)=>i.jsx("tr",{children:t.columns.map((s,o)=>i.jsx("td",{style:{textAlign:s.align||"left"},children:jo(n[o])},`${s.key}-${o}`))},r))})]})})}function sk({content:e}){const t=m.useRef(null),n=m.useMemo(()=>bq(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 o=!1,a=null,l=null,u=null;return s({loading:!0,error:""}),aq(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{o||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),u=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(u),l.observe(t.current)),window.addEventListener("resize",u),window.requestAnimationFrame(u),o||s({loading:!1,error:""}))}).catch(d=>{o||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,p;o=!0,u&&window.removeEventListener("resize",u),(d=l==null?void 0:l.disconnect)==null||d.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const Aq="af:workspace-graph:v2",uu=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],Iq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),Tq={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:""}]},Rq={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a local interval while this workspace page is open.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Mq={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}]},Lq={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}]},Oq=new Set(["png","jpg","jpeg","gif","webp","svg"]),AR=320,IR=180,TR=960,Rg=96,RR=900,nm=52,Cc=240,Ec=160,rv="display-ref:",$q="0.1.71";function Dq(){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 Ui(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 Mg(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 Oq.has(n)}function Lg(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=Ui(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function Fq(e,t){const n=String(e||"").trim();if(!n)return"";const r=Ui(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function zq(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 Hq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function Bq(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 Wq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!Bq(e)}function Vq(e){const t=String(e||"").trim();if(!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 o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function K1(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 Kq(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,o=Number.isFinite(r)&&Number.isFinite(s)?`(+${K1(r)} / 总 ${K1(s)})`:"";return`${t+1}. ${n}${o}`}function U1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function MR(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 LR(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function ik(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function bf(e){const t=String(ik(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 q1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Og(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function vf(e){return Og(e)}function sv(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function rm(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 Y1(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(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function G1(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 tw(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])),o=od(s.get(n),e.sourceHandle||"output-0","source"),a=od(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&bl(o,a))}function Uq(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 o=t.find(l=>l.id===n),a=od(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:sR(a)}:null}function qq(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 o=0;o<s.length;o+=1){const a=s[o];if(!(t.handleType==="source"?bl(t.slot,a):bl(a,t.slot)))continue;const u=bf(n);return{def:n,order:r,category:u,categoryRank:uu.indexOf(u),slot:a,slotIndex:o,displayLabel:vf(n),description:sv(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Yq(e,t,n){var o,a,l,u;if(!n)return[];const r=[],s=n.handleType==="source";for(const d of e||[]){if(!d||d.id===n.nodeId)continue;const p=Array.isArray(s?(o=d.data)==null?void 0:o.inputs:(a=d.data)==null?void 0:a.outputs)?s?d.data.inputs:d.data.outputs:[];for(let c=0;c<p.length;c+=1){const f=p[c];if((f==null?void 0:f.showOnNode)===!1||!(s?bl(n.slot,f):bl(f,n.slot)))continue;const g=s?{source:n.nodeId,sourceHandle:n.handleId,target:d.id,targetHandle:`input-${c}`}:{source:d.id,sourceHandle:`output-${c}`,target:n.nodeId,targetHandle:n.handleId},b=(t||[]).some(k=>k.target===g.target&&k.targetHandle===g.targetHandle);r.push({node:d,nodeId:d.id,nodeLabel:((l=d.data)==null?void 0:l.label)||d.id,definitionId:((u=d.data)==null?void 0:u.definitionId)||"",slot:f,slotIndex:c,handleId:s?g.targetHandle:g.sourceHandle,connection:g,occupied:b})}}return r.sort((d,p)=>{var b,k,y,w,x,N,_,C;const c=Number(((k=(b=d.node)==null?void 0:b.position)==null?void 0:k.y)||0),f=Number(((w=(y=p.node)==null?void 0:y.position)==null?void 0:w.y)||0),h=Number(((N=(x=d.node)==null?void 0:x.position)==null?void 0:N.x)||0),g=Number(((C=(_=p.node)==null?void 0:_.position)==null?void 0:C.x)||0);return c-f||h-g||d.slotIndex-p.slotIndex||String(d.nodeId).localeCompare(String(p.nodeId))})}function kf(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 Gq(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 o=`${n}_${s}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function Xq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function ok(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes);return{enabled:t.enabled===!0,intervalMinutes:Number.isFinite(r)&&r>0?Math.min(Math.max(Math.round(r),1),1440):60}}function Jq(e){const t=ok(JSON.stringify(e||{}));return JSON.stringify(t)}function Qq(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function X1(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 nw(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:X1(n.nextRunAt),lastAt:X1(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||"")})}return t}function Hf(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function $g(e){return e>0?`Group ${e+1}`:"Group"}function Zq(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),u=Number(n==null?void 0:n.height);return!s||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(u)?null:{id:s,title:String((n==null?void 0:n.title)||$g(r)).trim()||$g(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Cc,Math.round(l)),height:Math.max(Ec,Math.round(u))}}).filter(Boolean)}function eY(e){var n;return Zq((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Nc,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 iv(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(Cc,Math.round(t)),height:Math.max(Ec,Math.round(n))}}function sm(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:Xq(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 OR(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,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 tY(e){var s,o;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:{};return[OR(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.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)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function rw(e,t){var h,g;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=DR(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(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 d=Array.from(l).map(b=>{const k=r[b]||{},y=k.definitionId||b,w=t.find(H=>H.id===y),x=ik(w)||y,N=t.find(H=>H.id===x)||w,_=k.marketplaceRef||LR(w),C=o[b]&&typeof o[b].x=="number"&&typeof o[b].y=="number"?o[b]:{x:320+l.size*20,y:180+l.size*12},T=!!Pn(x),F=a[b]&&typeof a[b].width=="number"&&typeof a[b].height=="number"?{width:a[b].width,height:a[b].height}:null,R=Hu(F,{display:T});return{id:b,type:Nc,position:C,...R?{width:R.width,height:R.height}:{},data:{label:k.label||Og(w)||Og(N)||b,definitionId:x,..._?{marketplaceRef:_}:{},...w!=null&&w.packageId?{marketplacePackageId:w.packageId}:{},...w!=null&&w.version?{marketplaceVersion:w.version}:{},schemaType:MR(x,N||w),role:k.role||"normal",model:k.model||void 0,body:k.body||"",script:k.script||"",scriptRef:k.scriptRef||"",implementationRef:k.implementationRef||"",implementationMode:k.implementationMode||"",displayReloadKey:k.displayReloadKey||"",...R?{nodeSize:R}:{},...T&&R?{displaySize:R}:{}}}}).map(b=>kp(b,r,t)),p=eY(e),c=s.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).filter(b=>!p.some(k=>k.id===String(b.source)||k.id===String(b.target))).map((b,k)=>({id:b.id||`we-${b.source}-${b.target}-${k}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:ks.ArrowClosed}})),f=[...p,...d];return{nodes:f,edges:nR(c,f),instances:r}}function J1(e){return`${rv}${e}`}function sw(e){const t=String(e||"");return t.startsWith(rv)?t.slice(rv.length):t}function $R(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 ov(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(c=>{var f;return Pn((f=c==null?void 0:c.data)==null?void 0:f.definitionId)}).map(c=>[c.id,c])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const c of r){const f=String(c||"").trim();!f||o.has(f)||!n.has(f)||(o.add(f),s.push(f))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((c,f)=>{const h=l[c];a[c]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+f*36,y:120+f*28}});const u={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(c=>{const f=Hu(d[c],{display:!0});f&&(u[c]=f)});const p=$R(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:u,...p?{viewport:p}:{}}}function nY(e,t=[]){return ov(e,t)}function rY(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function sY(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 Q1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Hu(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:Q1(n,IR,TR)||AR,height:Q1(r,Rg,RR)||Rg}}function du(e){var s,o,a,l,u,d,p,c,f,h,g;const t=!!Pn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((u=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:u.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((c=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:c.height)||((h=(f=e==null?void 0:e.data)==null?void 0:f.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 Hu({width:n,height:r},{display:t})}function im(e,t,n){var p,c,f,h,g,b,k,y,w,x,N,_,C;const r=(e||[]).filter(T=>!Hf(T)),s=(e||[]).filter(Hf),o=DR(Wp(r,n||{})),a=t.map(T=>({source:T.source,target:T.target,sourceHandle:T.sourceHandle??null,targetHandle:T.targetHandle??null})).filter(T=>!s.some(F=>F.id===T.source||F.id===T.target)),l={},u={},d=[];for(const T of r){l[T.id]={x:((p=T.position)==null?void 0:p.x)||0,y:((c=T.position)==null?void 0:c.y)||0};const F=du(T);F&&(u[T.id]=F)}for(const T of s){const F=Number(((h=(f=T.data)==null?void 0:f.nodeSize)==null?void 0:h.width)||T.width||((g=T.measured)==null?void 0:g.width)||0),R=Number(((k=(b=T.data)==null?void 0:b.nodeSize)==null?void 0:k.height)||T.height||((y=T.measured)==null?void 0:y.height)||0);d.push({id:T.id,title:String(((w=T.data)==null?void 0:w.title)||((x=T.data)==null?void 0:x.label)||"Group"),color:String(((N=T.data)==null?void 0:N.color)||"purple"),x:Number(((_=T.position)==null?void 0:_.x)||0),y:Number(((C=T.position)==null?void 0:C.y)||0),width:Math.max(Cc,Math.round(F||Cc)),height:Math.max(Ec,Math.round(R||Ec))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:u,groups:d}}}function DR(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Pn(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 Pn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function pc(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Pn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),o=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&o(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&o(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&o(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function ad(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"]),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 iY(e){let t=String(e||"").replace(/\r\n/g,`
149
- `).trim();return t.includes(`
150
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
151
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
152
- $2`)),t}function pa(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=iY(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const u=a.match(/^result\s*:\s*(.*)$/m);if(u){const p=String(u[1]||"").trim();return p==="|"||p===">"?a.slice((u.index||0)+u[0].length).split(`
153
- `).filter(f=>/^\s+/.test(f)||!f.trim()).map(f=>f.replace(/^\s{2}/,"")).join(`
154
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const d=t.replace(n[0],"").trim();if(d)return d}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+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 u=l.resultFile||l.result;return typeof u=="string"?u:JSON.stringify(u,null,2)}}catch{}return String(e||"")}async function ld(e,t){const n=Ui(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 av(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 oY(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=s.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},u=String(l.body||"").trim(),d=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return u&&d.push(` task: ${u.slice(0,4e3)}`),d.join(`
155
- `)}).filter(Boolean).join(`
156
-
157
- `)}function gd(e){let t=pa(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 o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[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((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function aY(e){const t=gd(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function ac(e,t){return e==="html"?aY(t):""}function FR(e,t=""){const n=gd(e);if(!n.trim())return"";const s=`<base target="_self"><script>
158
- (() => {
159
- const frameId = ${JSON.stringify(String(t||""))};
160
- const postSize = () => {
161
- const doc = document.documentElement;
162
- const body = document.body;
163
- const height = Math.ceil(Math.max(
164
- doc ? doc.scrollHeight : 0,
165
- doc ? doc.offsetHeight : 0,
166
- doc ? doc.clientHeight : 0,
167
- body ? body.scrollHeight : 0,
168
- body ? body.offsetHeight : 0,
169
- body ? body.clientHeight : 0,
170
- window.innerHeight || 0
171
- ));
172
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
173
- };
174
- document.addEventListener("click", (event) => {
175
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
176
- if (!link) return;
177
- const rawHref = String(link.getAttribute("href") || "").trim();
178
- if (!rawHref || rawHref.startsWith("#")) return;
179
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
180
- event.preventDefault();
181
- window.location.href = link.href;
182
- }, true);
183
- window.addEventListener("load", postSize);
184
- window.addEventListener("resize", postSize);
185
- requestAnimationFrame(postSize);
186
- setTimeout(postSize, 60);
187
- setTimeout(postSize, 300);
188
- if (typeof ResizeObserver !== "undefined") {
189
- const resizeObserver = new ResizeObserver(postSize);
190
- resizeObserver.observe(document.documentElement);
191
- if (document.body) resizeObserver.observe(document.body);
192
- }
193
- if (typeof MutationObserver !== "undefined") {
194
- const mutationObserver = new MutationObserver(postSize);
195
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
196
- }
197
- })();
198
- <\/script>`;return/<script\b[^>]*>\s*\(\(\)\s*=>\s*\{\s*document\.addEventListener\("click"/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 lY(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 cY(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function uY(e,t){const n=URL.createObjectURL(e);try{cY(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function zR(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 dY(e){const t=zR(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>"}
199
- ${t.documentElement.outerHTML}`:""}function iw(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 fY(e,t,n,r={}){var k;const s=(k=e==null?void 0:e.getBoundingClientRect)==null?void 0:k.call(e),o=zR(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,u=(r==null?void 0:r.card)||null,d=(r==null?void 0:r.displayBody)||null,p=(r==null?void 0:r.scroller)||null,c=(r==null?void 0:r.displaySize)||null,f={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((c==null?void 0:c.width)||0)||null,displaySizeHeight:Number((c==null?void 0:c.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:iw(u),displayBody:iw(d),scroller:iw(p)},h=[Number(t)||0,Number((c==null?void 0:c.width)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.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:f}}async function pY({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:u}){const d=fY(r,s,o,{...l||{},displaySize:u}),p=dY(r),c=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:p||t,sourceFilePath:n||"",width:d.width,height:d.height,filename:a})});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const f=await c.blob();uY(f,a)}function hY(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 HR(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function mY(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,u="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?u&&(n.get(d).label=u):n.set(d,{id:d,label:u||d}),d},a=l=>{const u=String(l||"").trim().replace(/[;,]+$/,""),d=u.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?o(d[1],d[2]||d[3]||d[4]||d[1]):o(u.replace(/[^A-Za-z0-9_]/g,"_"),u)};for(const l of t){const u=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(u){s=u[2].toUpperCase();continue}const d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function BR({code:e}){const t=m.useMemo(()=>mY(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((p,c)=>{l.set(p.id,{x:24+(n?c*(r+o):c%3*(r+o)),y:24+(n?c%3*(s+a):c*(s+a))})});const u=Math.max(360,...Array.from(l.values()).map(p=>p.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(p=>p.y+s+24));return i.jsx("div",{className:"af-work-node__mermaid-preview",children:i.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,role:"img","aria-label":"Mermaid preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,c)=>{const f=l.get(p.from),h=l.get(p.to);if(!f||!h)return null;const g=n?`M ${f.x+r} ${f.y+s/2} C ${(f.x+h.x+r)/2} ${f.y+s/2}, ${(f.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${f.x+r/2} ${f.y+s} C ${f.x+r/2} ${f.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${p.from}-${p.to}-${c}`)}),t.nodes.map(p=>{const c=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:c.x,y:c.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:c.x+r/2,y:c.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,22)})]},p.id)})]})})}function Vi({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const c=Math.max(1,p.scrollHeight),f=Math.max(1,p.clientHeight),h=c>f+1,g=h?Math.max(12,f/c*100):100,b=Math.max(0,100-g),k=h?Math.min(b,p.scrollTop/Math.max(1,c-f)*b):0;o({visible:h,top:k,height:g})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),c=n.current;if(!c||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const f=new ResizeObserver(a);f.observe(c);for(const h of Array.from(c.children))f.observe(h);return()=>{cancelAnimationFrame(p),f.disconnect()}},[t,a]);const l=m.useCallback(p=>{const c=n.current;if(!c)return;const f=Math.max(0,c.scrollHeight-c.clientHeight);c.scrollTop=Math.min(1,Math.max(0,p))*f,a()},[a]),u=m.useCallback((p,c=0)=>{const f=r.current;if(!f)return 0;const h=f.getBoundingClientRect(),g=s.height/100*h.height,b=Math.max(1,h.height-g);return(p-h.top-c)/b},[s.height]),d=m.useCallback(p=>{var N,_;if(!s.visible)return;p.preventDefault(),p.stopPropagation();const c=r.current;if(!c)return;const f=c.getBoundingClientRect(),h=s.top/100*f.height,g=s.height/100*f.height,k=p.clientY>=f.top+h&&p.clientY<=f.top+h+g?p.clientY-f.top-h:g/2;l(u(p.clientY,k));const y=p.pointerId;(_=(N=p.currentTarget).setPointerCapture)==null||_.call(N,y);const w=C=>{C.preventDefault(),l(u(C.clientY,k))},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)},[u,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[i.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function WR({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Pn(e==null?void 0:e.definitionId),o=pc(e),a=s==="image"?o:pa(o),l=s==="image"?"":ad(a,s),[u,d]=m.useState(""),[p,c]=m.useState(""),[f,h]=m.useState(!1);m.useEffect(()=>{let N=!1;return l?(h(!0),c(""),d(""),ld(t,l).then(_=>{N||d(_)}).catch(_=>{N||c(String(_.message||_))}).finally(()=>{N||h(!1)}),()=>{N=!0}):(d(""),c(""),h(!1),()=>{N=!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?u:a,b=s==="html"?gd(g):pa(g),k=m.useRef(""),[y,w]=m.useState(0);if(k.current||(k.current=`html-display-${Math.random().toString(36).slice(2,10)}`),m.useEffect(()=>{if(s!=="html"){w(0);return}const N=k.current,_=C=>{const T=n.current;if(!T||C.source!==T.contentWindow)return;const F=C.data&&typeof C.data=="object"?C.data:null;if(!F||F.source!=="agentflow-html-display-size"||F.frameId!==N)return;const R=Math.ceil(Number(F.height||0));!Number.isFinite(R)||R<=0||w(Math.min(2e5,Math.max(220,R)))};return w(0),window.addEventListener("message",_),()=>window.removeEventListener("message",_)},[b,n,r,s]),!s)return null;const x=ac(s,b);if(f)return i.jsxs(Vi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(p)return i.jsx(Vi,{className:"af-work-display-empty",children:p});if(x)return i.jsx(Vi,{className:"af-work-display-empty",children:x});if(!b.trim())return i.jsx(Vi,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return i.jsx(Vi,{className:"af-work-display-body af-work-display-body--html",children:i.jsx("iframe",{ref:n,className:"af-work-display-html-frame",style:y>0?{height:`${y}px`}:void 0,title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals",srcDoc:FR(b,k.current)},r)});if(s==="image"){const N=Lg(b,t);return i.jsx(Vi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:N,alt:hY(e),loading:"lazy"})})}return s==="markdown"?i.jsx(Vi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(nk,{content:b,basePath:l,resolveSrc:(N,_)=>Lg(N,t,_)})}):s==="chart"?i.jsx(Vi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(sk,{content:b})}):s==="table"?i.jsx(Vi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(rk,{content:b})}):s==="mermaid"?i.jsxs(Vi,{className:"af-work-display-body",children:[i.jsx(BR,{code:b}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:b})]}):i.jsx(Vi,{className:"af-work-display-body af-work-display-body--ascii",children:i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:b})})}function gY({node:e,onClose:t}){var o,a,l;const n=m.useRef(null),r=Pn((o=e==null?void 0:e.data)==null?void 0:o.definitionId),s=((a=e==null?void 0:e.data)==null?void 0:a.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览");return m.useEffect(()=>{const u=d=>{d.key==="Escape"&&(t==null||t())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t]),e?$r.createPortal(i.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:i.jsxs("div",{className:"af-display-preview-shell",children:[i.jsxs("div",{className:"af-display-preview-head",children:[i.jsxs("div",{className:"af-display-preview-title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:HR(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsx("button",{type:"button",className:"af-display-preview-close",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsx("div",{className:"af-display-preview-content",children:i.jsx(WR,{data:e.data,flowParams:(l=e.data)==null?void 0:l.flowParams,htmlFrameRef:n})})]})}),document.body):null}function yY({node:e}){var f,h,g,b,k,y,w,x,N,_,C;const t=Pn((f=e==null?void 0:e.data)==null?void 0:f.definitionId),n=pc(e==null?void 0:e.data),r=t==="image"?n:pa(n),s=t==="image"?"":ad(r,t),[o,a]=m.useState(""),[l,u]=m.useState(!1);m.useEffect(()=>{var F;let T=!1;return s?(u(!0),a(""),ld(((F=e==null?void 0:e.data)==null?void 0:F.flowParams)||{},s).then(R=>{T||a(R)}).catch(()=>{T||a("")}).finally(()=>{T||u(!1)}),()=>{T=!0}):(a(""),u(!1),()=>{T=!0})},[s,(g=(h=e==null?void 0:e.data)==null?void 0:h.flowParams)==null?void 0:g.flowId,(k=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:k.flowSource,(w=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:w.archived,(x=e==null?void 0:e.data)==null?void 0:x.displayReloadKey]);const d=s?o:r,p=t==="html"?gd(d):pa(d),c=ac(t,p);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):c?i.jsx("div",{className:"af-display-picker-preview__empty",children:c}):p.trim()?t==="html"?i.jsx("iframe",{title:((N=e==null?void 0:e.data)==null?void 0:N.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals",srcDoc:FR(p)}):t==="image"?i.jsx("img",{src:Lg(p,(_=e==null?void 0:e.data)==null?void 0:_.flowParams),alt:((C=e==null?void 0:e.data)==null?void 0:C.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(nk,{content:p,basePath:s,resolveSrc:(T,F)=>{var R;return Lg(T,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,F)}})}):t==="chart"?i.jsx(sk,{content:p}):t==="table"?i.jsx(rk,{content:p}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(BR,{code:p}),i.jsx("pre",{children:p})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:p}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function xY({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,u]=m.useState(!1),[d,p]=m.useState({visible:!1,top:0,height:100}),c=m.useCallback(()=>{const y=s.current;if(!y)return;const w=Math.max(1,y.scrollHeight),x=Math.max(1,y.clientHeight),N=w>x+1,_=N?Math.max(12,x/w*100):100,C=Math.max(0,100-_),T=N?Math.min(C,y.scrollTop/Math.max(1,w-x)*C):0;p({visible:N,top:T,height:_})},[]);m.useEffect(()=>{const y=requestAnimationFrame(c),w=s.current;if(!w||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(y);const x=new ResizeObserver(c);return x.observe(w),()=>{cancelAnimationFrame(y),x.disconnect()}},[c,e]);const f=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,c()},[c]),h=m.useCallback((y,w=0)=>{const x=a.current;if(!x)return 0;const N=x.getBoundingClientRect(),_=d.height/100*N.height,C=Math.max(1,N.height-_);return(y-N.top-w)/C},[d.height]),g=m.useCallback(y=>{if(!d.visible)return;y.preventDefault(),y.stopPropagation();const w=a.current;if(!w)return;const x=w.getBoundingClientRect(),N=d.top/100*x.height,_=d.height/100*x.height,T=y.clientY>=x.top+N&&y.clientY<=x.top+N+_?y.clientY-x.top-N:_/2;f(h(y.clientY,T));const F=H=>{H.preventDefault(),f(h(H.clientY,T))},R=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R)};window.addEventListener("pointermove",F),window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R)},[h,f,d.height,d.top,d.visible]),b=m.useCallback(y=>{const w=String(e||""),x=s.current,N=Number((x==null?void 0:x.selectionStart)??w.length),_=Number((x==null?void 0:x.selectionEnd)??N),C=w.slice(0,N),T=w.slice(_),F=C&&!C.endsWith(`
200
- `)?`
201
- `:"",R=T&&!T.startsWith(`
202
- `)?`
203
- `:"",H=`${C}${F}${y}${R}${T}`;t==null||t(H),window.requestAnimationFrame(()=>{var $,B;const D=C.length+F.length+y.length;($=s.current)==null||$.focus(),(B=s.current)==null||B.setSelectionRange(D,D)})},[t,e]),k=m.useCallback(async y=>{if(!r&&!(!y||l)){u(!0);try{const w=await(n==null?void 0:n(y)),x=String(w||"").trim();if(x){const N=String(y.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";b(`![${N}](${x})`)}}finally{u(!1)}}},[b,n,r,l]);return i.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(N=>String((N==null?void 0:N.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(Mg);w&&(y.preventDefault(),k(w))},children:[i.jsxs("div",{className:"af-work-display-editor__toolbar",children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var y;return(y=o.current)==null?void 0:y.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),i.jsx("input",{ref:o,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&&k(w)}})]}),i.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:y=>t==null?void 0:t(y.target.value),onScroll:c,onKeyDown:y=>{y.key==="Escape"&&y.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),i.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(d.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:g,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${d.height}%`,top:`${d.top}%`}})})]})}function wY({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,u]=m.useState(a),d=m.useRef(!1),p=String(s.candidateContent||""),c=!!s.running,f=!!(t!=null&&t.readOnly),h=String(s.error||"");return m.useEffect(()=>{d.current||u(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-work-node-chat__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"继续微调"}),i.jsx("span",{children:(t==null?void 0:t.label)||e})]}),i.jsx("button",{type:"button",onClick:()=>{var g;return(g=t==null?void 0:t.onCloseNodeChat)==null?void 0:g.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||c||h||p.trim()?i.jsxs("div",{className:"af-work-node-chat__messages",children:[o.slice(-4).map((g,b)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${g.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:g.role==="assistant"?"AI":"你"}),i.jsx("p",{children:g.text})]},`${g.at||b}-${b}`)),c?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?i.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:c||f,"aria-label":"添加上下文",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),i.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:c||f,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:g=>{var k;d.current=!1;const b=g.currentTarget.value;u(b),(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,b)},onChange:g=>{var k;const b=g.target.value;u(b),d.current||(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,b)},onKeyDown:g=>{var b,k;g.isComposing||(b=g.nativeEvent)!=null&&b.isComposing||g.keyCode===229||(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),(k=t==null?void 0:t.onSendNodeChat)==null||k.call(t,e,l))}}),i.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:c||f||!l.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onSendNodeChat)==null?void 0:g.call(t,e,l)},"aria-label":"发送",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),i.jsxs("div",{className:"af-work-node-chat__actions",children:[i.jsx("button",{type:"button",disabled:c||f||!p.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"replace")},children:"替换当前内容"}),i.jsx("button",{type:"button",disabled:c||f||!p.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"append")},children:"追加"})]})]}):i.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:g=>{var b;g.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function bY(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function vY(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function Z1(e,t){const n=Pn(t==null?void 0:t.definitionId)||"markdown";return`outputs/${vY((t==null?void 0:t.label)||e||n)}.${bY(n)}`}function kY({id:e,data:t,selected:n,deleteNode:r}){var we,ue,Ne;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((le,ce)=>({slot:le,idx:ce})).sort((le,ce)=>{var We,ut,Ve,xt;const xe=String(((We=le.slot)==null?void 0:We.name)||"").trim(),Se=String(((ut=ce.slot)==null?void 0:ut.name)||"").trim();if(xe==="next"&&Se!=="next")return-1;if(Se==="next"&&xe!=="next")return 1;const Ke=String(((Ve=le.slot)==null?void 0:Ve.type)||"").trim(),et=String(((xt=ce.slot)==null?void 0:xt.type)||"").trim();return Ke==="node"&&et!=="node"?-1:et==="node"&&Ke!=="node"?1:le.idx-ce.idx}),l=Pn(t==null?void 0:t.definitionId),u=m.useRef(null),d=m.useRef(null),[p,c]=m.useState(0),[f,h]=m.useState(!1),[g,b]=m.useState(!1),[k,y]=m.useState(!1),[w,x]=m.useState(""),[N,_]=m.useState(""),[C,T]=m.useState(!1),[F,R]=m.useState(!1),H=m.useRef(null),D=pc(t),$=l==="markdown"?pa(D):"",B=l==="markdown"?ad($,"markdown"):"",L=l==="markdown"?B?N:$:"",M=!!(t!=null&&t.readOnly),I=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let le=!1;return l!=="markdown"||!B?(_(""),T(!1),()=>{le=!0}):(T(!0),ld((t==null?void 0:t.flowParams)||{},B).then(ce=>{le||_(ce)}).catch(ce=>{var xe;le||(_(""),(xe=t==null?void 0:t.onStatus)==null||xe.call(t,String(ce.message||ce)))}).finally(()=>{le||T(!1)}),()=>{le=!0})},[l,B,(we=t==null?void 0:t.flowParams)==null?void 0:we.flowId,(ue=t==null?void 0:t.flowParams)==null?void 0:ue.flowSource,(Ne=t==null?void 0:t.flowParams)==null?void 0:Ne.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!g)return;const le=()=>b(!1);return window.addEventListener("pointerup",le,!0),window.addEventListener("pointercancel",le,!0),window.addEventListener("mouseup",le,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("pointerup",le,!0),window.removeEventListener("pointercancel",le,!0),window.removeEventListener("mouseup",le,!0),window.removeEventListener("blur",le)}},[g]),m.useEffect(()=>{k||x(String(L||""))},[L,k]);const z=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),A=String((t==null?void 0:t.sourceNodeId)||e),O=(t==null?void 0:t.sharingDisplayNodeId)===A,E=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,J=m.useCallback(async()=>{var bt,Jn,Ut,nn,rn,hn,fe,je,He,ot;if(l!=="html"||f)return;const le=pc(t),ce=ad(le,l);let xe=le;if(ce)try{xe=await ld((t==null?void 0:t.flowParams)||{},ce)}catch(at){h(!1),console.warn("Failed to read HTML display file before saving image.",at);return}const Se=gd(xe);if(!Se.trim())return;const Ke=ac(l,Se);if(Ke){console.warn(Ke);return}const et=(Jn=(bt=d.current)==null?void 0:bt.getBoundingClientRect)==null?void 0:Jn.call(bt),We=(nn=(Ut=u.current)==null?void 0:Ut.querySelector)==null?void 0:nn.call(Ut,".af-work-display-body"),ut=(hn=(rn=u.current)==null?void 0:rn.querySelector)==null?void 0:hn.call(rn,".af-visible-scroll-frame__scroller"),Ve=Math.round(Math.max(Number((et==null?void 0:et.width)||0),Number((E==null?void 0:E.width)||0),Number(((fe=u.current)==null?void 0:fe.clientWidth)||0),Number((We==null?void 0:We.clientWidth)||0),Number((ut==null?void 0:ut.clientWidth)||0),Math.max(320,Number((E==null?void 0:E.width)||960)-2))),xt=Math.round(Math.max(Number((et==null?void 0:et.height)||0),Number((E==null?void 0:E.height)||0),Number(((je=u.current)==null?void 0:je.clientHeight)||0),Number((We==null?void 0:We.clientHeight)||0),Number((ut==null?void 0:ut.clientHeight)||0),Math.max(180,Number((E==null?void 0:E.height)||640)-46)));h(!0);try{await pY({flowParams:(t==null?void 0:t.flowParams)||{},content:Se,sourceFilePath:ce,iframe:d.current,width:Ve,height:xt,filename:lY((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:u.current,displayBody:We,scroller:ut},displaySize:E}),(He=t==null?void 0:t.onStatus)==null||He.call(t,"已导出 HTML 展示截图")}catch(at){const Tt=String((at==null?void 0:at.message)||at||"截图失败");(ot=t==null?void 0:t.onStatus)==null||ot.call(t,`HTML 截图失败:${Tt}`),console.warn("Failed to save HTML display as PNG.",at)}finally{h(!1)}},[t,E==null?void 0:E.height,E==null?void 0:E.width,e,l,f]),Z=m.useCallback(le=>{var ce;M||!le||l!=="image"||(ce=t==null?void 0:t.onUploadImageToDisplayNode)==null||ce.call(t,e,le)},[t,e,l,M]),K=m.useCallback(le=>{var ce,xe;(ce=le==null?void 0:le.stopPropagation)==null||ce.call(le),!M&&((xe=t==null?void 0:t.onSetDisplayNodeContent)==null||xe.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),y(!1)))},[t,e,l,M]),oe=m.useCallback(le=>{var Se,Ke;M||l!=="image"||!(Array.from(((Se=le.dataTransfer)==null?void 0:Se.files)||[]).some(Mg)||Array.from(((Ke=le.dataTransfer)==null?void 0:Ke.items)||[]).some(et=>String((et==null?void 0:et.type)||"").startsWith("image/")))||(le.preventDefault(),le.stopPropagation(),le.dataTransfer.dropEffect="copy",R(!0))},[l,M]),de=m.useCallback(le=>{l==="image"&&(le.currentTarget.contains(le.relatedTarget)||R(!1))},[l]),he=m.useCallback(le=>{var xe;if(l!=="image")return;const ce=Array.from(((xe=le.dataTransfer)==null?void 0:xe.files)||[]).find(Mg);ce&&(le.preventDefault(),le.stopPropagation(),R(!1),Z(ce))},[l,Z]);return i.jsxs("div",{className:"af-work-display-card"+(E?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(g?" af-work-display-card--resizing":"")+(F?" af-work-display-card--image-drop":"")+(I?" 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:E?{width:E.width,height:E.height}:void 0,ref:u,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:oe,onDragLeave:de,onDrop:he,children:[i.jsx(T0,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>b(!0),onResizeEnd:()=>b(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((le,ce)=>{if(le.showOnNode===!1)return null;const xe=`${4.15+ce*1.75}rem`,Se=le.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:xe},children:Se}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:xe,background:Fn(le.type)},title:`${Se} · ${le.type}`})]},`in-${ce}`)}),a.map(({slot:le,idx:ce},xe)=>{if(le.showOnNode===!1)return null;const Se=`${4.15+xe*1.75}rem`,Ke=le.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Se},children:Ke}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Se,background:Fn(le.type)},title:`${Ke} · ${le.type}`})]},`out-${ce}`)}),i.jsxs("div",{className:"af-work-display-card__head",children:[i.jsxs("div",{className:"af-work-display-card__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:HR(l)}),i.jsx("strong",{children:z}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:le=>le.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var le,ce,xe,Se;try{(Se=(xe=(ce=(le=d.current)==null?void 0:le.contentWindow)==null?void 0:ce.history)==null?void 0:xe.back)==null||Se.call(xe)}catch{}},"aria-label":"后退",title:"后退",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var le,ce,xe,Se;try{(Se=(xe=(ce=(le=d.current)==null?void 0:le.contentWindow)==null?void 0:ce.history)==null?void 0:xe.forward)==null||Se.call(xe)}catch{}},"aria-label":"前进",title:"前进",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>c(le=>le+1),"aria-label":"刷新",title:"刷新",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:f,onClick:J,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:f?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?k?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:le=>le.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:M||C,onClick:async()=>{var le,ce,xe;if(B){try{const Se=await av((t==null?void 0:t.flowParams)||{},B,w);_(w),(le=t==null?void 0:t.onSetDisplayNodeContent)==null||le.call(t,e,Se,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${Se}`}),y(!1)}catch(Se){(ce=t==null?void 0:t.onStatus)==null||ce.call(t,String(Se.message||Se))}return}(xe=t==null?void 0:t.onSetDisplayNodeContent)==null||xe.call(t,e,w,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),y(!1)},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"done"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String(L||"")),y(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M||C,onClick:le=>{le.stopPropagation(),x(String(L||"")),y(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:H,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:le=>{var xe;const ce=(xe=le.target.files)==null?void 0:xe[0];le.target.value="",ce&&Z(ce)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:le=>{var ce;le.stopPropagation(),(ce=H.current)==null||ce.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:le=>{var ce;le.stopPropagation(),(ce=t==null?void 0:t.onOpenDisplayPreview)==null||ce.call(t,A)},"aria-label":"全屏预览",title:"全屏预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:O,onClick:le=>{var ce;le.stopPropagation(),(ce=t==null?void 0:t.onShareDisplayNode)==null||ce.call(t,A)},"aria-label":"分享展示",title:"分享展示(1 天有效)",children:i.jsx("span",{className:"material-symbols-outlined",children:O?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:K,"aria-label":"清空内容",title:"清空内容",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:()=>{var le;return(le=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:le.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"save"})}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:M,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&k?i.jsx(xY,{value:w,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:M}):i.jsx(WR,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:d,htmlFrameVersion:p}),i.jsx(wY,{nodeId:e,data:t})]})}function SY({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=(t==null?void 0:t.runningRunNodeId)===e,l=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return i.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(l?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((d,p)=>{if(d.showOnNode===!1)return null;const c=`${2.25+p*1.75}rem`,f=d.name||`#${p+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:c},children:f}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${p}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:c,background:Fn(d.type)},title:`${f} · ${d.type}`})]},`in-${p}`)}),o.map((d,p)=>{if(d.showOnNode===!1)return null;const c=`${2.25+p*1.75}rem`,f=d.name||`#${p+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:c},children:f}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${p}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:c,background:Fn(d.type)},title:`${f} · ${d.type}`})]},`out-${p}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u,onClick:d=>{var p,c;d.stopPropagation(),a?(p=t==null?void 0:t.onStopWorkspaceNode)==null||p.call(t,e):(c=t==null?void 0:t.onRunWorkspaceNode)==null||c.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),i.jsx("span",{children:a?"Stop":"Run line"})]})]})}function NY({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=ok((t==null?void 0:t.body)||""),l=(t==null?void 0:t.scheduledRunState)||{},u=(t==null?void 0:t.runningRunNodeId)===e,d=(t==null?void 0:t.nodeStatus)==="stopped",p=!!(t!=null&&t.readOnly),c=f=>{var h;(h=t==null?void 0:t.onChangeScheduledRunConfig)==null||h.call(t,e,{...a,...f})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(u?" 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":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((f,h)=>{if(f.showOnNode===!1)return null;const g=`${2.25+h*1.75}rem`,b=f.name||`#${h+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:g},children:b}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${h}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:g,background:Fn(f.type)},title:`${b} · ${f.type}`})]},`in-${h}`)}),o.map((f,h)=>{if(f.showOnNode===!1)return null;const g=`${2.25+h*1.75}rem`,b=f.name||`#${h+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:g},children:b}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${h}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:g,background:Fn(f.type)},title:`${b} · ${f.type}`})]},`out-${h}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:p,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[i.jsxs("label",{className:"af-work-schedule-card__toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,disabled:p,onChange:f=>c({enabled:f.target.checked})}),i.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"每"}),i.jsx("input",{type:"number",min:"1",max:"1440",step:"1",value:a.intervalMinutes,disabled:p,onChange:f=>c({intervalMinutes:f.target.value})}),i.jsx("span",{children:"分钟"})]}),i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:["Next ",Qq(l.nextAt)]}),i.jsx("span",{children:l.lastStatus||"idle"})]})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(u?" af-work-run-card__button--stop":""),disabled:p,onClick:f=>{var h,g;f.stopPropagation(),u?(h=t==null?void 0:t.onStopWorkspaceNode)==null||h.call(t,e):(g=t==null?void 0:t.onRunWorkspaceNode)==null||g.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:u?"stop_circle":"play_arrow"}),i.jsx("span",{children:u?"Stop":"Run now"})]})]})}function jY({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=El(),o=!!(t!=null&&t.readOnly),a=iv(t==null?void 0:t.nodeSize)||{width:Cc,height:Ec},l=m.useCallback(u=>{var d,p;u.button!==0||u.metaKey||u.ctrlKey||u.shiftKey||(p=(d=u.target)==null?void 0:d.closest)!=null&&p.call(d,".af-work-group-node__resize, .af-work-group-node__delete")||s(c=>UR(c,e))},[e,s]);return i.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:i.jsx(T0,{className:"af-work-group-node__resize nodrag",minWidth:Cc,minHeight:Ec,position:"bottom-right",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsxs("div",{className:"af-work-group-node__title nodrag",children:[i.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),i.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:o,onClick:u=>{u.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function CY(e){var g,b,k,y,w,x,N,_,C,T,F,R,H,D,$;const{setEdges:t,setNodes:n}=El(),r=(g=e.data)==null?void 0:g.onSyncNodePropDraft,s=!!((b=e.data)!=null&&b.readOnly),[o,a]=m.useState(!1),l=(k=e.data)!=null&&k.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,u=m.useCallback(B=>{s||(n(L=>L.filter(M=>M.id!==B)),t(L=>L.filter(M=>M.source!==B&&M.target!==B)))},[s,t,n]),d=m.useCallback(B=>{var L,M;B.button!==0||B.metaKey||B.ctrlKey||B.shiftKey||(M=(L=B.target)==null?void 0:L.closest)!=null&&M.call(L,".react-flow__handle, .af-work-display-resize")||(n(I=>UR(I,e.id)),t(I=>_Y(I)))},[e.id,t,n]),p=m.useCallback((B,L)=>{s||(n(M=>M.map(I=>I.id===B?{...I,data:{...I.data,model:L}}:I)),r==null||r(B,{model:L}))},[s,n,r]),c=m.useCallback((B,L)=>{s||(n(M=>M.map(I=>{var A;if(I.id!==B)return I;const z=Array.isArray((A=I.data)==null?void 0:A.outputs)&&I.data.outputs.length?I.data.outputs.map((O,E)=>E===0?{...O,default:L,value:L}:O):[{type:"bool",name:"value",default:L,value:L}];return{...I,data:{...I.data,body:"",outputs:z}}})),r==null||r(B,M=>({body:"",outputs:Array.isArray(M==null?void 0:M.outputs)&&M.outputs.length?M.outputs.map((z,A)=>A===0?{...z,default:L,value:L}:z):[{type:"bool",name:"value",default:L,value:L}]})))},[s,n,r]),f=m.useCallback((B,L)=>{s||(n(M=>M.map(I=>I.id===B?{...I,data:{...I.data,body:L}}:I)),r==null||r(B,{body:L}))},[s,n,r]),h=m.useCallback((B,L)=>{if(s)return;const M=Fs(L);n(I=>I.map(z=>z.id===B?{...z,data:{...z.data,images:M}}:z)),r==null||r(B,{images:M})},[s,n,r]);return(y=e.data)!=null&&y.isWorkspaceGroup?i.jsx(jY,{...e,deleteNode:u}):Pn((w=e.data)==null?void 0:w.definitionId)?i.jsx(kY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:u}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(SY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:u}):((N=e.data)==null?void 0:N.definitionId)==="workspace_scheduled_run"?i.jsx(NY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:u}):((_=e.data)==null?void 0:_.definitionId)==="control_load_skills"?i.jsx(FY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:u,skills:(C=e.data)==null?void 0:C.skills,skillCollections:(T=e.data)==null?void 0:T.skillCollections,onChangeSkillKeys:(F=e.data)==null?void 0:F.onChangeLoadSkillKeys}):((R=e.data)==null?void 0:R.definitionId)==="control_load_mcp"?i.jsx(zY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:u,servers:(H=e.data)==null?void 0:H.mcpServers,onChangeMcpNames:(D=e.data)==null?void 0:D.onChangeLoadMcpNames}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:d,children:[s?null:i.jsx(T0,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:IR,minHeight:Rg,maxWidth:TR,maxHeight:RR,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(iR,{...e,deleteNode:u,modelLists:($=e.data)==null?void 0:$.modelLists,onModelChange:p,onProvideValueChange:c,onNodeBodyChange:f,onNodeImagesChange:h})]})}const EY={[Nc]:CY};function VR(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&VR(n.children,t);return t}function KR(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&KR(n.children,t));return t}function om(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 UR(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?s:e}function _Y(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function PY(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function AY(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(o,a,l)=>{const u=r[a],d=l?`${l}/${u}`:u,p=a===r.length-1;let c=!1;const f=(Array.isArray(o)?o:[]).map(h=>h.name!==u?h:(c=!0,p?{...h,type:"file",name:u,path:d,icon:kf(u),size:n}:{...h,type:"directory",name:u,path:d,icon:kf(u,!0),children:s(h.children||[],a+1,d)}));return c||f.push(p?{type:"file",name:u,path:d,icon:kf(u),size:n}:{type:"directory",name:u,path:d,icon:kf(u,!0),children:s([],a+1,d)}),PY(f)};return s(e||[],0,"")}function qR({items:e,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:o,onCreateFolder:a,onDelete:l,onFileDragStart:u}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(d=>{var f;const p=d.type==="directory",c=p&&(r==null?void 0:r.has(d.path));return i.jsxs("li",{children:[i.jsxs("div",{className:"af-work-file-row",children:[i.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+d.type,draggable:!p,onDragStart:h=>{p||u==null||u(h,d)},onClick:()=>p?s==null?void 0:s(d.path):n(d),title:d.path,children:[p?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:c?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:d.icon||kf(d.name,p)}),i.jsx("span",{children:d.name})]}),p?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>o==null?void 0:o(d.path),title:"新增文件","aria-label":`在 ${d.name} 新增文件`,children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>a==null?void 0:a(d.path),title:"新增文件夹","aria-label":`在 ${d.name} 新增文件夹`,children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,p?null:i.jsx("a",{className:"af-work-file-action",href:Fq(d.path,t),download:d.name,onClick:h=>h.stopPropagation(),title:"下载","aria-label":`下载 ${d.name}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"download"})}),i.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:()=>l==null?void 0:l(d),title:"删除","aria-label":`删除 ${d.name}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),p&&!c&&((f=d.children)!=null&&f.length)?i.jsx(qR,{items:d.children,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:o,onCreateFolder:a,onDelete:l,onFileDragStart:u}):null]},d.path)})})}function IY({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return i.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,o)=>{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 i.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[i.jsx("div",{className:"af-composer-ai-block-label",children:l}),i.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${o}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function Dg(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 TY(e){const t=Dg((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 Dg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function RY(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function MY(e){const t=Dg((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 Dg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function LY(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function eC(e){var r,s,o,a,l,u,d,p,c;if(!e)return null;const{inputs:t,outputs:n}=tR(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(((o=e.data)==null?void 0:o.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:Fs((l=e.data)==null?void 0:l.images),script:String(((u=e.data)==null?void 0:u.script)??""),scriptRef:String(((d=e.data)==null?void 0:d.scriptRef)??""),implementationRef:String(((p=e.data)==null?void 0:p.implementationRef)??""),implementationMode:String(((c=e.data)==null?void 0:c.implementationMode)??""),inputs:t,outputs:n}}function tC(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 OY(e,t,n){var p,c;const r=String(((p=e==null?void 0:e.data)==null?void 0:p.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=wl.includes(o)?o:"normal",l=String((t==null?void 0:t.model)||"").trim(),u={...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?[]:Fs(t==null?void 0:t.images),inputs:tC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((c=e.data)==null?void 0:c.outputs)?e.data.outputs:tC(t==null?void 0:t.outputs)},d=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||d!==""?u.script=String((t==null?void 0:t.script)??""):delete u.script;for(const f of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[f])??"").trim();h?u[f]=h:delete u[f]}return u}function nC({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:o=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),u=o?l:a;if(o){if(!hR.test(u))return{ok:!1,error:"Invalid instance id"};if(e.some(b=>b.id===u&&b.id!==a))return{ok:!1,error:"Duplicate instance id"}}const d=OY(r,s,u),p=r.data||{};if(!(u!==a||p.label!==d.label||p.role!==d.role||p.model!==d.model||p.body!==d.body||JSON.stringify(Fs(p.images))!==JSON.stringify(d.images)||(p.script??void 0)!==(d.script??void 0)||(p.scriptRef??void 0)!==(d.scriptRef??void 0)||(p.implementationRef??void 0)!==(d.implementationRef??void 0)||(p.implementationMode??void 0)!==(d.implementationMode??void 0)||JSON.stringify(p.inputs||[])!==JSON.stringify(d.inputs||[])||JSON.stringify(p.outputs||[])!==JSON.stringify(d.outputs||[])))return{ok:!0,changed:!1,nextId:u,nodes:e,edges:t,instances:n};const f=e.map(b=>b.id===a?{...b,id:u,selected:!0,data:d}:b);let h=t,g=n;if(u!==a){g={...n||{}};const b={...g[a]||{}};delete g[a],g[u]=b,h=t.map((k,y)=>({...k,source:k.source===a?u:k.source,target:k.target===a?u:k.target,id:`we-${k.source===a?u:k.source}-${k.target===a?u:k.target}-${y}`}))}return{ok:!0,changed:!0,nextId:u,nodes:f,edges:h,instances:g}}function $Y(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function DY(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"])$Y(e[s],t[s])&&(r[s]=n[s]);return r}function FY({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],u=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],d=Array.isArray(s)?s:[],p=Array.isArray(o)?o:[],[c,f]=m.useState(!1),[h,g]=m.useState(""),[b,k]=m.useState(()=>new Set),y=m.useRef(null),w=m.useRef(null),[x,N]=m.useState({visible:!1,top:0,height:100}),_=m.useMemo(()=>new Set(TY(t)),[t]),C=m.useMemo(()=>new Map(d.map(M=>[M.key,M])),[d]),T=m.useMemo(()=>{const M=new Set,I=p.map(A=>{const O=yl(A,d).map(E=>C.get(E)).filter(Boolean);for(const E of O)M.add(E.key);return{...A,skills:O}}).filter(A=>A.skills.length>0),z=d.filter(A=>!M.has(A.key));return{collectionGroups:I,ungrouped:z}},[C,p,d]);m.useEffect(()=>{k(M=>{let I=!1;const z=new Set(M);for(const A of T.collectionGroups)z.has(A.id)||(z.add(A.id),I=!0);return I?z:M})},[T.collectionGroups]);const F=m.useMemo(()=>{const M=h.trim().toLowerCase();if(!M)return T;const I=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(E=>String(E||"").toLowerCase()).join(" ").includes(M);return{collectionGroups:T.collectionGroups.map(A=>{const E=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(J=>String(J||"").toLowerCase()).join(" ").includes(M)?A.skills:A.skills.filter(I);return{...A,skills:E}}).filter(A=>A.skills.length>0),ungrouped:T.ungrouped.filter(I)}},[T,h]),R=m.useCallback((M,I)=>{const z=new Set(_);for(const A of M)I?z.add(A):z.delete(A);a==null||a(e,Array.from(z))},[e,_,a]),H=m.useCallback(M=>{k(I=>{const z=new Set(I);return z.has(M)?z.delete(M):z.add(M),z})},[]),D=m.useCallback(()=>{const M=y.current;if(!M)return;const I=Math.max(1,M.scrollHeight),z=Math.max(1,M.clientHeight),A=I>z+1,O=A?Math.max(12,z/I*100):100,E=Math.max(0,100-O),J=A?Math.min(E,M.scrollTop/Math.max(1,I-z)*E):0;N({visible:A,top:J,height:O})},[]);m.useEffect(()=>{if(!c)return;const M=requestAnimationFrame(D);return()=>cancelAnimationFrame(M)},[b,F,_.size,c,D]);const $=m.useCallback(M=>{const I=y.current;if(!I)return;const z=Math.max(0,I.scrollHeight-I.clientHeight);I.scrollTop=Math.min(1,Math.max(0,M))*z,D()},[D]),B=m.useCallback((M,I=0)=>{const z=w.current;if(!z)return 0;const A=z.getBoundingClientRect(),O=x.height/100*A.height,E=Math.max(1,A.height-O);return(M-A.top-I)/E},[x.height]),L=m.useCallback(M=>{var de,he;if(!x.visible)return;M.preventDefault(),M.stopPropagation();const I=w.current;if(!I)return;const z=I.getBoundingClientRect(),A=x.top/100*z.height,O=x.height/100*z.height,J=M.clientY>=z.top+A&&M.clientY<=z.top+A+O?M.clientY-z.top-A:O/2;$(B(M.clientY,J));const Z=M.pointerId;(he=(de=M.currentTarget).setPointerCapture)==null||he.call(de,Z);const K=we=>{we.preventDefault(),$(B(we.clientY,J))},oe=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",oe),window.removeEventListener("pointercancel",oe)};window.addEventListener("pointermove",K),window.addEventListener("pointerup",oe),window.addEventListener("pointercancel",oe)},[B,$,x.height,x.top,x.visible]);return i.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((M,I)=>{if(M.showOnNode===!1)return null;const z=`${2.6+I*1.7}rem`,A=M.name||`#${I+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:z},children:A}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${I}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:z,background:Fn(M.type)},title:`${A} · ${M.type}`})]},`in-${I}`)}),u.map((M,I)=>{if(M.showOnNode===!1)return null;const z=`${2.6+I*1.7}rem`,A=M.name||`#${I+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:z},children:A}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${I}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:z,background:Fn(M.type)},title:`${A} · ${M.type}`})]},`out-${I}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:M=>{var I;M.stopPropagation(),c||(I=t==null?void 0:t.onRefreshSkills)==null||I.call(t),f(z=>!z)},children:[i.jsx("span",{children:_.size>0?`${_.size} skills selected`:"选择 Skills"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:h,onChange:M=>g(M.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?i.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:D,children:[F.collectionGroups.map(M=>{const I=M.skills.map(E=>E.key),z=I.filter(E=>_.has(E)).length,A=I.length>0&&z===I.length,O=b.has(M.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(O?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:A,onChange:E=>R(I,E.target.checked),"aria-label":`选择 ${M.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>H(M.id),"aria-expanded":!O,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:M.name}),M.description?i.jsx("em",{children:M.description}):null]})}),i.jsxs("small",{children:[z,"/",I.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>H(M.id),"aria-label":O?`展开 ${M.name}`:`收起 ${M.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:O?"chevron_right":"expand_more"})})]}),O?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:M.skills.map(E=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:_.has(E.key),onChange:J=>R([E.key],J.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:E.name}),E.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:E.description}):null]})]},`${M.id}:${E.key}`))})]},M.id)}),F.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:F.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:F.ungrouped.map(M=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:_.has(M.key),onChange:I=>R([M.key],I.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:M.name}),M.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:M.description}):null]})]},`ungrouped:${M.key}`))})]}):null,F.collectionGroups.length===0&&F.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),i.jsx("div",{ref:w,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:L,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function zY({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,d]=m.useState(!1),[p,c]=m.useState(""),f=m.useMemo(()=>new Set(MY(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(k=>({name:String((k==null?void 0:k.name)||""),description:String((k==null?void 0:k.description)||""),detail:String((k==null?void 0:k.url)||[k==null?void 0:k.command,...Array.isArray(k==null?void 0:k.args)?k.args:[]].filter(Boolean).join(" ")||""),type:String((k==null?void 0:k.type)||"")})).filter(k=>k.name),[s]),g=m.useMemo(()=>{const k=p.trim().toLowerCase();return k?h.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(k)):h},[p,h]),b=m.useCallback((k,y)=>{const w=new Set(f);for(const x of k)y?w.add(x):w.delete(x);o==null||o(e,Array.from(w))},[e,f,o]);return i.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((k,y)=>{if(k.showOnNode===!1)return null;const w=`${2.6+y*1.7}rem`,x=k.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:w},children:x}),i.jsx(ds,{type:"target",position:Je.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:w,background:Fn(k.type)},title:`${x} · ${k.type}`})]},`in-${y}`)}),l.map((k,y)=>{if(k.showOnNode===!1)return null;const w=`${2.6+y*1.7}rem`,x=k.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:w},children:x}),i.jsx(ds,{type:"source",position:Je.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:w,background:Fn(k.type)},title:`${x} · ${k.type}`})]},`out-${y}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"hub"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:k=>{var y;k.stopPropagation(),u||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(w=>!w)},children:[i.jsx("span",{children:f.size>0?`${f.size} MCP selected`:"选择 MCP"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:k=>k.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:p,onChange:k=>c(k.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),p?i.jsx("button",{type:"button",onClick:()=>c(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{className:"af-work-load-skills-menu",children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"MCP Servers"}),i.jsx("small",{children:g.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(k=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:f.has(k.name),onChange:y=>b([k.name],y.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:k.name}),k.description||k.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:k.description||k.detail}):null]})]},k.name))})]}),g.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function HY(){var zd,Qc;const{t:e,i18n:t}=Tn(),{navigate:n}=Bo(),r=El(),s=A0(),o=m.useMemo(Dq,[]),[a,l]=m.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[u,d]=m.useState(!1),[p,c]=m.useState(!1),[f,h]=vI([]),[g,b,k]=kI([]),y=m.useRef([]),w=m.useRef([]),[x,N]=m.useState(()=>ov(null,[])),_=m.useRef(x),[C,T]=m.useState(null),F=m.useRef(null),[R,H]=m.useState([]),D=m.useRef(new Map),$=m.useRef(new Map),B=m.useRef(null),L=m.useRef(null),M=m.useRef(null),[I,z]=m.useState(null),[A,O]=m.useState({}),E=m.useRef({}),J=m.useRef(!1),Z=m.useRef(null),[K,oe]=m.useState([]),[de,he]=m.useState(""),[we,ue]=m.useState("nodes"),[Ne,le]=m.useState([]),[ce,xe]=m.useState(!1),[Se,Ke]=m.useState(""),[et,We]=m.useState(!1),[ut,Ve]=m.useState({name:"",id:"",description:""}),[xt,bt]=m.useState(!1),[Jn,Ut]=m.useState(""),[nn,rn]=m.useState(""),hn=m.useRef(null),[fe,je]=m.useState(!1),[He,ot]=m.useState(!1),[at,Tt]=m.useState(""),[mt,dn]=m.useState(null),[sn,Rn]=m.useState({title:"",layout:"gallery",nodeIds:[]}),[on,Mn]=m.useState(""),[Ln,zr]=m.useState(!1),[be,$e]=m.useState(""),[ft,St]=m.useState(!1),[mn,es]=m.useState(""),[Cs,_r]=m.useState(""),[Hr,hr]=m.useState(!1),[kr,hs]=m.useState("nodes"),[Br,Ei]=m.useState(""),[Qn,Wr]=m.useState(0),[ae,Ce]=m.useState(""),tt=m.useRef(""),[De,Ae]=m.useState(null),Nt=m.useRef(null),[mr,it]=m.useState(""),[lr,Zn]=m.useState([]),[Vr,ms]=m.useState(""),[Ie,Us]=m.useState(!0),[pt,xn]=m.useState(""),[an,cr]=m.useState(()=>new Set),nt=m.useRef(null),[Kr,Na]=m.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[Ko,ao]=m.useState(!1),[Es,Uo]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[ts,Nn]=m.useState(""),[sr,lo]=m.useState([]),[fi,qs]=m.useState(!1),[ir,Ys]=m.useState([]),[U,ge]=m.useState([]),[ze,Le]=m.useState(!1),[rt,ln]=m.useState([]),Rt=m.useCallback(S=>{hn.current&&window.clearTimeout(hn.current),rn(S),hn.current=window.setTimeout(()=>{rn(""),hn.current=null},3800)},[]),Wn=m.useCallback(S=>{const P=String(S||"").trim();if(!P)return;const V=()=>s(P);window.requestAnimationFrame(V),window.setTimeout(V,80)},[s]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Kr)))}catch{}},[Kr]);const Pr=m.useCallback(S=>{const P=nt.current;if(!P)return;const V=P.getBoundingClientRect(),q=16,Q=150,re=230,ie=V.top+q,te=V.bottom-q,ee=Math.max(Q,te-ie-re),me=Math.min(Math.max(S-ie,Q),ee);Na(me)},[]),_i=m.useCallback(S=>{S.preventDefault(),S.stopPropagation(),ao(!0),Pr(S.clientY);const P=q=>{q.preventDefault(),Pr(q.clientY)},V=()=>{ao(!1),window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",V,!0),window.removeEventListener("pointercancel",V,!0)};window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",V,!0),window.addEventListener("pointercancel",V,!0)},[Pr]);m.useEffect(()=>()=>{hn.current&&window.clearTimeout(hn.current)},[]);const[On,ja]=m.useState(()=>new Set),[Pl,Tc]=m.useState(!1),Gs=m.useRef(null),kd=m.useRef(null),Al=m.useRef(null),[Il,Rc]=m.useState({}),[co,cn]=m.useState(""),[ns,Vn]=m.useState(!1),[Mc,qo]=m.useState([]),[Pi,Ur]=m.useState([]),[Tl,Ai]=m.useState("workspace"),[gr,Yo]=m.useState(!1),[Rl,Ca]=m.useState(!0),[Sd,Ea]=m.useState(""),[Ii,Ti]=m.useState({}),[Ml,_a]=m.useState(!1),[Nd,_s]=m.useState(!1),[Ll,jd]=m.useState(!1),[Go,Lc]=m.useState("pan"),[rs,Ol]=m.useState(null),[Ri,Mi]=m.useState(""),Oc=m.useRef(""),[$c,Sr]=m.useState({}),pi=m.useRef(null),Ps=m.useRef(!1),[Pa,gs]=m.useState(()=>new Set),[Xo,uo]=m.useState({}),[Cd,_e]=m.useState(""),ys=m.useMemo(()=>zq(o),[o]),[Dc,Ed]=m.useState(""),fo=o.flowSource||"user",Fc=!!(o.flowId&&!o.archived&&(fo==="user"||fo==="workspace")),$l=m.useMemo(()=>{if(!o.flowId)return"/flow?panel=settings";const S=cg({id:o.flowId,source:fo,archived:!!o.archived},"pipeline"),[P,V=""]=S.split("?"),q=new URLSearchParams(V);return q.set("panel","settings"),`${P}?${q.toString()}`},[o.archived,o.flowId,fo]);m.useEffect(()=>{o.flowId&&jP(o.flowId,o.flowSource||"user","workspace",!!o.archived)},[o]),m.useEffect(()=>{const S=()=>{l(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[]),m.useEffect(()=>{qo([]),Ur([]),Ai("workspace"),Ca(!0)},[o]);const ur=m.useCallback(async()=>{const S=Ui(o),P=await fetch(`/api/workspace/files?${S.toString()}`),V=await P.json();if(!P.ok)throw new Error(V.error||"读取 workspace 失败");const q=V.files||[];Zn(q),cr(new Set(KR(q))),ms(V.root||"")},[o]),zc=m.useCallback(async()=>{xe(!0),Ke("");try{const S=await fetch("/api/marketplace/flow-snippets"),P=await S.json().catch(()=>({}));if(!S.ok)throw new Error(P.error||"读取流程片段失败");le(Array.isArray(P.snippets)?P.snippets:[])}catch(S){Ke(String(S.message||S)),le([])}finally{xe(!1)}},[]),qe=m.useCallback(async(S=f,P=g)=>{var re;if(!J.current)return;if(!Ie)throw _e("Readonly workspace"),new Error("Readonly workspace");const V=im(S,P,E.current);V.ui={...V.ui||{},...F.current?{viewport:F.current}:{},displayPage:nY(_.current,S)};const q=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,graph:V})}),Q=await q.json();if(!q.ok)throw new Error(Q.error||"保存 workspace graph 失败");E.current=((re=Q.graph)==null?void 0:re.instances)||V.instances,O(E.current),Sr(nw(Q.workspaceSchedules||[])),_e("Workspace graph saved")},[g,o,f,Ie]),_d=m.useCallback(S=>{var V;const P=(V=S==null?void 0:S.extra)!=null&&V.instances&&typeof S.extra.instances=="object"?S.extra.instances:{};E.current=P,O(P),h(Array.isArray(S==null?void 0:S.nodes)?S.nodes:[]),b(Array.isArray(S==null?void 0:S.edges)?S.edges:[]),Ce(""),z(null)},[b,h]),Oy=m.useMemo(()=>({instances:A}),[A]),Hc=rR({nodes:f,edges:g,extra:Oy,enabled:J.current,onRestore:_d}),{resetHistory:Et,undo:Gp,redo:po}=Hc,Jo=m.useCallback(async()=>{var dt,Ye;J.current=!1;const S=Ui(o),P=Ui(o);P.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[V,q]=await Promise.all([fetch(`/api/nodes?${P.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),ur()]),Q=await V.json(),re=await q.json();if(!V.ok)throw new Error(Q.error||"读取节点定义失败");if(!q.ok)throw new Error(re.error||"读取 workspace graph 失败");const ie=[...(Array.isArray(Q)?Q:Q.nodes||[]).filter(It=>!Iq.has(It.id)),Mq,Lq,Tq,Rq];oe(ie);const te=re.graph||JSON.parse(localStorage.getItem(Aq)||"null")||{},ee=rw(te,ie),me=ov((dt=te==null?void 0:te.ui)==null?void 0:dt.displayPage,ee.nodes),ke=$R((Ye=te==null?void 0:te.ui)==null?void 0:Ye.viewport);E.current=ee.instances,O(ee.instances),h(ee.nodes),b(ee.edges),Sr(nw(re.workspaceSchedules||[])),N(me),_.current=me,T(ke),F.current=ke,H([]),Et(ee.nodes,ee.edges,{instances:ee.instances});const Re=re.writable!==!1;Us(Re),_e(Re?"Workspace ready":"Readonly workspace"),J.current=!0},[o,t.language,ur,Et,b,h]),Pd=m.useCallback(async(S,P)=>{const V={packageId:(S==null?void 0:S.newId)||(S==null?void 0:S.id)||(S==null?void 0:S.label),label:(S==null?void 0:S.label)||(S==null?void 0:S.newId)||(S==null?void 0:S.id),version:"1.0.0",definitionId:P,body:(S==null?void 0:S.body)||"",script:(S==null?void 0:S.script)||"",scriptRef:(S==null?void 0:S.scriptRef)||"",implementationRef:(S==null?void 0:S.implementationRef)||"",implementationMode:(S==null?void 0:S.implementationMode)||"",inputs:Array.isArray(S==null?void 0:S.inputs)?S.inputs:[],outputs:Array.isArray(S==null?void 0:S.outputs)?S.outputs:[],flowId:o.flowId,flowSource:o.flowSource||"user",archived:!!o.archived},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)}),Q=await q.json().catch(()=>({}));if(!q.ok||(Q==null?void 0:Q.ok)===!1)throw new Error((Q==null?void 0:Q.error)||"Publish failed");return await Jo(),_e(`Published node ${Q.definitionId||Q.id||V.packageId}`),Q},[o,Jo]),$y=m.useCallback((S="workspace")=>{Yo(!0),Ae(null),Ai(S||"workspace")},[]),hi=m.useCallback(async(S="")=>{const P=String(S||Ri||"").trim();Ps.current=!0,pi.current&&(pi.current.abort(),pi.current=null),Mi(""),gs(new Set),uo(V=>{const q={...V};for(const[Q,re]of Object.entries(q))(re==null?void 0:re.status)==="running"&&(q[Q]={status:"stopped"});return P&&(q[P]={status:"stopped"}),q}),_e(P?`Workspace run stopped: ${P}`:"Workspace run stopped"),Ur(V=>V.map(q=>(!P||q.runNodeId===P)&&q.status==="running"?{...q,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(q.messages)?q.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:q));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,runNodeId:P})})}catch{}},[o,Ri]),Xp=m.useCallback(async()=>{if(o.flowId)try{const S=Ui(o),P=await fetch(`/api/workspace/run/status?${S.toString()}`),V=await P.json().catch(()=>({}));if(!P.ok||!V.running)return;const q=String(V.runNodeId||"").trim();q?(Mi(q),gs(new Set([q])),uo(Q=>({...Q,[q]:{status:"running"}})),_e(`Workspace run still running: ${q}`)):_e("Workspace run still running"),Ur(Q=>{if(Q.some(ie=>ie.status==="running"&&(!q||ie.runNodeId===q)))return Q;const re=`run-restored-${V.startedAt||Date.now()}`;return[...Q.slice(-7),{id:re,label:q?`Run ${q}`:"Workspace Run",runNodeId:q,status:"running",startedAt:V.startedAt||Date.now(),steps:q?[{id:q,label:q,status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:"Workspace run is still running in the background.",at:Date.now()}]}]})}catch{}},[o]),ho=m.useCallback(async S=>{if(!Ie){_e("Readonly workspace");return}if(!S||Ri)return;let P=f,V=g,q=E.current;const Q=Nt.current;if(Q!=null&&Q.id){const me=P.find(Re=>Re.id===Q.id),ke=nC({nodes:P,edges:V,instances:q,selectedNode:me,draft:Q,allowRename:!1});if(ke!=null&&ke.error){it(ke.error),_e(ke.error);return}ke!=null&&ke.ok&&ke.changed&&(P=ke.nodes,V=ke.edges,q=ke.instances,E.current=q,O(q),h(P),b(V),Wn(ke.nextId||Q.id))}const re=im(P,V,q),ie=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,te=`Run ${S}`,ee=new AbortController;pi.current=ee,Ps.current=!1,Mi(S),gs(new Set([S])),uo({[S]:{status:"running"}}),_e(`Running ${S}...`),Ai(ie),Ur(me=>[...me.slice(-7),{id:ie,label:te,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await qe(P,V);const me=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:ee.signal,body:JSON.stringify({...o,graph:re,runNodeId:S,model:ts,selectedSkills:ir,stream:!0})});if(!me.ok){const Ee=await me.json().catch(()=>({}));throw new Error(Ee.error||"Workspace run failed")}if(!me.body)throw new Error("Workspace run stream unavailable");const ke=me.body.getReader(),Re=new TextDecoder;let dt="",Ye=[],It=[],jn=S;const qn=(Ee,lt)=>{var zt,Bt;const yt=f.find(Yt=>Yt.id===Ee),jt=String(((zt=yt==null?void 0:yt.data)==null?void 0:zt.label)||Ee||"").trim(),Oe=String(lt||((Bt=yt==null?void 0:yt.data)==null?void 0:Bt.definitionId)||"").trim();return Oe&&Oe!==jt?`${jt} (${Oe})`:jt},Qt=(Ee,lt,yt)=>{const jt=String(Ee||"").trim();jt&&Ur(Oe=>Oe.map(zt=>{if(zt.id!==ie)return zt;const Yt=[...Array.isArray(zt.steps)?zt.steps:[]],Wt=Yt.findIndex(Mr=>Mr.id===jt),Lt={id:jt,label:qn(jt,lt),status:yt};Wt>=0?Yt[Wt]={...Yt[Wt],...Lt}:Yt.push(Lt);const fn=Yt.map((Mr,Fa)=>{const ea=Mr.status==="done"?"[done]":Mr.status==="failed"?"[failed]":"[running]";return`${Fa+1}. ${ea} ${Mr.label}`}).join(`
204
- `),en=Array.isArray(zt.messages)?zt.messages:[],yn=en.findIndex(Mr=>Mr.kind==="run-summary"),Cn={role:"assistant",kind:"run-summary",text:fn||"准备运行...",at:Date.now()},Rr=[...en];return yn>=0?Rr[yn]=Cn:Rr.unshift(Cn),{...zt,steps:Yt,messages:Rr.slice(-160)}}))},Xt=Ee=>{const lt=String(Ee||"").trim();if(!lt)return;const yt=jn;jn=lt,gs(new Set([lt])),uo(jt=>{var Oe;return{...jt,...yt&&yt!==lt&&((Oe=jt[yt])==null?void 0:Oe.status)==="running"?{[yt]:{status:"success"}}:{},[lt]:{status:"running"}}})},$n=Ee=>{const lt=String(Ee||"").trim();lt&&(gs(yt=>{const jt=new Set(yt);return jt.delete(lt),jt}),uo(yt=>({...yt,[lt]:{status:"success"}})))},Ft=(Ee,lt)=>{const yt=String(lt||"");if(!yt.trim())return;const jt=["assistant","thinking","result","error","prompt"].includes(Ee)?Ee:"assistant";Ur(Oe=>Oe.map(zt=>{if(zt.id!==ie)return zt;let Bt=Array.isArray(zt.messages)?zt.messages:[];if(jt==="result"){const Lt=[...Bt].reverse().find(fn=>fn.kind==="assistant");if(String((Lt==null?void 0:Lt.text)||"").trim()===yt.trim())return zt}if(jt==="assistant"){const Lt=Bt.findIndex(fn=>fn.kind==="result"&&String(fn.text||"").trim()===yt.trim());Lt>=0&&(Bt=Bt.filter((fn,en)=>en!==Lt))}const Yt=[...Bt],Wt=Yt[Yt.length-1];return Wt&&Wt.kind===jt&&!Wt.error?Yt[Yt.length-1]={...Wt,text:`${Wt.text||""}${Wt.text?`
205
- `:""}${yt}`}:Yt.push({role:"assistant",kind:jt,text:yt,...jt==="error"?{error:!0}:{},at:Date.now()}),{...zt,messages:Yt.slice(-160)}}))},gn=Ee=>{const lt=String(Ee||"");lt.trim()&&Ur(yt=>yt.map(jt=>{var Yt;if(jt.id!==ie)return jt;const Oe=Array.isArray(jt.messages)?jt.messages:[],zt=Oe.findIndex(Wt=>Wt.kind==="thinking"),Bt=[...Oe];if(zt>=0){const Wt=String(((Yt=Bt[zt])==null?void 0:Yt.text)||"");Bt[zt]={...Bt[zt],text:`${Wt}${Wt&&!Wt.endsWith(`
206
- `),""}${lt}`,at:Date.now()}}else{const Wt=Bt.findIndex(Lt=>Lt.kind==="activity");Bt.splice(Wt>=0?Wt+1:Bt.length,0,{role:"assistant",kind:"thinking",text:lt,at:Date.now()})}return{...jt,messages:Bt.slice(-160)}}))},Ue=(Ee,lt=null)=>{const yt=Vq(Ee);yt&&Ur(jt=>jt.map(Oe=>{if(Oe.id!==ie)return Oe;const zt=Number(lt==null?void 0:lt.ts)||Date.now(),Bt=Number(Oe.startedAt)||zt,Yt=Number(Oe.lastActivityAt)||Bt,Wt=Math.max(0,zt-Yt),Lt=Number.isFinite(Number(lt==null?void 0:lt.runElapsedMs))?Math.max(0,Number(lt.runElapsedMs)):Math.max(0,zt-Bt),fn=Array.isArray(Oe.activities)?Oe.activities:[],en=fn[fn.length-1],Cn=(typeof en=="string"?en:String((en==null?void 0:en.text)||""))===yt?fn:[...fn,{text:yt,stepMs:Wt,totalMs:Lt,at:zt}].slice(-8),Rr=Array.isArray(Oe.messages)?Oe.messages:[],Mr=Rr.findIndex(za=>za.kind==="activity"),Fa={role:"assistant",kind:"activity",text:Cn.map((za,Hd)=>Kq(za,Hd)).join(`
207
- `),at:Date.now()},ea=[...Rr];if(Mr>=0)ea[Mr]=Fa;else{const za=ea.findIndex(Hd=>Hd.kind==="run-summary");ea.splice(za>=0?za+1:0,0,Fa)}return{...Oe,activities:Cn,lastActivityAt:zt,messages:ea.slice(-160)}}))},Pt=Ee=>{const lt=String((Ee==null?void 0:Ee.source)||"runner"),yt=String((Ee==null?void 0:Ee.stream)||""),jt=String((Ee==null?void 0:Ee.eventType)||"event"),Oe=String((Ee==null?void 0:Ee.text)||"").trim();if(!Oe)return;const zt=`[${lt}${yt?`:${yt}`:""}] ${jt}
208
- ${Oe}`;Ur(Bt=>Bt.map(Yt=>{if(Yt.id!==ie)return Yt;const Lt=[...Array.isArray(Yt.rawTrace)?Yt.rawTrace:[],zt].slice(-80),fn=Array.isArray(Yt.messages)?Yt.messages:[],en=fn.findIndex(Rr=>Rr.kind==="raw"),yn={role:"assistant",kind:"raw",text:Lt.join(`
209
-
210
- ---
211
-
212
- `),at:Date.now()},Cn=[...fn];return en>=0?Cn[en]=yn:Cn.push(yn),{...Yt,rawTrace:Lt,messages:Cn.slice(-160)}}))},Tr=Ee=>{Ur(lt=>lt.map(yt=>yt.id===ie?{...yt,status:Ee,endedAt:Date.now()}:yt))},Da=Ee=>{const lt=new Set,yt=String((Ee==null?void 0:Ee.nodeId)||"").trim();yt&&lt.add(yt);for(const jt of Array.isArray(Ee==null?void 0:Ee.displayNodeIds)?Ee.displayNodeIds:[]){const Oe=String(jt||"").trim();Oe&&lt.add(Oe)}for(const jt of Array.isArray(Ee==null?void 0:Ee.touchedNodeIds)?Ee.touchedNodeIds:[]){const Oe=String(jt||"").trim();Oe&&lt.add(Oe)}if(lt.size===0)for(const jt of Array.isArray(Ee==null?void 0:Ee.order)?Ee.order:[]){const Oe=String(jt||"").trim();Oe&&lt.add(Oe)}return lt},ql=(Ee,lt=null)=>{const yt=rw(Ee||re,K),jt=new Map(yt.nodes.map(Wt=>[Wt.id,Wt])),Oe=yt.instances||{},zt=lt instanceof Set?lt:null,Bt=(Wt,Lt)=>{const fn={...Wt||Lt};Array.isArray(Lt==null?void 0:Lt.output)&&(fn.output=Lt.output);for(const en of["scriptRef","implementationRef","implementationMode"])(Lt==null?void 0:Lt[en])!=null&&String(Lt[en]).trim()!==""&&(fn[en]=Lt[en]);return fn},Yt=(Wt,Lt)=>{const fn={...Wt||{}};Array.isArray(Lt==null?void 0:Lt.outputs)&&(fn.outputs=Lt.outputs);for(const en of["scriptRef","implementationRef","implementationMode"])(Lt==null?void 0:Lt[en])!=null&&String(Lt[en]).trim()!==""&&(fn[en]=Lt[en]);return fn};h(Wt=>{const Lt=new Set(Wt.map(yn=>yn.id)),en={...im(Wt,w.current,E.current).instances||{}};for(const[yn,Cn]of Object.entries(Oe)){if(zt&&!zt.has(yn)||!Lt.has(yn))continue;const Rr=en[yn];Pn((Cn==null?void 0:Cn.definitionId)||(Rr==null?void 0:Rr.definitionId))?en[yn]=Cn:Array.isArray(Cn==null?void 0:Cn.output)&&(en[yn]=Bt(Rr,Cn))}return E.current=en,O(en),Wt.map(yn=>{var Rr,Mr;if(zt&&!zt.has(yn.id))return yn;const Cn=jt.get(yn.id);return Cn?Pn(((Rr=Cn.data)==null?void 0:Rr.definitionId)||((Mr=yn.data)==null?void 0:Mr.definitionId))?{...yn,data:{...yn.data,...Cn.data}}:{...yn,data:Yt(yn.data,Cn.data)}:yn})})};for(;;){const{value:Ee,done:lt}=await ke.read();if(lt)break;dt+=Re.decode(Ee,{stream:!0});const yt=dt.split(`
213
- `);dt=yt.pop()||"";for(const jt of yt){if(!jt.trim())continue;const Oe=JSON.parse(jt);if(Oe.type==="error")throw new Error(Oe.error||"Workspace run failed");if(Oe.type==="stopped"){Ps.current=!0,Ye=Array.isArray(Oe.order)?Oe.order:Ye,Ue("运行停止",Oe);continue}if(Oe.type==="node-start"&&(_e(`Running ${Oe.nodeId}...`),Xt(Oe.nodeId),Qt(Oe.nodeId,Oe.definitionId,"running")),Oe.type==="node-done"&&($n(Oe.nodeId),Qt(Oe.nodeId,Oe.definitionId,"done")),Oe.type==="status"&&Ue(Oe.line||Oe.message||"",Oe),Oe.type==="paused"&&(It=Array.isArray(Oe.nodeIds)?Oe.nodeIds:[],Ue("运行暂停",Oe)),Oe.type==="natural"&&(Oe.kind==="thinking"?gn(Oe.text||""):Ft(Oe.kind,Oe.text||"")),Oe.type==="raw"){const zt=U1(Oe);zt&&gn(zt),Pt(Oe)}Oe.type==="graph"&&Oe.graph&&ql(Oe.graph,Da(Oe)),Oe.type==="done"&&(Oe.graph&&ql(Oe.graph,Da(Oe)),Ye=Array.isArray(Oe.order)?Oe.order:[],It=Array.isArray(Oe.pauseNodeIds)?Oe.pauseNodeIds:It,Ue(It.length?"运行暂停":"运行完成",Oe))}}if(dt.trim()){const Ee=JSON.parse(dt);if(Ee.type==="error")throw new Error(Ee.error||"Workspace run failed");if(Ee.type==="stopped"&&(Ps.current=!0,Ue("运行停止",Ee)),Ee.type==="node-start"&&(_e(`Running ${Ee.nodeId}...`),Xt(Ee.nodeId),Qt(Ee.nodeId,Ee.definitionId,"running")),Ee.type==="node-done"&&($n(Ee.nodeId),Qt(Ee.nodeId,Ee.definitionId,"done")),Ee.type==="status"&&Ue(Ee.line||Ee.message||"",Ee),Ee.type==="paused"&&(It=Array.isArray(Ee.nodeIds)?Ee.nodeIds:[],Ue("运行暂停",Ee)),Ee.type==="natural"&&(Ee.kind==="thinking"?gn(Ee.text||""):Ft(Ee.kind,Ee.text||"")),Ee.type==="raw"){const lt=U1(Ee);lt&&gn(lt),Pt(Ee)}Ee.type==="graph"&&Ee.graph&&ql(Ee.graph,Da(Ee)),Ee.type==="done"&&(Ee.graph&&ql(Ee.graph,Da(Ee)),Ye=Array.isArray(Ee.order)?Ee.order:[],It=Array.isArray(Ee.pauseNodeIds)?Ee.pauseNodeIds:It,Ue(It.length?"运行暂停":"运行完成",Ee))}Ps.current&&(gs(new Set),uo(Ee=>{var yt;const lt=((yt=Object.entries(Ee).find(([,jt])=>(jt==null?void 0:jt.status)==="running"))==null?void 0:yt[0])||S;return lt?{...Ee,[lt]:{status:"stopped"}}:Ee})),_e(Ps.current?`Workspace run stopped: ${S}`:It.length?`Workspace run paused at ${It.join(", ")}`:`Workspace run done: ${Ye.length?Ye.join(" -> "):S}`),Tr(Ps.current?"stopped":It.length?"paused":"done"),Ps.current||await ur()}catch(me){if(Ps.current||(me==null?void 0:me.name)==="AbortError"){gs(new Set),uo(ke=>{var dt;const Re=((dt=Object.entries(ke).find(([,Ye])=>(Ye==null?void 0:Ye.status)==="running"))==null?void 0:dt[0])||S;return Re?{...ke,[Re]:{status:"stopped"}}:ke}),_e(`Workspace run stopped: ${S}`),Ur(ke=>ke.map(Re=>Re.id===ie?{...Re,status:"stopped",endedAt:Date.now()}:Re));return}gs(new Set),uo(ke=>{var dt;const Re=(dt=Object.entries(ke).find(([,Ye])=>(Ye==null?void 0:Ye.status)==="running"))==null?void 0:dt[0];return Re?{...ke,[Re]:{status:"failed"}}:ke}),_e(String(me.message||me)),Ur(ke=>ke.map(Re=>Re.id===ie?{...Re,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Re.messages)?Re.messages:[],{role:"assistant",error:!0,text:String(me.message||me),at:Date.now()}].slice(-160)}:Re))}finally{pi.current===ee&&(pi.current=null),Mi(""),gs(new Set)}},[ts,g,o,ur,f,K,Wn,Ri,qe,ir,b,h,Ie]),mo=m.useCallback(async()=>{try{const P=await(await fetch("/api/skills")).json().catch(()=>({})),V=Array.isArray(P.skills)?P.skills.map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];lo(V),qs(!0)}catch{qs(!0)}},[]),Dl=m.useCallback(async()=>{try{const P=await(await fetch("/api/mcps")).json().catch(()=>({})),V=Array.isArray(P.servers)?P.servers.map(q=>({name:String((q==null?void 0:q.name)||""),type:String((q==null?void 0:q.type)||""),url:String((q==null?void 0:q.url)||""),command:String((q==null?void 0:q.command)||""),args:Array.isArray(q==null?void 0:q.args)?q.args.map(String):[],description:String((q==null?void 0:q.description)||"")})).filter(q=>q.name):[];ln(V)}catch{ln([])}},[]);m.useEffect(()=>{Jo().catch(S=>_e(String(S.message||S))),zc(),fetch("/api/model-lists").then(S=>S.json()).then(S=>Uo({cursor:Array.isArray(S.cursor)?S.cursor.map(String):[],opencode:Array.isArray(S.opencode)?S.opencode.map(String):[],claudeCode:Array.isArray(S.claudeCode)?S.claudeCode.map(String):[]})).catch(()=>{}),mo(),Dl(),Xp(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{ge(dl(S)),Le(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>Ol(S.user||null)).catch(()=>Ol(null))},[Jo,zc,Dl,mo,Xp,ys]),m.useEffect(()=>{if(Ed(""),!(!fi||!ze)){if(!ys){Ys([]);return}Ys(PP(ys,"workspace",sr,U)),Ed(ys)}},[U,ze,sr,fi,ys]),m.useEffect(()=>{if(!(Dc!==ys||!ys))try{localStorage.setItem(ys,JSON.stringify(ir))}catch{}},[ir,ys,Dc]),m.useEffect(()=>{E.current=A},[A]),m.useEffect(()=>{y.current=f},[f]),m.useEffect(()=>{Oc.current=Ri},[Ri]),m.useEffect(()=>{const S=D.current,P=new Map,V=[];for(const ie of f){const te=OR(ie);P.set(ie.id,te),S.get(ie.id)!==te&&V.push(ie.id)}if(D.current=P,V.length===0)return;const q=()=>V.forEach(ie=>s(ie)),Q=window.requestAnimationFrame(q),re=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[f,s]),m.useEffect(()=>{w.current=g},[g]),m.useEffect(()=>{_.current=x},[x]),m.useEffect(()=>{F.current=C},[C]),m.useEffect(()=>{Nt.current=De},[De]),m.useEffect(()=>{tt.current=ae},[ae]),m.useEffect(()=>{M.current=I},[I]),m.useEffect(()=>{if(!I)return;const S=V=>{V.key==="Escape"&&z(null)},P=V=>{var q,Q;(Q=(q=V.target)==null?void 0:q.closest)!=null&&Q.call(q,".af-connect-node-menu")||z(null)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",P),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",P)}},[I]),m.useEffect(()=>{if(J.current&&Ie)return Z.current&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{qe().catch(S=>_e(String(S.message||S)))},650),()=>{Z.current&&window.clearTimeout(Z.current)}},[f,g,x,qe,Ie]);const Fl=m.useMemo(()=>f.filter(S=>{var P;return((P=S==null?void 0:S.data)==null?void 0:P.definitionId)==="workspace_scheduled_run"}).map(S=>{var P;return{id:S.id,config:ok(((P=S.data)==null?void 0:P.body)||"")}}),[f]),Bc=m.useMemo(()=>Fl.map(S=>`${S.id}:${S.config.enabled?"1":"0"}:${S.config.intervalMinutes}`).join("|"),[Fl]);m.useEffect(()=>{if(!J.current||a!=="workspace"||!o.flowId){Sr({});return}if(!Fl.length){Sr({});return}let S=!1;const P=async()=>{try{const q=Ui(o),Q=await fetch(`/api/workspace/schedules?${q.toString()}`),re=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(re.error||"读取 Workspace 定时状态失败");S||Sr(nw(re.schedules||[]))}catch{S||Sr(q=>{var re;const Q={};for(const ie of Fl)Q[ie.id]={...q[ie.id]||{},lastStatus:((re=q[ie.id])==null?void 0:re.lastStatus)||"unknown"};return Q})}};P();const V=window.setInterval(P,5e3);return()=>{S=!0,window.clearInterval(V)}},[o,Fl,Bc,a]);const Jp=m.useCallback((S,P)=>{if(!Ie){_e("Readonly workspace");return}const V=RY(P),q=ee=>Array.isArray(ee)?ee.map(me=>(me==null?void 0:me.name)!=="skillKeys"&&(me==null?void 0:me.name)!=="skillsContext"&&(me==null?void 0:me.type)!=="text"?me:{...me,default:V,value:V}):[],Q=f.map(ee=>{var me;return ee.id!==S?ee:{...ee,data:{...ee.data,body:V,inputs:q((me=ee.data)==null?void 0:me.inputs)}}}),re=E.current||{},ie=re[S]&&typeof re[S]=="object"?re[S]:{},te={...re,[S]:{...ie,body:V,input:q(ie.input)}};E.current=te,h(Q),O(te),Ae(ee=>!ee||ee.id!==S?ee:{...ee,body:V,inputs:q(ee.inputs)}),qe(Q,g).catch(ee=>_e(String(ee.message||ee)))},[g,f,qe,h,Ie]),Ad=m.useCallback((S,P)=>{if(!Ie){_e("Readonly workspace");return}const V=LY(P),q=ee=>Array.isArray(ee)?ee.map(me=>(me==null?void 0:me.name)!=="serverNames"&&(me==null?void 0:me.name)!=="mcpContext"&&(me==null?void 0:me.type)!=="text"?me:{...me,default:V,value:V}):[],Q=f.map(ee=>{var me;return ee.id!==S?ee:{...ee,data:{...ee.data,body:V,inputs:q((me=ee.data)==null?void 0:me.inputs)}}}),re=E.current||{},ie=re[S]&&typeof re[S]=="object"?re[S]:{},te={...re,[S]:{...ie,body:V,input:q(ie.input)}};E.current=te,h(Q),O(te),Ae(ee=>!ee||ee.id!==S?ee:{...ee,body:V,inputs:q(ee.inputs)}),qe(Q,g).catch(ee=>_e(String(ee.message||ee)))},[g,f,qe,h,Ie]),Qp=m.useCallback((S,P)=>{if(!Ie){_e("Readonly workspace");return}const V=Jq(P),q=f.map(te=>te.id===S?{...te,data:{...te.data,body:V}}:te),Q=E.current||{},re=Q[S]&&typeof Q[S]=="object"?Q[S]:{},ie={...Q,[S]:{...re,body:V}};E.current=ie,h(q),O(ie),Ae(te=>(te==null?void 0:te.id)===S?{...te,body:V}:te),qe(q,g).catch(te=>_e(String(te.message||te)))},[g,f,qe,h,Ie]),Zp=m.useCallback(S=>{const P=String(S||"").trim();P&&(Ea(V=>V===P?"":P),Ti(V=>({...V,[P]:V[P]||{sessionId:`nodechat_${Date.now()}_${P.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),eh=m.useCallback((S,P)=>{const V=String(S||"").trim();V&&Ti(q=>({...q,[V]:{...q[V]||{sessionId:`nodechat_${Date.now()}_${V.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(P||""),error:""}}))},[]),Ar=m.useCallback((S,P,V="replace",q={})=>{var Xt,$n;if(!Ie){_e("Readonly workspace");return}const Q=String(S||"").trim();if(!Q)return;const re=y.current.find(Ft=>Ft.id===Q),ie=Pn((Xt=re==null?void 0:re.data)==null?void 0:Xt.definitionId),te=pa(P),ee=ie==="html"?gd(te):String(te||""),me=re?pc(re.data):"",ke=V==="append"&&String(me||"").trim()?`${String(me).replace(/\s+$/g,"")}
214
-
215
- ${ee.trim()}`:ee,Re=ie==="image"?"src":"content",dt=q!=null&&q.reloadDisplay?Date.now():($n=re==null?void 0:re.data)==null?void 0:$n.displayReloadKey,Ye=Ft=>{let gn=!1;return(Array.isArray(Ft)?Ft:[]).map(Pt=>{const Tr=String((Pt==null?void 0:Pt.name)||""),Da=String((Pt==null?void 0:Pt.type)||"");return Tr===Re||Tr==="filePath"||Da==="text"?gn?{...Pt,default:"",value:""}:(gn=!0,{...Pt,default:ke,value:ke}):Pt})},It=y.current.map(Ft=>{var gn,Ue;return Ft.id!==Q?Ft:{...Ft,data:{...Ft.data,body:ke,...dt?{displayReloadKey:dt}:{},inputs:Ye((gn=Ft.data)==null?void 0:gn.inputs),outputs:Ye((Ue=Ft.data)==null?void 0:Ue.outputs)}}}),jn=E.current||{},qn=jn[Q]&&typeof jn[Q]=="object"?jn[Q]:{},Qt={...jn,[Q]:{...qn,body:ke,input:Ye(qn.input),output:Ye(qn.output)}};E.current=Qt,h(It),O(Qt),Ae(Ft=>(Ft==null?void 0:Ft.id)===Q?{...Ft,body:ke}:Ft),(q==null?void 0:q.logChat)!==!1&&Ti(Ft=>{var gn;return{...Ft,[Q]:{...Ft[Q]||{},candidateContent:"",messages:[...(gn=Ft[Q])!=null&&gn.messages&&Array.isArray(Ft[Q].messages)?Ft[Q].messages:[],{role:"assistant",text:V==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),qe(It,w.current).catch(Ft=>_e(String(Ft.message||Ft))),_e(String((q==null?void 0:q.statusMessage)||"")||(V==="append"?"已追加节点内容":"已替换节点内容"))},[qe,h,Ie]),Aa=m.useCallback(async S=>{if(!Ie)return _e("Readonly workspace"),"";if(!Mg(S))return _e("请选择图片文件"),"";try{const P=new FormData;P.set("file",S),P.set("dir","img"),o.flowId&&P.set("flowId",o.flowId),o.flowSource&&P.set("flowSource",o.flowSource),o.archived&&P.set("archived","1");const V=await fetch("/api/workspace/upload",{method:"POST",body:P}),q=await V.json().catch(()=>({}));if(!V.ok)throw new Error(q.error||"上传图片失败");const Q=String(q.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await ur(),cr(re=>{const ie=new Set(re);for(const te of om(Q))ie.delete(te);return ie}),_e(`已上传图片 ${Q}`),Q}catch(P){return _e(String(P.message||P)),""}},[o,ur,Ie]),Wc=m.useCallback(async(S,P)=>{const V=String(S||"").trim();if(!V)return;const q=await Aa(P);q&&Ar(V,q,"replace",{logChat:!1,statusMessage:`已上传图片 ${q}`})},[Ar,Aa]),Id=m.useCallback((S,P="replace")=>{var Q;const V=String(S||"").trim(),q=String(((Q=Ii[V])==null?void 0:Q.candidateContent)||"").trim();!V||!q||Ar(V,q,P)},[Ii,Ar]),th=m.useCallback(async(S,P=void 0)=>{var It,jn,qn;if(!Ie){_e("Readonly workspace");return}const V=String(S||"").trim();if(!V)return;const q=Ii[V]||{},Q=String(P!==void 0?P:q.draft||"").trim();if(!Q||q.running)return;const re=y.current.find(Qt=>Qt.id===V);if(!re)return;const ie=Pn((It=re.data)==null?void 0:It.definitionId)||"markdown",te=pc(re.data);let ee=ad(te,ie),me=pa(te);if(ee)try{me=await ld(o,ee)}catch(Qt){_e(String(Qt.message||Qt))}else if(ie!=="image"&&String(me||"").trim()){const Qt=ac(ie,me);if(Qt){_e(`${Qt} 未进入微调。`);return}try{const Xt=await av(o,Z1(V,re.data),me);await ur(),Ar(V,Xt,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Xt}`}),ee=Xt,me=""}catch(Xt){_e(String(Xt.message||Xt));return}}const ke=oY(V,y.current,w.current),Re={role:"user",text:Q,at:Date.now()},dt=Array.isArray(q.messages)?q.messages:[],Ye=q.sessionId||`nodechat_${Date.now()}_${V.replace(/[^a-z0-9_-]+/gi,"_")}`;Ti(Qt=>({...Qt,[V]:{...q,sessionId:Ye,messages:[...dt,Re],draft:"",running:!0,error:""}}));try{const Qt=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,sessionId:Ye,node:{id:V,label:((jn=re.data)==null?void 0:jn.label)||V,definitionId:((qn=re.data)==null?void 0:qn.definitionId)||""},nodeKind:ie,currentContent:ee?"":me,sourceContext:ke,targetFilePath:ee,messages:dt,message:Q,model:ts})}),Xt=await Qt.json().catch(()=>({}));if(!Qt.ok)throw new Error(Xt.error||"节点微调失败");const $n=String(Xt.candidateContent||Xt.reply||"").trim(),Ft=!!Xt.directFileEdit,gn=String(Xt.artifactPath||ee||"").trim();if(Ft&&gn){const Ue=ac(ie,$n);if(Ue)throw new Error(`${Ue} 文件已由 agent 修改,请检查 ${gn}。`);await ur(),Ar(V,gn,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${gn}`})}else if($n){const Ue=ac(ie,$n);if(Ue)throw new Error(`${Ue} 已取消写入,避免覆盖当前展示文件。`);if(ee){const Pt=await av(o,ee,$n);await ur(),Ar(V,Pt,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Pt}`})}else Ar(V,$n,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}Ti(Ue=>{var Pt;return{...Ue,[V]:{...Ue[V]||{},sessionId:String(Xt.sessionId||Ye),running:!1,candidateContent:"",messages:[...(Pt=Ue[V])!=null&&Pt.messages&&Array.isArray(Ue[V].messages)?Ue[V].messages:[...dt,Re],{role:"assistant",text:$n||Ft?gn?`已更新文件 ${gn}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(Qt){const Xt=String(Qt.message||Qt);Ti($n=>({...$n,[V]:{...$n[V]||{},running:!1,error:Xt}})),_e(Xt)}},[ts,o,ur,Ii,Ar,Ie]),nh=m.useCallback(async(S,P)=>{if(!Ie){_e("Readonly workspace");return}const V=Pn(P==null?void 0:P.definitionId)||"markdown",q=pc(P),Q=ad(q,V);let re=pa(q);if(Q)try{re=await ld(o,Q)}catch(me){_e(String(me.message||me));return}if(!String(re||"").trim()){_e("展示节点没有可保存内容");return}const ie=ac(V,re);if(ie){_e(`${ie} 未保存文件。`);return}const te=Z1(S,P),ee=window.prompt("保存到 workspace 相对路径",te);if(ee)try{const me=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:ee,content:re})}),ke=await me.json().catch(()=>({}));if(!me.ok)throw new Error(ke.error||"保存文件失败");const Re=ke.path||ee,dt=Ui(o);dt.set("path",Re);const Ye=await fetch(`/api/workspace/file?${dt.toString()}`);if(!Ye.ok){const It=await Ye.json().catch(()=>({}));throw new Error(It.error||`保存后读取失败:${Re}`)}await ur(),Zn(It=>AY(It,Re,String(re||"").length)),cr(It=>{const jn=new Set(It);for(const qn of om(Re))jn.delete(qn);return jn}),Ar(S,Re,"replace",{logChat:!1,statusMessage:`已保存并引用 ${Re}`}),_e(`已保存 ${Re}`)}catch(me){_e(String(me.message||me))}},[o,ur,Ar,Ie]),zl=m.useCallback(async S=>{var Q,re,ie,te;const P=String(S||"").trim();if(!P||on)return;const V=y.current.find(ee=>ee.id===P);if(!V||!Pn((Q=V==null?void 0:V.data)==null?void 0:Q.definitionId)){_e("展示节点不可用");return}Mn(P),Tt("");const q=window.open("","_blank");try{await qe(y.current,w.current);const ee=String(((re=V.data)==null?void 0:re.label)||((ie=V.data)==null?void 0:ie.displayName)||P).trim()||"AgentFlow Display",me=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:ee,layout:"single",nodeIds:[P]})}),ke=await me.json().catch(()=>({}));if(!me.ok||ke.ok===!1)throw new Error(ke.error||"生成展示链接失败");const Re=new URL(ke.url||`/display/${((te=ke.share)==null?void 0:te.id)||""}`,window.location.origin).href;dn({...ke,absoluteUrl:Re}),$e(""),_e("已生成 1 天有效的展示链接"),q?q.location.href=Re:window.location.assign(Re)}catch(ee){q&&q.close();const me=String(ee.message||ee);Tt(me),_e(me)}finally{Mn("")}},[o,qe,on]),Td=m.useCallback((S,P)=>{const V=String(S||"");V&&Ae(q=>{if(!q||q.id!==V)return q;const Q=typeof P=="function"?P(q):P;return!Q||typeof Q!="object"?q:{...q,...Q}})},[]),As=m.useMemo(()=>f.map(S=>{var P,V;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:Es,showBodyPreview:!0,isExecuting:Pa.has(S.id),nodeStatus:((P=Xo[S.id])==null?void 0:P.status)??null,nodeElapsed:((V=Xo[S.id])==null?void 0:V.elapsed)??null,flowParams:o,readOnly:!Ie,onRunWorkspaceNode:ho,onStopWorkspaceNode:hi,runningRunNodeId:Ri,scheduledRunState:$c[S.id]||null,onChangeScheduledRunConfig:Qp,skills:sr,skillCollections:U,onChangeLoadSkillKeys:Jp,onRefreshSkills:mo,mcpServers:rt,onChangeLoadMcpNames:Ad,onRefreshMcps:Dl,onSaveDisplayNodeToFile:nh,onShareDisplayNode:zl,onOpenDisplayPreview:_r,sharingDisplayNodeId:on,onUploadWorkspaceImage:Aa,onUploadImageToDisplayNode:Wc,onStatus:_e,nodeChatActive:Sd===S.id,nodeChat:Ii[S.id]||null,onSetDisplayNodeContent:Ar,onToggleNodeChat:Zp,onCloseNodeChat:()=>Ea(""),onUpdateNodeChatDraft:eh,onSendNodeChat:th,onApplyNodeChatCandidate:Id,onSyncNodePropDraft:Td}}}),[Sd,Id,Ad,Jp,Qp,o,rt,Es,Ii,f,Dl,mo,ho,Ri,nh,$c,th,Ar,zl,on,U,sr,hi,Td,Zp,eh,Wc,Aa,Pa,Xo,Ie]),Ia=m.useMemo(()=>new Map(As.map(S=>[S.id,S])),[As]),go=Cs?Ia.get(Cs):null,yo=m.useMemo(()=>{const S=new Set(R);return x.nodeIds.map((P,V)=>{var te;const q=Ia.get(P);if(!q||!Pn((te=q.data)==null?void 0:te.definitionId))return null;const Q=du(q)||{width:520,height:320},re=Hu(x.nodeSizes[P]||Q,{display:!0})||Q,ie=x.nodePositions[P]||{x:180+V*36,y:120+V*28};return{...q,id:J1(P),position:ie,selected:S.has(P),width:re.width,height:re.height,data:{...q.data,sourceNodeId:P,displayPageMode:!0,readOnly:!0,selected:S.has(P),displaySize:re,nodeSize:re}}}).filter(Boolean)},[x,Ia,R]),Ir=m.useMemo(()=>As.filter(S=>{var P;return Pn((P=S==null?void 0:S.data)==null?void 0:P.definitionId)}),[As]),st=a==="display";m.useEffect(()=>{if(!st||!x.viewport)return;const S=x.viewport,P=()=>{try{r.setViewport(S,{duration:0})}catch{}},V=window.requestAnimationFrame(()=>window.requestAnimationFrame(P));return()=>window.cancelAnimationFrame(V)},[x.viewport,st,r]),m.useEffect(()=>{if(st||!C)return;const S=C,P=()=>{try{r.setViewport(S,{duration:0})}catch{}},V=window.requestAnimationFrame(()=>window.requestAnimationFrame(P));return()=>window.cancelAnimationFrame(V)},[st,r,C]),m.useEffect(()=>{const S=$.current,P=new Map,V=[];for(const ie of[...As,...yo]){const te=tY(ie);P.set(ie.id,te),S.get(ie.id)!==te&&V.push(ie.id)}if($.current=P,V.length===0)return;const q=()=>V.forEach(ie=>s(ie)),Q=window.requestAnimationFrame(q),re=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[yo,As,s]);const _t=m.useMemo(()=>f.find(S=>S.id===ae)||null,[f,ae]),mi=m.useRef({id:"",draft:null}),xo=m.useMemo(()=>{const S=eC(_t);return S?JSON.stringify(S):""},[_t]);m.useEffect(()=>{if(!_t){mi.current={id:"",draft:null},Ae(null),it("");return}const S=eC(_t),P=mi.current;mi.current={id:_t.id,draft:S},Ae(V=>!V||V.id!==_t.id||P.id!==_t.id||!P.draft?S:DY(V,P.draft,S)),it("")},[_t==null?void 0:_t.id,xo]);const Vc=m.useCallback((S=!1)=>{if(!De||!_t)return!1;if(!Ie)return it("Readonly workspace"),_e("Readonly workspace"),!1;it("");const P=nC({nodes:f,edges:g,instances:E.current,selectedNode:_t,draft:De,allowRename:S});return P!=null&&P.error?(it(P.error),!1):(!(P!=null&&P.ok)||!P.changed||(E.current=P.instances,O(P.instances),h(P.nodes),b(P.edges),P.nextId!==_t.id&&Ce(P.nextId),Wn(P.nextId)),!0)},[g,De,f,_t,b,h,Wn,Ie]);m.useEffect(()=>{if(!Ie||!De||!_t)return;const S=window.setTimeout(()=>{Vc(!1)},350);return()=>window.clearTimeout(S)},[De==null?void 0:De.label,De==null?void 0:De.role,De==null?void 0:De.model,De==null?void 0:De.body,JSON.stringify((De==null?void 0:De.images)||[]),De==null?void 0:De.script,De==null?void 0:De.scriptRef,De==null?void 0:De.implementationRef,De==null?void 0:De.implementationMode,JSON.stringify((De==null?void 0:De.inputs)||[]),JSON.stringify((De==null?void 0:De.outputs)||[]),Vc,_t==null?void 0:_t.id,Ie]);const rh=m.useMemo(()=>{const S=new Map(As.map(P=>[P.id,P]));return g.map(P=>{var me,ke,Re,dt;const V=S.get(P.source),q=S.get(P.target),Q=/^output-(\d+)$/.exec(P.sourceHandle||""),re=/^input-(\d+)$/.exec(P.targetHandle||""),ie=V&&Q?(ke=(me=V.data)==null?void 0:me.outputs)==null?void 0:ke[parseInt(Q[1],10)]:null,te=q&&re?(dt=(Re=q.data)==null?void 0:Re.inputs)==null?void 0:dt[parseInt(re[1],10)]:null,ee=ie!=null&&ie.type?Fn(ie.type):te!=null&&te.type?Fn(te.type):"";return ee?{...P,style:{...P.style||{},stroke:ee,strokeWidth:2},markerEnd:{type:ks.ArrowClosed,color:ee}}:P})},[g,As]),Kc=st?yo:As,Rd=st?[]:rh,er=m.useMemo(()=>st?yo.map(S=>({...S,id:sw(S.id)})):As,[yo,As,st]),Kn=m.useCallback(S=>{const P=String(S||"").trim();if(!P)return;const V=st?J1(P):P;st?H([P]):(h(Q=>Q.map(re=>({...re,selected:re.id===V}))),b(Q=>Q.map(re=>({...re,selected:!1}))),Ce(V));const q=()=>{var me,ke,Re;const Q=r.getNode(V);if(!Q)return;const re=(me=r.getInternalNode)==null?void 0:me.call(r,V),ie=((ke=re==null?void 0:re.measured)==null?void 0:ke.width)??(re==null?void 0:re.width)??Q.width??260,te=((Re=re==null?void 0:re.measured)==null?void 0:Re.height)??(re==null?void 0:re.height)??Q.height??120,{zoom:ee}=r.getViewport();r.setCenter(Q.position.x+ie/2,Q.position.y+te/2,{zoom:rY(ee),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(q))},[st,r,b,h]),Ta=m.useCallback(()=>{const S=r.getViewport(),P={x:Number(S.x)||0,y:Number(S.y)||0,zoom:Math.min(Math.max(Number(S.zoom)||1,.1),4)};if(st){const V={..._.current,viewport:P};_.current=V,N(V),_e("已固定 Display 进入视角")}else F.current=P,T(P),_e("已固定 Workspace 进入视角");qe(y.current,w.current).catch(V=>_e(String(V.message||V)))},[st,r,qe]),Qo=m.useMemo(()=>{const S=de.trim().toLowerCase(),P={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const V of K)S&&![V.id,V.label,V.displayName,V.description].some(q=>String(q||"").toLowerCase().includes(S))||P[bf(V)].push(V);for(const V of uu)P[V].sort((q,Q)=>q.id.localeCompare(Q.id));return P},[K,de]),Li=m.useMemo(()=>{const S=Br.trim().toLowerCase();return K.filter(P=>!S||[P.id,P.label,P.displayName,P.description].some(V=>String(V||"").toLowerCase().includes(S))).sort((P,V)=>{const q=uu.indexOf(bf(P)),Q=uu.indexOf(bf(V));return q!==Q?q-Q:vf(P).localeCompare(vf(V))}).slice(0,30)},[K,Br]),Ra=m.useMemo(()=>{const S=Br.trim().toLowerCase();return Ne.filter(P=>!S||[P.id,P.version,P.displayName,P.name,P.description,...Array.isArray(P.tags)?P.tags:[]].some(V=>String(V||"").toLowerCase().includes(S))).sort((P,V)=>String(P.displayName||P.name||P.id).localeCompare(String(V.displayName||V.name||V.id))).slice(0,30)},[Ne,Br]);m.useEffect(()=>{Wr(0)},[Br,Hr,kr]),m.useEffect(()=>{if(!Hr)return;const S=window.setTimeout(()=>{var P;return(P=Al.current)==null?void 0:P.focus()},0);return()=>window.clearTimeout(S)},[Hr]);const Mt=m.useMemo(()=>{const S=pt.trim().toLowerCase();return S?VR(lr).filter(P=>P.path.toLowerCase().includes(S)):lr},[pt,lr]),sh=[...(Es.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(Es.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(Es.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],Hl=m.useMemo(()=>new Set(ir),[ir]),Oi=m.useMemo(()=>{const S=new Map(sr.map(re=>[re.key,re])),P=new Set,V=new Set,q=U.map(re=>{const ie=yl(re,sr).map(te=>S.get(te)).filter(Boolean);for(const te of ie)P.add(te.key),V.add(String(te.name||te.id||te.key||"").trim());return{...re,skills:ie}}).filter(re=>re.skills.length>0),Q=sr.filter(re=>{const ie=String(re.name||re.id||re.key||"").trim();return!P.has(re.key)&&!V.has(ie)});return{groups:q,ungrouped:Q}},[U,sr]);m.useEffect(()=>{ja(S=>{let P=!1;const V=new Set(S);for(const q of Oi.groups)V.has(q.id)||(V.add(q.id),P=!0);return P?V:S})},[Oi.groups]);const Un=m.useMemo(()=>{const S=f.filter(P=>P.selected);return S.length>0?S:ae?f.filter(P=>P.id===ae):[]},[f,ae]),Bl=m.useMemo(()=>Un.map(S=>S.id),[Un]),Uc=m.useCallback(()=>{if(st)return;if(!Ie){_e("Readonly workspace");return}const S=(y.current||[]).filter(te=>(te==null?void 0:te.selected)&&!Hf(te));if(S.length<2){_e("选择至少两个节点后按 G 创建 Group");return}const P=S.reduce((te,ee)=>{var Ye,It,jn,qn,Qt,Xt,$n,Ft,gn,Ue,Pt,Tr;const me=Number(((Ye=ee.position)==null?void 0:Ye.x)||0),ke=Number(((It=ee.position)==null?void 0:It.y)||0),Re=Number(((jn=ee.measured)==null?void 0:jn.width)||ee.width||((Qt=(qn=ee.data)==null?void 0:qn.nodeSize)==null?void 0:Qt.width)||(($n=(Xt=ee.data)==null?void 0:Xt.displaySize)==null?void 0:$n.width)||AR),dt=Number(((Ft=ee.measured)==null?void 0:Ft.height)||ee.height||((Ue=(gn=ee.data)==null?void 0:gn.nodeSize)==null?void 0:Ue.height)||((Tr=(Pt=ee.data)==null?void 0:Pt.displaySize)==null?void 0:Tr.height)||Rg);return{minX:Math.min(te.minX,me),minY:Math.min(te.minY,ke),maxX:Math.max(te.maxX,me+Re),maxY:Math.max(te.maxY,ke+dt)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(P.minX)||!Number.isFinite(P.minY))return;const V=new Set((y.current||[]).map(te=>te.id));let q=1,Q=`group_${q}`;for(;V.has(Q);)q+=1,Q=`group_${q}`;const re=iv({width:P.maxX-P.minX+nm*2,height:P.maxY-P.minY+nm*2})||{width:Cc,height:Ec},ie={id:Q,type:Nc,position:{x:P.minX-nm,y:P.minY-nm},width:re.width,height:re.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:$g(q-1),title:$g(q-1),color:"purple",nodeSize:re}};h(te=>[ie,...te.map(ee=>({...ee,selected:!1}))]),b(te=>te.map(ee=>({...ee,selected:!1}))),Ce(""),_e(`Created group for ${S.length} nodes`)},[st,b,h,Ie]),Ma=m.useMemo(()=>f.filter(S=>{var P;return Pn((P=S==null?void 0:S.data)==null?void 0:P.definitionId)}),[f]),Md=m.useMemo(()=>Un.filter(S=>{var P;return Pn((P=S==null?void 0:S.data)==null?void 0:P.definitionId)}).map(S=>S.id),[Un]),ih=m.useMemo(()=>{const S=String((rs==null?void 0:rs.username)||(rs==null?void 0:rs.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[rs]),qc=m.useMemo(()=>new Set(Bl),[Bl]),Nr=m.useMemo(()=>g.filter(S=>qc.has(S.source)&&qc.has(S.target)),[g,qc]),Ld=m.useCallback(S=>{const P=S==="display"?"display":"workspace";l(P),Ce(""),H([]),z(null),hr(!1),St(!1);const V=Ui(o);P==="display"&&V.set("view","display");const q=`/workspace${V.toString()?`?${V.toString()}`:""}`;window.history.pushState({},"",q)},[o]),Xs=m.useCallback(S=>{var q;const P=String(S||"").trim();if(!P)return;const V=y.current.find(Q=>Q.id===P);if(!V||!Pn((q=V.data)==null?void 0:q.definitionId)){_e("展示节点不可用");return}N(Q=>{if(Q.nodeIds.includes(P))return Q;const re=Q.nodeIds.length,ie=du(V);return{nodeIds:[...Q.nodeIds,P],nodePositions:{...Q.nodePositions,[P]:{x:180+re*36,y:120+re*28}},nodeSizes:{...Q.nodeSizes,...ie?{[P]:ie}:{}}}}),H([P])},[]),Js=m.useCallback(S=>{const P=String(S||"").trim();P&&(N(V=>{const q=V.nodeIds.filter(ie=>ie!==P),Q={...V.nodePositions},re={...V.nodeSizes};return delete Q[P],delete re[P],{nodeIds:q,nodePositions:Q,nodeSizes:re}}),H(V=>V.filter(q=>q!==P)))},[]),Od=m.useCallback(S=>{const P=String(S||"").trim();P&&(_.current.nodeIds.includes(P)?Js(P):Xs(P))},[Xs,Js]),wo=m.useMemo(()=>{const S=mn.trim().toLowerCase();return S?Ir.filter(P=>{var V,q;return[P.id,(V=P.data)==null?void 0:V.label,(q=P.data)==null?void 0:q.definitionId].filter(Boolean).some(Q=>String(Q).toLowerCase().includes(S))}):Ir},[Ir,mn]),$d=m.useMemo(()=>{const S=wo.length,P=S<=1?1:S<=4?2:3,V=Array.from({length:P},()=>({height:0,nodes:[]}));for(const q of wo){const Q=du(q)||{width:420,height:260},re=Math.max(1,Number(Q.width)||420),ie=Math.max(1,Number(Q.height)||260),te=Math.min(26,Math.max(5.5,ie/re*16))+3.2;let ee=V[0];for(const me of V)me.height<ee.height&&(ee=me);ee.nodes.push(q),ee.height+=te}return V.map(q=>q.nodes)},[wo]),Wl=m.useCallback(S=>{var re,ie;const P=x.nodeIds.includes(S.id),V=du(S)||{width:420,height:260},q=Math.max(1,Math.round(Number(V.width)||420)),Q=Math.max(1,Math.round(Number(V.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(P?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${q} / ${Q}`},onClick:()=>Od(S.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:P,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(yY,{node:S})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((re=S.data)==null?void 0:re.label)||S.id}),i.jsxs("small",{children:[Pn((ie=S.data)==null?void 0:ie.definitionId)," · ",S.id]})]})]},S.id)},[x.nodeIds,Od]),Dd=m.useMemo(()=>{const S=de.trim().toLowerCase();return S?Ne.filter(P=>[P.id,P.version,P.displayName,P.name,P.description,...Array.isArray(P.tags)?P.tags:[]].filter(Boolean).some(V=>String(V).toLowerCase().includes(S))):Ne},[Ne,de]),yr=m.useCallback((S,P)=>{const V=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let q=`${V}_${Date.now().toString(36)}`,Q=2;for(;P.has(q);)q=`${V}_${Date.now().toString(36)}_${Q}`,Q+=1;return P.add(q),q},[]),La=m.useCallback((S,P)=>{var Ft,gn;if(!Ie){_e("Readonly workspace");return}const V=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},q=V.instances&&typeof V.instances=="object"?V.instances:{},Q=Object.keys(q);if(Q.length===0)return;const re=new Set(y.current.map(Ue=>Ue.id)),ie={};for(const Ue of Q)ie[Ue]=yr(Ue,re);const te=(Ft=V.ui)!=null&&Ft.nodePositions&&typeof V.ui.nodePositions=="object"?V.ui.nodePositions:{},ee=(gn=V.ui)!=null&&gn.nodeSizes&&typeof V.ui.nodeSizes=="object"?V.ui.nodeSizes:{},me=Q.map(Ue=>{const Pt=te[Ue];return{id:Ue,x:typeof(Pt==null?void 0:Pt.x)=="number"?Pt.x:0,y:typeof(Pt==null?void 0:Pt.y)=="number"?Pt.y:0}}),ke=Math.min(...me.map(Ue=>Ue.x)),Re=Math.min(...me.map(Ue=>Ue.y));let dt=P||{x:360+y.current.length*24,y:180+y.current.length*18};if(!P){const Ue=document.querySelector(".af-workspace-canvas .react-flow");if(Ue){const Pt=Ue.getBoundingClientRect();dt=r.screenToFlowPosition({x:Pt.left+Pt.width*.48,y:Pt.top+Pt.height*.32})}}const Ye={},It={},jn={};for(const Ue of me){const Pt=ie[Ue.id];Ye[Pt]={...q[Ue.id]||{}},It[Pt]={x:dt.x+(Ue.x-ke),y:dt.y+(Ue.y-Re)};const Tr=ee[Ue.id];typeof(Tr==null?void 0:Tr.width)=="number"&&typeof(Tr==null?void 0:Tr.height)=="number"&&(jn[Pt]={width:Tr.width,height:Tr.height})}const qn=new Set(Q),Qt=(Array.isArray(V.edges)?V.edges:[]).filter(Ue=>qn.has(Ue==null?void 0:Ue.source)&&qn.has(Ue==null?void 0:Ue.target)).map(Ue=>({source:ie[Ue.source],target:ie[Ue.target],sourceHandle:Ue.sourceHandle??null,targetHandle:Ue.targetHandle??null})),Xt=rw({instances:Ye,edges:Qt,ui:{nodePositions:It,nodeSizes:jn}},K),$n=Xt.nodes.map(Ue=>({...Ue,selected:!0}));E.current={...E.current,...Xt.instances},O(E.current),h(Ue=>[...Ue.map(Pt=>({...Pt,selected:!1})),...$n]),b(Ue=>[...Ue.map(Pt=>({...Pt,selected:!1})),...Xt.edges]),_e(`已添加流程片段:${S.displayName||S.id}`)},[yr,K,r,b,h,Ie]),$i=m.useCallback(()=>{var V,q;if(Un.length<2){Ke("请先在 workspace 画布上选择至少两个节点。"),ue("flows");return}const S=Un[0],P=Un.length===2?`${((V=S.data)==null?void 0:V.label)||S.id} 片段`:`${((q=S.data)==null?void 0:q.label)||S.id} 等 ${Un.length} 个节点`;Ve({name:P,id:P.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Ut(""),We(!0),ue("flows")},[Un]),Yc=m.useCallback(async()=>{var Q,re;if(Un.length<2)return;const S=ut.name.trim();if(!S){Ut("请填写片段名称。");return}const P={},V={};for(const ie of Un){P[ie.id]={x:((Q=ie.position)==null?void 0:Q.x)||0,y:((re=ie.position)==null?void 0:re.y)||0};const te=du(ie);te&&(V[ie.id]=te)}const q=Nr.map(ie=>({source:ie.source,target:ie.target,sourceHandle:ie.sourceHandle??null,targetHandle:ie.targetHandle??null}));bt(!0),Ut("");try{const ie=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:ut.id,name:S,displayName:S,version:"1.0.0",description:ut.description,snippet:{instances:Wp(Un,E.current),edges:q,ui:{nodePositions:P,nodeSizes:V}}})}),te=await ie.json().catch(()=>({}));if(!ie.ok||te.ok===!1)throw new Error(te.error||"发布流程片段失败");We(!1),_e(`流程片段已发布:${te.id||S}`),Rt(`流程片段已发布:${te.id||S}`),await zc(),ue("flows")}catch(ie){Ut(String(ie.message||ie))}finally{bt(!1)}},[zc,ut,Nr,Un,Rt]);m.useCallback(()=>{if(Ma.length===0){_e("当前 workspace 没有 display 节点");return}const S=Md.length>0?Md:Ma.map(V=>V.id),P=o.flowId?`${o.flowId} 展示页`:"AgentFlow Display";Rn({title:P,layout:"gallery",nodeIds:S}),Tt(""),dn(null),je(!0)},[o.flowId,Md,Ma]);const bo=m.useCallback(S=>{Rn(P=>{const V=Array.isArray(P.nodeIds)?P.nodeIds:[];return V.includes(S)?{...P,nodeIds:V.filter(q=>q!==S)}:{...P,nodeIds:[...V,S]}})},[]),Oa=m.useCallback(async()=>{var V;const S=sn.title.trim(),P=Array.isArray(sn.nodeIds)?sn.nodeIds:[];if(P.length===0){Tt("请选择至少一个 display 节点。");return}ot(!0),Tt(""),dn(null);try{await qe(f,g);const q=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:S,layout:sn.layout,nodeIds:P})}),Q=await q.json().catch(()=>({}));if(!q.ok||Q.ok===!1)throw new Error(Q.error||"发布展示页失败");const re=new URL(Q.url||`/display/${((V=Q.share)==null?void 0:V.id)||""}`,window.location.origin).href;dn({...Q,absoluteUrl:re}),_e("展示页已生成")}catch(q){Tt(String(q.message||q))}finally{ot(!1)}},[sn,g,o,f,qe]),Gc=m.useCallback(async()=>{var P;const S=Array.isArray(x.nodeIds)?x.nodeIds:[];if(S.length===0){Tt("请先添加至少一个展示节点。"),_e("请先添加至少一个展示节点"),St(!0);return}ot(!0),Tt("");try{await qe(f,g);const V=o.flowId?`${o.flowId} 展示页`:"AgentFlow Display",q=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:V,layout:"canvas",nodeIds:S})}),Q=await q.json().catch(()=>({}));if(!q.ok||Q.ok===!1)throw new Error(Q.error||"生成展示链接失败");const re=new URL(Q.url||`/display/${((P=Q.share)==null?void 0:P.id)||""}`,window.location.origin).href;dn({...Q,absoluteUrl:re}),zr(!0),_e("展示链接已生成")}catch(V){const q=String(V.message||V);Tt(q),_e(q)}finally{ot(!1)}},[x.nodeIds,g,o,f,qe]),Vl=m.useCallback(async()=>{const S=mt==null?void 0:mt.absoluteUrl;if(!S)return;const P=await sY(S);$e(P?"copied":"failed"),window.setTimeout(()=>$e(""),1600)},[mt==null?void 0:mt.absoluteUrl]),Dt=m.useCallback(S=>{h(P=>P.map(V=>V.id===S?{...V,selected:!1}:V)),Ce(P=>P===S?"":P)},[h]),wt=m.useCallback(()=>{const S=Gs.current;if(!S)return;const P=S.getBoundingClientRect(),V=Math.min(420,Math.max(320,P.width+160)),q=12,Q=Math.max(180,P.top-q*2),re=Math.min(560,Q);Rc({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-V-12,P.left)),top:Math.max(q,P.top-re-q),width:V,maxHeight:re,zIndex:1e4})},[]);m.useEffect(()=>{if(!Pl)return;wt();const S=V=>{var Q,re;const q=V.target;(Q=Gs.current)!=null&&Q.contains(q)||(re=kd.current)!=null&&re.contains(q)||Tc(!1)},P=V=>{V.key==="Escape"&&Tc(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",P),window.addEventListener("resize",wt),window.addEventListener("scroll",wt,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",P),window.removeEventListener("resize",wt),window.removeEventListener("scroll",wt,!0)}},[Pl,wt]);const Dy=m.useCallback(S=>{var q,Q,re;if(a==="display"){const ie=[];let te=!1;N(ee=>{var Re,dt;const me={...ee.nodePositions},ke={...ee.nodeSizes};for(const Ye of S||[]){const It=sw(Ye==null?void 0:Ye.id);if(!(!It||!ee.nodeIds.includes(It))){if(Ye.type==="select"){Ye.selected&&ie.push(It);continue}if(Ye.type==="position"&&Ye.position){me[It]={x:Ye.position.x,y:Ye.position.y},te=!0;continue}if(Ye.type==="dimensions"&&((Re=Ye.dimensions)!=null&&Re.width)&&((dt=Ye.dimensions)!=null&&dt.height)){const jn=Hu({width:Math.round(Number(Ye.dimensions.width)),height:Math.round(Number(Ye.dimensions.height))},{display:!0});jn&&(ke[It]=jn,te=!0)}}}return te?{...ee,nodePositions:me,nodeSizes:ke}:ee}),(S||[]).some(ee=>(ee==null?void 0:ee.type)==="select")&&H(ie);return}if(!Ie){const ie=(S||[]).filter(te=>(te==null?void 0:te.type)==="select");ie.length>0&&h(te=>wg(ie,te));return}const P=new Map;for(const ie of S||[])if((ie==null?void 0:ie.type)==="dimensions"&&((q=ie.dimensions)!=null&&q.width)&&((Q=ie.dimensions)!=null&&Q.height)){const te=f.find(dt=>dt.id===ie.id),ee=Hf(te),me=!!Pn((re=te==null?void 0:te.data)==null?void 0:re.definitionId),ke={width:Math.round(Number(ie.dimensions.width)),height:Math.round(Number(ie.dimensions.height))},Re=ee?iv(ke):Hu(ke,{display:me});Re&&P.set(ie.id,Re)}const V=Array.from(P.keys());if(h(ie=>wg(S,ie).map(te=>{var me;const ee=P.get(te.id);return ee?Hf(te)?{...te,width:ee.width,height:ee.height,data:{...te.data,nodeSize:ee}}:Pn((me=te.data)==null?void 0:me.definitionId)?{...te,width:ee.width,height:ee.height,data:{...te.data,nodeSize:ee,displaySize:ee}}:{...te,width:ee.width,height:ee.height,data:{...te.data,nodeSize:ee}}:te})),V.length>0){const ie=()=>V.forEach(te=>s(te));window.requestAnimationFrame(ie),window.setTimeout(ie,80)}},[f,h,s,a,Ie]),wn=m.useCallback(S=>{if(a!=="display"){if(!Ie){const P=(S||[]).filter(V=>(V==null?void 0:V.type)==="select");P.length>0&&b(V=>E0(P,V));return}k(S)}},[k,b,a,Ie]),Gt=m.useCallback(()=>{const S=document.querySelector(".af-workspace-canvas .react-flow");if(S){const P=S.getBoundingClientRect();return r.screenToFlowPosition({x:P.left+P.width*.48,y:P.top+P.height*.32})}return{x:360+f.length*36,y:180+f.length*28}},[f.length,r]),Xc=m.useCallback(()=>{var S,P,V;if(_t){const q=Number(((S=_t.measured)==null?void 0:S.width)||_t.width||260);return{x:Number(((P=_t.position)==null?void 0:P.x)||0)+q+140,y:Number(((V=_t.position)==null?void 0:V.y)||0)}}return Gt()},[Gt,_t]),dr=m.useCallback((S,P={})=>{if(!Ie)return _e("Readonly workspace"),null;if(!S)return null;const V=ik(S)||S.id,q=LR(S),Q=P.id||Gq(V,f),re=sm(S.inputs),ie=sm(S.outputs),te={definitionId:V,...q?{marketplaceRef:q}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:P.label||Og(S),role:"normal",body:P.body||"",...P.script?{script:P.script}:{},...P.scriptRef?{scriptRef:P.scriptRef}:{},...P.implementationRef?{implementationRef:P.implementationRef}:{},...P.implementationMode?{implementationMode:P.implementationMode}:{},input:P.inputs||re,output:P.outputs||ie},ee={id:Q,type:Nc,position:P.position||Gt(),data:{label:te.label,definitionId:V,...q?{marketplaceRef:q}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:MR(V,S),role:"normal",body:te.body,...te.script?{script:te.script}:{},...te.scriptRef?{scriptRef:te.scriptRef}:{},...te.implementationRef?{implementationRef:te.implementationRef}:{},...te.implementationMode?{implementationMode:te.implementationMode}:{},inputs:te.input,outputs:te.output}},me={...kp(ee,{...E.current,[Q]:te},K),selected:!0};return h(ke=>[...ke.map(Re=>({...Re,selected:!1})),me]),P.openProperties&&Ce(Q),Q},[Gt,f,K,h,Ie]),Zo=m.useCallback(S=>tw(S,y.current),[]),oh=m.useCallback(S=>{if(!Ie){_e("Readonly workspace");return}if(!tw(S,y.current)){_e("端口类型不匹配,已取消连线");return}z(null),h(P=>Ff(P,S)),b(P=>{const V=P.filter(q=>!(q.target===S.target&&q.targetHandle===S.targetHandle));return Du({...S,markerEnd:{type:ks.ArrowClosed}},V)})},[b,h,Ie]),Fd=m.useCallback((S,P)=>{if(!Ie)return;const V=Uq(P,y.current);L.current=V?{...V,preferExisting:!!(S!=null&&S.shiftKey)}:null,z(null)},[Ie]),ah=m.useCallback((S,P)=>{var qn,Qt,Xt,$n;if(!Ie)return;const V=L.current;if(L.current=null,!V||P!=null&&P.toNode)return;const q=qq(K,V),Q=Yq(y.current,w.current,V);if(q.length===0&&Q.length===0){_e(`没有匹配 ${V.slotType} 端口的节点`);return}const ie=!!(S!=null&&S.shiftKey||V.preferExisting)?Q.length>0?"existing":"create":q.length>0?"create":"existing",te=((Qt=(qn=S==null?void 0:S.changedTouches)==null?void 0:qn[0])==null?void 0:Qt.clientX)??(S==null?void 0:S.clientX),ee=(($n=(Xt=S==null?void 0:S.changedTouches)==null?void 0:Xt[0])==null?void 0:$n.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(te)||!Number.isFinite(ee))return;const me=document.querySelector(".af-workspace-canvas .react-flow");if(!me)return;const ke=me.getBoundingClientRect(),Re=320,dt=Math.max(q.length,Q.length),Ye=Math.min(480,150+dt*58),It=Math.max(12,Math.min(te-ke.left,ke.width-Re-12)),jn=Math.max(12,Math.min(ee-ke.top,ke.height-Ye-12));z({left:It,top:jn,flowPosition:r.screenToFlowPosition({x:te,y:ee}),draft:V,candidates:q,existingCandidates:Q,mode:ie,query:""})},[K,r,Ie]),Jc=m.useCallback(S=>{if(!Ie){_e("Readonly workspace"),z(null);return}const P=M.current;if(!P||!(S!=null&&S.def))return;const V=dr(S.def,{position:P.flowPosition});if(!V)return;const q=P.draft.handleType==="source"?{source:P.draft.nodeId,sourceHandle:P.draft.handleId,target:V,targetHandle:`input-${S.slotIndex}`}:{source:V,sourceHandle:`output-${S.slotIndex}`,target:P.draft.nodeId,targetHandle:P.draft.handleId};h(Q=>Ff(Q,q)),b(Q=>{const re=Q.filter(ie=>!(ie.target===q.target&&ie.targetHandle===q.targetHandle));return Du({...q,markerEnd:{type:ks.ArrowClosed}},re)}),z(null)},[dr,b,Ie]),ss=m.useCallback(S=>{if(!Ie){_e("Readonly workspace"),z(null);return}const P=S==null?void 0:S.connection;if(!P||!tw(P,y.current)){_e("端口类型不匹配,已取消连线"),z(null);return}h(V=>Ff(V,P)),b(V=>{const q=V.filter(Q=>!(Q.target===P.target&&Q.targetHandle===P.targetHandle));return Du({...P,markerEnd:{type:ks.ArrowClosed}},q)}),z(null)},[b,h,Ie]),gi=m.useCallback(S=>{S&&(dr(S,{position:Xc()}),hr(!1),Ei(""))},[dr,Xc]),lh=m.useCallback(S=>{S&&(La(S,Xc()),hr(!1),Ei(""))},[La,Xc]);m.useEffect(()=>{const S=P=>{var me;if(P.defaultPrevented)return;const V=oR(P.target)||Hq(P.target);if((P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="s"){P.preventDefault(),qe().catch(ke=>_e(String(ke.message||ke)));return}if((P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="k"){P.preventDefault(),P.stopPropagation(),jd(ke=>!ke);return}if(Ll)return;if(Nd){(P.key==="Escape"||Tg(P))&&(P.preventDefault(),_s(!1));return}const q=P.key.toLowerCase(),Q=(P.metaKey||P.ctrlKey)&&q==="c",re=(P.metaKey||P.ctrlKey)&&q==="v",ie=V&&Q&&Wq(P.target);if(V&&!ie)return;const te=(P.metaKey||P.ctrlKey)&&!P.shiftKey&&q==="z",ee=(P.metaKey||P.ctrlKey)&&(P.shiftKey&&q==="z"||q==="y");if(te||ee){if(st){P.preventDefault(),P.stopPropagation(),_e("展示页布局会自动保存");return}if(!Ie){P.preventDefault(),_e("Readonly workspace");return}P.preventDefault(),P.stopPropagation();const ke=te?Gp():po();_e(ke?te?"Undo canvas change":"Redo canvas change":te?"Nothing to undo":"Nothing to redo");return}if(Q){if(st)return;const ke=tt.current,Re=(y.current||[]).some(Ye=>Ye==null?void 0:Ye.selected)?y.current:(y.current||[]).map(Ye=>ke&&Ye.id===ke?{...Ye,selected:!0}:Ye),dt=JT(Re,w.current,E.current);dt&&(P.preventDefault(),P.stopPropagation(),B.current=dt,ie&&typeof((me=P.target)==null?void 0:me.blur)=="function"&&P.target.blur(),_e(`Copied ${dt.nodes.length} node${dt.nodes.length>1?"s":""}`));return}if(re){if(st){P.preventDefault(),P.stopPropagation();return}if(!Ie){P.preventDefault(),_e("Readonly workspace");return}const ke=QT(B.current,y.current,w.current,E.current);ke&&(P.preventDefault(),P.stopPropagation(),E.current=ke.instances,O(ke.instances),h(ke.nodes),b(ke.edges),_e(`Pasted ${ke.pastedNodeIds.length} node${ke.pastedNodeIds.length>1?"s":""}`));return}if(Tg(P)&&!P.metaKey&&!P.ctrlKey&&!P.altKey){P.preventDefault(),_s(!0);return}if(q==="g"&&!P.metaKey&&!P.ctrlKey&&!P.altKey){P.preventDefault(),Uc();return}if(P.key==="a"||P.key==="A"){if(P.metaKey||P.ctrlKey){P.preventDefault(),st?H(_.current.nodeIds):(h(ke=>ke.map(Re=>({...Re,selected:!0}))),b(ke=>ke.map(Re=>({...Re,selected:!1}))));return}if(P.altKey)return;if(st){P.preventDefault(),St(!0);return}if(!Ie){P.preventDefault(),_e("Readonly workspace");return}P.preventDefault(),hr(!0);return}if((P.key==="v"||P.key==="V")&&!P.metaKey&&!P.ctrlKey&&!P.altKey){P.preventDefault(),Lc("select");return}if((P.key==="h"||P.key==="H")&&!P.metaKey&&!P.ctrlKey&&!P.altKey){P.preventDefault(),Lc("pan");return}(P.key==="f"||P.key==="F")&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&(P.preventDefault(),Ta())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[Uc,st,Ll,Ta,po,qe,Nd,b,h,Gp,Ie]);const Fy=m.useCallback(S=>{cr(P=>{const V=new Set(P);return V.has(S)?V.delete(S):V.add(S),V})},[]),ch=m.useCallback((S,P)=>{S.dataTransfer.effectAllowed="copy",S.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:P.path,name:P.name,type:P.type})),S.dataTransfer.setData("text/plain",P.path)},[]),uh=m.useCallback((S,P)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",P.id),S.dataTransfer.setData("text/plain",P.id)},[]),Kl=m.useCallback(async(S,P)=>{const V=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),q=V.split(".").pop(),Q=q==="html"?"display_html":q==="csv"||q==="tsv"||q==="json"&&/\b(table|data|rows|report)\b/i.test(V)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(q)?"display_image":"display_markdown",re=K.find(Re=>Re.id===Q);if(!re){_e("展示节点不可用");return}const ie=Q==="display_image";let te=String(S.path||"");if(!ie){const Re=Ui(o);Re.set("path",S.path);const dt=await fetch(`/api/workspace/file?${Re.toString()}`),Ye=await dt.json();if(!dt.ok)throw new Error(Ye.error||"读取文件失败");te=String(Ye.content||"")}const ee=Q==="display_image"?"src":"content",me=sm(re.inputs).map(Re=>Re.name===ee?{...Re,default:te,value:te}:Re),ke=sm(re.outputs).map(Re=>Re.name===ee?{...Re,default:te,value:te}:Re);dr(re,{label:S.name||"Display",body:te,inputs:me,outputs:ke,position:P}),_e(`已创建展示:${S.path}`)},[dr,o,K]),Qs=m.useCallback(S=>{if(!Ie){_e("Readonly workspace");return}Kl(S,Gt()).catch(P=>_e(String(P.message||P)))},[Kl,Gt,Ie]),$a=m.useCallback(S=>{if(!Ie){S.preventDefault(),_e("Readonly workspace");return}const P=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(P){S.preventDefault();let ie;try{ie=JSON.parse(P)}catch{return}if(!(ie!=null&&ie.path))return;const te=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Kl(ie,te).catch(ee=>_e(String(ee.message||ee)));return}const V=S.dataTransfer.getData("application/agentflow-snippet");if(V){const ie=Ne.find(ee=>`${ee.id}@${ee.version}`===V);if(!ie)return;S.preventDefault();const te=r.screenToFlowPosition({x:S.clientX,y:S.clientY});La(ie,te);return}const q=S.dataTransfer.getData("application/agentflow-node");if(!q)return;const Q=K.find(ie=>ie.id===q);if(!Q)return;S.preventDefault();const re=r.screenToFlowPosition({x:S.clientX,y:S.clientY});dr(Q,{position:re})},[Kl,dr,Ne,La,K,r,Ie]),Ul=m.useCallback(S=>{if(!Ie)return;const P=Array.from(S.dataTransfer.types||[]);!P.includes("application/x-agentflow-workspace-file")&&!P.includes("application/agentflow-node")&&!P.includes("application/agentflow-snippet")||(S.preventDefault(),S.dataTransfer.dropEffect=P.includes("application/agentflow-node")||P.includes("application/agentflow-snippet")?"move":"copy")},[Ie]),dh=m.useCallback(async(S="")=>{if(!Ie){_e("Readonly workspace");return}const P=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!P)return;const V=S&&!P.includes("/")?`${S}/${P}`:P;try{const q=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:V,content:""})}),Q=await q.json();if(!q.ok)throw new Error(Q.error||"创建文件失败");await ur(),cr(re=>{const ie=new Set(re);for(const te of om(Q.path||V))ie.delete(te);return ie}),_e(`已创建 ${Q.path}`)}catch(q){_e(String(q.message||q))}},[o,ur,Ie]),fh=m.useCallback(async(S="")=>{if(!Ie){_e("Readonly workspace");return}const P=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!P)return;const V=S&&!P.includes("/")?`${S}/${P}`:P;try{const q=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:V})}),Q=await q.json();if(!q.ok)throw new Error(Q.error||"创建文件夹失败");await ur(),cr(re=>{const ie=new Set(re);for(const te of om(Q.path||V))ie.delete(te);return Q.path&&ie.delete(Q.path),ie}),_e(`已创建 ${Q.path}`)}catch(q){_e(String(q.message||q))}},[o,ur,Ie]),vo=m.useCallback(async S=>{if(!Ie){_e("Readonly workspace");return}if(!(!(S!=null&&S.path)||!window.confirm(`删除 ${S.path}?`)))try{const P=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:S.path})}),V=await P.json();if(!P.ok)throw new Error(V.error||"删除失败");_e(`已删除 ${V.path}`),await ur()}catch(P){_e(String(P.message||P))}},[o,ur,Ie]),Di=m.useCallback(async()=>{if(!Ie){_e("Readonly workspace");return}const S=co.trim();if(!S||ns)return;const P=im(f,g,E.current);cn(""),Vn(!0),$y("workspace"),qo(V=>[...V,{role:"user",text:S,at:Date.now()}]);try{await qe(f,g);const V=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,prompt:S,outputKind:"markdown",workspaceGraph:P,allowFlowYaml:!1,model:ts,selectedSkills:ir,selectedNodeIds:Bl})}),q=await V.json();if(!V.ok)throw new Error(q.error||"生成失败");const Q=String(q.content||"").trim();qo(re=>[...re,{role:"assistant",text:Q,at:Date.now()}]),await Jo(),_e("AI 生成完成")}catch(V){const q=String(V.message||V);qo(Q=>[...Q,{role:"assistant",text:q,error:!0,at:Date.now()}]),_e(q)}finally{Vn(!1)}},[ts,ns,co,g,o,Jo,f,$y,qe,Bl,ir,Ie]),is=Pi.find(S=>S.id===Tl)||null,gt=is?Array.isArray(is.messages)?is.messages:[]:Mc,Zs=is?is.status==="running":ns,zy=is?is.status==="running"?`${is.label} running`:is.status==="paused"?`${is.label} paused`:is.status==="failed"?`${is.label} failed`:`${is.label} done`:ns?"Workspace agent running":Mc.length>0?"Workspace conversation":"Ready";return i.jsxs("div",{className:"af-workspace-page",children:[i.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n("/projects"),"aria-label":"返回",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",title:o.flowId?`${o.flowId} · ${Vr}`:Vr||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",$q,"-STABLE"]})]}),i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:a==="workspace"?"af-view-switch__active":"",onClick:()=>Ld("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:a==="display"?"af-view-switch__active":"",onClick:()=>Ld("display"),children:"Display"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:"af-workspace-save-status",children:Cd}),st?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:He||!(mt!=null&&mt.absoluteUrl)&&x.nodeIds.length===0,onClick:()=>{$e(""),mt!=null&&mt.absoluteUrl?zr(!0):Gc()},title:mt!=null&&mt.absoluteUrl?"查看展示链接":x.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:He?"hourglass_empty":"ios_share"}),He?"生成中":mt!=null&&mt.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ir.length===0,onClick:()=>St(!0),title:Ir.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>n($l),"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),children:i.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Fc,onClick:()=>d(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:i.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!Fc,onClick:()=>c(!0),"aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>_s(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(gr?" af-composer-topbar-btn--active":"")+(ns?" af-composer-topbar-btn--running":""),disabled:st,onClick:()=>Yo(S=>!S),children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Ie,onClick:()=>qe().catch(S=>_e(String(S.message||S))),children:"Save"})]})]}),nn?i.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsx("span",{children:nn}),i.jsx("button",{type:"button",onClick:()=>rn(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!st&&(gr||De)?" af-workspace-body--drawer":"")+(!st&&Ml?" af-workspace-body--sidebar-collapsed":"")+(st?" af-workspace-body--display-mode":""),children:[!st&&Ml?i.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:i.jsxs("div",{className:"af-workspace-rail__stack",children:[i.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>hr(!0),"aria-label":"添加节点",title:"添加节点",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),i.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>_a(!1),"aria-label":"展开文件",title:"展开文件",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),i.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),i.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>_a(!1),"aria-label":"展开侧边栏",title:(rs==null?void 0:rs.username)||(rs==null?void 0:rs.userId)||"展开侧边栏",children:ih})]})}):null,st?null:i.jsxs("aside",{ref:nt,className:"af-workspace-sidebar"+(Ko?" af-workspace-sidebar--resizing":""),"aria-hidden":Ml,style:{"--af-work-files-pane-height":`${Math.round(Kr)}px`},children:[i.jsxs("section",{className:"af-workspace-files-section",children:[i.jsxs("div",{className:"af-workspace-sidebar-head",children:[i.jsx("h2",{children:"Files"}),i.jsxs("div",{className:"af-workspace-sidebar-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>_a(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ie,onClick:()=>dh(""),"aria-label":"新增文件",title:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ie,onClick:()=>fh(""),"aria-label":"新增文件夹",title:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void ur(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),i.jsx("input",{className:"af-workspace-search",value:pt,onChange:S=>xn(S.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",children:i.jsx(qR,{items:Mt,flowParams:o,onOpen:Qs,collapsedDirs:an,onToggleDir:Fy,onCreateFile:dh,onCreateFolder:fh,onDelete:vo,onFileDragStart:ch})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:_i,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),i.jsxs("section",{className:"af-workspace-nodes-section",children:[i.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[i.jsxs("h2",{className:"af-node-palette-title",children:[i.jsx("span",{children:"Palette"}),i.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),i.jsxs("label",{className:"af-palette-search-wrap",children:[i.jsx("span",{className:"af-visually-hidden",children:we==="flows"?"搜索流程片段":"搜索节点"}),i.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",className:"af-palette-search-input",value:de,onChange:S=>he(S.target.value),placeholder:we==="flows"?"搜索流程片段...":"搜索节点...","aria-label":we==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":we==="nodes",className:"af-palette-tab"+(we==="nodes"?" af-palette-tab--active":""),onClick:()=>ue("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":we==="flows",className:"af-palette-tab"+(we==="flows"?" af-palette-tab--active":""),onClick:()=>ue("flows"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),i.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:we==="flows"?i.jsxs(i.Fragment,{children:[i.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:i.jsxs("div",{className:"af-flow-snippet-actions",children:[i.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:$i,disabled:Un.length<2,title:Un.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Un.length," 节点 / ",Nr.length," 连线"]})]})}),Se?i.jsx("p",{className:"af-err af-palette-list-err",children:Se}):null,ce?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Dd.length>0?i.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[i.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),i.jsx("div",{className:"af-palette-cards",children:Dd.map(S=>{const P=`${S.id}@${S.version}`,V=S.displayName||S.name||S.id,q=S.description||`${S.nodeCount||0} 个节点,${S.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Q=>{Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/agentflow-snippet",P),Q.dataTransfer.setData("text/plain",P)},onClick:()=>La(S),title:q,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:V}),i.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),q?i.jsx("span",{className:"af-palette-card-desc",children:q}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[S.nodeCount||0," nodes"]}),i.jsxs("span",{children:[S.edgeCount||0," edges"]})]})]},P)})})]}):i.jsx("p",{className:"af-palette-empty",children:de.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[uu.map(S=>{var P;return(P=Qo[S])!=null&&P.length?i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${S}`,children:[i.jsx("h3",{className:"af-palette-cat",children:S}),i.jsx("div",{className:"af-palette-cards",children:Qo[S].map(V=>{const q=G1(V.inputs,"input"),Q=G1(V.outputs,"output"),re=sv(V),ie=vf(V);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:te=>uh(te,V),onClick:()=>dr(V),title:re||V.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:q1(S)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:ie}),ie!==V.id?i.jsx("span",{className:"af-palette-card-id",children:V.id}):null]})]}),re?i.jsx("span",{className:"af-palette-card-desc",children:re}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[q.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[q.shown.map((te,ee)=>i.jsxs("span",{className:"af-palette-card-port",title:Y1("input",te,ee),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Fn(te==null?void 0:te.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:rm(te,ee)})]},`in-${ee}`)),q.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",q.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((te,ee)=>i.jsxs("span",{className:"af-palette-card-port",title:Y1("output",te,ee),children:[i.jsx("span",{className:"af-palette-card-port-name",children:rm(te,ee)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Fn(te==null?void 0:te.type)}})]},`out-${ee}`)),Q.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},V.id)})})]},S):null}),K.length>0&&de.trim()&&uu.every(S=>{var P;return!((P=Qo[S])!=null&&P.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),i.jsxs("main",{className:"af-workspace-canvas",children:[i.jsx(P0,{className:"af-flow-canvas af-workspace-flow"+(Go==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(st?" af-workspace-flow--display-mode":""),nodes:Kc,edges:Rd,nodeTypes:EY,onNodesChange:Dy,onEdgesChange:wn,onConnect:st?void 0:oh,onConnectStart:st?void 0:Fd,onConnectEnd:st?void 0:ah,isValidConnection:st?void 0:Zo,onNodeClick:(S,P)=>{var V;if(st){H([sw(P.id)]);return}if((V=P==null?void 0:P.data)!=null&&V.isWorkspaceGroup){Ce("");return}if(S.detail>=3){Yo(!1),h(q=>q.map(Q=>({...Q,selected:Q.id===P.id}))),b(q=>q.map(Q=>({...Q,selected:!1}))),Ce(P.id);return}ae&&Ce(P.id)},onNodeDoubleClick:S=>{S.preventDefault()},onPaneClick:()=>{st?H([]):Ce("")},onDrop:st?void 0:$a,onDragOver:st?void 0:Ul,nodesDraggable:st?!0:Ie,nodesConnectable:st?!1:Ie,edgesReconnectable:st?!1:Ie,deleteKeyCode:st?null:Ie?["Backspace","Delete"]:null,selectionOnDrag:Go==="select",panOnDrag:Go==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(I0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!st&&I?(()=>{var te;const S=String(I.query||"").trim().toLowerCase(),P=I.mode==="create"?"create":"existing",V=Array.isArray(I.candidates)?I.candidates:[],q=Array.isArray(I.existingCandidates)?I.existingCandidates:[],Q=S?V.filter(ee=>{var me,ke,Re;return[(me=ee.def)==null?void 0:me.id,ee.displayLabel,ee.description,(ke=ee.slot)==null?void 0:ke.name,(Re=ee.slot)==null?void 0:Re.type].filter(Boolean).some(dt=>String(dt).toLowerCase().includes(S))}):V,re=S?q.filter(ee=>{var me,ke;return[ee.nodeId,ee.nodeLabel,ee.definitionId,(me=ee.slot)==null?void 0:me.name,(ke=ee.slot)==null?void 0:ke.type].filter(Boolean).some(Re=>String(Re).toLowerCase().includes(S))}):q,ie=I.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:I.left,top:I.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Fn((te=I.draft.slot)==null?void 0:te.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",I.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>z(null),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[i.jsxs("button",{type:"button",className:P==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:q.length===0,onClick:()=>z(ee=>ee&&{...ee,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:q.length})]}),i.jsxs("button",{type:"button",className:P==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:V.length===0,onClick:()=>z(ee=>ee&&{...ee,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:V.length})]})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:I.query,onChange:ee=>z(me=>me&&{...me,query:ee.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[P==="create"?Q.map(ee=>{var Re,dt;const me=ee.displayLabel||((Re=ee.def)==null?void 0:Re.id),ke=rm(ee.slot,ee.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>Jc(ee),title:ee.description||ee.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:me}),me!==ee.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:ee.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:ie}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Fn((dt=ee.slot)==null?void 0:dt.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ke})]})]},`${ee.def.id}-${ee.slotIndex}`)}):re.map(ee=>{var Re;const me=ee.nodeLabel||ee.nodeId,ke=rm(ee.slot,ee.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>ss(ee),title:`${ee.definitionId||ee.nodeId} · ${ke}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:me}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[ee.definitionId?`${ee.definitionId} · `:"",ee.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:ie}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Fn((Re=ee.slot)==null?void 0:Re.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ke}),ee.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${ee.nodeId}-${ee.handleId}`)}),(P==="create"?Q.length:re.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!st&&!Rl?i.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:i.jsxs("div",{className:"af-pipeline-composer-inner",children:[i.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Ca(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),i.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:Un.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Un.map(S=>{var Q,re;const P=String(((Q=S.data)==null?void 0:Q.label)??S.id),V=(re=S.data)!=null&&re.definitionId?String(S.data.definitionId):"",q=V&&V!==P?`${P} · ${S.id} · ${V}`:`${P} · ${S.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:q,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:V||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:P}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Dt(S.id),"aria-label":`取消选择 ${S.id}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},S.id)})}),i.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[i.jsx("div",{className:"af-composer-input-wrap",children:i.jsx("textarea",{className:"af-composer-textarea",value:co,rows:2,onChange:S=>cn(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),Di())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Ie})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Gs,type:"button",className:"af-composer-skills-button"+(ir.length>0?" af-composer-skills-button--active":""),disabled:ns||!Ie,"aria-haspopup":"listbox","aria-expanded":Pl,onClick:()=>Tc(S=>!S),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:ir.length>0?`Skills ${ir.length}`:"Skills"})]}),Pl&&!ns?$r.createPortal(i.jsx("div",{ref:kd,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:Il,children:sr.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Oi.groups.map(S=>{const P=yl(S,sr),V=_P(S,Hl,sr),q=On.has(S.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(q?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:V==="all",disabled:P.length===0,onChange:Q=>{const re=Q.target.checked;Ys(ie=>re?CP(ie,P):EP(ie,P))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:S.name}),S.builtin?i.jsx("em",{children:"built-in"}):null,V==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":q?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{ja(Q=>{const re=new Set(Q);return re.has(S.id)?re.delete(S.id):re.add(S.id),re})},children:[i.jsx("span",{children:S.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:q?"expand_more":"expand_less"})]})]}),q?null:i.jsx("div",{className:"af-composer-skill-group-items",children:S.skills.map(Q=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Hl.has(Q.key),onChange:re=>{const ie=re.target.checked;Ys(te=>ie?te.includes(Q.key)?te:[...te,Q.key]:te.filter(ee=>ee!==Q.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${S.id}:${Q.key}`))})]},S.id)}),Oi.ungrouped.length>0?i.jsxs("div",{className:"af-composer-skill-group",children:[i.jsxs("div",{className:"af-composer-skill-group-title",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("span",{children:Oi.ungrouped.length})]}),Oi.ungrouped.map(S=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Hl.has(S.key),onChange:P=>{const V=P.target.checked;Ys(q=>V?q.includes(S.key)?q:[...q,S.key]:q.filter(Q=>Q!==S.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:S.name}),S.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:S.description}):null]})]},`ungrouped:${S.key}`))]}):null]})}),document.body):null]}),i.jsx("label",{className:"af-composer-model-field",children:i.jsxs("select",{className:"af-composer-model-select",value:ts,onChange:S=>Nn(S.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),sh.map(S=>i.jsx("option",{value:S.value,children:S.label},S.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(co.trim()&&!ns?" af-composer-send--active":"")+(ns?" af-composer-send--stop":""),disabled:ns||!co.trim()||!Ie,"aria-label":ns?"Running":"Send",onClick:()=>void Di(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ns?"sync":"arrow_upward"})})]})]})]})}):st?null:i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Ca(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!st&&gr?i.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:i.jsxs("div",{className:"af-composer-sidebar",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Yo(!1),"aria-label":"关闭 AI 对话侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-composer-session-tabs",children:[i.jsx("button",{type:"button",className:"af-composer-session-tab"+(Tl==="workspace"?" af-composer-session-tab--active":""),onClick:()=>Ai("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Pi.map(S=>i.jsx("button",{type:"button",className:"af-composer-session-tab"+(Tl===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>Ai(S.id),title:S.runNodeId||S.label,children:i.jsx("span",{className:"af-composer-session-label",children:S.label})},S.id))]}),i.jsx("div",{className:"af-composer-sidebar-status"+(Zs?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:zy}),i.jsx("div",{className:"af-composer-sidebar-thread",children:i.jsx(IY,{messages:gt,running:Zs,showRunningIndicator:!is})})]})}):!st&&De&&_t?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(mR,{draft:De,setDraft:Ae,definitionId:String(((zd=_t.data)==null?void 0:zd.definitionId)||_t.id),systemPromptReadonly:String(((Qc=_t.data)==null?void 0:Qc.description)||""),modelLists:Es,disabled:!Ie,onIdBlur:()=>Vc(!0),onClose:()=>Ce(""),onPublishToMarketplace:Pd,error:mr,ioSlots:{inputs:Array.isArray(De==null?void 0:De.inputs)?De.inputs:[],outputs:Array.isArray(De==null?void 0:De.outputs)?De.outputs:[]}})}):null,i.jsx(cR,{open:Nd,onClose:()=>_s(!1)}),i.jsx(uR,{open:Ll,onClose:()=>jd(!1),onJump:Kn,nodes:er}),i.jsx(aR,{open:u,onClose:()=>d(!1),flowId:o.flowId||"",flowSource:fo,onArchived:()=>{d(!1),n("/projects?tab=archived")}}),i.jsx(lR,{open:p&&!!o.flowId,onClose:()=>c(!1),flowId:o.flowId||"",flowSource:fo,flowArchived:!!o.archived,onDeleted:async()=>{c(!1),n("/projects")}}),et?$r.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>We(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"名称"}),i.jsx("input",{type:"text",value:ut.name,onChange:S=>{const P=S.target.value;Ve(V=>({...V,name:P,id:V.id?V.id:P.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"ID"}),i.jsx("input",{type:"text",value:ut.id,onChange:S=>Ve(P=>({...P,id:S.target.value})),placeholder:"content-cleanup-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:ut.description,onChange:S=>Ve(P=>({...P,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Un.length," 个节点和 ",Nr.length," 条内部连线。"]}),Jn?i.jsx("div",{className:"af-flow-snippet-error",children:Jn}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>We(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:xt||!ut.name.trim(),onClick:()=>void Yc(),children:xt?"发布中...":"发布"})]})]})}),document.body):null,go?i.jsx(gY,{node:go,onClose:()=>_r("")}):null,fe?$r.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"发布展示页",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>je(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{type:"text",value:sn.title,onChange:S=>Rn(P=>({...P,title:S.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:sn.layout,onChange:S=>Rn(P=>({...P,layout:S.target.value})),children:[i.jsx("option",{value:"gallery",children:"Gallery"}),i.jsx("option",{value:"document",children:"Document"}),i.jsx("option",{value:"slides",children:"Slides"})]})]}),i.jsx("div",{className:"af-display-share-node-list",role:"group","aria-label":"选择展示节点",children:Ma.map(S=>{var V,q;const P=Array.isArray(sn.nodeIds)&&sn.nodeIds.includes(S.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:P,onChange:()=>bo(S.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((V=S.data)==null?void 0:V.label)||S.id}),i.jsxs("small",{children:[Pn((q=S.data)==null?void 0:q.definitionId)," · ",S.id]})]})]},S.id)})}),mt!=null&&mt.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:mt.absoluteUrl,onFocus:S=>S.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(mt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void Vl(),children:be==="copied"?"已复制":be==="failed"?"复制失败":"复制"})]}):null,at?i.jsx("div",{className:"af-flow-snippet-error",children:at}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>je(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:He||!Array.isArray(sn.nodeIds)||sn.nodeIds.length===0,onClick:()=>void Oa(),children:He?"生成中...":"生成链接"})]})]})}),document.body):null,Ln?$r.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{$e(""),zr(!1)},"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[mt!=null&&mt.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:mt.absoluteUrl,onFocus:S=>S.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(mt.absoluteUrl,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void Vl(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:be==="copied"?"check":"content_copy"}),be==="copied"?"已复制":be==="failed"?"复制失败":"复制"]})]}):i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),at?i.jsx("div",{className:"af-flow-snippet-error",children:at}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{$e(""),zr(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:He||x.nodeIds.length===0,onClick:()=>void Gc(),children:He?"生成中...":mt!=null&&mt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,ft?$r.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>St(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-display-picker-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:mn,onChange:S=>es(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":$d.length||1},children:wo.length>0?$d.map((S,P)=>i.jsx("div",{className:"af-display-picker-column",children:S.map(Wl)},`display-picker-column-${P}`)):i.jsx("div",{className:"af-display-picker-empty",children:Ir.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>St(!1),children:"完成"})})]})}),document.body):null,!st&&Hr?$r.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>hr(!1),children:i.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:S=>S.stopPropagation(),children:[i.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":kr==="nodes",className:"af-workspace-quick-add__tab"+(kr==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>hs("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":kr==="flows",className:"af-workspace-quick-add__tab"+(kr==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>hs("flows"),children:"流程"})]}),i.jsxs("div",{className:"af-workspace-quick-add__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:Al,value:Br,onChange:S=>Ei(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),hr(!1);else if(S.key==="ArrowDown"){S.preventDefault();const P=kr==="flows"?Ra.length:Li.length;Wr(V=>Math.min(Math.max(0,P-1),V+1))}else S.key==="ArrowUp"?(S.preventDefault(),Wr(P=>Math.max(0,P-1))):S.key==="Tab"?(S.preventDefault(),hs(P=>P==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),kr==="flows"?lh(Ra[Qn]||Ra[0]):gi(Li[Qn]||Li[0]))},placeholder:kr==="flows"?"搜索流程片段...":"搜索节点...","aria-label":kr==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:kr==="flows"?Ra.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:ce?"正在加载流程片段...":Se||"没有匹配的流程片段"}):Ra.map((S,P)=>{const V=S.displayName||S.name||S.id,q=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,Q=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,re=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(q||{}).length,ie=Number.isFinite(Number(S.edgeCount))?Number(S.edgeCount):Array.isArray(Q)?Q.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(P===Qn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Wr(P),onClick:()=>lh(S),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:V}),i.jsxs("span",{className:"af-workspace-quick-add__meta",children:[S.id,S.version?` · v${S.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:S.description||`${re} 节点 / ${ie} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):Li.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Li.map((S,P)=>{const V=bf(S),q=vf(S),Q=sv(S);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(P===Qn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Wr(P),onClick:()=>gi(S),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:q1(V)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:q}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:S.id}),Q?i.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:V})]},S.id)})})]})}),document.body):null]})]})}function BY(){return i.jsx(Sy,{children:i.jsx(HY,{})})}function WY(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(),o=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)||(o?r(o):""))}function VY(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function KY(e){let t=String(e||"").replace(/\r\n/g,`
216
- `).trim();return t.includes(`
217
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
218
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
219
- $2`)),t}function YR(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=KY(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const u=a.match(/^result\s*:\s*(.*)$/m);if(u){const p=String(u[1]||"").trim();return p==="|"||p===">"?a.slice((u.index||0)+u[0].length).split(`
220
- `).filter(f=>/^\s+/.test(f)||!f.trim()).map(f=>f.replace(/^\s{2}/,"")).join(`
221
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const d=t.replace(n[0],"").trim();if(d)return d}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+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 u=l.resultFile||l.result;return typeof u=="string"?u:JSON.stringify(u,null,2)}}catch{}return String(e||"")}function ak(e){let t=YR(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 o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[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((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function UY(e){const t=ak(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function qY(e){const t=ak(e);if(!t.trim())return"";const n=`<base target="_self"><script>
222
- (() => {
223
- document.addEventListener("click", (event) => {
224
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
225
- if (!link) return;
226
- const rawHref = String(link.getAttribute("href") || "").trim();
227
- if (!rawHref || rawHref.startsWith("#")) return;
228
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
229
- event.preventDefault();
230
- window.location.href = link.href;
231
- }, true);
232
- })();
233
- <\/script>`;return/<script\b[^>]*>\s*\(\(\)\s*=>\s*\{\s*document\.addEventListener\("click"/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 GR(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 YY(e,t,n={}){const r=String(e||"").trim();return r?GR(r,t,n):""}function GY({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const c=Math.max(1,p.scrollHeight),f=Math.max(1,p.clientHeight),h=c>f+1,g=h?Math.max(12,f/c*100):100,b=Math.max(0,100-g),k=h?Math.min(b,p.scrollTop/Math.max(1,c-f)*b):0;o({visible:h,top:k,height:g})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),c=n.current;if(!c||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const f=new ResizeObserver(a);f.observe(c);for(const h of Array.from(c.children))f.observe(h);return()=>{cancelAnimationFrame(p),f.disconnect()}},[t,a]);const l=m.useCallback(p=>{const c=n.current;if(!c)return;const f=Math.max(0,c.scrollHeight-c.clientHeight);c.scrollTop=Math.min(1,Math.max(0,p))*f,a()},[a]),u=m.useCallback((p,c=0)=>{const f=r.current;if(!f)return 0;const h=f.getBoundingClientRect(),g=s.height/100*h.height,b=Math.max(1,h.height-g);return(p-h.top-c)/b},[s.height]),d=m.useCallback(p=>{if(!s.visible)return;p.preventDefault(),p.stopPropagation();const c=r.current;if(!c)return;const f=c.getBoundingClientRect(),h=s.top/100*f.height,g=s.height/100*f.height,k=p.clientY>=f.top+h&&p.clientY<=f.top+h+g?p.clientY-f.top-h:g/2;l(u(p.clientY,k));const y=x=>{x.preventDefault(),l(u(x.clientY,k))},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)},[u,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[i.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function lv({node:e,shareId:t,style:n,bare:r=!1}){const s=WY(e),o=e.kind==="html"?ak(s):YR(s),a=e.kind==="html"?UY(o):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return i.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:i.jsx("div",{className:"af-public-display-node__head",children:i.jsxs("div",{className:"af-public-display-node__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:VY(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(GY,{className:l,children:a?i.jsx("div",{className:"af-public-display-empty",children:a}):o.trim()?i.jsxs(i.Fragment,{children:[e.kind==="html"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals",srcDoc:qY(o)}):null,e.kind==="image"?i.jsx("img",{src:GR(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(nk,{content:o,resolveSrc:(u,d)=>YY(u,t,d)})}):null,e.kind==="chart"?i.jsx(sk,{content:o}):null,e.kind==="table"?i.jsx(rk,{content:o}):null,e.kind==="mermaid"||e.kind==="ascii"?i.jsx("pre",{children:o}):null]}):i.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function XY({data:e}){return i.jsx(lv,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const JY={publicDisplay:XY};function QY(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 XR(){var l,u,d,p;const{path:e}=Bo(),t=m.useMemo(()=>QY(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let c=!1;async function f(){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||"展示页不存在");c||r({loading:!1,error:"",share:g.share||null,nodes:Array.isArray(g.nodes)?g.nodes:[]})}catch(h){c||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return f(),()=>{c=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((f,h)=>{const g=f.position&&typeof f.position.x=="number"&&typeof f.position.y=="number"?f.position:{x:120+h*40,y:100+h*32},b=f.size&&typeof f.size.width=="number"&&typeof f.size.height=="number"?f.size:{width:520,height:320};return{id:f.id,type:"publicDisplay",position:g,data:{node:f,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]),o=m.useMemo(()=>{var b;const c=(b=n.share)==null?void 0:b.viewport;if(!c||typeof c!="object")return null;const f=Number(c.x),h=Number(c.y),g=Number(c.zoom);return!Number.isFinite(f)||!Number.isFinite(h)||!Number.isFinite(g)?null:{x:f,y:h,zoom:Math.min(Math.max(g,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return i.jsx("main",{className:"af-public-display-page",children:i.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return i.jsx("main",{className:"af-public-display-page",children:i.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),i.jsx("span",{children:n.error})]})});const a=String(((u=n.share)==null?void 0:u.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return i.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(f=>i.jsx(lv,{node:f,shareId:t,bare:!0},f.id))})});const c=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return i.jsxs("main",{className:`af-public-display-page ${c}`,children:[i.jsxs("header",{className:"af-public-display-hero",children:[i.jsxs("div",{children:[i.jsx("p",{children:"AgentFlow Display"}),i.jsx("h1",{children:((d=n.share)==null?void 0:d.title)||"AgentFlow Display"})]}),(p=n.share)!=null&&p.expiresAt?i.jsxs("span",{children:["有效期至 ",new Date(n.share.expiresAt).toLocaleString()]}):null]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(f=>i.jsx(lv,{node:f,shareId:t},f.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(Sy,{children:i.jsx(P0,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:JY,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:i.jsx(I0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const At=e=>typeof e=="string",lf=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},rC=e=>e==null?"":""+e,ZY=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},eG=/###/g,sC=e=>e&&e.indexOf("###")>-1?e.replace(eG,"."):e,iC=e=>!e||At(e),Bf=(e,t,n)=>{const r=At(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(iC(e))return{};const o=sC(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return iC(e)?{}:{obj:e,k:sC(r[s])}},oC=(e,t,n)=>{const{obj:r,k:s}=Bf(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let o=t[t.length-1],a=t.slice(0,t.length-1),l=Bf(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Bf(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},tG=(e,t,n,r)=>{const{obj:s,k:o}=Bf(e,t,Object);s[o]=s[o]||[],s[o].push(n)},Fg=(e,t)=>{const{obj:n,k:r}=Bf(e,t);if(n)return n[r]},nG=(e,t,n)=>{const r=Fg(e,n);return r!==void 0?r:Fg(t,n)},JR=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?At(e[r])||e[r]instanceof String||At(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):JR(e[r],t[r],n):e[r]=t[r]);return e},au=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var rG={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const sG=e=>At(e)?e.replace(/[&<>"'\/]/g,t=>rG[t]):e;class iG{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 oG=[" ",",","?","!",";"],aG=new iG(20),lG=(e,t,n)=>{t=t||"",n=n||"";const r=oG.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=aG.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!s.test(e);if(!o){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(o=!0)}return o},cv=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 o=0;o<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let u=o;u<r.length;++u)if(u!==o&&(l+=n),l+=r[u],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&u<r.length-1)continue;o+=u-o+1;break}s=a}return s},zg=e=>e&&e.replace("_","-"),cG={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 Hg{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||cG,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:(At(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Hg(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Hg(this.logger,t)}}var Ro=new Hg;class Ay{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,u]=a;for(let d=0;d<u;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l.apply(l,[t,...r])})}}class aC extends Ay{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 o=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):At(r)&&o?l.push(...r.split(o)):l.push(r)));const u=Fg(this.data,l);return!u&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),u||!a||!At(r)?u:cv(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,s){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.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),oC(this.data,l,s),o.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 o in r)(At(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,o){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 u=Fg(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?JR(u,r,o):u={...u,...r},oC(this.data,l,u),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 QR={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,s))}),t}};const lC={};class Bg extends Ay{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),ZY(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ro.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 o=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!lG(t,r,s);if(a&&!l){const u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:At(o)?[o]:o};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(o=d.shift()),t=d.join(s)}return{key:t,namespaces:At(o)?[o]:o}}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,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),u=l[l.length-1],d=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(p){const N=n.nsSeparator||this.options.nsSeparator;return s?{res:`${u}${N}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:`${u}${N}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:a}const c=this.resolve(t,n);let f=c&&c.res;const h=c&&c.usedKey||a,g=c&&c.exactUsedKey||a,b=Object.prototype.toString.apply(f),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!At(f)&&typeof f!="boolean"&&typeof f!="number";if(w&&f&&x&&k.indexOf(b)<0&&!(At(y)&&Array.isArray(f))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const N=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,f,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(c.res=N,c.usedParams=this.getUsedParamsDetails(n),c):N}if(o){const N=Array.isArray(f),_=N?[]:{},C=N?g:h;for(const T in f)if(Object.prototype.hasOwnProperty.call(f,T)){const F=`${C}${o}${T}`;_[T]=this.translate(F,{...n,joinArrays:!1,ns:l}),_[T]===F&&(_[T]=f[T])}f=_}}else if(w&&At(y)&&Array.isArray(f))f=f.join(y),f&&(f=this.extendTranslation(f,t,n,r));else{let N=!1,_=!1;const C=n.count!==void 0&&!At(n.count),T=Bg.hasDefaultValue(n),F=C?this.pluralResolver.getSuffix(d,n.count,n):"",R=n.ordinal&&C?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",H=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),D=H&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${F}`]||n[`defaultValue${R}`]||n.defaultValue;!this.isValidLookup(f)&&T&&(N=!0,f=D),this.isValidLookup(f)||(_=!0,f=a);const B=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:f,L=T&&D!==f&&this.options.updateMissing;if(_||N||L){if(this.logger.log(L?"updateKey":"missingKey",d,u,a,L?D:f),o){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 M=[];const I=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&I&&I[0])for(let A=0;A<I.length;A++)M.push(I[A]);else this.options.saveMissingTo==="all"?M=this.languageUtils.toResolveHierarchy(n.lng||this.language):M.push(n.lng||this.language);const z=(A,O,E)=>{const J=T&&E!==f?E:B;this.options.missingKeyHandler?this.options.missingKeyHandler(A,u,O,J,L,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(A,u,O,J,L,n),this.emit("missingKey",A,u,O,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?M.forEach(A=>{const O=this.pluralResolver.getSuffixes(A,n);H&&n[`defaultValue${this.options.pluralSeparator}zero`]&&O.indexOf(`${this.options.pluralSeparator}zero`)<0&&O.push(`${this.options.pluralSeparator}zero`),O.forEach(E=>{z([A],a+E,n[`defaultValue${E}`]||D)})}):z(M,a,D))}f=this.extendTranslation(f,t,n,c,r),_&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${u}:${a}`),(_||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}:${a}`:a,N?f:void 0):f=this.options.parseMissingKeyHandler(f))}return s?(c.res=f,c.usedParams=this.getUsedParamsDetails(n),c):f}extendTranslation(t,n,r,s,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=At(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(d){const f=t.match(this.interpolator.nestingRegexp);p=f&&f.length}let c=r.replace&&!At(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||s.usedLng,r),d){const f=t.match(this.interpolator.nestingRegexp),h=f&&f.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 f=arguments.length,h=new Array(f),g=0;g<f;g++)h[g]=arguments[g];return o&&o[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,u=At(l)?[l]:l;return t!=null&&u&&u.length&&r.applyPostProcessor!==!1&&(t=QR.handle(u,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,o,a,l;return At(t)&&(t=[t]),t.forEach(u=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(u,n),p=d.key;s=p;let c=d.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const f=n.count!==void 0&&!At(n.count),h=f&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(At(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(k=>{this.isValidLookup(r)||(l=k,!lC[`${b[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(lC[`${b[0]}-${k}`]=!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,k,n);else{let N;f&&(N=this.pluralResolver.getSuffix(y,n.count,n));const _=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(w.push(p+N),n.ordinal&&N.indexOf(C)===0&&w.push(p+N.replace(C,this.options.pluralSeparator)),h&&w.push(p+_)),g){const T=`${p}${this.options.contextSeparator}${n.context}`;w.push(T),f&&(w.push(T+N),n.ordinal&&N.indexOf(C)===0&&w.push(T+N.replace(C,this.options.pluralSeparator)),h&&w.push(T+_))}}let x;for(;x=w.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(y,k,x,n))}))})}),{res:r,usedKey:s,exactUsedKey:o,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&&!At(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 o of n)delete s[o]}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 ow=e=>e.charAt(0).toUpperCase()+e.slice(1);class cC{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ro.create("languageUtils")}getScriptPartFromCode(t){if(t=zg(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=zg(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(At(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]=ow(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]=ow(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=ow(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(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),At(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=[],o=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return At(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):At(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let uG=[{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}],dG={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 fG=["v1","v2","v3"],pG=["v4"],uC={zero:0,one:1,two:2,few:3,many:4,other:5},hG=()=>{const e={};return uG.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:dG[t.fc]}})}),e};class mG{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Ro.create("pluralResolver"),(!this.options.compatibilityJSON||pG.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=hG(),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=zg(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:s});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const u=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(u,n)}return this.pluralRulesCache[o]=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,o)=>uC[s]-uC[o]).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 o=()=>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()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!fG.includes(this.options.compatibilityJSON)}}const dC=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,o=nG(e,t,n);return!o&&s&&At(n)&&(o=cv(e,n,r),o===void 0&&(o=cv(t,n,r))),o},aw=e=>e.replace(/\$/g,"$$$$");class gG{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ro.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:o,prefixEscaped:a,suffix:l,suffixEscaped:u,formatSeparator:d,unescapeSuffix:p,unescapePrefix:c,nestingPrefix:f,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:sG,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?au(o):a||"{{",this.suffix=l?au(l):u||"}}",this.formatSeparator=d||",",this.unescapePrefix=p?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=f?au(f):h||au("$t("),this.nestingSuffix=g?au(g):b||au(")"),this.nestingOptionsSeparator=k||",",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 o,a,l;const u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const y=dC(n,u,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(),k=g.join(this.formatSeparator).trim();return this.format(dC(n,u,b,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const p=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,c=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>aw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?aw(this.escape(h)):aw(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const g=o[1].trim();if(a=d(g),a===void 0)if(typeof p=="function"){const k=p(t,o,s);a=At(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(c){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!At(a)&&!this.useRawValueToEscape&&(a=rC(a));const b=h.safeValue(a);if(t=t.replace(o[0],b),c?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[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,o,a;const l=(u,d)=>{const p=this.nestingOptionsSeparator;if(u.indexOf(p)<0)return u;const c=u.split(new RegExp(`${p}[ ]*{`));let f=`{${c[1]}`;u=c[0],f=this.interpolate(f,a);const h=f.match(/'/g),g=f.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(f=f.replace(/'/g,'"'));try{a=JSON.parse(f),d&&(a={...d,...a})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,b),`${u}${p}${f}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,u};for(;s=this.nestingRegexp.exec(t);){let u=[];a={...r},a=a.replace&&!At(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const p=s[1].split(this.formatSeparator).map(c=>c.trim());s[1]=p.shift(),u=p,d=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!At(o))return o;At(o)||(o=rC(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),d&&(o=u.reduce((p,c)=>this.format(p,c,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const yG=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,...u]=a.split(":"),d=u.join(":").trim().replace(/^'+|'+$/g,""),p=l.trim();n[p]||(n[p]=d),d==="false"&&(n[p]=!1),d==="true"&&(n[p]=!0),isNaN(d)||(n[p]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},lu=e=>{const t={};return(n,r,s)=>{let o=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(o={...o,[s.interpolationkey]:void 0});const a=r+JSON.stringify(o);let l=t[a];return l||(l=e(zg(r),s),t[a]=l),l(n)}};class xG{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ro.create("formatter"),this.options=t,this.formats={number:lu((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:lu((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:lu((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:lu((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:lu((n,r)=>{const s=new Intl.ListFormat(n,{...r});return o=>s.format(o)})},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()]=lu(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(u=>u.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,u)=>{const{formatName:d,formatOptions:p}=yG(u);if(this.formats[d]){let c=l;try{const f=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=f.locale||f.lng||s.locale||s.lng||r;c=this.formats[d](l,h,{...p,...s,...f})}catch(f){this.logger.warn(f)}return c}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const wG=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class bG extends Ay{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=Ro.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 o={},a={},l={},u={};return t.forEach(d=>{let p=!0;n.forEach(c=>{const f=`${d}|${c}`;!r.reload&&this.store.hasResourceBundle(d,c)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?a[f]===void 0&&(a[f]=!0):(this.state[f]=1,p=!1,a[f]===void 0&&(a[f]=!0),o[f]===void 0&&(o[f]=!0),u[c]===void 0&&(u[c]=!0)))}),p||(l[d]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(u)}}loaded(t,n,r){const s=t.split("|"),o=s[0],a=s[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,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(u=>{tG(u.loaded,[o],a),wG(u,t),n&&u.errors.push(n),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(d=>{l[d]||(l[d]={});const p=u.loaded[d];p.length&&p.forEach(c=>{l[d][c]===void 0&&(l[d][c]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(u=>!u.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=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:o,callback:a});return}this.readingCalls++;const l=(d,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const c=this.waitingReads.shift();this.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}if(d&&p&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(d,p)},u=this.backend[r].bind(this.backend);if(u.length===2){try{const d=u(t,n);d&&typeof d.then=="function"?d.then(p=>l(null,p)).catch(l):l(null,d)}catch(d){l(d)}return}return u(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();At(t)&&(t=this.languageUtils.toResolveHierarchy(t)),At(n)&&(n=[n]);const o=this.queueLoad(t,n,r,s);if(!o.toLoad.length)return o.pending.length||s(),null;o.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],o=r[1];this.read(s,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,o){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 u={...a,isUpdate:o},d=this.backend.create.bind(this.backend);if(d.length<6)try{let p;d.length===5?p=d(t,n,r,s,u):p=d(t,n,r,s),p&&typeof p.then=="function"?p.then(c=>l(null,c)).catch(l):l(null,p)}catch(p){l(p)}else d(t,n,r,s,l,u)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const fC=()=>({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]),At(e[1])&&(t.defaultValue=e[1]),At(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}}),pC=e=>(At(e.ns)&&(e.ns=[e.ns]),At(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),At(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),am=()=>{},vG=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Sp extends Ay{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=pC(t),this.services={},this.logger=Ro,this.modules={external:[]},vG(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&&(At(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=fC();this.options={...s,...this.options,...pC(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 o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Ro.init(o(this.modules.logger),this.options):Ro.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:typeof Intl<"u"&&(p=xG);const c=new cC(this.options);this.store=new aC(this.options.resources,this.options);const f=this.services;f.logger=Ro,f.resourceStore=this.store,f.languageUtils=c,f.pluralResolver=new mG(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(f.formatter=o(p),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new gG(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new bG(o(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),k=1;k<g;k++)b[k-1]=arguments[k];t.emit(h,...b)}),this.modules.languageDetector&&(f.languageDetector=o(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=o(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Bg(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),k=1;k<g;k++)b[k-1]=arguments[k];t.emit(h,...b)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=am),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 u=lf(),d=()=>{const p=(c,f)=>{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),u.resolve(f),r(c,f)};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?d():setTimeout(d,0),u}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:am;const s=At(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 o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&o.indexOf(d)<0&&o.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>a(u)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=lf();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=am),this.services.backendConnector.reload(t,n,o=>{s.resolve(),r(o)}),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"&&QR.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=lf();this.emit("languageChanging",t);const o=u=>{this.language=u,this.languages=this.services.languageUtils.toResolveHierarchy(u),this.resolvedLanguage=void 0,this.setResolvedLanguage(u)},a=(u,d)=>{d?(o(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(u,function(){return r.t(...arguments)})},l=u=>{!t&&!u&&this.services.languageDetector&&(u=[]);const d=At(u)?u:this.services.languageUtils.getBestMatchFromCodes(u);d&&(this.language||o(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,p=>{a(p,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let u;if(typeof l!="object"){for(var d=arguments.length,p=new Array(d>2?d-2:0),c=2;c<d;c++)p[c-2]=arguments[c];u=s.options.overloadTranslationOptionHandler([a,l].concat(p))}else u={...l};u.lng=u.lng||o.lng,u.lngs=u.lngs||o.lngs,u.ns=u.ns||o.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||o.keyPrefix);const f=s.options.keySeparator||".";let h;return u.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${u.keyPrefix}${f}${g}`):h=u.keyPrefix?`${u.keyPrefix}${f}${a}`:a,s.t(h,u)};return At(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}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,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=this.services.backendConnector.state[`${l}|${u}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(o,t)))}loadNamespaces(t,n){const r=lf();return this.options.ns?(At(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=lf();At(t)&&(t=[t]);const s=this.options.preload||[],o=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=s.concat(o),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 cC(fC());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 Sp(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:am;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new Sp(s);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(l=>{o[l]=this[l]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new aC(this.store.data,s),o.services.resourceStore=o.store),o.translator=new Bg(o.services,s),o.translator.on("*",function(l){for(var u=arguments.length,d=new Array(u>1?u-1:0),p=1;p<u;p++)d[p-1]=arguments[p];o.emit(l,...d)}),o.init(s,n),o.translator.options=s,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Zr=Sp.createInstance();Zr.createInstance=Sp.createInstance;Zr.createInstance;Zr.dir;Zr.init;Zr.loadResources;Zr.reloadResources;Zr.use;Zr.changeLanguage;Zr.getFixedT;Zr.t;Zr.exists;Zr.setDefaultNamespace;Zr.hasLoadedNamespace;Zr.loadNamespaces;Zr.loadLanguages;function kG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Np(e){"@babel/helpers - typeof";return Np=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},Np(e)}function SG(e,t){if(Np(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Np(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function NG(e){var t=SG(e,"string");return Np(t)=="symbol"?t:t+""}function jG(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,NG(r.key),r)}}function CG(e,t,n){return t&&jG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var ZR=[],EG=ZR.forEach,_G=ZR.slice;function PG(e){return EG.call(_G.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var hC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,AG=function(t,n,r){var s=r||{};s.path=s.path||"/";var o=encodeURIComponent(n),a="".concat(t,"=").concat(o);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(!hC.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!hC.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 u=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(u){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},mC={create:function(t,n,r,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),s&&(o.domain=s),document.cookie=AG(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var o=r[s];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},IG={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=mC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&mC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},TG={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),o=s.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var u=o[a].substring(0,l);u===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},cf=null,gC=function(){if(cf!==null)return cf;try{cf=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{cf=!1}return cf},RG={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&gC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&gC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},uf=null,yC=function(){if(uf!==null)return uf;try{uf=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{uf=!1}return uf},MG={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&yC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&yC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},LG={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}},OG={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}},$G={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}},DG={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]}},e2=!1;try{document.cookie,e2=!0}catch{}var t2=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];e2||t2.splice(1,1);function FG(){return{order:t2,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var n2=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};kG(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return CG(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=PG(r,this.options||{},FG()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(IG),this.addDetector(TG),this.addDetector(RG),this.addDetector(MG),this.addDetector(LG),this.addDetector(OG),this.addDetector($G),this.addDetector(DG)}},{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(o){if(r.detectors[o]){var a=r.detectors[o].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(o){return r.options.convertDetectedLanguage(o)}),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(o){s.detectors[o]&&s.detectors[o].cacheUserLanguage(n,s.options)}))}}])}();n2.type="languageDetector";const zG={name:"AgentFlow",tagline:"AI Workflow Orchestration"},HG={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},BG={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"},WG={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},VG={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},KG={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},UG={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},qG={app:zG,nav:HG,common:BG,status:WG,nodeTypes:VG,engine:KG,links:UG},YG="Flow Editor",GG="Nodes",XG="Edges",JG="Properties",QG={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"},ZG={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}}"},eX={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},tX={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},nX={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"},rX={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)"},sX={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},iX={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},oX={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},aX={node:"Node",text:"Text",file:"File",bool:"Boolean"},lX={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"},cX={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"},uX={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},dX={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."},fX={mainNav:"Main Navigation"},pX={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'},hX={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):
234
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
235
- 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}}"},mX={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"},gX={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},yX={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}}"},xX={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"},wX={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"},bX={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"},vX={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"},kX={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"},SX={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},NX={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},jX={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"},CX={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."},EX={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},_X={save:"Save",cancel:"Cancel"},PX={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},AX={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},IX={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"},TX={title:YG,nodes:GG,edges:XG,properties:JG,node:QG,nodeProps:ZG,actions:eX,panel:tX,palette:nX,pipeline:rX,status:sX,roles:iX,phases:oX,types:aX,runContext:lX,shortcuts:cX,jumpPalette:uX,emptyCanvas:dX,sidebar:fX,validation:pX,composer:hX,topbar:mX,palette2:gX,run:yX,fileEdit:xX,settings:wX,schedule:bX,history:vX,nodePropsError:kX,placeholder:SX,time:NX,userCheck:jX,userAsk:CX,toolPrint:EX,provideEdit:_X,runParams:PX,runPreset:AX,runConfig:IX},RX="Settings",MX={engine:"Engine Settings",preferences:"Global Preferences"},LX={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)."},OX={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..."}},$X={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."},DX={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."},FX={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)"},zX={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"},HX={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},BX={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},WX={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},VX={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."},KX={title:RX,crumb:MX,workspace:LX,cursor:OX,opencode:$X,claudeCode:DX,env:FX,allowlist:zX,system:HX,shortcuts:BX,language:WX,onboarding:VX},UX={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},qX={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)"},YX={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},GX={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},XX={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},JX={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},QX={aiLabels:UX,placeholders:qX,actions:YX,labels:GX,tooltips:XX,rightPanel:JX},ZX="Projects",eJ="All",tJ="Archived",nJ="Nodes",rJ="My Nodes",sJ="My Flows",iJ="Skills",oJ="Active Projects",aJ="Archived Pipelines",lJ="Global Nodes",cJ="Manage node versions published to the current workspace marketplace, {{count}} total.",uJ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",dJ="Global Skills",fJ="Create New Project",pJ="New Pipeline",hJ="SEARCH PIPELINES...",mJ="SEARCH NODES...",gJ="SEARCH FLOW SNIPPETS...",yJ="SEARCH SKILLS...",xJ="Refresh Resources",wJ="Loading pipelines...",bJ="Loading global resources...",vJ="Filter result: {{count}} items (matching title, description, path and tags)",kJ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",SJ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",NJ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",jJ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",CJ="Executable building blocks for pipeline runtime",EJ="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.",_J="Published local node packages",PJ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",AJ="Published flow snippets",IJ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",TJ="Operating guides for Composer and agents",RJ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",MJ="No archived projects.",LJ="No active pipelines; archived items are in the Archived tab.",OJ="No global nodes available.",$J="No marketplace nodes have been published.",DJ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",FJ="No skills available.",zJ="No description.",HJ='No node matches "{{query}}".',BJ='No flow snippet matches "{{query}}".',WJ='No skill matches "{{query}}".',VJ="{{inputs}} in / {{outputs}} out",KJ="Flow Snippet",UJ="{{nodes}} nodes / {{edges}} edges",qJ="Skill",YJ="Node detail",GJ="Flow snippet detail",XJ="Skill detail",JJ="Type",QJ="Source",ZJ="Package",eQ="Version",tQ="Path",nQ="Editable",rQ="Read only",sQ="Editable",iQ="Schema",oQ="Inputs",aQ="Outputs",lQ="Runtime",cQ="Node Body",uQ="Files",dQ="Usage",fQ="No runtime manifest.",pQ="No node body or README.",hQ="No previewable files.",mQ="Select a file to preview.",gQ="Binary file preview is not supported.",yQ="Large file; showing the first 256KB only.",xQ="No pipelines using this node were found.",wQ="Node Management",bQ="Delete Node Version",vQ="Deleting...",kQ="AgentFlow checks all flow references before deleting; installed or used versions are kept.",SQ="Delete {{id}}@{{version}}? This cannot be undone.",NQ="Deleted {{id}}@{{version}}.",jQ="{{count}} flow(s) still use it.",CQ="Flow Snippet Management",EQ="Delete Flow Snippet",_Q="Deleting...",PQ="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",AQ="Delete {{id}}@{{version}}? This cannot be undone.",IQ="Deleted {{id}}@{{version}}.",TQ="No slots",RQ="Purpose",MQ="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",LQ="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.",OQ="Scale",$Q="Flow Preview",DQ="Edges",FQ="Snippet JSON",zQ="{{count}} more edge(s)",HQ="No previewable nodes.",BQ="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",WQ="SKILL.md Preview",VQ="No preview content available.",KQ="Select a resource to inspect details.",UQ="Failed to load pipeline list.",qQ="No pipelines in current workspace.",YQ="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.",GQ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',XQ="Recent Activity",JQ="No recent activity",QQ="No recent activity matching the keyword",ZQ="Recent Run",eZ="Recent Open",tZ={builtin:"Built-in",workspace:"Workspace",user:"User"},nZ={flow:"Flow",global:"Global",marketplace:"Marketplace"},rZ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},sZ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},iZ="Open to edit this pipeline in the node canvas.",oZ={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>"},aZ={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"},lZ={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"},cZ={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"},uZ={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"},dZ={title:ZX,all:eJ,archived:tJ,nodes:nJ,myNodes:rJ,myFlows:sJ,skills:iJ,activeProjects:oJ,archivedPipelines:aJ,globalNodes:lJ,myNodesHint:cJ,myFlowsHint:uJ,globalSkills:dJ,createNew:fJ,newPipeline:pJ,searchPipelines:hJ,searchNodes:mJ,searchFlows:gJ,searchSkills:yJ,refreshResources:xJ,loadingPipelines:wJ,loadingResources:bJ,filterResult:vJ,archivedHint:kJ,activeHint:SJ,nodesHint:NJ,skillsHint:jJ,nodesPurposeTitle:CJ,nodesPurposeDesc:EJ,myNodesPurposeTitle:_J,myNodesPurposeDesc:PJ,myFlowsPurposeTitle:AJ,myFlowsPurposeDesc:IJ,skillsPurposeTitle:TJ,skillsPurposeDesc:RJ,noArchived:MJ,noActive:LJ,noNodes:OJ,noMyNodes:$J,noMyFlows:DJ,noSkills:FJ,noDescription:zJ,noNodeMatch:HJ,noFlowSnippetMatch:BJ,noSkillMatch:WJ,nodeSlots:VJ,flowSnippet:KJ,flowSnippetNodes:UJ,skill:qJ,nodeDetail:YJ,flowDetail:GJ,skillDetail:XJ,detailType:JJ,detailSource:QJ,detailPackage:ZJ,detailVersion:eQ,detailPath:tQ,detailEditable:nQ,readOnly:rQ,editable:sQ,nodeSchema:iQ,nodeInputs:oQ,nodeOutputs:aQ,nodeRuntime:lQ,nodeBody:cQ,nodeFiles:uQ,nodeUsage:dQ,noRuntimeManifest:fQ,noNodeBody:pQ,noNodeFiles:hQ,selectNodeFile:mQ,binaryFile:gQ,fileTruncated:yQ,noNodeUsage:xQ,myNodeManagement:wQ,deleteMyNode:bQ,deletingMyNode:vQ,deleteMyNodeHint:kQ,deleteMyNodeConfirm:SQ,deleteMyNodeSuccess:NQ,deleteMyNodeUsedBy:jQ,myFlowManagement:CQ,deleteMyFlow:EQ,deletingMyFlow:_Q,deleteMyFlowHint:PQ,deleteMyFlowConfirm:AQ,deleteMyFlowSuccess:IQ,noSlots:TQ,resourceMeaning:RQ,nodesMeaning:MQ,myFlowsMeaning:LQ,flowSnippetScale:OQ,flowSnippetPreview:$Q,flowSnippetEdges:DQ,flowSnippetJson:FQ,flowSnippetMoreEdges:zQ,noFlowSnippetPreview:HQ,skillsMeaning:BQ,skillPreview:WQ,skillPreviewEmpty:VQ,selectResource:KQ,loadFailed:UQ,noPipelines:qQ,emptyHint:YQ,noMatch:GQ,recentActivity:XQ,noRecentActivity:JQ,noMatchRecent:QQ,recentRun:ZQ,recentOpen:eZ,sourceBadge:tZ,resourceSource:nZ,resourceFilter:rZ,nodeDetailTabs:sZ,defaultCardDesc:iZ,hubCard:oZ,newPipelineModal:aZ,importModal:lZ,deleteModal:cZ,archiveModal:uZ},fZ="Back",pZ="Next",hZ="Skip",mZ="Done",gZ="Start Creating",yZ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
236
-
237
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
238
-
239
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},xZ={intro:`Now you're in the flow editor.
240
-
241
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
242
-
243
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
244
-
245
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
246
-
247
- The left node panel allows you to freely drag, delete, and adjust connections.`},wZ={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"},bZ={back:fZ,next:pZ,skip:hZ,done:mZ,startCreate:gZ,projects:yZ,flow:xZ,newPipeline:wZ},vZ={name:"AgentFlow",tagline:"AI 工作流编排"},kZ={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},SZ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},NZ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},jZ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},CZ={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},EZ={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},_Z={app:vZ,nav:kZ,common:SZ,status:NZ,nodeTypes:jZ,engine:CZ,links:EZ},PZ="流程编辑器",AZ="节点",IZ="连线",TZ="属性",RZ={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:"编辑内容"},MZ={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}}"},LZ={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},OZ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},$Z={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},DZ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},FZ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},zZ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},HZ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},BZ={node:"节点",text:"文本",file:"文件",bool:"布尔"},WZ={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:"等待"},VZ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},KZ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},UZ={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},qZ={mainNav:"主导航"},YZ={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},GZ={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}} 步):
248
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
249
- 当前:{{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}}"},XZ={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},JZ={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},QZ={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}} 的分支"},ZZ={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},eee={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:"已复制"},tee={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:"定时配置已保存"},nee={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},ree={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},see={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},iee={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},oee={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},aee={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},lee={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},cee={save:"保存",cancel:"取消"},uee={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},dee={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},fee={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},pee={title:PZ,nodes:AZ,edges:IZ,properties:TZ,node:RZ,nodeProps:MZ,actions:LZ,panel:OZ,palette:$Z,pipeline:DZ,status:FZ,roles:zZ,phases:HZ,types:BZ,runContext:WZ,shortcuts:VZ,jumpPalette:KZ,emptyCanvas:UZ,sidebar:qZ,validation:YZ,composer:GZ,topbar:XZ,palette2:JZ,run:QZ,fileEdit:ZZ,settings:eee,schedule:tee,history:nee,nodePropsError:ree,placeholder:see,time:iee,userCheck:oee,userAsk:aee,toolPrint:lee,provideEdit:cee,runParams:uee,runPreset:dee,runConfig:fee},hee="设置",mee={engine:"引擎设置",preferences:"全局首选项"},gee={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},yee={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},xee={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},wee={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},bee={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},vee={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:"添加"},kee={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},See={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},Nee={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},jee={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},Cee={title:hee,crumb:mee,workspace:gee,cursor:yee,opencode:xee,claudeCode:wee,env:bee,allowlist:vee,system:kee,shortcuts:See,language:Nee,onboarding:jee},Eee={thinking:"思考",result:"结果",reply:"回复",error:"错误"},_ee={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},Pee={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},Aee={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Iee={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},Tee={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Ree={aiLabels:Eee,placeholders:_ee,actions:Pee,labels:Aee,tooltips:Iee,rightPanel:Tee},Mee="项目",Lee="全部",Oee="已归档",$ee="Nodes",Dee="我的 Nodes",Fee="我的流程",zee="Skills",Hee="活跃项目",Bee="已归档流水线",Wee="全局 Nodes",Vee="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Kee="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Uee="全局 Skills",qee="创建新项目",Yee="新建流水线",Gee="搜索流水线…",Xee="搜索 nodes…",Jee="搜索流程片段…",Qee="搜索 skills…",Zee="刷新资源",ete="加载流水线列表…",tte="加载全局资源…",nte="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",rte="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",ste="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",ite="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",ote="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",ate="流程运行时的可执行积木",lte="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",cte="已发布的本地节点包",ute="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",dte="已发布的流程片段",fte="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",pte="Composer/Agent 的操作指南",hte="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",mte="暂无归档项目。",gte="暂无未归档流水线;已归档项在 Archived 标签中查看。",yte="暂无可用全局 nodes。",xte="暂无已发布的 marketplace nodes。",wte="暂无已发布的流程片段。可在画布中选中多个节点后发布。",bte="暂无可用 skills。",vte="暂无描述。",kte="未找到与「{{query}}」匹配的 node。",Ste="未找到与「{{query}}」匹配的流程片段。",Nte="未找到与「{{query}}」匹配的 skill。",jte="{{inputs}} in / {{outputs}} out",Cte="流程片段",Ete="{{nodes}} 节点 / {{edges}} 连线",_te="Skill",Pte="Node 详情",Ate="流程片段详情",Ite="Skill 详情",Tte="类型",Rte="来源",Mte="包",Lte="版本",Ote="路径",$te="可编辑",Dte="只读",Fte="可编辑",zte="Schema",Hte="输入",Bte="输出",Wte="Runtime",Vte="节点内容",Kte="Files",Ute="Usage",qte="暂无 runtime manifest。",Yte="暂无节点正文或 README。",Gte="暂无可预览文件。",Xte="请选择文件查看内容。",Jte="二进制文件暂不支持预览。",Qte="文件较大,仅显示前 256KB。",Zte="暂未发现使用此 node 的流水线。",ene="节点管理",tne="删除节点版本",nne="删除中…",rne="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",sne="确定删除 {{id}}@{{version}}?此操作不可撤销。",ine="已删除 {{id}}@{{version}}。",one="仍有 {{count}} 个 Flow 使用它。",ane="流程片段管理",lne="删除流程片段",cne="删除中…",une="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",dne="确定删除 {{id}}@{{version}}?此操作不可撤销。",fne="已删除 {{id}}@{{version}}。",pne="无槽位",hne="作用",mne="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",gne="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",yne="规模",xne="流程预览",wne="连线",bne="片段 JSON",vne="还有 {{count}} 条连线",kne="暂无可预览节点。",Sne="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Nne="SKILL.md 预览",jne="暂无可预览内容。",Cne="请选择一个资源查看详情。",Ene="未能加载流水线列表。",_ne="当前工作区暂无流水线。",Pne="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Ane="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Ine="最近打开或最近运行",Tne="暂无打开或运行记录",Rne="暂无与关键词匹配的最近记录",Mne="最近运行",Lne="最近打开",One={builtin:"内置",workspace:"工作区",user:"用户"},$ne={flow:"Flow",global:"Global",marketplace:"Marketplace"},Dne={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Fne={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},zne="打开以在节点画布中编辑此流水线。",Hne={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Bne={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:"关闭"},Wne={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Vne={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Kne={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Une={title:Mee,all:Lee,archived:Oee,nodes:$ee,myNodes:Dee,myFlows:Fee,skills:zee,activeProjects:Hee,archivedPipelines:Bee,globalNodes:Wee,myNodesHint:Vee,myFlowsHint:Kee,globalSkills:Uee,createNew:qee,newPipeline:Yee,searchPipelines:Gee,searchNodes:Xee,searchFlows:Jee,searchSkills:Qee,refreshResources:Zee,loadingPipelines:ete,loadingResources:tte,filterResult:nte,archivedHint:rte,activeHint:ste,nodesHint:ite,skillsHint:ote,nodesPurposeTitle:ate,nodesPurposeDesc:lte,myNodesPurposeTitle:cte,myNodesPurposeDesc:ute,myFlowsPurposeTitle:dte,myFlowsPurposeDesc:fte,skillsPurposeTitle:pte,skillsPurposeDesc:hte,noArchived:mte,noActive:gte,noNodes:yte,noMyNodes:xte,noMyFlows:wte,noSkills:bte,noDescription:vte,noNodeMatch:kte,noFlowSnippetMatch:Ste,noSkillMatch:Nte,nodeSlots:jte,flowSnippet:Cte,flowSnippetNodes:Ete,skill:_te,nodeDetail:Pte,flowDetail:Ate,skillDetail:Ite,detailType:Tte,detailSource:Rte,detailPackage:Mte,detailVersion:Lte,detailPath:Ote,detailEditable:$te,readOnly:Dte,editable:Fte,nodeSchema:zte,nodeInputs:Hte,nodeOutputs:Bte,nodeRuntime:Wte,nodeBody:Vte,nodeFiles:Kte,nodeUsage:Ute,noRuntimeManifest:qte,noNodeBody:Yte,noNodeFiles:Gte,selectNodeFile:Xte,binaryFile:Jte,fileTruncated:Qte,noNodeUsage:Zte,myNodeManagement:ene,deleteMyNode:tne,deletingMyNode:nne,deleteMyNodeHint:rne,deleteMyNodeConfirm:sne,deleteMyNodeSuccess:ine,deleteMyNodeUsedBy:one,myFlowManagement:ane,deleteMyFlow:lne,deletingMyFlow:cne,deleteMyFlowHint:une,deleteMyFlowConfirm:dne,deleteMyFlowSuccess:fne,noSlots:pne,resourceMeaning:hne,nodesMeaning:mne,myFlowsMeaning:gne,flowSnippetScale:yne,flowSnippetPreview:xne,flowSnippetEdges:wne,flowSnippetJson:bne,flowSnippetMoreEdges:vne,noFlowSnippetPreview:kne,skillsMeaning:Sne,skillPreview:Nne,skillPreviewEmpty:jne,selectResource:Cne,loadFailed:Ene,noPipelines:_ne,emptyHint:Pne,noMatch:Ane,recentActivity:Ine,noRecentActivity:Tne,noMatchRecent:Rne,recentRun:Mne,recentOpen:Lne,sourceBadge:One,resourceSource:$ne,resourceFilter:Dne,nodeDetailTabs:Fne,defaultCardDesc:zne,hubCard:Hne,newPipelineModal:Bne,importModal:Wne,deleteModal:Vne,archiveModal:Kne},qne="返回",Yne="下一步",Gne="跳过",Xne="完成",Jne="开始创建",Qne={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
250
-
251
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
252
-
253
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Zne={intro:`现在进入流程编辑器。
254
-
255
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
256
-
257
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
258
-
259
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
260
-
261
- 左侧节点面板可以自由拖拽、删除和调整连接。`},ere={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},tre={back:qne,next:Yne,skip:Gne,done:Xne,startCreate:Jne,projects:Qne,flow:Zne,newPipeline:ere},nre={en:{common:qG,flow:TX,settings:KX,composer:QX,project:dZ,onboarding:bZ},zh:{common:_Z,flow:pee,settings:Cee,composer:Ree,project:Une,onboarding:tre}};Zr.use(n2).use(zO).init({resources:nre,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 rre=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function sre(e){return Zr.changeLanguage(e)}const uv="agentflow-settings-opencode-plan-v1";function lw(e){if(!e||typeof e!="object")return{cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null};const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null}}function r2(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function ire(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function tc(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(),o=String(r.value??""),a=String(r.id??"").trim()||r2(),u=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:u})}return n}function xC(e){return tc(e).map(({key:t,value:n})=>({key:t,value:n}))}function wC(){try{return localStorage.getItem(uv)??""}catch{return""}}function ore(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function bC(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 are({authUser:e}){const{t,i18n:n}=Tn(["common","settings"]),r=n.language||"zh",[s,o]=m.useState(""),[a,l]=m.useState(""),[u,d]=m.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[p,c]=m.useState(""),[f,h]=m.useState(!1),[g,b]=m.useState(!1),[k,y]=m.useState(""),[w,x]=m.useState([]),[N,_]=m.useState(""),[C,T]=m.useState(!1),[F,R]=m.useState(""),[H,D]=m.useState(""),[$,B]=m.useState(!1),[L,M]=m.useState(()=>new Set),[I,z]=m.useState(""),[A,O]=m.useState([]),[E,J]=m.useState(!1),[Z,K]=m.useState(""),[oe,de]=m.useState([]),[he,we]=m.useState([]),[ue,Ne]=m.useState(""),[le,ce]=m.useState(""),[xe,Se]=m.useState(!1),[Ke,et]=m.useState(!1),[We,ut]=m.useState(""),[Ve,xt]=m.useState(""),[bt,Jn]=m.useState(null),[Ut,nn]=m.useState(!1),[rn,hn]=m.useState(!1),[fe,je]=m.useState(""),He=m.useRef(null),ot=m.useRef(!1),at=m.useRef(!1),Tt=m.useRef(""),mt=m.useCallback(async()=>{l("");try{const ae=await fetch("/api/ui-context");if(!ae.ok)throw new Error("HTTP "+ae.status);const Ce=await ae.json();o(typeof Ce.workspaceRoot=="string"?Ce.workspaceRoot:"")}catch(ae){l(String(ae.message||ae)),o("")}},[]),dn=m.useCallback(async()=>{c(""),h(!0);try{const ae=await fetch("/api/model-lists");if(!ae.ok)throw new Error("HTTP "+ae.status);const Ce=await ae.json();d(lw(Ce))}catch(ae){c(String(ae.message||ae))}finally{h(!1)}},[]),sn=m.useCallback(async()=>{_("");try{const ae=await fetch("/api/user-env"),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);const tt=tc(Array.isArray(Ce.env)?Ce.env:[],"user").map(Nt=>({...Nt,scope:"user"})),Ae=[...e!=null&&e.isAdmin?tc(Array.isArray(Ce.globalEnv)?Ce.globalEnv:[],"global").map(Nt=>({...Nt,scope:"global"})):[],...tt];Tt.current=JSON.stringify(Ae),x(Ae)}catch(ae){x([]),_(String(ae.message||ae))}finally{at.current=!0}},[e==null?void 0:e.isAdmin]),Rn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){J(!0),K("");try{const ae=await fetch("/api/feedback"),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);O(Array.isArray(Ce.feedback)?Ce.feedback:[])}catch(ae){K(String(ae.message||ae))}finally{J(!1)}}},[e==null?void 0:e.isAdmin]),on=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Se(!0),ut("");try{const ae=await fetch("/api/admin/user-allowlist"),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);const tt=Ce.allowlist&&typeof Ce.allowlist=="object"?Ce.allowlist:{};de(Array.isArray(tt.fileUsers)?tt.fileUsers.map(String):[]),we(Array.isArray(tt.envUsers)?tt.envUsers.map(String):[]),Ne(typeof tt.path=="string"?tt.path:"")}catch(ae){ut(String(ae.message||ae))}finally{Se(!1)}}},[e==null?void 0:e.isAdmin]),Mn=m.useCallback(async ae=>{if(e!=null&&e.isAdmin){et(!0),ut("");try{const Ce=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ae})}),tt=await Ce.json().catch(()=>({}));if(!Ce.ok)throw new Error(typeof tt.error=="string"?tt.error:"HTTP "+Ce.status);const De=tt.allowlist&&typeof tt.allowlist=="object"?tt.allowlist:{};de(Array.isArray(De.fileUsers)?De.fileUsers.map(String):[]),we(Array.isArray(De.envUsers)?De.envUsers.map(String):[]),Ne(typeof De.path=="string"?De.path:"")}catch(Ce){ut(String(Ce.message||Ce))}finally{et(!1)}}},[e==null?void 0:e.isAdmin]),Ln=m.useCallback(async()=>{if(e!=null&&e.isAdmin){nn(!0),je("");try{const ae=await fetch("/api/admin/storage-config"),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);const tt=Ce.config&&typeof Ce.config=="object"?Ce.config:{};Jn(tt),xt(typeof tt.dataRoot=="string"?tt.dataRoot:"")}catch(ae){je(String(ae.message||ae))}finally{nn(!1)}}},[e==null?void 0:e.isAdmin]),zr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){hn(!0),je("");try{const ae=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:Ve.trim()})}),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);const tt=Ce.config&&typeof Ce.config=="object"?Ce.config:{};Jn(tt),xt(typeof tt.dataRoot=="string"?tt.dataRoot:"")}catch(ae){je(String(ae.message||ae))}finally{hn(!1)}}},[e==null?void 0:e.isAdmin,Ve]),be=m.useCallback(async ae=>{const Ce=tc(ae),tt=Ce.filter(Ae=>Ae.scope!=="global"),De=Ce.filter(Ae=>Ae.scope==="global");T(!0),_("");try{const Ae=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:xC(tt),...e!=null&&e.isAdmin?{globalEnv:xC(De)}:{}})}),Nt=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(typeof Nt.error=="string"?Nt.error:"HTTP "+Ae.status);const mr=tc(Array.isArray(Nt.env)?Nt.env:[],"user").map(Zn=>({...Zn,scope:"user"})),lr=[...e!=null&&e.isAdmin?tc(Array.isArray(Nt.globalEnv)?Nt.globalEnv:[],"global").map(Zn=>({...Zn,scope:"global"})):[],...mr];Tt.current=JSON.stringify(lr),x(lr)}catch(Ae){_(String(Ae.message||Ae))}finally{T(!1)}},[e==null?void 0:e.isAdmin]),$e=m.useCallback(async()=>{c(""),h(!0);try{const ae=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:I.trim()})}),Ce=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof Ce.error=="string"?Ce.error:"HTTP "+ae.status);d(lw(Ce.modelLists))}catch(ae){c(String(ae.message||ae))}finally{h(!1)}},[I]);m.useEffect(()=>{mt(),dn(),sn(),e!=null&&e.isAdmin&&(Rn(),on(),Ln()),(async()=>{try{const ae=await fetch("/api/agentflow-config");if(ae.ok){const Ce=await ae.json(),tt=typeof Ce.opencodeProvider=="string"?Ce.opencodeProvider:"";z(tt),He.current=tt;try{localStorage.setItem(uv,tt)}catch{}}else{const Ce=wC();z(Ce),He.current=Ce}}catch{const ae=wC();z(ae),He.current=ae}finally{ot.current=!0}})()},[e==null?void 0:e.isAdmin,mt,Rn,dn,Ln,on,sn]),m.useEffect(()=>{if(!at.current||JSON.stringify(tc(w))===Tt.current)return;const Ce=setTimeout(()=>{be(w)},350);return()=>clearTimeout(Ce)},[w,be]),m.useEffect(()=>{if(!ot.current)return;const ae=I.trim();if(ae===He.current)return;const Ce=setTimeout(()=>{(async()=>{b(!0),y("");try{const tt=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ae})}),De=await tt.json().catch(()=>({}));if(!tt.ok)throw new Error(typeof De.error=="string"?De.error:"HTTP "+tt.status);He.current=ae;try{localStorage.setItem(uv,ae)}catch{}De.modelLists&&d(lw(De.modelLists))}catch(tt){y(String(tt.message||tt))}finally{b(!1)}})()},450);return()=>clearTimeout(Ce)},[I]);const ft=u.cursor.length>0,St=u.opencode.length>0,mn=u.claudeCode.length>0,es=oe.length>0||he.length>0,Cs=m.useCallback(()=>{var ae;s&&((ae=navigator.clipboard)==null||ae.writeText(s))},[s]),_r=m.useCallback(()=>{const ae=F.trim(),Ce=H;if(ae){if(!ire(ae)){_(t("settings:env.invalidKey"));return}x(tt=>[...tt,{id:r2(),key:ae,value:Ce,scope:e!=null&&e.isAdmin&&$?"global":"user"}]),R(""),D("")}},[e==null?void 0:e.isAdmin,$,F,H,t]),Hr=m.useCallback(ae=>{x(Ce=>Ce.filter(tt=>tt.id!==ae))},[]),hr=m.useCallback((ae,Ce)=>{x(tt=>tt.map(De=>De.id===ae?{...De,...Ce}:De))},[]),kr=m.useCallback(ae=>{M(Ce=>{const tt=new Set(Ce);return tt.has(ae)?tt.delete(ae):tt.add(ae),tt})},[]),hs=m.useCallback(()=>{const ae=le.trim();if(!ae)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ae)){ut("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(oe.map(tt=>String(tt||"").trim().toLowerCase())).has(ae.toLowerCase())){ce("");return}ce(""),Mn([...oe,ae])},[le,oe,Mn]),Br=m.useCallback(ae=>{const Ce=String(ae||"").trim().toLowerCase();Ce&&Mn(oe.filter(tt=>String(tt||"").trim().toLowerCase()!==Ce))},[oe,Mn]),Ei=m.useCallback(ae=>{const Ce=ae.target.value;sre(Ce)},[]),Qn=ae=>{const Ce=bC(ae,r);return Ce?t("settings:cursor.modelList.fetchedAt",{time:Ce}):t("settings:cursor.modelList.never")},Wr=ae=>bC(ae,r)||String(ae||"");return i.jsxs("div",{className:"af-settings-page",children:[i.jsx("header",{className:"af-settings-top",children:i.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[i.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),i.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),i.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,p?i.jsx("p",{className:"af-err af-settings-api-hint",children:p}):null,N?i.jsx("p",{className:"af-err af-settings-api-hint",children:N}):null,fe?i.jsx("p",{className:"af-err af-settings-api-hint",children:fe}):null]}),i.jsxs("div",{className:"af-settings-layout",children:[i.jsxs("div",{className:"af-settings-bento",children:[i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[i.jsxs("div",{className:"af-set-card-inner",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),i.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),i.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Cs,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:i.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),i.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),i.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),i.jsx("span",{className:"af-set-badge"+(ft?" af-set-badge--ok":" af-set-badge--muted"),children:t(ft?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:ft?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(ft?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:ft?t("settings:cursor.modelList.count",{count:u.cursor.length})+" · "+Qn(u.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),ft?i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:u.cursor.join(`
262
- `)}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>$e(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),i.jsx("span",{className:"af-set-badge"+(St?" af-set-badge--ok":" af-set-badge--err"),children:t(St?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),i.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),i.jsxs("div",{children:[i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),i.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:I,onChange:ae=>z(ae.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:k}):null]}),St?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:u.opencode.length})+" · "+Qn(u.opencodeFetchedAt)}),i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:u.opencode.join(`
263
- `)})]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>$e(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),i.jsx("span",{className:"af-set-badge"+(mn?" af-set-badge--ok":" af-set-badge--err"),children:t(mn?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:mn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(mn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:mn?t("settings:cursor.modelList.count",{count:u.claudeCode.length})+" · "+Qn(u.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),mn?i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:u.claudeCode.join(`
264
- `)}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>$e(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),i.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),i.jsx("span",{className:"af-set-env-note",children:C?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),i.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[i.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[i.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?i.jsx("span",{children:t("settings:env.scope")}):null,i.jsx("span",{children:t("settings:env.value")}),i.jsx("span",{})]}),w.map(ae=>i.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ae.key,onChange:Ce=>hr(ae.id,{key:Ce.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:ae.scope!=="global"?"is-active":"",onClick:()=>hr(ae.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:ae.scope==="global"?"is-active":"",onClick:()=>hr(ae.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,i.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:L.has(ae.id)?"text":"password",value:ae.value,onChange:Ce=>hr(ae.id,{value:Ce.target.value}),placeholder:ore(ae.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>kr(ae.id),"aria-label":L.has(ae.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:L.has(ae.id)?"visibility_off":"visibility"})})]}),i.jsx("div",{className:"af-set-env-actions",children:i.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ae.key}),onClick:()=>Hr(ae.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ae.id)),i.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:F,onChange:ae=>R(ae.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:$?"":"is-active",onClick:()=>B(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:$?"is-active":"",onClick:()=>B(!0),children:t("settings:env.global")})]})}):null,i.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:H,onChange:ae=>D(ae.target.value),"aria-label":t("settings:env.newValue")})}),i.jsx("div",{className:"af-set-env-actions",children:i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:_r,disabled:!F.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]})]})]}),e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),i.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),i.jsx("span",{className:"af-set-badge"+(bt!=null&&bt.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:bt!=null&&bt.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Ln(),disabled:Ut||rn,children:Ut?"刷新中...":"刷新"})]}),fe?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:fe}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:Ve,onChange:ae=>xt(ae.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(bt!=null&&bt.envLocked)||rn}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void zr(),"aria-label":"保存 AgentFlow Data Root",disabled:rn||!!(bt!=null&&bt.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:rn?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(bt==null?void 0:bt.dataRoot)||Ve||"-"}),bt!=null&&bt.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:bt.configPath})]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",i.jsx("code",{children:"users/"}),"、",i.jsx("code",{children:"pipelines/"}),"、",i.jsx("code",{children:"runBuild/"}),"、",i.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",bt!=null&&bt.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),i.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),i.jsx("span",{className:"af-set-badge"+(es?" af-set-badge--ok":" af-set-badge--muted"),children:t(es?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void on(),disabled:xe,children:t(xe?"settings:allowlist.refreshing":"common:common.refresh")})]}),We?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:We}):null,ue?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:ue})]}):null,i.jsxs("div",{className:"af-allowlist-grid",children:[i.jsxs("div",{className:"af-allowlist-main",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.fileList")}),i.jsx("span",{children:Ke?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:oe.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:oe.length>0?oe.map(ae=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:ae}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>Br(ae),"aria-label":t("settings:allowlist.remove",{username:ae}),disabled:Ke,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ae)):i.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),i.jsxs("div",{className:"af-allowlist-add",children:[i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:le,onChange:ae=>ce(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&hs()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:hs,disabled:Ke||!le.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),i.jsxs("div",{className:"af-allowlist-side",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.envList")}),i.jsx("span",{children:t("settings:allowlist.readonly")})]}),i.jsx("div",{className:"af-allowlist-env-list",children:he.length>0?he.map(ae=>i.jsx("code",{children:ae},ae)):i.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),i.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Rn(),disabled:E,children:E?"刷新中...":"刷新"})]}),Z?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Z}):null,i.jsx("div",{className:"af-feedback-list",children:A.length>0?A.map(ae=>i.jsxs("article",{className:"af-feedback-item",children:[i.jsxs("header",{className:"af-feedback-item__head",children:[i.jsxs("div",{children:[i.jsx("h3",{children:ae.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:ae.username||ae.userId||"unknown"}),i.jsx("span",{children:Wr(ae.createdAt)})]})]}),ae.contact?i.jsx("span",{className:"af-feedback-item__contact",children:ae.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:ae.content}),ae.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:ae.pageUrl}):null]},ae.id)):i.jsx("div",{className:"af-feedback-empty",children:E?"正在加载反馈...":"暂无反馈"})})]}):null]}),i.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[i.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[i.jsxs("div",{className:"af-set-rail-inner",children:[i.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),i.jsxs("div",{className:"af-set-health-line",children:[i.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),i.jsx("span",{className:"af-set-health-label",children:t(!a&&!p?"settings:system.normal":"settings:system.abnormal")})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.cursorModels")}),i.jsx("span",{children:u.cursor.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.cursor.length>0?12+u.cursor.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.opencodeModels")}),i.jsx("span",{children:u.opencode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.opencode.length>0?12+u.opencode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.claudeCodeModels")}),i.jsx("span",{children:u.claudeCode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.claudeCode.length>0?12+u.claudeCode.length*3:4)}%`}})})]})]}),i.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),i.jsxs("div",{className:"af-set-rail-card",children:[i.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),i.jsxs("div",{className:"af-set-language-selector",children:[i.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Ei,"aria-label":t("settings:language.description"),children:rre.map(ae=>i.jsxs("option",{value:ae.code,children:[ae.flag," ",ae.name]},ae.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function Rs(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function lm(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function cw(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 lre(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function uw(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 cre(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function ure(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function dre({authUser:e}){const[t,n]=m.useState(null),[r,s]=m.useState(!1),[o,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 u=Array.isArray(t==null?void 0:t.dailyTrend)?t.dailyTrend:[],d=m.useMemo(()=>{const b={top:20,right:24,bottom:42,left:42},k=980-b.left-b.right,y=250-b.top-b.bottom,w=u.length>0?u:[],x=Math.max(1,...w.map(R=>Number(R.runs||0))),N=Math.max(1,...w.flatMap(R=>[Number(R.users||0),Number(R.pipelines||0)])),_=R=>b.left+(w.length<=1?k/2:R*k/(w.length-1)),C=R=>b.top+y-Math.max(0,Number(R||0))/x*y,T=R=>b.top+y-Math.max(0,Number(R||0))/N*y,F=R=>w.map((H,D)=>`${D===0?"M":"L"} ${_(D)} ${T(H[R])}`).join(" ");return{width:980,height:250,margin:b,innerHeight:y,rows:w,x:_,yRuns:C,yLine:T,lineUsers:F("users"),linePipelines:F("pipelines"),barWidth:Math.min(34,Math.max(12,k/Math.max(1,w.length)*.44))}},[u]),p=(t==null?void 0:t.usage)||{},c=(t==null?void 0:t.totals)||{},f=Array.isArray(t==null?void 0:t.recentRuns)?t.recentRuns:[];return e!=null&&e.isAdmin?i.jsxs("main",{className:"af-admin-usage-page",children:[i.jsxs("section",{className:"af-admin-usage-hero",children:[i.jsxs("div",{children:[i.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),i.jsx("h1",{children:"管理看板"}),i.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),i.jsxs("button",{type:"button",onClick:()=>void l(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),r?"刷新中":"刷新"]})]}),o?i.jsx("div",{className:"af-project-admin-usage__error",children:o}):null,i.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[i.jsxs("div",{children:[i.jsx("span",{children:"7日活跃用户率"}),i.jsx("strong",{children:lm(p.activeUserRate)}),i.jsxs("em",{children:[Rs(p.activeUsers)," / ",Rs(c.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:lm(p.activePipelineRate)}),i.jsxs("em",{children:[Rs(p.activePipelines)," / ",Rs(c.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Rs(p.runs)}),i.jsxs("em",{children:[Rs(p.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:lm(p.successRate)}),i.jsxs("em",{children:["失败率 ",lm(p.failureRate)," · avg ",cw(p.avgDurationMs)]})]})]}),i.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"每日趋势"}),i.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),i.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[i.jsxs("div",{className:"af-admin-usage-chart__legend",children:[i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),i.jsx("div",{className:"af-admin-usage-chart__canvas",children:i.jsxs("svg",{viewBox:`0 0 ${d.width} ${d.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:d.margin.left,y1:d.margin.top+d.innerHeight,x2:d.width-d.margin.right,y2:d.margin.top+d.innerHeight}),[.25,.5,.75,1].map(h=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:d.margin.left,y1:d.margin.top+d.innerHeight-d.innerHeight*h,x2:d.width-d.margin.right,y2:d.margin.top+d.innerHeight-d.innerHeight*h},h)),d.rows.map((h,g)=>{const b=d.x(g),k=d.yRuns(h.runs),y=d.margin.top+d.innerHeight,w=Math.max(2,y-k);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:b-d.barWidth/2,y:y-w,width:d.barWidth,height:w,rx:"5",children:i.jsx("title",{children:`${h.date}: ${h.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:b,y:y+22,children:Rs(h.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:b,y:y+42,children:lre(h.date)})]},h.date)}),d.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:d.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:d.linePipelines}),d.rows.map((h,g)=>{const b=d.x(g);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:b,cy:d.yLine(h.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:b,cy:d.yLine(h.pipelines),r:"3.5"})]},`${h.date}-points`)})]}):null]})})]}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"用户"}),i.jsx("th",{children:"流水线"}),i.jsx("th",{children:"运行时间"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"耗时"}),i.jsx("th",{children:"Run ID"})]})}),i.jsx("tbody",{children:f.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):f.map(h=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:h.username||h.userId||"-"}),i.jsx("span",{children:h.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:h.flowId||"-"}),i.jsxs("span",{children:[h.runType==="workspace"?"Workspace Run":"Pipeline"," · ",h.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:uw(h.at)}),h.endedAt?i.jsxs("span",{children:["结束 ",uw(h.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:ure(h.status)})})}),i.jsx("td",{children:cw(h.durationMs)}),i.jsx("td",{children:i.jsx("code",{className:"af-admin-usage-run-id",children:cre(h.runId)})})]},`${h.userId}:${h.flowSource}:${h.flowId}:${h.runId}:${h.at}`))})]})})]}),i.jsxs("section",{className:"af-project-admin-usage",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"用户使用明细"}),i.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"User"}),i.jsx("th",{children:"Pipeline"}),i.jsx("th",{children:"Runs"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"最近运行"})]})}),i.jsx("tbody",{children:r&&!t?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"正在加载..."})}):((t==null?void 0:t.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"暂无用户数据"})}):((t==null?void 0:t.users)||[]).map(h=>{var g,b,k,y,w,x,N,_,C,T,F;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:h.username||h.userId}),i.jsxs("span",{children:[h.userId,h.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Rs((g=h.pipelines)==null?void 0:g.total)}),i.jsxs("span",{children:[Rs((b=h.pipelines)==null?void 0:b.active)," active / ",Rs((k=h.pipelines)==null?void 0:k.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Rs((y=h.runs)==null?void 0:y.total)}),i.jsxs("span",{children:["avg ",cw((w=h.runs)==null?void 0:w.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Rs((x=h.runs)==null?void 0:x.success)]}),i.jsxs("em",{children:["失败 ",Rs((N=h.runs)==null?void 0:N.failed)]}),i.jsxs("em",{children:["运行中 ",Rs((_=h.runs)==null?void 0:_.running)]})]})}),i.jsx("td",{children:(C=h.runs)!=null&&C.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((T=h.runs)==null?void 0:T.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((F=h.runs)==null?void 0:F.lastRunStatus)||"unknown"," · ",uw(h.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})})]},h.userId)})})]})})]})]}):i.jsx("main",{className:"af-admin-usage-page",children:i.jsx("section",{className:"af-project-admin-usage",children:i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"管理看板"}),i.jsx("span",{children:"需要管理员权限。"})]})})})})}function fre(){const{navigate:e}=Bo(),[t,n]=m.useState(""),[r,s]=m.useState(""),[o,a]=m.useState(!1),[l,u]=m.useState(""),[d,p]=m.useState(!1),c=async f=>{if(f.preventDefault(),!o){a(!0),u("");try{const h=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,content:r,pageUrl:window.location.href})}),g=await h.json().catch(()=>({}));if(!h.ok)throw new Error(g.error||"提交失败");p(!0),n(""),s("")}catch(h){u(String(h.message||h))}finally{a(!1)}}};return i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?i.jsxs("div",{className:"af-feedback-success",role:"status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("div",{children:[i.jsx("strong",{children:"已提交"}),i.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,i.jsxs("form",{className:"af-feedback-form",onSubmit:c,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:t,onChange:f=>n(f.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"反馈内容"}),i.jsx("textarea",{value:r,onChange:f=>s(f.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),l?i.jsx("p",{className:"af-err af-feedback-error",children:l}):null,i.jsx("div",{className:"af-feedback-actions",children:i.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:o||!t.trim()||!r.trim(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:o?"hourglass_empty":"send"}),o?"提交中...":"提交反馈"]})})]})]})})}function s2(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function vC(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:s2(),key:r,value:String(s??""),private:n.has(r)}))}function kC(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 Lm(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(`
265
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:vC(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:vC(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 dw(){return Lm({name:"",raw:{command:""}})}function pre(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 o=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);o.length&&(n.args=o)}const r=kC(e.envRows),s=kC(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(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean)}}function SC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function NC(e){return e?e.ok?"ok":"error":"unknown"}function jC({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const o=(a,l,u)=>n(t.map(d=>d.id===a?{...d,[l]:u}:d));return i.jsxs("div",{className:"af-mcp-field",children:[i.jsxs("div",{className:"af-mcp-field-head",children:[i.jsx("span",{children:e}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:s2(),key:"",value:"",private:!0}]),children:"添加"})]}),i.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?i.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>i.jsxs("div",{className:"af-mcp-kv-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>o(a.id,"key",l.target.value)}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>o(a.id,"value",l.target.value)}),i.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[i.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>o(a.id,"private",l.target.checked)}),i.jsx("span",{children:"个人"})]}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function hre(){var $;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(dw),[a,l]=m.useState(""),[u,d]=m.useState(!1),[p,c]=m.useState(!1),[f,h]=m.useState(!1),[g,b]=m.useState({}),[k,y]=m.useState(""),[w,x]=m.useState(""),N=m.useMemo(()=>n.find(B=>B.name===a)||null,[a,n]),_=N&&g[N.name]||null,C=m.useCallback(async()=>{d(!0),y("");try{const B=await fetch("/api/mcps"),L=await B.json().catch(()=>({}));if(!B.ok)throw new Error(L.error||"MCP HTTP "+B.status);const M=Array.isArray(L.servers)?L.servers:[];t(String(L.path||"")),r(M),a&&M.some(I=>I.name===a)&&o(Lm(M.find(I=>I.name===a)))}catch(B){y(String(B.message||B))}finally{d(!1)}},[a]);m.useEffect(()=>{C()},[C]);const T=()=>{l(""),o(dw()),x(""),y("")},F=B=>{l(B.name),o(Lm(B)),x(""),y("")},R=async(B="")=>{h(!0),y(""),x("");try{const L=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B?{name:B}:{})}),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(M.error||"检测 MCP 失败");const I=Array.isArray(M.results)?M.results:[];b(z=>{const A={...z};for(const O of I)O!=null&&O.name&&(A[O.name]=O);return A}),x(B?`已检测 ${B}。`:"已检测所有 MCP。")}catch(L){y(String(L.message||L))}finally{h(!1)}},H=async()=>{c(!0),y(""),x("");try{const B=pre(s);if(!B.nextName)throw new Error("请填写 MCP 名称");const L=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(M.error||"保存 MCP 失败");const I=Array.isArray(M.servers)?M.servers:[];r(I),t(String(M.path||e)),l(B.nextName),o(Lm(I.find(z=>z.name===B.nextName)||null)),b(z=>{const A={...z};return s.originalName&&s.originalName!==B.nextName&&delete A[s.originalName],delete A[B.nextName],A}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(B){y(String(B.message||B))}finally{c(!1)}},D=async B=>{if(B!=null&&B.name&&window.confirm(`删除 MCP "${B.name}"?`)){c(!0),y(""),x("");try{const L=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B.name})}),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(M.error||"删除 MCP 失败");r(Array.isArray(M.servers)?M.servers:[]),l(""),o(dw()),b(I=>{const z={...I};return delete z[B.name],z}),x("已删除。")}catch(L){y(String(L.message||L))}finally{c(!1)}}};return i.jsxs("main",{className:"af-settings-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),i.jsxs("div",{className:"af-settings-top-right",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:u||p,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(),disabled:f||u||p||n.length===0,children:f?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:T,disabled:p,children:"新增 MCP"})]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),i.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",i.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),i.jsxs("div",{className:"af-mcp-layout",children:[i.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2",children:"Servers"}),i.jsxs("div",{className:"af-mcp-list-head-actions",children:[i.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),i.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:T,disabled:p,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),u?i.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!u?i.jsxs("div",{className:"af-mcp-empty",children:[i.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:T,disabled:p,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(B=>i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===B.name?" af-mcp-server-item--active":""),onClick:()=>F(B),children:[i.jsx("span",{className:"material-symbols-outlined",children:B.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:B.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${NC(g[B.name])}`,children:SC(g[B.name])})]}),i.jsx("em",{children:B.url||[B.command,...B.args||[]].filter(Boolean).join(" ")})]})]},B.name))})]}),i.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:N?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),N?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(N.name),disabled:f||p,children:f?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>D(N),disabled:p,children:"删除"})]}):null]}),k?i.jsx("p",{className:"af-mcp-error",children:k}):null,w?i.jsx("p",{className:"af-mcp-status",children:w}):null,_?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${NC(_)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:SC(_)}),i.jsxs("span",{children:[_.elapsedMs||0,"ms"]})]}),_.error?i.jsx("p",{children:_.error}):null,($=_.tools)!=null&&$.length?i.jsx("div",{className:"af-mcp-tools-list",children:_.tools.map(B=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:B.name}),B.description?i.jsx("span",{children:B.description}):null]},B.name))}):null]}):null,i.jsxs("div",{className:"af-mcp-form",children:[i.jsxs("label",{className:"af-set-label",children:["MCP 名称",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:B=>o(L=>({...L,name:B.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:B=>o(L=>({...L,type:B.target.value})),children:[i.jsx("option",{value:"url",children:"URL / HTTP"}),i.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:B=>o(L=>({...L,url:B.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-set-label",children:["Command",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:B=>o(L=>({...L,command:B.target.value})),placeholder:"uvx"})]}),i.jsxs("label",{className:"af-set-label",children:["Args,每行一个",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:B=>o(L=>({...L,argsText:B.target.value})),placeholder:`mcp-server-example
266
- --flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:B=>o(L=>({...L,description:B.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(jC,{title:"Headers",rows:s.headerRows,onChange:B=>o(L=>({...L,headerRows:B})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(jC,{title:"Env",rows:s.envRows,onChange:B=>o(L=>({...L,envRows:B})),placeholderKey:"TOKEN",placeholderValue:"..."}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:B=>o(L=>({...L,extraJson:B.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:T,disabled:p,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:H,disabled:p,children:p?"保存中...":"保存 MCP"})]})]})]})]})})]})}const mre=[{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"}],gre=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],yre=[{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"}],xre=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function cm({icon:e,title:t,label:n,tone:r="violet"}){return i.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[i.jsx("span",{className:"material-symbols-outlined",children:e}),i.jsxs("div",{children:[i.jsx("strong",{children:t}),i.jsx("small",{children:n})]})]})}function wre(){return i.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[i.jsx("div",{className:"likee-scene-grid"}),i.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[i.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),i.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),i.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),i.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),i.jsx("div",{className:"likee-node-pos likee-node-a",children:i.jsx(cm,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(cm,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(cm,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(cm,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),i.jsxs("div",{className:"likee-phone-preview",children:[i.jsxs("div",{className:"likee-phone-top",children:[i.jsx("span",{children:"关注"}),i.jsx("strong",{children:"推荐"}),i.jsx("span",{children:"直播"})]}),i.jsxs("div",{className:"likee-phone-card",children:[i.jsx("div",{className:"likee-gift",children:"AD"}),i.jsx("h4",{children:"广告个性化引导弹框"}),i.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),i.jsx("button",{children:"继续"}),i.jsx("button",{className:"secondary",children:"稍后"})]})]}),i.jsxs("div",{className:"likee-display-panel",children:[i.jsxs("div",{className:"likee-panel-header",children:[i.jsx("span",{children:"DISPLAY"}),i.jsx("strong",{children:"需求资产面板"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"需求"}),i.jsx("strong",{children:"首页广告个性化引导"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"数据"}),i.jsx("strong",{children:"m09 PV Top 1"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"同步"}),i.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function Om({kicker:e,title:t,children:n}){return i.jsxs("div",{className:"likee-section-copy",children:[i.jsx("p",{className:"likee-section-kicker",children:e}),i.jsx("h2",{children:t}),i.jsx("p",{children:n})]})}function bre(){return i.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[i.jsx(Om,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:yre.map(e=>i.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[i.jsxs("div",{className:"likee-skill-head",children:[i.jsx("div",{className:"likee-skill-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.name}),i.jsx("span",{children:e.namespace})]})]}),i.jsx("div",{className:"likee-skill-mode",children:e.mode}),i.jsx("p",{children:e.usage}),i.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>i.jsx("strong",{children:t},t))})]},e.name))})]})})}function i2(){return i.jsxs("div",{className:"likee-page",children:[i.jsx("div",{className:"likee-top-actions",children:i.jsxs("a",{href:"/projects",className:"likee-home-link",children:[i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),i.jsxs("section",{className:"likee-hero",children:[i.jsx(wre,{}),i.jsxs("div",{className:"likee-hero-content",children:[i.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),i.jsx("h1",{children:"Likee Agent 工作台"}),i.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),i.jsxs("div",{className:"likee-signal-row",children:[i.jsx("span",{children:"查业务逻辑"}),i.jsx("span",{children:"查 CK / Hive"}),i.jsx("span",{children:"生成原型"}),i.jsx("span",{children:"生成 PRD"}),i.jsx("span",{children:"同步 TAPD / Git"})]}),i.jsxs("div",{className:"likee-hero-actions",children:[i.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),i.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),i.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),i.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),i.jsx("section",{id:"likee-scenarios",className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner",children:[i.jsx(Om,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:mre.map(e=>i.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[i.jsx("div",{className:"likee-scenario-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.question})]}),i.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>i.jsx("span",{children:t},t))}),i.jsxs("div",{className:"likee-scenario-result",children:[i.jsx("span",{children:"产出"}),i.jsx("strong",{children:e.result})]})]},e.title))})]})}),i.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[i.jsx(Om,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:gre.map(e=>i.jsxs("article",{className:"likee-usecase-card",children:[i.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>i.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),i.jsxs("div",{className:"likee-usecase-body",children:[i.jsx("div",{className:"likee-usecase-label",children:e.label}),i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.trigger}),i.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>i.jsx("li",{children:t},t))}),i.jsxs("div",{className:"likee-usecase-output",children:[i.jsx("span",{children:"实际产物"}),i.jsx("div",{children:e.outputs.map(t=>i.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),i.jsx(bre,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(Om,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:xre.map(([e,t,n])=>i.jsxs("div",{className:"likee-capability-row",children:[i.jsx("span",{children:e}),i.jsx("strong",{children:t}),i.jsx("p",{children:n})]},e))})]})})]})}function o2(e){return t=>typeof t===e}var vre=o2("function"),kre=e=>e===null,CC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",EC=e=>!Sre(e)&&!kre(e)&&(vre(e)||typeof e=="object"),Sre=o2("undefined");function Nre(e,t,n){return Ire(n,e,t)?!0:(Tre(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?jre(e,t,n):e instanceof Map&&t instanceof Map?_re(e,t,n):e instanceof Set&&t instanceof Set?Are(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Cre(e,t):CC(e)&&CC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Ere(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Pre(e,t,n))}function Vp(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!EC(e)||!t||!EC(t)?!1:Nre(e,t,n)}function jre(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!Vp(e[s],t[s],n))return!1;return!0}function Cre(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 Ere(e,t,n){return e.message===t.message&&e.name===t.name&&Vp(e.cause,t.cause,n)}function _re(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(!Vp(r[1],t.get(r[0]),n))return!1;return!0}function Pre(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 o=r[s];if(!(o==="_owner"&&e.$$typeof)&&!Vp(e[o],t[o],n))return!1}return!0}function Are(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 Ire(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Tre(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function lk(e,t){return Vp(e,t,new WeakMap)}function fw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Rre(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Mre(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Lre(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Ore(e,t){const n=Lre();m.useEffect(()=>{if(!n)return e()},t)}function a2(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function $re(e,t){const n=m.useRef(t);return lk(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Dre(e){m.useEffect(()=>{e()},[])}function Fre(e=0){const[t,n]=m.useState({height:fw()?window.innerHeight:0,width:fw()?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(!fw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Mre(window,"resize",o),()=>{Rre(window,"resize",o)}},[]),t}var zre=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Hre=["bigint","boolean","null","number","string","symbol","undefined"];function Kp(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Bre(t))return t}function oo(e){return t=>Kp(t)===e}function Bre(e){return zre.includes(e)}function yd(e){return t=>typeof t===e}function Wre(e){return Hre.includes(e)}var Vre=["innerHTML","ownerDocument","style","attributes","nodeValue"],Up=e=>Array.isArray(e),Kre=e=>Kp(e)==="AsyncGeneratorFunction",Ure=oo("AsyncFunction"),qre=yd("bigint"),Yre=e=>e===!0||e===!1,Gre=oo("Date"),Xre=oo("Error"),vl=yd("function"),Jre=oo("GeneratorFunction"),Qre=e=>typeof e=="number"&&Number.isInteger(e),dv=oo("Map"),l2=e=>Number.isNaN(e),ck=e=>e===null,c2=oo("Function"),Zre=oo("Promise"),ese=oo("RegExp"),fv=oo("Set"),qp=yd("string"),tse=yd("symbol"),uk=yd("undefined"),nse=oo("WeakMap"),rse=oo("WeakSet"),dk=e=>ck(e)||uk(e),u2=e=>!uk(e),sse=e=>yd("number")(e)&&!l2(e),ise=e=>qp(e)&&e.trim().length>0,ose=e=>{if(!qp(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},Iy=e=>!dk(e)&&(vl(e)||typeof e=="object"),d2=e=>{if(Kp(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},ase=e=>ck(e)||Wre(typeof e),lse=e=>Kp(e)==="URL",f2=e=>!dk(e)&&vl(e[Symbol.iterator]),cse=e=>f2(e)&&vl(e.next)&&vl(e.throw),use=e=>vl(e)&&/^class\s/.test(e.toString()),dse=(e,t)=>!Up(e)||!vl(t)?!1:e.every(n=>t(n)),fse=e=>Iy(e)&&!d2(e)&&e.nodeType===1&&qp(e.nodeName)&&Vre.every(t=>t in e),pse=e=>qp(e)&&e.length===0||Up(e)&&e.length===0||Iy(e)&&!dv(e)&&!fv(e)&&Object.keys(e).length===0||fv(e)&&e.size===0||dv(e)&&e.size===0,hse=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,mse=(e,t)=>Up(e)?e.indexOf(t)>-1:!1,gse=(e,t,n)=>{if(!Iy(e)||!t)return!1;const r=e[t];return vl(n)?n(r):u2(r)};function $t(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(Up(e))return"Array";if(c2(e))return"Function";const t=Kp(e);return t||"Object"}$t.array=Up;$t.arrayOf=dse;$t.asyncGeneratorFunction=Kre;$t.asyncFunction=Ure;$t.bigint=qre;$t.boolean=Yre;$t.class=use;$t.date=Gre;$t.defined=u2;$t.domElement=fse;$t.empty=pse;$t.error=Xre;$t.function=vl;$t.generator=cse;$t.generatorFunction=Jre;$t.instanceOf=hse;$t.integer=Qre;$t.iterable=f2;$t.map=dv;$t.nan=l2;$t.null=ck;$t.nullOrUndefined=dk;$t.nonEmptyString=ise;$t.number=sse;$t.numericString=ose;$t.object=Iy;$t.oneOf=mse;$t.plainFunction=c2;$t.plainObject=d2;$t.primitive=ase;$t.promise=Zre;$t.propertyOf=gse;$t.regexp=ese;$t.set=fv;$t.string=qp;$t.symbol=tse;$t.undefined=uk;$t.url=lse;$t.weakMap=nse;$t.weakSet=rse;var cs=$t;/* v8 ignore next -- @preserve */var yse=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},xse=function(e,t){return e+jp(t)},jp=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(xse,""):yse(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?jp(e.props.children):""};jp.default=jp;var wse=jp;const pw=Sl(wse);var p2={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(o){return typeof o=="object"&&o!==null&&!(o instanceof RegExp)&&!(o instanceof Date)}}function r(s){function o(_){return _!=="constructor"&&_!=="prototype"&&_!=="__proto__"}function a(_){let C=0;const T=_.length,F=new Array(T);for(C;C<T;++C)F[C]=y(_[C]);return F}function l(_){const C={};if(f&&Object.getPrototypeOf(_)!==t)return f(_);const T=c(_);let F,R,H;for(F=0,R=T.length;F<R;++F)o(H=T[F])&&(C[H]=y(_[H]));return C}function u(_,C){const T=_.length,F=C.length;let R=0;const H=new Array(T+F);for(R;R<T;++R)H[R]=y(_[R]);for(R=0;R<F;++R)H[R+T]=y(C[R]);return H}const d=Object.prototype.propertyIsEnumerable;function p(_){const C=Object.keys(_),T=Object.getOwnPropertySymbols(_);for(let F=0,R=T.length;F<R;++F)d.call(_,T[F])&&C.push(T[F]);return C}const c=s!=null&&s.symbols?p:Object.keys,f=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(_){return typeof _!="object"||_===null}const k=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:x,getKeys:c,isMergeableObject:h}):u;function y(_){return h(_)?Array.isArray(_)?a(_):l(_):_}function w(_,C){const T={},F=c(_),R=c(C);let H,D,$;for(H=0,D=F.length;H<D;++H)o($=F[H])&&R.indexOf($)===-1&&(T[$]=y(_[$]));for(H=0,D=R.length;H<D;++H)if(o($=R[H]))if($ in _)F.indexOf($)!==-1&&(f&&h(C[$])&&Object.getPrototypeOf(C[$])!==t?T[$]=f(C[$]):T[$]=x(_[$],C[$]));else{if(g&&typeof C[$]>"u")continue;T[$]=y(C[$])}return T}function x(_,C){if(g&&typeof C>"u")return y(_);const T=Array.isArray(C),F=Array.isArray(_);return b(C)?C:h(_)?T&&F?k(_,C):T!==F?y(C):w(_,C):y(C)}function N(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return x(arguments[0],arguments[1])}let _;for(let C=0,T=arguments.length;C<T;++C)_=x(_,arguments[C]);return _}return s!=null&&s.all?N:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(p2);var bse=p2.exports;const vse=Sl(bse);var kse=new Error("Element already at target scroll position"),Sse=new Error("Scroll cancelled"),Nse=Math.min,_C=Date.now,jse={left:PC("scrollLeft"),top:PC("scrollTop")};function PC(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=Ese);var a=_C(),l=n[e],u=s.ease||Cse,d=isNaN(s.duration)?350:+s.duration,p=!1;return l===r?o(kse,n[e]):requestAnimationFrame(f),c;function c(){p=!0}function f(h){if(p)return o(Sse,n[e]);var g=_C(),b=Nse(1,(g-a)/d),k=u(b);n[e]=k*(r-l)+l,b<1?requestAnimationFrame(f):requestAnimationFrame(function(){o(null,n[e])})}}}function Cse(e){return .5*(1-Math.cos(Math.PI*e))}function Ese(){}const _se=Sl(jse);var h2={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(Wf,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})})(h2);var Pse=h2.exports;const m2=Sl(Pse),Ase=["top","right","bottom","left"],AC=["start","end"],IC=Ase.reduce((e,t)=>e.concat(t,t+"-"+AC[0],t+"-"+AC[1]),[]),cd=Math.min,hc=Math.max,Wg=Math.round,um=Math.floor,Do=e=>({x:e,y:e}),Ise={left:"right",right:"left",bottom:"top",top:"bottom"};function pv(e,t,n){return hc(e,cd(t,n))}function xd(e,t){return typeof e=="function"?e(t):e}function ba(e){return e.split("-")[0]}function Fo(e){return e.split("-")[1]}function g2(e){return e==="x"?"y":"x"}function fk(e){return e==="y"?"height":"width"}function nl(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function pk(e){return g2(nl(e))}function y2(e,t,n){n===void 0&&(n=!1);const r=Fo(e),s=pk(e),o=fk(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Kg(a)),[a,Kg(a)]}function Tse(e){const t=Kg(e);return[Vg(e),t,Vg(t)]}function Vg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const TC=["left","right"],RC=["right","left"],Rse=["top","bottom"],Mse=["bottom","top"];function Lse(e,t,n){switch(e){case"top":case"bottom":return n?t?RC:TC:t?TC:RC;case"left":case"right":return t?Rse:Mse;default:return[]}}function Ose(e,t,n,r){const s=Fo(e);let o=Lse(ba(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(Vg)))),o}function Kg(e){const t=ba(e);return Ise[t]+e.slice(t.length)}function $se(e){return{top:0,right:0,bottom:0,left:0,...e}}function x2(e){return typeof e!="number"?$se(e):{top:e,right:e,bottom:e,left:e}}function Ug(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 MC(e,t,n){let{reference:r,floating:s}=e;const o=nl(t),a=pk(t),l=fk(a),u=ba(t),d=o==="y",p=r.x+r.width/2-s.width/2,c=r.y+r.height/2-s.height/2,f=r[l]/2-s[l]/2;let h;switch(u){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:c};break;case"left":h={x:r.x-s.width,y:c};break;default:h={x:r.x,y:r.y}}switch(Fo(t)){case"start":h[a]-=f*(n&&d?-1:1);break;case"end":h[a]+=f*(n&&d?-1:1);break}return h}async function Dse(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:c="floating",altBoundary:f=!1,padding:h=0}=xd(t,e),g=x2(h),k=l[f?c==="floating"?"reference":"floating":c],y=Ug(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(k)))==null||n?k:k.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),w=c==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),N=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},_=Ug(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:u}):w);return{top:(y.top-_.top+g.top)/N.y,bottom:(_.bottom-y.bottom+g.bottom)/N.y,left:(y.left-_.left+g.left)/N.x,right:(_.right-y.right+g.right)/N.x}}const Fse=50,zse=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Dse},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:c}=MC(d,r,u),f=r,h=0;const g={};for(let b=0;b<o.length;b++){const k=o[b];if(!k)continue;const{name:y,fn:w}=k,{x,y:N,data:_,reset:C}=await w({x:p,y:c,initialPlacement:r,placement:f,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});p=x??p,c=N??c,g[y]={...g[y],..._},C&&h<Fse&&(h++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(d=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:p,y:c}=MC(d,f,u)),b=-1)}return{x:p,y:c,placement:f,strategy:s,middlewareData:g}},Hse=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=xd(e,t)||{};if(d==null)return{};const c=x2(p),f={x:n,y:r},h=pk(s),g=fk(h),b=await a.getDimensions(d),k=h==="y",y=k?"top":"left",w=k?"bottom":"right",x=k?"clientHeight":"clientWidth",N=o.reference[g]+o.reference[h]-f[h]-o.floating[g],_=f[h]-o.reference[h],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let T=C?C[x]:0;(!T||!await(a.isElement==null?void 0:a.isElement(C)))&&(T=l.floating[x]||o.floating[g]);const F=N/2-_/2,R=T/2-b[g]/2-1,H=cd(c[y],R),D=cd(c[w],R),$=H,B=T-b[g]-D,L=T/2-b[g]/2+F,M=pv($,L,B),I=!u.arrow&&Fo(s)!=null&&L!==M&&o.reference[g]/2-(L<$?H:D)-b[g]/2<0,z=I?L<$?L-$:L-B:0;return{[h]:f[h]+z,data:{[h]:M,centerOffset:L-M-z,...I&&{alignmentOffset:z}},reset:I}}});function Bse(e,t,n){return(e?[...n.filter(s=>Fo(s)===e),...n.filter(s=>Fo(s)!==e)]:n.filter(s=>ba(s)===s)).filter(s=>e?Fo(s)===e||(t?Vg(s)!==s:!1):!0)}const Wse=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:o,middlewareData:a,placement:l,platform:u,elements:d}=t,{crossAxis:p=!1,alignment:c,allowedPlacements:f=IC,autoAlignment:h=!0,...g}=xd(e,t),b=c!==void 0||f===IC?Bse(c||null,h,f):f,k=await u.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,w=b[y];if(w==null)return{};const x=y2(w,o,await(u.isRTL==null?void 0:u.isRTL(d.floating)));if(l!==w)return{reset:{placement:b[0]}};const N=[k[ba(w)],k[x[0]],k[x[1]]],_=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:N}],C=b[y+1];if(C)return{data:{index:y+1,overflows:_},reset:{placement:C}};const T=_.map(H=>{const D=Fo(H.placement);return[H.placement,D&&p?H.overflows.slice(0,2).reduce(($,B)=>$+B,0):H.overflows[0],H.overflows]}).sort((H,D)=>H[1]-D[1]),R=((s=T.filter(H=>H[2].slice(0,Fo(H[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||T[0][0];return R!==l?{data:{index:y+1,overflows:_},reset:{placement:R}}:{}}}},Vse=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:c=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...k}=xd(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=ba(s),w=nl(l),x=ba(l)===l,N=await(u.isRTL==null?void 0:u.isRTL(d.floating)),_=f||(x||!b?[Kg(l)]:Tse(l)),C=g!=="none";!f&&C&&_.push(...Ose(l,b,g,N));const T=[l,..._],F=await u.detectOverflow(t,k),R=[];let H=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&R.push(F[y]),c){const L=y2(s,a,N);R.push(F[L[0]],F[L[1]])}if(H=[...H,{placement:s,overflows:R}],!R.every(L=>L<=0)){var D,$;const L=(((D=o.flip)==null?void 0:D.index)||0)+1,M=T[L];if(M&&(!(c==="alignment"?w!==nl(M):!1)||H.every(A=>nl(A.placement)===w?A.overflows[0]>0:!0)))return{data:{index:L,overflows:H},reset:{placement:M}};let I=($=H.filter(z=>z.overflows[0]<=0).sort((z,A)=>z.overflows[1]-A.overflows[1])[0])==null?void 0:$.placement;if(!I)switch(h){case"bestFit":{var B;const z=(B=H.filter(A=>{if(C){const O=nl(A.placement);return O===w||O==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(O=>O>0).reduce((O,E)=>O+E,0)]).sort((A,O)=>A[1]-O[1])[0])==null?void 0:B[0];z&&(I=z);break}case"initialPlacement":I=l;break}if(s!==I)return{reset:{placement:I}}}return{}}}},Kse=new Set(["left","top"]);async function Use(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=ba(n),l=Fo(n),u=nl(n)==="y",d=Kse.has(a)?-1:1,p=o&&u?-1:1,c=xd(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:g}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),u?{x:h*p,y:f*d}:{x:f*d,y:h*p}}const qse=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:a,middlewareData:l}=t,u=await Use(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+u.x,y:o+u.y,data:{...u,placement:a}}}}},Yse=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:y=>{let{x:w,y:x}=y;return{x:w,y:x}}},...d}=xd(e,t),p={x:n,y:r},c=await o.detectOverflow(t,d),f=nl(ba(s)),h=g2(f);let g=p[h],b=p[f];if(a){const y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",x=g+c[y],N=g-c[w];g=pv(x,g,N)}if(l){const y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",x=b+c[y],N=b-c[w];b=pv(x,b,N)}const k=u.fn({...t,[h]:g,[f]:b});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[h]:a,[f]:l}}}}}};function Ty(){return typeof window<"u"}function wd(e){return w2(e)?(e.nodeName||"").toLowerCase():"#document"}function ai(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Vo(e){var t;return(t=(w2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function w2(e){return Ty()?e instanceof Node||e instanceof ai(e).Node:!1}function ro(e){return Ty()?e instanceof Element||e instanceof ai(e).Element:!1}function Sa(e){return Ty()?e instanceof HTMLElement||e instanceof ai(e).HTMLElement:!1}function LC(e){return!Ty()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ai(e).ShadowRoot}function Yp(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=so(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Gse(e){return/^(table|td|th)$/.test(wd(e))}function Ry(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Xse=/transform|translate|scale|rotate|perspective|filter/,Jse=/paint|layout|strict|content/,Jl=e=>!!e&&e!=="none";let hw;function hk(e){const t=ro(e)?so(e):e;return Jl(t.transform)||Jl(t.translate)||Jl(t.scale)||Jl(t.rotate)||Jl(t.perspective)||!mk()&&(Jl(t.backdropFilter)||Jl(t.filter))||Xse.test(t.willChange||"")||Jse.test(t.contain||"")}function Qse(e){let t=kl(e);for(;Sa(t)&&!ud(t);){if(hk(t))return t;if(Ry(t))return null;t=kl(t)}return null}function mk(){return hw==null&&(hw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hw}function ud(e){return/^(html|body|#document)$/.test(wd(e))}function so(e){return ai(e).getComputedStyle(e)}function My(e){return ro(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kl(e){if(wd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||LC(e)&&e.host||Vo(e);return LC(t)?t.host:t}function b2(e){const t=kl(e);return ud(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sa(t)&&Yp(t)?t:b2(t)}function Cp(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=b2(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ai(s);if(o){const l=hv(a);return t.concat(a,a.visualViewport||[],Yp(s)?s:[],l&&n?Cp(l):[])}else return t.concat(s,Cp(s,[],n))}function hv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function v2(e){const t=so(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Sa(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Wg(n)!==o||Wg(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function gk(e){return ro(e)?e:e.contextElement}function Bu(e){const t=gk(e);if(!Sa(t))return Do(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=v2(t);let a=(o?Wg(n.width):n.width)/r,l=(o?Wg(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Zse=Do(0);function k2(e){const t=ai(e);return!mk()||!t.visualViewport?Zse:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function eie(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ai(e)?!1:t}function _c(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=gk(e);let a=Do(1);t&&(r?ro(r)&&(a=Bu(r)):a=Bu(e));const l=eie(o,n,r)?k2(o):Do(0);let u=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,p=s.width/a.x,c=s.height/a.y;if(o){const f=ai(o),h=r&&ro(r)?ai(r):r;let g=f,b=hv(g);for(;b&&r&&h!==g;){const k=Bu(b),y=b.getBoundingClientRect(),w=so(b),x=y.left+(b.clientLeft+parseFloat(w.paddingLeft))*k.x,N=y.top+(b.clientTop+parseFloat(w.paddingTop))*k.y;u*=k.x,d*=k.y,p*=k.x,c*=k.y,u+=x,d+=N,g=ai(b),b=hv(g)}}return Ug({width:p,height:c,x:u,y:d})}function Ly(e,t){const n=My(e).scrollLeft;return t?t.left+n:_c(Vo(e)).left+n}function S2(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ly(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function tie(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Vo(r),l=t?Ry(t.floating):!1;if(r===a||l&&o)return n;let u={scrollLeft:0,scrollTop:0},d=Do(1);const p=Do(0),c=Sa(r);if((c||!c&&!o)&&((wd(r)!=="body"||Yp(a))&&(u=My(r)),c)){const h=_c(r);d=Bu(r),p.x=h.x+r.clientLeft,p.y=h.y+r.clientTop}const f=a&&!c&&!o?S2(a,u):Do(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+f.x,y:n.y*d.y-u.scrollTop*d.y+p.y+f.y}}function nie(e){return Array.from(e.getClientRects())}function rie(e){const t=Vo(e),n=My(e),r=e.ownerDocument.body,s=hc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=hc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Ly(e);const l=-n.scrollTop;return so(r).direction==="rtl"&&(a+=hc(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const OC=25;function sie(e,t){const n=ai(e),r=Vo(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,u=0;if(s){o=s.width,a=s.height;const p=mk();(!p||p&&t==="fixed")&&(l=s.offsetLeft,u=s.offsetTop)}const d=Ly(r);if(d<=0){const p=r.ownerDocument,c=p.body,f=getComputedStyle(c),h=p.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(r.clientWidth-c.clientWidth-h);g<=OC&&(o-=g)}else d<=OC&&(o+=d);return{width:o,height:a,x:l,y:u}}function iie(e,t){const n=_c(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=Sa(e)?Bu(e):Do(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,u=s*o.x,d=r*o.y;return{width:a,height:l,x:u,y:d}}function $C(e,t,n){let r;if(t==="viewport")r=sie(e,n);else if(t==="document")r=rie(Vo(e));else if(ro(t))r=iie(t,n);else{const s=k2(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ug(r)}function N2(e,t){const n=kl(e);return n===t||!ro(n)||ud(n)?!1:so(n).position==="fixed"||N2(n,t)}function oie(e,t){const n=t.get(e);if(n)return n;let r=Cp(e,[],!1).filter(l=>ro(l)&&wd(l)!=="body"),s=null;const o=so(e).position==="fixed";let a=o?kl(e):e;for(;ro(a)&&!ud(a);){const l=so(a),u=hk(a);!u&&l.position==="fixed"&&(s=null),(o?!u&&!s:!u&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Yp(a)&&!u&&N2(e,a))?r=r.filter(p=>p!==a):s=l,a=kl(a)}return t.set(e,r),r}function aie(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Ry(t)?[]:oie(t,this._c):[].concat(n),r],l=$C(t,a[0],s);let u=l.top,d=l.right,p=l.bottom,c=l.left;for(let f=1;f<a.length;f++){const h=$C(t,a[f],s);u=hc(h.top,u),d=cd(h.right,d),p=cd(h.bottom,p),c=hc(h.left,c)}return{width:d-c,height:p-u,x:c,y:u}}function lie(e){const{width:t,height:n}=v2(e);return{width:t,height:n}}function cie(e,t,n){const r=Sa(t),s=Vo(t),o=n==="fixed",a=_c(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const u=Do(0);function d(){u.x=Ly(s)}if(r||!r&&!o)if((wd(t)!=="body"||Yp(s))&&(l=My(t)),r){const h=_c(t,!0,o,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else s&&d();o&&!r&&s&&d();const p=s&&!r&&!o?S2(s,l):Do(0),c=a.left+l.scrollLeft-u.x-p.x,f=a.top+l.scrollTop-u.y-p.y;return{x:c,y:f,width:a.width,height:a.height}}function mw(e){return so(e).position==="static"}function DC(e,t){if(!Sa(e)||so(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Vo(e)===n&&(n=n.ownerDocument.body),n}function j2(e,t){const n=ai(e);if(Ry(e))return n;if(!Sa(e)){let s=kl(e);for(;s&&!ud(s);){if(ro(s)&&!mw(s))return s;s=kl(s)}return n}let r=DC(e,t);for(;r&&Gse(r)&&mw(r);)r=DC(r,t);return r&&ud(r)&&mw(r)&&!hk(r)?n:r||Qse(e)||n}const uie=async function(e){const t=this.getOffsetParent||j2,n=this.getDimensions,r=await n(e.floating);return{reference:cie(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function die(e){return so(e).direction==="rtl"}const fie={convertOffsetParentRelativeRectToViewportRelativeRect:tie,getDocumentElement:Vo,getClippingRect:aie,getOffsetParent:j2,getElementRects:uie,getClientRects:nie,getDimensions:lie,getScale:Bu,isElement:ro,isRTL:die};function C2(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function pie(e,t){let n=null,r;const s=Vo(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),o();const d=e.getBoundingClientRect(),{left:p,top:c,width:f,height:h}=d;if(l||t(),!f||!h)return;const g=um(c),b=um(s.clientWidth-(p+f)),k=um(s.clientHeight-(c+h)),y=um(p),x={rootMargin:-g+"px "+-b+"px "+-k+"px "+-y+"px",threshold:hc(0,cd(1,u))||1};let N=!0;function _(C){const T=C[0].intersectionRatio;if(T!==u){if(!N)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!C2(d,e.getBoundingClientRect())&&a(),N=!1}try{n=new IntersectionObserver(_,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return a(!0),o}function FC(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=gk(e),p=s||o?[...d?Cp(d):[],...t?Cp(t):[]]:[];p.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const c=d&&l?pie(d,n):null;let f=-1,h=null;a&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),d&&!u&&h.observe(d),t&&h.observe(t));let g,b=u?_c(e):null;u&&k();function k(){const y=_c(e);b&&!C2(b,y)&&n(),b=y,g=requestAnimationFrame(k)}return n(),()=>{var y;p.forEach(w=>{s&&w.removeEventListener("scroll",n),o&&w.removeEventListener("resize",n)}),c==null||c(),(y=h)==null||y.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const hie=qse,mie=Wse,gie=Yse,yie=Vse,zC=Hse,xie=(e,t,n)=>{const r=new Map,s={platform:fie,...n},o={...s.platform,_c:r};return zse(e,t,{...s,platform:o})};var wie=typeof document<"u",bie=function(){},$m=wie?m.useLayoutEffect:bie;function qg(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(!qg(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 o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!qg(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function E2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function HC(e,t){const n=E2(e);return Math.round(t*n)/n}function gw(e){const t=m.useRef(e);return $m(()=>{t.current=e}),t}function BC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,c]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=m.useState(r);qg(f,r)||h(r);const[g,b]=m.useState(null),[k,y]=m.useState(null),w=m.useCallback(A=>{A!==C.current&&(C.current=A,b(A))},[]),x=m.useCallback(A=>{A!==T.current&&(T.current=A,y(A))},[]),N=o||g,_=a||k,C=m.useRef(null),T=m.useRef(null),F=m.useRef(p),R=u!=null,H=gw(u),D=gw(s),$=gw(d),B=m.useCallback(()=>{if(!C.current||!T.current)return;const A={placement:t,strategy:n,middleware:f};D.current&&(A.platform=D.current),xie(C.current,T.current,A).then(O=>{const E={...O,isPositioned:$.current!==!1};L.current&&!qg(F.current,E)&&(F.current=E,$r.flushSync(()=>{c(E)}))})},[f,t,n,D,$]);$m(()=>{d===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,c(A=>({...A,isPositioned:!1})))},[d]);const L=m.useRef(!1);$m(()=>(L.current=!0,()=>{L.current=!1}),[]),$m(()=>{if(N&&(C.current=N),_&&(T.current=_),N&&_){if(H.current)return H.current(N,_,B);B()}},[N,_,B,H,R]);const M=m.useMemo(()=>({reference:C,floating:T,setReference:w,setFloating:x}),[w,x]),I=m.useMemo(()=>({reference:N,floating:_}),[N,_]),z=m.useMemo(()=>{const A={position:n,left:0,top:0};if(!I.floating)return A;const O=HC(I.floating,p.x),E=HC(I.floating,p.y);return l?{...A,transform:"translate("+O+"px, "+E+"px)",...E2(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:E}},[n,l,I.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:B,refs:M,elements:I,floatingStyles:z}),[p,B,M,I,z])}const vie=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?zC({element:r.current,padding:s}).fn(n):{}:r?zC({element:r,padding:s}).fn(n):{}}}},WC=(e,t)=>{const n=hie(e);return{name:n.name,fn:n.fn,options:[e,t]}},kie=(e,t)=>{const n=gie(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sie=(e,t)=>{const n=yie(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nie=(e,t)=>{const n=mie(e);return{name:n.name,fn:n.fn,options:[e,t]}},jie=(e,t)=>{const n=vie(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cie={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},Eie={beaconOptions:{offset:-18}},_2={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},_ie={isFixed:!1,locale:_2,placement:"bottom"},Pie={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},qt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},Lr={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Ge={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Po={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Ht={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Aie="react-joyride-portal";function Iie(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function Pu(...e){return vse({all:!0,isMergeableObject:t=>!(!cs.plainObject(t)||m.isValidElement(t))})(...e)}function P2(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function oa(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=pw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&P2(e.type)==="function")try{o=oa(e.type({}),t)}catch{o=pw(n)}else o=pw(n);return o}function Dr(e,t,n,...r){if(!e)return;const s=new Date,o=`${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 ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Tie(e,t){const n=Iie(t);return{...e,...n}}function Ep(){}function Rie(e){return Object.keys(e)}function Yg(e,...t){if(!cs.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 VC(e,...t){if(!cs.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 mv(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(P2(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(cs.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):mv(o,t,n))});if(cs.function(e.type)&&!Object.values(e.props).length)try{return mv(e.type({}),t,n)}catch{return e}return e}function KC(e){return Rie(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function yk(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function UC(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 xk(e){return e?e.getBoundingClientRect():null}function Mie(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((o,a)=>o-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 ki(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 Lie(e,t,n){const r=xk(e),s=bd(e),o=s?!s.isSameNode(zs()):!1,a=n??vd(e);let l=0,u=(r==null?void 0:r.top)??0;return o&&a?u=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!o&&!a&&(u+=l),s.isSameNode(zs())||(u+=zs().scrollTop)),Math.floor(u-t)}function bd(e,t){if(!e)return zs();const n=m2(e);if(n){if(n.isSameNode(zs()))return t?document:zs();if(!(n.scrollHeight>n.offsetHeight))return zs()}return n}function Oie(e){const t=e.getBoundingClientRect(),n=zs(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function $ie(e,t){if(!e)return 0;const n=m2(e)??zs(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=xk(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let u=e.getBoundingClientRect().top+l;if(a&&(A2(e)||Die(e))){const p=e.getBoundingClientRect(),c=p.top-((s==null?void 0:s.top)??0),f=c+p.height,h=n.clientHeight,g=h*.2;c>=g&&f<=h-g?u=o:u=c+o}const d=Math.floor(u-t-r);return d<0?0:d}function Die(e){return e.offsetParent!==document.body}function A2(e){if(!e)return!1;const t=bd(e);return t?!t.isSameNode(zs()):!1}function vd(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?vd(e.parentNode,t):!1}function dm(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 qC(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Ge.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?bd(s):zs(),l=a?!a.isSameNode(zs()):!1;return(r.isFixed||vd(s))&&!l?!1:a.scrollHeight>a.clientHeight}function zs(){return document.scrollingElement??document.documentElement}function YC(e,t){const{duration:n,element:r}=t;let s=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,u=e>l?e-l:l-e;s=_se.top(r,e,{duration:u<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function Fie(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,o,a)=>s+s+o+o+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 I2={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},fm={...I2,borderRadius:4,padding:8};function zie(e,t){const{styles:n}=e,r=Pu(n??{},t.styles??{});let{width:s}=t;yk()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const o={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return Pu({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...I2,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(${Fie(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:{...fm,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...fm,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...fm,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...fm,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:{...o,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 Hie=["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 wk(e,t){if(!t)return null;const n=Pu(_ie,VC(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=Pu(Cie,e.options??{},VC(t,...Hie)),s=zie(e,{...n,...r}),o=Pu(Eie,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:Pu(_2,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Bie(r.spotlightPadding),styles:s}}function Bie(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 Wie(e,t,n){const{action:r}=t,s=n&&[qt.PREV,qt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function T2(e,t=!1){return cs.plainObject(e)?e.target?!0:(Dr(t,"tour","target is missing from the step"),!1):(Dr(t,"tour","step must be an object"),!1)}function R2(e,t=!1){return cs.array(e)?e.every(n=>T2(n,t)):(Dr(t,"tour","steps must be an array"),!1)}var Vie=class{constructor(e){or(this,"beaconPosition",null);or(this,"debug");or(this,"eventListeners",new Map);or(this,"listeners",new Set);or(this,"props");or(this,"snapshot");or(this,"state");or(this,"steps");or(this,"tooltipPosition",null);or(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});or(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);or(this,"getServerSnapshot",()=>this.snapshot);or(this,"getSnapshot",()=>this.snapshot);or(this,"getEventState",()=>Yg(this.snapshot,"positioned"));or(this,"getState",()=>Yg(this.snapshot,"positioned"));or(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Dr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Ge.BEACON_BEFORE||this.state.lifecycle===Ge.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});or(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});or(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});or(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)}});or(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));or(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,o=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:o,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,!lk(s,l)){this.snapshot=Object.freeze({...l});for(const u of this.listeners)u(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},s=cs.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,cs.number(t)&&Dr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):cs.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&Dr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:qt.INIT,controlled:s,index:o,lifecycle:Ge.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Ht.READY:Ht.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Ht.WAITING&&e.size>0?{...e,status:Ht.RUNNING}:e}getStep(e){return wk(this.props,this.steps[e??this.state.index])}};function Kie(e){return new Vie(e)}function GC(e,t){return Math.min(Math.max(e,0),t)}function Uie(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(k=null)=>{const{index:y,status:w}=o();w===Ht.RUNNING&&e.current.updateState({action:qt.CLOSE,index:y+1,origin:k,lifecycle:Ge.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:k=>{const{controlled:y,size:w,status:x}=o();if(y){Dr(r.current,"tour","go() is not supported in controlled mode");return}x===Ht.RUNNING&&e.current.updateState({action:qt.GO,index:k,lifecycle:Ge.COMPLETE,positioned:!1,scrolling:!1,status:k<w?x:Ht.FINISHED,waiting:!1})},info:()=>Yg(e.current.getSnapshot(),"positioned"),next:k=>{const{index:y,size:w,status:x}=o();x===Ht.RUNNING&&e.current.updateState({action:qt.NEXT,index:GC(y+1,w),lifecycle:Ge.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:k}=o();k===Ht.RUNNING&&e.current.updateState({action:qt.UPDATE,lifecycle:Ge.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:k=>{const{index:y,size:w,status:x}=o();x===Ht.RUNNING&&e.current.updateState({action:qt.PREV,index:GC(y-1,w),lifecycle:Ge.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},reset:(k=!1)=>{const{controlled:y}=o();if(y){Dr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:qt.RESET,index:0,lifecycle:Ge.INIT,positioned:!1,scrolling:!1,status:k?Ht.RUNNING:Ht.READY,waiting:!1})},skip:k=>{const{status:y}=o();y===Ht.RUNNING&&e.current.updateState({action:qt.SKIP,lifecycle:Ge.COMPLETE,origin:k,positioned:!1,scrolling:!1,status:Ht.SKIPPED,waiting:!1})},start:k=>{const{index:y,size:w}=o();s.current(),e.current.updateState({action:qt.START,index:cs.number(k)?k:y,lifecycle:Ge.INIT,positioned:!1,scrolling:!1,status:w?Ht.RUNNING:Ht.WAITING,waiting:!1},!0)},stop:(k=!1)=>{const{index:y,status:w}=o();[Ht.FINISHED,Ht.SKIPPED].includes(w)||e.current.updateState({action:qt.STOP,index:y+(k?1:0),lifecycle:Ge.COMPLETE,positioned:!1,scrolling:!1,status:Ht.PAUSED,waiting:!1})}}},[e])}const qie=new Set(["origin","positioned"]);function Yie(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Dr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const o=n.current;if(n.current=s,!o)return;const a={};let l=!1;for(const u of Object.keys(s))s[u]!==o[u]&&!qie.has(u)&&(a[u]={from:o[u],to:s[u]},(u==="status"||u==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||Dr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Gie(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.useCallback((o,a,l)=>{var d;const u={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(d=r.current)==null||d.call(r,u,s.current),n.current.dispatch(u,s.current)},[n])}function Ga(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],o=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(o):s===r&&o!==r},previous:t}}function Xie(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:u}=e,{action:d,index:p,lifecycle:c,positioned:f,scrolling:h,size:g,status:b}=a,k=a2(l)??null,y=m.useRef(null),w=m.useRef(o),x=m.useRef(a),N=m.useRef(s),_=m.useRef(l),C=m.useRef(k),T=m.useRef(n),F=m.useRef(null),R=m.useRef(null),H=m.useRef(null);w.current=o,x.current=a,N.current=s,_.current=l,C.current=k,T.current=n;const D=()=>{F.current&&(clearInterval(F.current),F.current=null),R.current=null,H.current&&(H.current.cancel(),H.current=null)};m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:$}=Ga(x.current,N.current);($("action",[qt.NEXT,qt.PREV,qt.SKIP,qt.CLOSE])||y.current===qt.CLOSE&&d===qt.START)&&(y.current=d)},[d]),m.useEffect(()=>{if(!N.current)return()=>{D()};const{hasChanged:$}=Ga(x.current,N.current),B=_.current;if($("index")&&D(),b!==Ht.RUNNING||!B||c!==Ge.INIT)return()=>{D()};const{hasChangedTo:L}=Ga(x.current,N.current);L("status",Ht.RUNNING)&&[Ht.IDLE,Ht.READY,Ht.PAUSED].includes(N.current.status)&&r(Lr.TOUR_START,B),u.current.cleanupPositionData();const{debug:M}=w.current;if(B.before&&!H.current){Dr(M,`step:${p}`,"before()",B),H.current={cancel:()=>{}},u.current.updateState({waiting:!0}),r(Lr.STEP_BEFORE_HOOK,B,{action:y.current??x.current.action});const I=()=>{H.current=null,u.current.updateState({action:y.current??x.current.action,waiting:!1,lifecycle:Ge.READY})},z=new AbortController,A=B.beforeTimeout;H.current={cancel:()=>z.abort()};const O=A?setTimeout(()=>{z.signal.aborted||(Dr(M,`step:${p}`,"before()","timed out",`${A}ms`),z.abort(),t(B,"before_hook"),r(Lr.ERROR,B,{error:new Error("Step before hook timed out")}),I())},A):null;B.before({...u.current.getState(),action:y.current??u.current.getState().action,step:B}).then(()=>{z.signal.aborted||(O&&clearTimeout(O),I())}).catch(E=>{z.signal.aborted||(O&&clearTimeout(O),t(B,"before_hook"),r(Lr.ERROR,B,{error:E instanceof Error?E:new Error(String(E))}),I())})}else if(!H.current){F.current&&R.current!==B.target&&D();const I=ki(B.target);if(I&&dm(I))D(),u.current.updateState({action:y.current??qt.UPDATE,lifecycle:Ge.READY,waiting:!1});else if(B.targetWaitTimeout===0)u.current.updateState({action:y.current??qt.UPDATE,lifecycle:Ge.READY,waiting:!1});else if(!F.current){const{targetWaitTimeout:z}=B,A=Date.now();R.current=B.target,Dr(M,`step:${p}`,"polling","started",`${z}ms`),u.current.updateState({waiting:!0}),F.current=setInterval(()=>{const O=ki(B.target),E=Date.now()-A,J=E>=z;(O&&dm(O)||J)&&(Dr(M,`step:${p}`,"polling",O&&dm(O)?"found":"timed out",`${E}ms`),D(),u.current.updateState({action:y.current??qt.UPDATE,lifecycle:Ge.READY,waiting:!1}))},100)}}return()=>{D()}},[t,r,p,c,b,u]),m.useEffect(()=>{if(!N.current)return;const{hasChanged:$,hasChangedTo:B,previous:L}=Ga(x.current,N.current),M=_.current;if(!M)return;const I=ki(M.target),z=!!I;if(z&&dm(I)){if(B("lifecycle",Ge.READY)&&L.lifecycle===Ge.INIT&&r(Lr.STEP_BEFORE,M,{action:y.current??x.current.action}),B("lifecycle",Ge.READY)){const A=x.current,O=Wie(M,A,w.current.continuous)?Ge.TOOLTIP:Ge.BEACON,E=ki(M.scrollTarget??M.spotlightTarget??M.target),J=qC({isFirstStep:A.index===0,scrollToFirstStep:w.current.scrollToFirstStep,step:M,target:E,targetLifecycle:O}),Z=O===Ge.TOOLTIP?Ge.TOOLTIP_BEFORE:Ge.BEACON_BEFORE;Dr(w.current.debug,`step:${p}`,"scroll",J?"needed":"skipped"),u.current.updateState({action:qt.UPDATE,lifecycle:Z,scrolling:J})}}else if(x.current.status===Ht.RUNNING&&c!==Ge.INIT&&c!==Ge.COMPLETE&&$("lifecycle")){Dr(w.current.debug,`step:${p}`,z?"Target not visible":"Target not mounted",M),t(M,"target_not_found"),r(Lr.TARGET_NOT_FOUND,M);const A=x.current;A.controlled||u.current.updateState({action:qt.UPDATE,index:A.index+(A.action===qt.PREV?-1:1),lifecycle:Ge.INIT})}},[t,r,p,c,u]),m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:$,previous:B}=Ga(x.current,N.current),L=_.current,M=C.current;if(L&&$("lifecycle",Ge.TOOLTIP_BEFORE)&&B.lifecycle===Ge.BEACON){const A=ki(L.scrollTarget??L.spotlightTarget??L.target);if(qC({isFirstStep:x.current.index===0,scrollToFirstStep:w.current.scrollToFirstStep,step:L,target:A,targetLifecycle:Ge.TOOLTIP})){u.current.updateState({scrolling:!0,positioned:!1});return}}const I=c===Ge.BEACON_BEFORE||c===Ge.TOOLTIP_BEFORE;if(L&&I&&!h){const A=c===Ge.TOOLTIP_BEFORE?Ge.TOOLTIP:Ge.BEACON;u.current.updateState({action:qt.UPDATE,lifecycle:A})}L&&$("lifecycle",Ge.BEACON)&&r(Lr.BEACON,L),L&&$("lifecycle",Ge.TOOLTIP)&&r(Lr.TOOLTIP,L);const z=x.current;if((z.status===Ht.RUNNING||z.controlled&&z.status===Ht.PAUSED&&L)&&M&&$("lifecycle",Ge.COMPLETE)&&B.lifecycle===Ge.TOOLTIP&&(r(Lr.STEP_AFTER,M,{action:y.current??qt.UPDATE,index:B.index??z.index,lifecycle:z.lifecycle}),M.after)){r(Lr.STEP_AFTER_HOOK,M,{action:y.current??qt.UPDATE,index:B.index??z.index,lifecycle:z.lifecycle});try{M.after({...u.current.getState(),action:y.current??qt.UPDATE,index:B.index??z.index,lifecycle:z.lifecycle,step:M})}catch{}}},[r,c,f,h,u]),m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:$,previous:B}=Ga(x.current,N.current),L=_.current,M=C.current;g&&!L&&c===Ge.INIT&&u.current.updateState({action:qt.UPDATE,lifecycle:Ge.COMPLETE,status:Ht.FINISHED}),!x.current.controlled&&b===Ht.RUNNING&&$("lifecycle",Ge.COMPLETE)&&p<g&&u.current.updateState({action:qt.UPDATE,lifecycle:Ge.INIT}),$("lifecycle",Ge.COMPLETE)&&p>=g&&u.current.updateState({action:qt.UPDATE,lifecycle:Ge.COMPLETE,status:Ht.FINISHED});const I=L??M??wk(w.current,w.current.steps[p-1]);if(I&&$("status",[Ht.FINISHED,Ht.SKIPPED])){let z;L?z=p:M?z=B.index??p:z=p-1,r(Lr.TOUR_END,I,{index:z}),x.current.controlled||T.current.reset(),y.current=null}L&&$("action",qt.STOP)&&(y.current=null,r(Lr.TOUR_STATUS,L)),L&&$("action",qt.RESET)&&(r(Lr.TOUR_STATUS,L),y.current=null)},[d,r,p,c,g,b,u])}function Jie({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:u,steps:d}=n,p=m.useRef(void 0),c=m.useRef(r),f=m.useRef(e);c.current=r,f.current=e,m.useEffect(()=>{const h=p.current;if(p.current=n,!h||n===h)return;const{hasChanged:g}=Ga(n,h);if(lk(h.steps,d)||(R2(d,o)?s.current.setSteps(d):(Dr(o,"tour","Steps are not valid",d),t(Lr.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&f.current.start(u??a):f.current.stop();else if(cs.number(u)&&g("stepIndex")){const b=cs.number(h.stepIndex)&&h.stepIndex<u?qt.NEXT:qt.PREV;[Ht.FINISHED,Ht.SKIPPED].includes(c.current.status)||s.current.updateState({action:b,index:u,lifecycle:Ge.INIT,positioned:!1},!0)}},[o,t,a,n,l,u,d,s])}function Qie(e,t){var l,u,d,p;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Ge.BEACON_BEFORE&&(n!=null&&n.placement)){const c=Zie(n);["bottom"].includes(n.placement)||(a+=Math.floor(c-s))}else if(r===Ge.TOOLTIP_BEFORE){const{placement:c}=o;if(c==="top"){const f=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(u=o.floatingOptions)!=null&&u.hideArrow?0:o.arrowSize,g=o.offset+o.spotlightPadding.top+h;a-=f+g}else if(c==="left"||c==="right"){const f=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,h=((p=ki(o.target))==null?void 0:p.getBoundingClientRect().height)??0,g=s+o.spotlightPadding.top+h/2-f/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Zie(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 eoe({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:u,scrolling:d,status:p}=r,c=m.useRef(null),f=m.useRef(r),h=m.useRef(t),g=m.useRef(n),b=m.useRef(s);f.current=r,h.current=t,g.current=n,b.current=s,m.useEffect(()=>()=>{var k;(k=c.current)==null||k.call(c)},[]),m.useEffect(()=>{var _;if(!h.current||!b.current)return;const{hasChangedTo:k}=Ga(f.current,h.current),y=b.current,{debug:w}=g.current,{scrollDuration:x}=y,N=l===Ge.BEACON_BEFORE||l===Ge.TOOLTIP_BEFORE;if(p===Ht.RUNNING&&N&&d&&k("positioned",!0)){const C=ki(y.scrollTarget??y.spotlightTarget??y.target),T=o.current.getPositionData("beacon"),F=bd(C),R=F?!F.isSameNode(zs()):!1;(_=c.current)==null||_.call(c),(async()=>{if(R&&!vd(F)){const z=zs(),A=Oie(F),O={initial:z.scrollTop,target:A,element:z,duration:x};e(Lr.SCROLL_START,y,{scroll:O});const{cancel:E,promise:J}=YC(A,{element:z,duration:x});c.current=E,await J,e(Lr.SCROLL_END,y,{scroll:O})}const D=Math.floor($ie(C,y.scrollOffset))||0,$=R?D:Qie(D,{beaconPosition:T,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Dr(w,`step:${a}`,"scroll",R?"custom":"document",`${D} → ${$}`);const B=F,L={initial:B.scrollTop,target:$,element:B,duration:x};e(Lr.SCROLL_START,y,{scroll:L});const{cancel:M,promise:I}=YC($,{element:B,duration:x});c.current=M,await I,e(Lr.SCROLL_END,y,{scroll:L}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,u,d,p,o])}function toe(e){const t=$re(()=>Tie(Pie,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,u=m.useRef(Kie(t)),d=VA.useSyncExternalStore(u.current.subscribe,u.current.getSnapshot,u.current.getServerSnapshot),[p,c]=m.useState([]),f=m.useCallback((_,C)=>{c(T=>[...T,{reason:C,step:_}])},[]),h=m.useCallback(()=>{c([])},[]);Yie(u,n);const g=Uie(u,n,h),b=Gie(s,g,u),{index:k,size:y,status:w}=d,x=a2(d),N=m.useMemo(()=>wk(t,l[k]),[k,t,l]);return Dre(()=>{o&&y&&R2(l,n)&&g.start(a??r)}),Ore(()=>{o&&y&&w===Ht.IDLE&&u.current.updateState({status:Ht.READY})},[o,y,w]),Jie({controls:g,emitEvent:b,props:t,state:d,store:u}),Xie({addFailure:f,controls:g,emitEvent:b,previousState:x,props:t,state:d,step:N,store:u}),eoe({emitEvent:b,previousState:x,props:t,state:d,step:N,store:u}),{controls:g,failures:p,mergedProps:t,state:d,step:N,store:u}}function noe(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(cs.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=Aie,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const roe={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function soe({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Ep;const u=document.createElement("style");return u.id="joyride-loader-animation",e&&u.setAttribute("nonce",e),u.appendChild(document.createTextNode(`
267
- @keyframes joyride-loader-spin {
268
- to { transform: rotate(360deg); }
269
- }
270
- `)),document.head.appendChild(u),()=>{const d=document.getElementById("joyride-loader-animation");d!=null&&d.parentNode&&d.parentNode.removeChild(d)}},[r,e]),n===null)return null;const{height:s,width:o,...a}=t.styles.loader;let l;if(n){const u=n;l=ht.createElement(u,{step:t})}else l=ht.createElement("div",{style:{...roe,height:s,width:o,borderTopColor:t.primaryColor}});return ht.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const ioe={height:0,isFixed:!1,left:0,top:0,width:0};function df(e,t){const n=ki(e);if(!n)return ioe;const r=xk(n),s=vd(n),o=Lie(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:o,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function ooe(e,t,n){const[r,s]=m.useState(()=>df(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),u=m.useRef(null),d=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(c=>{const f=df(e,t);return c.top===f.top&&c.left===f.left&&c.width===f.width&&c.height===f.height&&c.isFixed===f.isFixed?c:f})},100)},[e,t]);m.useEffect(()=>{let c=null;const f=g=>{a.current=bd(g,!0),a.current&&a.current.addEventListener("scroll",d,{passive:!0}),window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),typeof ResizeObserver<"u"&&(u.current=new ResizeObserver(d),u.current.observe(g)),s(df(e,t))},h=ki(e);return h?f(h):(c=new MutationObserver(()=>{const g=ki(e);g&&(c==null||c.disconnect(),c=null,f(g))}),c.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;c==null||c.disconnect(),a.current&&a.current.removeEventListener("scroll",d),window.removeEventListener("scroll",d),window.removeEventListener("resize",d),(g=u.current)==null||g.disconnect(),clearTimeout(o.current)}},[e,t,d]),m.useEffect(()=>{l.current&&!n&&s(df(e,t)),l.current=n},[n,e,t]);let p=r;return l.current&&!n&&(p=df(e,t)),p}function aoe(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function XC(e,t,n,r,s){if(n<=0||r<=0)return"";const o=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+o} ${t}`;return a+=`H${e+n-o}`,a+=`A${o} ${o} 0 0 1 ${e+n} ${t+o}`,a+=`V${t+r-o}`,a+=`A${o} ${o} 0 0 1 ${e+n-o} ${t+r}`,a+=`H${e+o}`,a+=`A${o} ${o} 0 0 1 ${e} ${t+r-o}`,a+=`V${t+o}`,a+=`A${o} ${o} 0 0 1 ${e+o} ${t}Z`,a}const loe=[Ge.BEACON_BEFORE,Ge.BEACON];function coe(e){var I,z;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:u,scrolling:d,spotlightPadding:p,spotlightRadius:c,spotlightTarget:f,styles:h,target:g,waiting:b}=e,k=Fre(),y=ooe(f??g,p,d||b),w=m.useRef(null),x=(s===Ge.TOOLTIP||s===Ge.TOOLTIP_BEFORE)&&l!=="center",[N,_]=m.useState(!1),C=u?(I=w.current)==null?void 0:I.offsetParent:null,T=(C==null?void 0:C.clientWidth)??k.width,F=(C==null?void 0:C.clientHeight)??Mie()??k.height,R=((z=h.overlay)==null?void 0:z.backgroundColor)??"rgba(0, 0, 0, 0.5)",H=m.useMemo(()=>{const{backgroundColor:A,mixBlendMode:O,...E}=h.overlay;return{height:F,pointerEvents:"none",...E}},[F,h.overlay]),D=x&&!d&&!b;m.useEffect(()=>{D?requestAnimationFrame(()=>_(!0)):_(!1)},[D]);const $=n&&loe.includes(s),B=!n&&s!==Ge.TOOLTIP;if(r||!b&&($||B))return null;let L="";if(D)if(u&&C){const A=ki(f??g);if(A){const O=UC(A),E=UC(C);L=XC(O.left-E.left-p.left,O.top-E.top-p.top,A.offsetWidth+p.left+p.right,A.offsetHeight+p.top+p.bottom,c)}}else L=XC(y.left,y.top,y.width,y.height,c);const M=aoe(T,F,L);return ht.createElement("div",{ref:w,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:H},ht.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:F,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:T}},ht.createElement("path",{d:M,fill:R,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),L&&ht.createElement("path",{d:L,fill:R,style:{opacity:N?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),L&&Object.keys(h.spotlight).length>0&&ht.createElement("path",{d:L,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function M2(e){const{children:t,element:n}=e;return n?$r.createPortal(t,n):null}const uoe='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function doe(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return Ep;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(uoe)],{shiftKey:l}=o;if(!a.length)return;o.preventDefault();let u=document.activeElement?a.indexOf(document.activeElement):0;u===-1||!l&&u+1===a.length?u=0:l&&u===0?u=a.length-1:u+=l?-1:1,a[u].focus()};e.addEventListener("keydown",r,!1);let s;{const o=e.querySelector(t);o&&(s=setTimeout(()=>{o.focus({preventScroll:!0})},100))}return()=>{var o;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(o=n.current)==null||o.focus({preventScroll:!0})}},[e,t])}function da(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 foe(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...da(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...da(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...da(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...da(e,t,n)};default:return null}}function poe(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...da(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...da(e,r,n)};case"left":return{right:-n,top:t.y??0,...da(e,r,n)};case"right":return{left:-n,top:t.y??0,...da(e,r,n)};default:return{}}}function hoe({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let u=null;if(l){if(!da(r,n,o))return null;u=ht.createElement("span",{style:{flexShrink:0}},ht.createElement(l,{base:n,placement:r,size:o}))}else{const d=foe(r,n,o);if(!d)return null;u=ht.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},ht.createElement("polygon",{fill:"currentColor",points:d.points}))}return ht.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...poe(r,s,o,n),...s?{}:{visibility:"hidden"}}},u)}function moe(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:u,size:d,step:p,styles:c}=e,f=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return Ep;const k=document.createElement("style");k.id="joyride-beacon-animation",a&&k.setAttribute("nonce",a),k.appendChild(document.createTextNode(`
271
- @keyframes joyride-beacon-inner {
272
- 20% {
273
- opacity: 0.9;
274
- }
275
-
276
- 90% {
277
- opacity: 0.7;
278
- }
279
- }
280
-
281
- @keyframes joyride-beacon-outer {
282
- 0% {
283
- transform: scale(1);
284
- }
285
-
286
- 45% {
287
- opacity: 0.7;
288
- transform: scale(0.75);
289
- }
290
-
291
- 100% {
292
- opacity: 0.9;
293
- transform: scale(1);
294
- }
295
- }
296
- `)),document.head.appendChild(k);const y=setTimeout(()=>{cs.domElement(f.current)&&u&&f.current.focus()},0);return()=>{clearTimeout(y);const w=document.getElementById("joyride-beacon-animation");w!=null&&w.parentNode&&w.parentNode.removeChild(w)}},[h,a,u]);const g=oa(o.open);let b;if(t){const k=t;b=ht.createElement(k,{continuous:n,index:r,isLastStep:s,size:d,step:p})}else b=ht.createElement("span",{style:c.beacon},ht.createElement("span",{style:c.beaconOuter}),ht.createElement("span",{style:c.beaconInner}));return ht.createElement("button",{ref:f,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:c.beaconWrapper,title:g,type:"button"},b)}function goe({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return ht.createElement("button",{style:o,type:"button",...t},ht.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"},ht.createElement("g",null,ht.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 yoe(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:u}=e,{buttons:d,content:p,styles:c,title:f}=l,h={};d.includes("primary")&&(h.primary=ht.createElement("button",{"data-testid":"button-primary",style:c.buttonPrimary,type:"button",...o})),d.includes("skip")&&!s&&(h.skip=ht.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:c.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(h.back=ht.createElement("button",{"data-testid":"button-back",style:c.buttonBack,type:"button",...t})),h.close=d.includes("close")&&ht.createElement(goe,{"data-testid":"button-close",styles:c.buttonClose,...n});const g=f?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":oa(p),"aria-describedby":"joyride-tooltip-content"};return ht.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:c.tooltip,...u,...g},ht.createElement("div",{style:c.tooltipContainer},f&&ht.createElement("h4",{id:"joyride-tooltip-title",style:c.tooltipTitle},f),ht.createElement("div",{id:"joyride-tooltip-content",style:c.tooltipContent},p)),d.some(b=>b==="back"||b==="primary"||b==="skip")&&ht.createElement("div",{style:c.tooltipFooter},ht.createElement("div",{style:c.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function xoe(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=y=>{y.preventDefault(),n.prev(Po.BUTTON_BACK)},u=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(Po.BUTTON_CLOSE):n.close(Po.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(Po.BUTTON_PRIMARY);return}n.next(Po.BUTTON_PRIMARY)},p=y=>{y.preventDefault(),n.skip(Po.BUTTON_SKIP)},c=()=>{const{back:y,close:w,last:x,next:N,nextWithProgress:_,skip:C}=a.locale,T=oa(y),F=oa(w),R=oa(x),H=oa(N),D=oa(C);let $=w,B=F;if(t){if($=N,B=H,a.showProgress&&!s){const L=oa(_,{step:r+1,steps:o});$=mv(_,r+1,o),B=L}s&&($=x,B=R)}return{backProps:{"aria-label":T,children:y,"data-action":"back",onClick:l,role:"button",title:T},closeProps:{"aria-label":F,children:w,"data-action":"close",onClick:u,role:"button",title:F},primaryProps:{"aria-label":B,children:$,"data-action":"primary",onClick:d,role:"button",title:B},skipProps:{"aria-label":D,children:C,"data-action":"skip",onClick:p,role:"button",title:D},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:f,beaconComponent:h,tooltipComponent:g,...b}=a;let k;if(g){const y=g;k=ht.createElement(y,{...c(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:b})}else k=ht.createElement(yoe,{...c(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:b});return k}function woe(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function boe(e,t,n){var r,s;return e?[Nie()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Sie({crossAxis:!1,fallbackPlacements:woe(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function voe(e){var O,E,J,Z,K;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:u,setTooltipRef:d,shouldScroll:p,size:c,step:f,target:h,updateState:g}=e,b=m.useRef(null),k=m.useRef({}),y=m.useRef({}),w=f.placement==="center",x=f.placement==="auto",N=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})}),[]),_=m.useMemo(()=>A2(h)?bd(h):void 0,[h]),C=m.useMemo(()=>vd(h),[h]),T=m.useMemo(()=>_?{boundary:_,rootBoundary:"viewport"}:{},[_]),F=w||x?"bottom":f.placement,R=w?"fixed":((O=f.floatingOptions)==null?void 0:O.strategy)??(f.isFixed||C?"fixed":"absolute"),H=m.useMemo(()=>{var oe,de,he,we;return w?[{name:"center",fn:({rects:ue})=>({x:(window.innerWidth-ue.floating.width)/2,y:(window.innerHeight-ue.floating.height)/2})}]:[WC(({placement:ue})=>{var ce;let Ne="right";ue.startsWith("top")?Ne="top":ue.startsWith("bottom")?Ne="bottom":ue.startsWith("left")&&(Ne="left");const le=f.spotlightTarget?0:f.spotlightPadding[Ne];return f.offset+le+((ce=f.floatingOptions)!=null&&ce.hideArrow?0:f.arrowSize)},[f.offset,f.spotlightPadding,f.spotlightTarget,f.arrowSize,(oe=f.floatingOptions)==null?void 0:oe.hideArrow]),...boe(x,f,F),kie({padding:10,...T,...(de=f.floatingOptions)==null?void 0:de.shiftOptions}),...(he=f.floatingOptions)!=null&&he.hideArrow?[]:[jie({element:b,padding:f.arrowSpacing},[f.arrowSpacing,f.arrowBase])],...((we=f.floatingOptions)==null?void 0:we.middleware)??[]]},[w,f,x,F,T]),D=BC({...w?{elements:{reference:N}}:{},placement:F,strategy:R,middleware:H}),$=BC({strategy:R,placement:f.beaconPlacement??(x||w?"bottom":f.placement),middleware:m.useMemo(()=>{var oe,de;return[WC(((de=(oe=f.floatingOptions)==null?void 0:oe.beaconOptions)==null?void 0:de.offset)??-18)]},[(J=(E=f.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:J.offset]),whileElementsMounted:FC});y.current=D.middlewareData,k.current=$.middlewareData,m.useEffect(()=>{var he;const{floating:oe,reference:de}=D.elements;if(!(!de||!oe||s!==Ge.TOOLTIP))return FC(de,oe,D.update,(he=f.floatingOptions)==null?void 0:he.autoUpdate)},[s,D.update,(Z=f.floatingOptions)==null?void 0:Z.autoUpdate,f.target,D.elements]),m.useEffect(()=>{!w&&h&&D.refs.setReference(h),h&&$.refs.setReference(h)},[$.refs,w,h,D.refs]),m.useEffect(()=>{D.isPositioned&&u("tooltip",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:y.current})},[u,D.isPositioned,D.placement,D.x,D.y]),m.useEffect(()=>{$.isPositioned&&u("beacon",{placement:$.placement,x:$.x??0,y:$.y??0,middlewareData:k.current})},[u,$.isPositioned,$.placement,$.x,$.y]);const B=f.zIndex+100,L=m.useCallback(oe=>{oe.type==="mouseenter"&&f.beaconTrigger!=="hover"||g({lifecycle:Ge.TOOLTIP_BEFORE,positioned:!1})},[f.beaconTrigger,g]),M=m.useCallback(oe=>{oe&&(D.refs.setFloating(oe),d(oe))},[D.refs,d]),{arrow:I,floater:z}=f.styles;let A=null;if(s===Ge.TOOLTIP||s===Ge.TOOLTIP_BEFORE){const oe=KC({...z,...D.floatingStyles,zIndex:B,opacity:a&&D.isPositioned?1:0,...!a&&{transition:"none"}});A=ht.createElement("div",{ref:M,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:oe},ht.createElement(xoe,{continuous:t,controls:n,index:r,isLastStep:r+1===c,size:c,step:f}),!w&&!((K=f.floatingOptions)!=null&&K.hideArrow)&&ht.createElement(hoe,{arrowComponent:f.arrowComponent,arrowRef:b,base:f.arrowBase,placement:D.placement,position:D.middlewareData.arrow,size:f.arrowSize,styles:I}))}else(s===Ge.BEACON||s===Ge.BEACON_BEFORE)&&(A=ht.createElement("div",{ref:$.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:KC({...$.floatingStyles,zIndex:B})},ht.createElement(moe,{beaconComponent:f.beaconComponent,continuous:t,index:r,isLastStep:r+1===c,locale:f.locale,nonce:o,onInteract:L,shouldFocus:p,size:c,step:f,styles:f.styles})));return ht.createElement(M2,{element:l},A)}function koe(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:u,size:d,step:p,updateState:c}=e,[f,h]=m.useState(null);doe(p.disableFocusTrap?null:f,"[data-action=primary]");const g=ki(p.target),b=s===Ge.TOOLTIP;return!T2(p)||!cs.domElement(g)?null:ht.createElement(voe,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:b,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:u,size:d,step:p,target:g,updateState:c})}function Soe({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:u,scrollToFirstStep:d}=t,p=noe(u),{index:c,lifecycle:f,status:h}=n,g=h===Ht.RUNNING,[b,k]=m.useState(!1),y=m.useRef(null),w=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?w===0?k(!0):y.current=setTimeout(()=>{k(!0)},w):k(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[w,n.waiting]),m.useEffect(()=>{if(!g)return;const _=C=>{!r||f!==Ge.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Po.KEYBOARD):e.close(Po.KEYBOARD))};return document.body.addEventListener("keydown",_,{passive:!0}),()=>{document.body.removeEventListener("keydown",_)}},[e,g,f,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Po.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Po.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const N=n.action===qt.START&&!r.skipBeacon&&r.placement!=="center";return ht.createElement(ht.Fragment,null,f!==Ge.INIT&&ht.createElement(koe,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(c!==0||d),step:r,updateState:s.current.updateState}),ht.createElement(M2,{element:p},ht.createElement(ht.Fragment,null,b&&ht.createElement(soe,{nonce:l,step:r}),!N&&ht.createElement(coe,{...r,continuous:o,lifecycle:f,onClickOverlay:x,portalElement:u?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Noe(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=toe(e);return{controls:t,failures:n,on:m.useCallback((l,u)=>a.current.on(l,u),[a]),state:m.useMemo(()=>Yg(s,"positioned"),[s]),step:o,Tour:yk()?ht.createElement(Soe,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function joe(e){const{Tour:t}=Noe(e);return t}function Coe(e){return yk()?ht.createElement(joe,e):null}function Eoe(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 _oe(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Poe(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const yw="af:onboarding";function Aoe({page:e,hasNodes:t=!1}){const{t:n}=Tn(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),u=m.useMemo(()=>e==="projects"?Eoe(n):t?_oe(n):Poe(n),[e,t,n]);return m.useEffect(()=>{const d=localStorage.getItem(yw);console.log("[Onboarding] localStorage:",d);const p=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",p,"page:",e),p.completed||p[e]){console.log("[Onboarding] skipped - already done"),s(!1),a([]);return}console.log("[Onboarding] starting with steps:",u),a(u),s(!0)},[e,t,u]),m.useEffect(()=>{if(!r)return;const d=p=>{var g;const c=p.target.closest("button");if(!c||!c.closest(".react-joyride__tooltip"))return;const h=(g=c.textContent)==null?void 0:g.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const b=localStorage.getItem(yw)||"{}",k=JSON.parse(b);h===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(yw,JSON.stringify(k)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const y=document.querySelector(".af-create-btn");y&&y.click()},500))}};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(Coe,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.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 Ioe(){const{navigate:e,path:t}=Bo(),[n,r]=m.useState([]),[s,o]=m.useState(!1);if(m.useEffect(()=>{let p=!1;const c=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(k=>k&&k.status==="running"))}catch{}};c();const f=window.setInterval(c,3e3);return()=>{p=!0,window.clearInterval(f)}},[]),n.length===0)return null;const a=p=>{const c=new URLSearchParams({flowId:p.flowId,flowSource:p.flowSource||"workspace"});e(`/flow?${c.toString()}`),o(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,u=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return i.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&i.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:n.map(p=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(p.flowId===u?" af-run-indicator__item--current":""),onClick:()=>a(p),title:`${p.flowId} · ${p.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:p.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:p.runId.slice(0,12)})]},`${p.flowId}:${p.runId}`))}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):o(p=>!p),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}function L2(e){return e==="/likee-context"||e==="/likee_context"}class Toe 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,o;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(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function Roe({authUser:e}){const{path:t}=Bo();return t==="/projects"||t==="/"?i.jsx(nu,{authUser:e}):t==="/nodes"?i.jsx(nu,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(nu,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(nu,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(nu,{authUser:e,resourceKind:"skills"}):t==="/mcps"?i.jsx(hre,{}):t==="/flow"?i.jsx(sq,{}):t==="/workspace"?i.jsx(BY,{}):t.startsWith("/display")?i.jsx(XR,{}):t==="/settings"?i.jsx(are,{authUser:e}):t==="/admin/usage"?i.jsx(dre,{authUser:e}):t==="/feedback"?i.jsx(fre,{}):L2(t)?i.jsx(i2,{}):i.jsx(nu,{})}function Moe({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,u]=m.useState(!1),[d,p]=m.useState(""),c=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(()=>{c()},[]);const f=async h=>{h.preventDefault(),u(!0),p("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),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{u(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.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})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:f,children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?i.jsx("p",{className:"af-auth-error",children:d}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Loe({authUser:e,onLogout:t}){const{path:n}=Bo(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(Aoe,{page:r?"flow":"projects"}):null,r?null:i.jsx(qO,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(Roe,{authUser:e})}),i.jsx(Ioe,{})]})}function Ooe(){return i.jsx(Toe,{children:i.jsx(_O,{children:i.jsx($oe,{})})})}function $oe(){const{path:e}=Bo();return e.startsWith("/display")?i.jsx(XR,{}):L2(e)?i.jsx(i2,{}):i.jsx(Moe,{children:({user:t,onLogout:n})=>i.jsx(Loe,{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 JC=document.querySelector('link[rel="icon"]');JC&&(JC.href=pP);xw.createRoot(document.getElementById("root")).render(i.jsx(ht.StrictMode,{children:i.jsx(Ooe,{})}));