@fieldwangai/agentflow 0.1.62 → 0.1.64

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,254 +0,0 @@
1
- var T2=Object.defineProperty;var R2=(e,t,n)=>t in e?T2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var sr=(e,t,n)=>R2(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var hf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var PC={exports:{}},Eg={},AC={exports:{}},$t={};/**
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 rp=Symbol.for("react.element"),L2=Symbol.for("react.portal"),O2=Symbol.for("react.fragment"),M2=Symbol.for("react.strict_mode"),$2=Symbol.for("react.profiler"),D2=Symbol.for("react.provider"),F2=Symbol.for("react.context"),z2=Symbol.for("react.forward_ref"),H2=Symbol.for("react.suspense"),B2=Symbol.for("react.memo"),W2=Symbol.for("react.lazy"),uk=Symbol.iterator;function V2(e){return e===null||typeof e!="object"?null:(e=uk&&e[uk]||e["@@iterator"],typeof e=="function"?e:null)}var IC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},TC=Object.assign,RC={};function zu(e,t,n){this.props=e,this.context=t,this.refs=RC,this.updater=n||IC}zu.prototype.isReactComponent={};zu.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")};zu.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function LC(){}LC.prototype=zu.prototype;function qb(e,t,n){this.props=e,this.context=t,this.refs=RC,this.updater=n||IC}var Yb=qb.prototype=new LC;Yb.constructor=qb;TC(Yb,zu.prototype);Yb.isPureReactComponent=!0;var dk=Array.isArray,OC=Object.prototype.hasOwnProperty,Gb={current:null},MC={key:!0,ref:!0,__self:!0,__source:!0};function $C(e,t,n){var r,s={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)OC.call(t,r)&&!MC.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:rp,type:e,key:i,ref:a,props:s,_owner:Gb.current}}function U2(e,t){return{$$typeof:rp,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Xb(e){return typeof e=="object"&&e!==null&&e.$$typeof===rp}function K2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var fk=/\/+/g;function Py(e,t){return typeof e=="object"&&e!==null&&e.key!=null?K2(""+e.key):t.toString(36)}function qh(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case rp:case L2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+Py(a,0):r,dk(s)?(n="",e!=null&&(n=e.replace(fk,"$&/")+"/"),qh(s,t,n,"",function(d){return d})):s!=null&&(Xb(s)&&(s=U2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(fk,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",dk(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+Py(i,l);a+=qh(i,t,n,c,s)}else if(c=V2(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+Py(i,l++),a+=qh(i,t,n,c,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function th(e,t,n){if(e==null)return e;var r=[],s=0;return qh(e,r,"","",function(i){return t.call(n,i,s++)}),r}function q2(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 ms={current:null},Yh={transition:null},Y2={ReactCurrentDispatcher:ms,ReactCurrentBatchConfig:Yh,ReactCurrentOwner:Gb};function DC(){throw Error("act(...) is not supported in production builds of React.")}$t.Children={map:th,forEach:function(e,t,n){th(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return th(e,function(){t++}),t},toArray:function(e){return th(e,function(t){return t})||[]},only:function(e){if(!Xb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};$t.Component=zu;$t.Fragment=O2;$t.Profiler=$2;$t.PureComponent=qb;$t.StrictMode=M2;$t.Suspense=H2;$t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y2;$t.act=DC;$t.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=TC({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Gb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)OC.call(t,c)&&!MC.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:rp,type:e.type,key:s,ref:i,props:r,_owner:a}};$t.createContext=function(e){return e={$$typeof:F2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:D2,_context:e},e.Consumer=e};$t.createElement=$C;$t.createFactory=function(e){var t=$C.bind(null,e);return t.type=e,t};$t.createRef=function(){return{current:null}};$t.forwardRef=function(e){return{$$typeof:z2,render:e}};$t.isValidElement=Xb;$t.lazy=function(e){return{$$typeof:W2,_payload:{_status:-1,_result:e},_init:q2}};$t.memo=function(e,t){return{$$typeof:B2,type:e,compare:t===void 0?null:t}};$t.startTransition=function(e){var t=Yh.transition;Yh.transition={};try{e()}finally{Yh.transition=t}};$t.unstable_act=DC;$t.useCallback=function(e,t){return ms.current.useCallback(e,t)};$t.useContext=function(e){return ms.current.useContext(e)};$t.useDebugValue=function(){};$t.useDeferredValue=function(e){return ms.current.useDeferredValue(e)};$t.useEffect=function(e,t){return ms.current.useEffect(e,t)};$t.useId=function(){return ms.current.useId()};$t.useImperativeHandle=function(e,t,n){return ms.current.useImperativeHandle(e,t,n)};$t.useInsertionEffect=function(e,t){return ms.current.useInsertionEffect(e,t)};$t.useLayoutEffect=function(e,t){return ms.current.useLayoutEffect(e,t)};$t.useMemo=function(e,t){return ms.current.useMemo(e,t)};$t.useReducer=function(e,t,n){return ms.current.useReducer(e,t,n)};$t.useRef=function(e){return ms.current.useRef(e)};$t.useState=function(e){return ms.current.useState(e)};$t.useSyncExternalStore=function(e,t,n){return ms.current.useSyncExternalStore(e,t,n)};$t.useTransition=function(){return ms.current.useTransition()};$t.version="18.3.1";AC.exports=$t;var h=AC.exports;const lt=dl(h);/**
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 G2=h,X2=Symbol.for("react.element"),J2=Symbol.for("react.fragment"),Q2=Object.prototype.hasOwnProperty,Z2=G2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,eL={key:!0,ref:!0,__self:!0,__source:!0};function FC(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)Q2.call(t,r)&&!eL.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:X2,type:e,key:i,ref:a,props:s,_owner:Z2.current}}Eg.Fragment=J2;Eg.jsx=FC;Eg.jsxs=FC;PC.exports=Eg;var o=PC.exports,Jx={},zC={exports:{}},si={},HC={exports:{}},BC={};/**
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,P){var C=A.length;A.push(P);e:for(;0<C;){var G=C-1>>>1,Z=A[G];if(0<s(Z,P))A[G]=P,A[C]=Z,C=G;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var P=A[0],C=A.pop();if(C!==P){A[0]=C;e:for(var G=0,Z=A.length,V=Z>>>1;G<V;){var ne=2*(G+1)-1,ce=A[ne],fe=ne+1,he=A[fe];if(0>s(ce,C))fe<Z&&0>s(he,ce)?(A[G]=he,A[fe]=C,G=fe):(A[G]=ce,A[ne]=C,G=ne);else if(fe<Z&&0>s(he,C))A[G]=he,A[fe]=C,G=fe;else break e}}return P}function s(A,P){var C=A.sortIndex-P.sortIndex;return C!==0?C:A.id-P.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],f=1,u=null,p=3,m=!1,g=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(A){for(var P=n(d);P!==null;){if(P.callback===null)r(d);else if(P.startTime<=A)r(d),P.sortIndex=P.expirationTime,t(c,P);else break;P=n(d)}}function j(A){if(b=!1,w(A),!g)if(n(c)!==null)g=!0,T(_);else{var P=n(d);P!==null&&z(j,P.startTime-A)}}function _(A,P){g=!1,b&&(b=!1,y(H),H=-1),m=!0;var C=p;try{for(w(P),u=n(c);u!==null&&(!(u.expirationTime>P)||A&&!D());){var G=u.callback;if(typeof G=="function"){u.callback=null,p=u.priorityLevel;var Z=G(u.expirationTime<=P);P=e.unstable_now(),typeof Z=="function"?u.callback=Z:u===n(c)&&r(c),w(P)}else r(c);u=n(c)}if(u!==null)var V=!0;else{var ne=n(d);ne!==null&&z(j,ne.startTime-P),V=!1}return V}finally{u=null,p=C,m=!1}}var E=!1,O=null,H=-1,L=5,F=-1;function D(){return!(e.unstable_now()-F<L)}function R(){if(O!==null){var A=e.unstable_now();F=A;var P=!0;try{P=O(!0,A)}finally{P?W():(E=!1,O=null)}}else E=!1}var W;if(typeof k=="function")W=function(){k(R)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,$=M.port2;M.port1.onmessage=R,W=function(){$.postMessage(null)}}else W=function(){v(R,0)};function T(A){O=A,E||(E=!0,W())}function z(A,P){H=v(function(){A(e.unstable_now())},P)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){g||m||(g=!0,T(_))},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"):L=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(p){case 1:case 2:case 3:var P=3;break;default:P=p}var C=p;p=P;try{return A()}finally{p=C}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,P){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var C=p;p=A;try{return P()}finally{p=C}},e.unstable_scheduleCallback=function(A,P,C){var G=e.unstable_now();switch(typeof C=="object"&&C!==null?(C=C.delay,C=typeof C=="number"&&0<C?G+C:G):C=G,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=C+Z,A={id:f++,callback:P,priorityLevel:A,startTime:C,expirationTime:Z,sortIndex:-1},C>G?(A.sortIndex=C,t(d,A),n(c)===null&&A===n(d)&&(b?(y(H),H=-1):b=!0,z(j,C-G))):(A.sortIndex=Z,t(c,A),g||m||(g=!0,T(_))),A},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(A){var P=p;return function(){var C=p;p=P;try{return A.apply(this,arguments)}finally{p=C}}}})(BC);HC.exports=BC;var tL=HC.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 nL=h,ni=tL;function je(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var WC=new Set,mf={};function pc(e,t){wu(e,t),wu(e+"Capture",t)}function wu(e,t){for(mf[e]=t,e=0;e<t.length;e++)WC.add(t[e])}var aa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qx=Object.prototype.hasOwnProperty,rL=/^[: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]*$/,pk={},hk={};function sL(e){return Qx.call(hk,e)?!0:Qx.call(pk,e)?!1:rL.test(e)?hk[e]=!0:(pk[e]=!0,!1)}function iL(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 oL(e,t,n,r){if(t===null||typeof t>"u"||iL(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 gs(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var Hr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Hr[e]=new gs(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Hr[t]=new gs(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Hr[e]=new gs(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Hr[e]=new gs(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){Hr[e]=new gs(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Hr[e]=new gs(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Hr[e]=new gs(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Hr[e]=new gs(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Hr[e]=new gs(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jb=/[\-:]([a-z])/g;function Qb(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(Jb,Qb);Hr[t]=new gs(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(Jb,Qb);Hr[t]=new gs(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(Jb,Qb);Hr[t]=new gs(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Hr[e]=new gs(e,1,!1,e.toLowerCase(),null,!1,!1)});Hr.xlinkHref=new gs("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Hr[e]=new gs(e,1,!1,e.toLowerCase(),null,!0,!0)});function Zb(e,t,n,r){var s=Hr.hasOwnProperty(t)?Hr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(oL(t,n,s,r)&&(n=null),r||s===null?sL(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 ha=nL.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nh=Symbol.for("react.element"),Bc=Symbol.for("react.portal"),Wc=Symbol.for("react.fragment"),ev=Symbol.for("react.strict_mode"),Zx=Symbol.for("react.profiler"),VC=Symbol.for("react.provider"),UC=Symbol.for("react.context"),tv=Symbol.for("react.forward_ref"),ew=Symbol.for("react.suspense"),tw=Symbol.for("react.suspense_list"),nv=Symbol.for("react.memo"),Ma=Symbol.for("react.lazy"),KC=Symbol.for("react.offscreen"),mk=Symbol.iterator;function bd(e){return e===null||typeof e!="object"?null:(e=mk&&e[mk]||e["@@iterator"],typeof e=="function"?e:null)}var Qn=Object.assign,Ay;function Dd(e){if(Ay===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Ay=t&&t[1]||""}return`
34
- `+Ay+e}var Iy=!1;function Ty(e,t){if(!e||Iy)return"";Iy=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
- `),i=r.stack.split(`
36
- `),a=s.length-1,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[l]){var c=`
37
- `+s[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{Iy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Dd(e):""}function aL(e){switch(e.tag){case 5:return Dd(e.type);case 16:return Dd("Lazy");case 13:return Dd("Suspense");case 19:return Dd("SuspenseList");case 0:case 2:case 15:return e=Ty(e.type,!1),e;case 11:return e=Ty(e.type.render,!1),e;case 1:return e=Ty(e.type,!0),e;default:return""}}function nw(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 Wc:return"Fragment";case Bc:return"Portal";case Zx:return"Profiler";case ev:return"StrictMode";case ew:return"Suspense";case tw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case UC:return(e.displayName||"Context")+".Consumer";case VC:return(e._context.displayName||"Context")+".Provider";case tv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case nv:return t=e.displayName||null,t!==null?t:nw(e.type)||"Memo";case Ma:t=e._payload,e=e._init;try{return nw(e(t))}catch{}}return null}function lL(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 nw(t);case 8:return t===ev?"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 sl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function qC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function cL(e){var t=qC(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rh(e){e._valueTracker||(e._valueTracker=cL(e))}function YC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=qC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function xm(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 rw(e,t){var n=t.checked;return Qn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function gk(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=sl(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 GC(e,t){t=t.checked,t!=null&&Zb(e,"checked",t,!1)}function sw(e,t){GC(e,t);var n=sl(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")?iw(e,t.type,n):t.hasOwnProperty("defaultValue")&&iw(e,t.type,sl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function yk(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 iw(e,t,n){(t!=="number"||xm(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fd=Array.isArray;function ou(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=""+sl(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 ow(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(je(91));return Qn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function xk(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(je(92));if(Fd(n)){if(1<n.length)throw Error(je(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:sl(n)}}function XC(e,t){var n=sl(t.value),r=sl(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 wk(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function JC(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 aw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?JC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var sh,QC=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(sh=sh||document.createElement("div"),sh.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=sh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Gd={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},uL=["Webkit","ms","Moz","O"];Object.keys(Gd).forEach(function(e){uL.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Gd[t]=Gd[e]})});function ZC(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Gd.hasOwnProperty(e)&&Gd[e]?(""+t).trim():t+"px"}function eE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=ZC(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var dL=Qn({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 lw(e,t){if(t){if(dL[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(je(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(je(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(je(61))}if(t.style!=null&&typeof t.style!="object")throw Error(je(62))}}function cw(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 uw=null;function rv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var dw=null,au=null,lu=null;function bk(e){if(e=op(e)){if(typeof dw!="function")throw Error(je(280));var t=e.stateNode;t&&(t=Tg(t),dw(e.stateNode,e.type,t))}}function tE(e){au?lu?lu.push(e):lu=[e]:au=e}function nE(){if(au){var e=au,t=lu;if(lu=au=null,bk(e),t)for(e=0;e<t.length;e++)bk(t[e])}}function rE(e,t){return e(t)}function sE(){}var Ry=!1;function iE(e,t,n){if(Ry)return e(t,n);Ry=!0;try{return rE(e,t,n)}finally{Ry=!1,(au!==null||lu!==null)&&(sE(),nE())}}function yf(e,t){var n=e.stateNode;if(n===null)return null;var r=Tg(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(je(231,t,typeof n));return n}var fw=!1;if(aa)try{var vd={};Object.defineProperty(vd,"passive",{get:function(){fw=!0}}),window.addEventListener("test",vd,vd),window.removeEventListener("test",vd,vd)}catch{fw=!1}function fL(e,t,n,r,s,i,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Xd=!1,wm=null,bm=!1,pw=null,pL={onError:function(e){Xd=!0,wm=e}};function hL(e,t,n,r,s,i,a,l,c){Xd=!1,wm=null,fL.apply(pL,arguments)}function mL(e,t,n,r,s,i,a,l,c){if(hL.apply(this,arguments),Xd){if(Xd){var d=wm;Xd=!1,wm=null}else throw Error(je(198));bm||(bm=!0,pw=d)}}function hc(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 oE(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 vk(e){if(hc(e)!==e)throw Error(je(188))}function gL(e){var t=e.alternate;if(!t){if(t=hc(e),t===null)throw Error(je(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return vk(s),e;if(i===r)return vk(s),t;i=i.sibling}throw Error(je(188))}if(n.return!==r.return)n=s,r=i;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a)throw Error(je(189))}}if(n.alternate!==r)throw Error(je(190))}if(n.tag!==3)throw Error(je(188));return n.stateNode.current===n?e:t}function aE(e){return e=gL(e),e!==null?lE(e):null}function lE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=lE(e);if(t!==null)return t;e=e.sibling}return null}var cE=ni.unstable_scheduleCallback,kk=ni.unstable_cancelCallback,yL=ni.unstable_shouldYield,xL=ni.unstable_requestPaint,pr=ni.unstable_now,wL=ni.unstable_getCurrentPriorityLevel,sv=ni.unstable_ImmediatePriority,uE=ni.unstable_UserBlockingPriority,vm=ni.unstable_NormalPriority,bL=ni.unstable_LowPriority,dE=ni.unstable_IdlePriority,_g=null,jo=null;function vL(e){if(jo&&typeof jo.onCommitFiberRoot=="function")try{jo.onCommitFiberRoot(_g,e,void 0,(e.current.flags&128)===128)}catch{}}var Xi=Math.clz32?Math.clz32:NL,kL=Math.log,SL=Math.LN2;function NL(e){return e>>>=0,e===0?32:31-(kL(e)/SL|0)|0}var ih=64,oh=4194304;function zd(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 km(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=zd(l):(i&=a,i!==0&&(r=zd(i)))}else a=n&~s,a!==0?r=zd(a):i!==0&&(r=zd(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Xi(t),s=1<<n,r|=e[n],t&=~s;return r}function jL(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 CL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Xi(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=jL(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function hw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function fE(){var e=ih;return ih<<=1,!(ih&4194240)&&(ih=64),e}function Ly(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function sp(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Xi(t),e[t]=n}function EL(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-Xi(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function iv(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Xi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var un=0;function pE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var hE,ov,mE,gE,yE,mw=!1,ah=[],Ka=null,qa=null,Ya=null,xf=new Map,wf=new Map,Fa=[],_L="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 Sk(e,t){switch(e){case"focusin":case"focusout":Ka=null;break;case"dragenter":case"dragleave":qa=null;break;case"mouseover":case"mouseout":Ya=null;break;case"pointerover":case"pointerout":xf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":wf.delete(t.pointerId)}}function kd(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=op(t),t!==null&&ov(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function PL(e,t,n,r,s){switch(t){case"focusin":return Ka=kd(Ka,e,t,n,r,s),!0;case"dragenter":return qa=kd(qa,e,t,n,r,s),!0;case"mouseover":return Ya=kd(Ya,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return xf.set(i,kd(xf.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,wf.set(i,kd(wf.get(i)||null,e,t,n,r,s)),!0}return!1}function xE(e){var t=Vl(e.target);if(t!==null){var n=hc(t);if(n!==null){if(t=n.tag,t===13){if(t=oE(n),t!==null){e.blockedOn=t,yE(e.priority,function(){mE(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 Gh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=gw(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);uw=r,n.target.dispatchEvent(r),uw=null}else return t=op(n),t!==null&&ov(t),e.blockedOn=n,!1;t.shift()}return!0}function Nk(e,t,n){Gh(e)&&n.delete(t)}function AL(){mw=!1,Ka!==null&&Gh(Ka)&&(Ka=null),qa!==null&&Gh(qa)&&(qa=null),Ya!==null&&Gh(Ya)&&(Ya=null),xf.forEach(Nk),wf.forEach(Nk)}function Sd(e,t){e.blockedOn===t&&(e.blockedOn=null,mw||(mw=!0,ni.unstable_scheduleCallback(ni.unstable_NormalPriority,AL)))}function bf(e){function t(s){return Sd(s,e)}if(0<ah.length){Sd(ah[0],e);for(var n=1;n<ah.length;n++){var r=ah[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ka!==null&&Sd(Ka,e),qa!==null&&Sd(qa,e),Ya!==null&&Sd(Ya,e),xf.forEach(t),wf.forEach(t),n=0;n<Fa.length;n++)r=Fa[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Fa.length&&(n=Fa[0],n.blockedOn===null);)xE(n),n.blockedOn===null&&Fa.shift()}var cu=ha.ReactCurrentBatchConfig,Sm=!0;function IL(e,t,n,r){var s=un,i=cu.transition;cu.transition=null;try{un=1,av(e,t,n,r)}finally{un=s,cu.transition=i}}function TL(e,t,n,r){var s=un,i=cu.transition;cu.transition=null;try{un=4,av(e,t,n,r)}finally{un=s,cu.transition=i}}function av(e,t,n,r){if(Sm){var s=gw(e,t,n,r);if(s===null)Vy(e,t,r,Nm,n),Sk(e,r);else if(PL(s,e,t,n,r))r.stopPropagation();else if(Sk(e,r),t&4&&-1<_L.indexOf(e)){for(;s!==null;){var i=op(s);if(i!==null&&hE(i),i=gw(e,t,n,r),i===null&&Vy(e,t,r,Nm,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Vy(e,t,r,null,n)}}var Nm=null;function gw(e,t,n,r){if(Nm=null,e=rv(r),e=Vl(e),e!==null)if(t=hc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=oE(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 Nm=e,null}function wE(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(wL()){case sv:return 1;case uE:return 4;case vm:case bL:return 16;case dE:return 536870912;default:return 16}default:return 16}}var Ba=null,lv=null,Xh=null;function bE(){if(Xh)return Xh;var e,t=lv,n=t.length,r,s="value"in Ba?Ba.value:Ba.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===s[i-r];r++);return Xh=s.slice(e,1<r?1-r:void 0)}function Jh(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 lh(){return!0}function jk(){return!1}function ii(e){function t(n,r,s,i,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?lh:jk,this.isPropagationStopped=jk,this}return Qn(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=lh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=lh)},persist:function(){},isPersistent:lh}),t}var Hu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cv=ii(Hu),ip=Qn({},Hu,{view:0,detail:0}),RL=ii(ip),Oy,My,Nd,Pg=Qn({},ip,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:uv,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!==Nd&&(Nd&&e.type==="mousemove"?(Oy=e.screenX-Nd.screenX,My=e.screenY-Nd.screenY):My=Oy=0,Nd=e),Oy)},movementY:function(e){return"movementY"in e?e.movementY:My}}),Ck=ii(Pg),LL=Qn({},Pg,{dataTransfer:0}),OL=ii(LL),ML=Qn({},ip,{relatedTarget:0}),$y=ii(ML),$L=Qn({},Hu,{animationName:0,elapsedTime:0,pseudoElement:0}),DL=ii($L),FL=Qn({},Hu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),zL=ii(FL),HL=Qn({},Hu,{data:0}),Ek=ii(HL),BL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},WL={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"},VL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function UL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=VL[e])?!!t[e]:!1}function uv(){return UL}var KL=Qn({},ip,{key:function(e){if(e.key){var t=BL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Jh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?WL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:uv,charCode:function(e){return e.type==="keypress"?Jh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Jh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),qL=ii(KL),YL=Qn({},Pg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_k=ii(YL),GL=Qn({},ip,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:uv}),XL=ii(GL),JL=Qn({},Hu,{propertyName:0,elapsedTime:0,pseudoElement:0}),QL=ii(JL),ZL=Qn({},Pg,{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}),eO=ii(ZL),tO=[9,13,27,32],dv=aa&&"CompositionEvent"in window,Jd=null;aa&&"documentMode"in document&&(Jd=document.documentMode);var nO=aa&&"TextEvent"in window&&!Jd,vE=aa&&(!dv||Jd&&8<Jd&&11>=Jd),Pk=" ",Ak=!1;function kE(e,t){switch(e){case"keyup":return tO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function SE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vc=!1;function rO(e,t){switch(e){case"compositionend":return SE(t);case"keypress":return t.which!==32?null:(Ak=!0,Pk);case"textInput":return e=t.data,e===Pk&&Ak?null:e;default:return null}}function sO(e,t){if(Vc)return e==="compositionend"||!dv&&kE(e,t)?(e=bE(),Xh=lv=Ba=null,Vc=!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 iO={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 Ik(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!iO[e.type]:t==="textarea"}function NE(e,t,n,r){tE(r),t=jm(t,"onChange"),0<t.length&&(n=new cv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Qd=null,vf=null;function oO(e){OE(e,0)}function Ag(e){var t=qc(e);if(YC(t))return e}function aO(e,t){if(e==="change")return t}var jE=!1;if(aa){var Dy;if(aa){var Fy="oninput"in document;if(!Fy){var Tk=document.createElement("div");Tk.setAttribute("oninput","return;"),Fy=typeof Tk.oninput=="function"}Dy=Fy}else Dy=!1;jE=Dy&&(!document.documentMode||9<document.documentMode)}function Rk(){Qd&&(Qd.detachEvent("onpropertychange",CE),vf=Qd=null)}function CE(e){if(e.propertyName==="value"&&Ag(vf)){var t=[];NE(t,vf,e,rv(e)),iE(oO,t)}}function lO(e,t,n){e==="focusin"?(Rk(),Qd=t,vf=n,Qd.attachEvent("onpropertychange",CE)):e==="focusout"&&Rk()}function cO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ag(vf)}function uO(e,t){if(e==="click")return Ag(t)}function dO(e,t){if(e==="input"||e==="change")return Ag(t)}function fO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Qi=typeof Object.is=="function"?Object.is:fO;function kf(e,t){if(Qi(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(!Qx.call(t,s)||!Qi(e[s],t[s]))return!1}return!0}function Lk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ok(e,t){var n=Lk(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=Lk(n)}}function EE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?EE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _E(){for(var e=window,t=xm();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=xm(e.document)}return t}function fv(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 pO(e){var t=_E(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&EE(n.ownerDocument.documentElement,n)){if(r!==null&&fv(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Ok(n,i);var a=Ok(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var hO=aa&&"documentMode"in document&&11>=document.documentMode,Uc=null,yw=null,Zd=null,xw=!1;function Mk(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xw||Uc==null||Uc!==xm(r)||(r=Uc,"selectionStart"in r&&fv(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}),Zd&&kf(Zd,r)||(Zd=r,r=jm(yw,"onSelect"),0<r.length&&(t=new cv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Uc)))}function ch(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Kc={animationend:ch("Animation","AnimationEnd"),animationiteration:ch("Animation","AnimationIteration"),animationstart:ch("Animation","AnimationStart"),transitionend:ch("Transition","TransitionEnd")},zy={},PE={};aa&&(PE=document.createElement("div").style,"AnimationEvent"in window||(delete Kc.animationend.animation,delete Kc.animationiteration.animation,delete Kc.animationstart.animation),"TransitionEvent"in window||delete Kc.transitionend.transition);function Ig(e){if(zy[e])return zy[e];if(!Kc[e])return e;var t=Kc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in PE)return zy[e]=t[n];return e}var AE=Ig("animationend"),IE=Ig("animationiteration"),TE=Ig("animationstart"),RE=Ig("transitionend"),LE=new Map,$k="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 fl(e,t){LE.set(e,t),pc(t,[e])}for(var Hy=0;Hy<$k.length;Hy++){var By=$k[Hy],mO=By.toLowerCase(),gO=By[0].toUpperCase()+By.slice(1);fl(mO,"on"+gO)}fl(AE,"onAnimationEnd");fl(IE,"onAnimationIteration");fl(TE,"onAnimationStart");fl("dblclick","onDoubleClick");fl("focusin","onFocus");fl("focusout","onBlur");fl(RE,"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 Hd="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(" "),yO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hd));function Dk(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,mL(r,t,void 0,e),e.currentTarget=null}function OE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;Dk(s,l,d),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;Dk(s,l,d),i=c}}}if(bm)throw e=pw,bm=!1,pw=null,e}function Dn(e,t){var n=t[Sw];n===void 0&&(n=t[Sw]=new Set);var r=e+"__bubble";n.has(r)||(ME(t,e,2,!1),n.add(r))}function Wy(e,t,n){var r=0;t&&(r|=4),ME(n,e,r,t)}var uh="_reactListening"+Math.random().toString(36).slice(2);function Sf(e){if(!e[uh]){e[uh]=!0,WC.forEach(function(n){n!=="selectionchange"&&(yO.has(n)||Wy(n,!1,e),Wy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[uh]||(t[uh]=!0,Wy("selectionchange",!1,t))}}function ME(e,t,n,r){switch(wE(t)){case 1:var s=IL;break;case 4:s=TL;break;default:s=av}n=s.bind(null,t,n,e),s=void 0,!fw||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 Vy(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;a=a.return}for(;l!==null;){if(a=Vl(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}iE(function(){var d=i,f=rv(n),u=[];e:{var p=LE.get(e);if(p!==void 0){var m=cv,g=e;switch(e){case"keypress":if(Jh(n)===0)break e;case"keydown":case"keyup":m=qL;break;case"focusin":g="focus",m=$y;break;case"focusout":g="blur",m=$y;break;case"beforeblur":case"afterblur":m=$y;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":m=Ck;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=OL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=XL;break;case AE:case IE:case TE:m=DL;break;case RE:m=QL;break;case"scroll":m=RL;break;case"wheel":m=eO;break;case"copy":case"cut":case"paste":m=zL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=_k}var b=(t&4)!==0,v=!b&&e==="scroll",y=b?p!==null?p+"Capture":null:p;b=[];for(var k=d,w;k!==null;){w=k;var j=w.stateNode;if(w.tag===5&&j!==null&&(w=j,y!==null&&(j=yf(k,y),j!=null&&b.push(Nf(k,j,w)))),v)break;k=k.return}0<b.length&&(p=new m(p,g,null,n,f),u.push({event:p,listeners:b}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==uw&&(g=n.relatedTarget||n.fromElement)&&(Vl(g)||g[la]))break e;if((m||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=d,g=g?Vl(g):null,g!==null&&(v=hc(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(b=Ck,j="onMouseLeave",y="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(b=_k,j="onPointerLeave",y="onPointerEnter",k="pointer"),v=m==null?p:qc(m),w=g==null?p:qc(g),p=new b(j,k+"leave",m,n,f),p.target=v,p.relatedTarget=w,j=null,Vl(f)===d&&(b=new b(y,k+"enter",g,n,f),b.target=w,b.relatedTarget=v,j=b),v=j,m&&g)t:{for(b=m,y=g,k=0,w=b;w;w=Ic(w))k++;for(w=0,j=y;j;j=Ic(j))w++;for(;0<k-w;)b=Ic(b),k--;for(;0<w-k;)y=Ic(y),w--;for(;k--;){if(b===y||y!==null&&b===y.alternate)break t;b=Ic(b),y=Ic(y)}b=null}else b=null;m!==null&&Fk(u,p,m,b,!1),g!==null&&v!==null&&Fk(u,v,g,b,!0)}}e:{if(p=d?qc(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var _=aO;else if(Ik(p))if(jE)_=dO;else{_=cO;var E=lO}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(_=uO);if(_&&(_=_(e,d))){NE(u,_,n,f);break e}E&&E(e,p,d),e==="focusout"&&(E=p._wrapperState)&&E.controlled&&p.type==="number"&&iw(p,"number",p.value)}switch(E=d?qc(d):window,e){case"focusin":(Ik(E)||E.contentEditable==="true")&&(Uc=E,yw=d,Zd=null);break;case"focusout":Zd=yw=Uc=null;break;case"mousedown":xw=!0;break;case"contextmenu":case"mouseup":case"dragend":xw=!1,Mk(u,n,f);break;case"selectionchange":if(hO)break;case"keydown":case"keyup":Mk(u,n,f)}var O;if(dv)e:{switch(e){case"compositionstart":var H="onCompositionStart";break e;case"compositionend":H="onCompositionEnd";break e;case"compositionupdate":H="onCompositionUpdate";break e}H=void 0}else Vc?kE(e,n)&&(H="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(H="onCompositionStart");H&&(vE&&n.locale!=="ko"&&(Vc||H!=="onCompositionStart"?H==="onCompositionEnd"&&Vc&&(O=bE()):(Ba=f,lv="value"in Ba?Ba.value:Ba.textContent,Vc=!0)),E=jm(d,H),0<E.length&&(H=new Ek(H,e,null,n,f),u.push({event:H,listeners:E}),O?H.data=O:(O=SE(n),O!==null&&(H.data=O)))),(O=nO?rO(e,n):sO(e,n))&&(d=jm(d,"onBeforeInput"),0<d.length&&(f=new Ek("onBeforeInput","beforeinput",null,n,f),u.push({event:f,listeners:d}),f.data=O))}OE(u,t)})}function Nf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function jm(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=yf(e,n),i!=null&&r.unshift(Nf(e,i,s)),i=yf(e,t),i!=null&&r.push(Nf(e,i,s))),e=e.return}return r}function Ic(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Fk(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=yf(n,i),c!=null&&a.unshift(Nf(n,c,l))):s||(c=yf(n,i),c!=null&&a.push(Nf(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var xO=/\r\n?/g,wO=/\u0000|\uFFFD/g;function zk(e){return(typeof e=="string"?e:""+e).replace(xO,`
38
- `).replace(wO,"")}function dh(e,t,n){if(t=zk(t),zk(e)!==t&&n)throw Error(je(425))}function Cm(){}var ww=null,bw=null;function vw(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 kw=typeof setTimeout=="function"?setTimeout:void 0,bO=typeof clearTimeout=="function"?clearTimeout:void 0,Hk=typeof Promise=="function"?Promise:void 0,vO=typeof queueMicrotask=="function"?queueMicrotask:typeof Hk<"u"?function(e){return Hk.resolve(null).then(e).catch(kO)}:kw;function kO(e){setTimeout(function(){throw e})}function Uy(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),bf(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);bf(t)}function Ga(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Bk(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 Bu=Math.random().toString(36).slice(2),vo="__reactFiber$"+Bu,jf="__reactProps$"+Bu,la="__reactContainer$"+Bu,Sw="__reactEvents$"+Bu,SO="__reactListeners$"+Bu,NO="__reactHandles$"+Bu;function Vl(e){var t=e[vo];if(t)return t;for(var n=e.parentNode;n;){if(t=n[la]||n[vo]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Bk(e);e!==null;){if(n=e[vo])return n;e=Bk(e)}return t}e=n,n=e.parentNode}return null}function op(e){return e=e[vo]||e[la],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function qc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(je(33))}function Tg(e){return e[jf]||null}var Nw=[],Yc=-1;function pl(e){return{current:e}}function zn(e){0>Yc||(e.current=Nw[Yc],Nw[Yc]=null,Yc--)}function Tn(e,t){Yc++,Nw[Yc]=e.current,e.current=t}var il={},ns=pl(il),Rs=pl(!1),nc=il;function bu(e,t){var n=e.type.contextTypes;if(!n)return il;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ls(e){return e=e.childContextTypes,e!=null}function Em(){zn(Rs),zn(ns)}function Wk(e,t,n){if(ns.current!==il)throw Error(je(168));Tn(ns,t),Tn(Rs,n)}function $E(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(je(108,lL(e)||"Unknown",s));return Qn({},n,r)}function _m(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||il,nc=ns.current,Tn(ns,e),Tn(Rs,Rs.current),!0}function Vk(e,t,n){var r=e.stateNode;if(!r)throw Error(je(169));n?(e=$E(e,t,nc),r.__reactInternalMemoizedMergedChildContext=e,zn(Rs),zn(ns),Tn(ns,e)):zn(Rs),Tn(Rs,n)}var Qo=null,Rg=!1,Ky=!1;function DE(e){Qo===null?Qo=[e]:Qo.push(e)}function jO(e){Rg=!0,DE(e)}function hl(){if(!Ky&&Qo!==null){Ky=!0;var e=0,t=un;try{var n=Qo;for(un=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Qo=null,Rg=!1}catch(s){throw Qo!==null&&(Qo=Qo.slice(e+1)),cE(sv,hl),s}finally{un=t,Ky=!1}}return null}var Gc=[],Xc=0,Pm=null,Am=0,bi=[],vi=0,rc=null,ta=1,na="";function Fl(e,t){Gc[Xc++]=Am,Gc[Xc++]=Pm,Pm=e,Am=t}function FE(e,t,n){bi[vi++]=ta,bi[vi++]=na,bi[vi++]=rc,rc=e;var r=ta;e=na;var s=32-Xi(r)-1;r&=~(1<<s),n+=1;var i=32-Xi(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,ta=1<<32-Xi(t)+s|n<<s|r,na=i+e}else ta=1<<i|n<<s|r,na=e}function pv(e){e.return!==null&&(Fl(e,1),FE(e,1,0))}function hv(e){for(;e===Pm;)Pm=Gc[--Xc],Gc[Xc]=null,Am=Gc[--Xc],Gc[Xc]=null;for(;e===rc;)rc=bi[--vi],bi[vi]=null,na=bi[--vi],bi[vi]=null,ta=bi[--vi],bi[vi]=null}var ei=null,Qs=null,Kn=!1,Ui=null;function zE(e,t){var n=Ni(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 Uk(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,ei=e,Qs=Ga(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ei=e,Qs=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=rc!==null?{id:ta,overflow:na}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ni(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ei=e,Qs=null,!0):!1;default:return!1}}function jw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Cw(e){if(Kn){var t=Qs;if(t){var n=t;if(!Uk(e,t)){if(jw(e))throw Error(je(418));t=Ga(n.nextSibling);var r=ei;t&&Uk(e,t)?zE(r,n):(e.flags=e.flags&-4097|2,Kn=!1,ei=e)}}else{if(jw(e))throw Error(je(418));e.flags=e.flags&-4097|2,Kn=!1,ei=e}}}function Kk(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ei=e}function fh(e){if(e!==ei)return!1;if(!Kn)return Kk(e),Kn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!vw(e.type,e.memoizedProps)),t&&(t=Qs)){if(jw(e))throw HE(),Error(je(418));for(;t;)zE(e,t),t=Ga(t.nextSibling)}if(Kk(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(je(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Qs=Ga(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Qs=null}}else Qs=ei?Ga(e.stateNode.nextSibling):null;return!0}function HE(){for(var e=Qs;e;)e=Ga(e.nextSibling)}function vu(){Qs=ei=null,Kn=!1}function mv(e){Ui===null?Ui=[e]:Ui.push(e)}var CO=ha.ReactCurrentBatchConfig;function jd(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(je(309));var r=n.stateNode}if(!r)throw Error(je(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var l=s.refs;a===null?delete l[i]:l[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(je(284));if(!n._owner)throw Error(je(290,e))}return e}function ph(e,t){throw e=Object.prototype.toString.call(t),Error(je(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function qk(e){var t=e._init;return t(e._payload)}function BE(e){function t(y,k){if(e){var w=y.deletions;w===null?(y.deletions=[k],y.flags|=16):w.push(k)}}function n(y,k){if(!e)return null;for(;k!==null;)t(y,k),k=k.sibling;return null}function r(y,k){for(y=new Map;k!==null;)k.key!==null?y.set(k.key,k):y.set(k.index,k),k=k.sibling;return y}function s(y,k){return y=Za(y,k),y.index=0,y.sibling=null,y}function i(y,k,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<k?(y.flags|=2,k):w):(y.flags|=2,k)):(y.flags|=1048576,k)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,k,w,j){return k===null||k.tag!==6?(k=Zy(w,y.mode,j),k.return=y,k):(k=s(k,w),k.return=y,k)}function c(y,k,w,j){var _=w.type;return _===Wc?f(y,k,w.props.children,j,w.key):k!==null&&(k.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Ma&&qk(_)===k.type)?(j=s(k,w.props),j.ref=jd(y,k,w),j.return=y,j):(j=sm(w.type,w.key,w.props,null,y.mode,j),j.ref=jd(y,k,w),j.return=y,j)}function d(y,k,w,j){return k===null||k.tag!==4||k.stateNode.containerInfo!==w.containerInfo||k.stateNode.implementation!==w.implementation?(k=ex(w,y.mode,j),k.return=y,k):(k=s(k,w.children||[]),k.return=y,k)}function f(y,k,w,j,_){return k===null||k.tag!==7?(k=Xl(w,y.mode,j,_),k.return=y,k):(k=s(k,w),k.return=y,k)}function u(y,k,w){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Zy(""+k,y.mode,w),k.return=y,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case nh:return w=sm(k.type,k.key,k.props,null,y.mode,w),w.ref=jd(y,null,k),w.return=y,w;case Bc:return k=ex(k,y.mode,w),k.return=y,k;case Ma:var j=k._init;return u(y,j(k._payload),w)}if(Fd(k)||bd(k))return k=Xl(k,y.mode,w,null),k.return=y,k;ph(y,k)}return null}function p(y,k,w,j){var _=k!==null?k.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return _!==null?null:l(y,k,""+w,j);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case nh:return w.key===_?c(y,k,w,j):null;case Bc:return w.key===_?d(y,k,w,j):null;case Ma:return _=w._init,p(y,k,_(w._payload),j)}if(Fd(w)||bd(w))return _!==null?null:f(y,k,w,j,null);ph(y,w)}return null}function m(y,k,w,j,_){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(w)||null,l(k,y,""+j,_);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case nh:return y=y.get(j.key===null?w:j.key)||null,c(k,y,j,_);case Bc:return y=y.get(j.key===null?w:j.key)||null,d(k,y,j,_);case Ma:var E=j._init;return m(y,k,w,E(j._payload),_)}if(Fd(j)||bd(j))return y=y.get(w)||null,f(k,y,j,_,null);ph(k,j)}return null}function g(y,k,w,j){for(var _=null,E=null,O=k,H=k=0,L=null;O!==null&&H<w.length;H++){O.index>H?(L=O,O=null):L=O.sibling;var F=p(y,O,w[H],j);if(F===null){O===null&&(O=L);break}e&&O&&F.alternate===null&&t(y,O),k=i(F,k,H),E===null?_=F:E.sibling=F,E=F,O=L}if(H===w.length)return n(y,O),Kn&&Fl(y,H),_;if(O===null){for(;H<w.length;H++)O=u(y,w[H],j),O!==null&&(k=i(O,k,H),E===null?_=O:E.sibling=O,E=O);return Kn&&Fl(y,H),_}for(O=r(y,O);H<w.length;H++)L=m(O,y,H,w[H],j),L!==null&&(e&&L.alternate!==null&&O.delete(L.key===null?H:L.key),k=i(L,k,H),E===null?_=L:E.sibling=L,E=L);return e&&O.forEach(function(D){return t(y,D)}),Kn&&Fl(y,H),_}function b(y,k,w,j){var _=bd(w);if(typeof _!="function")throw Error(je(150));if(w=_.call(w),w==null)throw Error(je(151));for(var E=_=null,O=k,H=k=0,L=null,F=w.next();O!==null&&!F.done;H++,F=w.next()){O.index>H?(L=O,O=null):L=O.sibling;var D=p(y,O,F.value,j);if(D===null){O===null&&(O=L);break}e&&O&&D.alternate===null&&t(y,O),k=i(D,k,H),E===null?_=D:E.sibling=D,E=D,O=L}if(F.done)return n(y,O),Kn&&Fl(y,H),_;if(O===null){for(;!F.done;H++,F=w.next())F=u(y,F.value,j),F!==null&&(k=i(F,k,H),E===null?_=F:E.sibling=F,E=F);return Kn&&Fl(y,H),_}for(O=r(y,O);!F.done;H++,F=w.next())F=m(O,y,H,F.value,j),F!==null&&(e&&F.alternate!==null&&O.delete(F.key===null?H:F.key),k=i(F,k,H),E===null?_=F:E.sibling=F,E=F);return e&&O.forEach(function(R){return t(y,R)}),Kn&&Fl(y,H),_}function v(y,k,w,j){if(typeof w=="object"&&w!==null&&w.type===Wc&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case nh:e:{for(var _=w.key,E=k;E!==null;){if(E.key===_){if(_=w.type,_===Wc){if(E.tag===7){n(y,E.sibling),k=s(E,w.props.children),k.return=y,y=k;break e}}else if(E.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Ma&&qk(_)===E.type){n(y,E.sibling),k=s(E,w.props),k.ref=jd(y,E,w),k.return=y,y=k;break e}n(y,E);break}else t(y,E);E=E.sibling}w.type===Wc?(k=Xl(w.props.children,y.mode,j,w.key),k.return=y,y=k):(j=sm(w.type,w.key,w.props,null,y.mode,j),j.ref=jd(y,k,w),j.return=y,y=j)}return a(y);case Bc:e:{for(E=w.key;k!==null;){if(k.key===E)if(k.tag===4&&k.stateNode.containerInfo===w.containerInfo&&k.stateNode.implementation===w.implementation){n(y,k.sibling),k=s(k,w.children||[]),k.return=y,y=k;break e}else{n(y,k);break}else t(y,k);k=k.sibling}k=ex(w,y.mode,j),k.return=y,y=k}return a(y);case Ma:return E=w._init,v(y,k,E(w._payload),j)}if(Fd(w))return g(y,k,w,j);if(bd(w))return b(y,k,w,j);ph(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,k!==null&&k.tag===6?(n(y,k.sibling),k=s(k,w),k.return=y,y=k):(n(y,k),k=Zy(w,y.mode,j),k.return=y,y=k),a(y)):n(y,k)}return v}var ku=BE(!0),WE=BE(!1),Im=pl(null),Tm=null,Jc=null,gv=null;function yv(){gv=Jc=Tm=null}function xv(e){var t=Im.current;zn(Im),e._currentValue=t}function Ew(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 uu(e,t){Tm=e,gv=Jc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(_s=!0),e.firstContext=null)}function Ci(e){var t=e._currentValue;if(gv!==e)if(e={context:e,memoizedValue:t,next:null},Jc===null){if(Tm===null)throw Error(je(308));Jc=e,Tm.dependencies={lanes:0,firstContext:e}}else Jc=Jc.next=e;return t}var Ul=null;function wv(e){Ul===null?Ul=[e]:Ul.push(e)}function VE(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,wv(t)):(n.next=s.next,s.next=n),t.interleaved=n,ca(e,r)}function ca(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 $a=!1;function bv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function UE(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 oa(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Yt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ca(e,n)}return s=r.interleaved,s===null?(t.next=t,wv(r)):(t.next=s.next,s.next=t),r.interleaved=t,ca(e,n)}function Qh(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,iv(e,n)}}function Yk(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Rm(e,t,n,r){var s=e.updateQueue;$a=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?i=d:a.next=d,a=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==a&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(i!==null){var u=s.baseState;a=0,f=d=c=null,l=i;do{var p=l.lane,m=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,b=l;switch(p=t,m=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){u=g.call(m,u,p);break e}u=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,p=typeof g=="function"?g.call(m,u,p):g,p==null)break e;u=Qn({},u,p);break e;case 2:$a=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=m,c=u):f=f.next=m,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(f===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);ic|=a,e.lanes=a,e.memoizedState=u}}function Gk(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(je(191,s));s.call(r)}}}var ap={},Co=pl(ap),Cf=pl(ap),Ef=pl(ap);function Kl(e){if(e===ap)throw Error(je(174));return e}function vv(e,t){switch(Tn(Ef,t),Tn(Cf,e),Tn(Co,ap),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:aw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=aw(t,e)}zn(Co),Tn(Co,t)}function Su(){zn(Co),zn(Cf),zn(Ef)}function KE(e){Kl(Ef.current);var t=Kl(Co.current),n=aw(t,e.type);t!==n&&(Tn(Cf,e),Tn(Co,n))}function kv(e){Cf.current===e&&(zn(Co),zn(Cf))}var Xn=pl(0);function Lm(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 qy=[];function Sv(){for(var e=0;e<qy.length;e++)qy[e]._workInProgressVersionPrimary=null;qy.length=0}var Zh=ha.ReactCurrentDispatcher,Yy=ha.ReactCurrentBatchConfig,sc=0,Jn=null,Sr=null,Ir=null,Om=!1,ef=!1,_f=0,EO=0;function Qr(){throw Error(je(321))}function Nv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Qi(e[n],t[n]))return!1;return!0}function jv(e,t,n,r,s,i){if(sc=i,Jn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Zh.current=e===null||e.memoizedState===null?IO:TO,e=n(r,s),ef){i=0;do{if(ef=!1,_f=0,25<=i)throw Error(je(301));i+=1,Ir=Sr=null,t.updateQueue=null,Zh.current=RO,e=n(r,s)}while(ef)}if(Zh.current=Mm,t=Sr!==null&&Sr.next!==null,sc=0,Ir=Sr=Jn=null,Om=!1,t)throw Error(je(300));return e}function Cv(){var e=_f!==0;return _f=0,e}function go(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ir===null?Jn.memoizedState=Ir=e:Ir=Ir.next=e,Ir}function Ei(){if(Sr===null){var e=Jn.alternate;e=e!==null?e.memoizedState:null}else e=Sr.next;var t=Ir===null?Jn.memoizedState:Ir.next;if(t!==null)Ir=t,Sr=e;else{if(e===null)throw Error(je(310));Sr=e,e={memoizedState:Sr.memoizedState,baseState:Sr.baseState,baseQueue:Sr.baseQueue,queue:Sr.queue,next:null},Ir===null?Jn.memoizedState=Ir=e:Ir=Ir.next=e}return Ir}function Pf(e,t){return typeof t=="function"?t(e):t}function Gy(e){var t=Ei(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=Sr,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=a=null,c=null,d=i;do{var f=d.lane;if((sc&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var u={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=u,a=r):c=c.next=u,Jn.lanes|=f,ic|=f}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,Qi(r,t.memoizedState)||(_s=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Jn.lanes|=i,ic|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Xy(e){var t=Ei(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do i=e(i,a.action),a=a.next;while(a!==s);Qi(i,t.memoizedState)||(_s=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function qE(){}function YE(e,t){var n=Jn,r=Ei(),s=t(),i=!Qi(r.memoizedState,s);if(i&&(r.memoizedState=s,_s=!0),r=r.queue,Ev(JE.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Ir!==null&&Ir.memoizedState.tag&1){if(n.flags|=2048,Af(9,XE.bind(null,n,r,s,t),void 0,null),Rr===null)throw Error(je(349));sc&30||GE(n,t,s)}return s}function GE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Jn.updateQueue,t===null?(t={lastEffect:null,stores:null},Jn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function XE(e,t,n,r){t.value=n,t.getSnapshot=r,QE(t)&&ZE(e)}function JE(e,t,n){return n(function(){QE(t)&&ZE(e)})}function QE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Qi(e,n)}catch{return!0}}function ZE(e){var t=ca(e,1);t!==null&&Ji(t,e,1,-1)}function Xk(e){var t=go();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pf,lastRenderedState:e},t.queue=e,e=e.dispatch=AO.bind(null,Jn,e),[t.memoizedState,e]}function Af(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Jn.updateQueue,t===null?(t={lastEffect:null,stores:null},Jn.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 e_(){return Ei().memoizedState}function em(e,t,n,r){var s=go();Jn.flags|=e,s.memoizedState=Af(1|t,n,void 0,r===void 0?null:r)}function Lg(e,t,n,r){var s=Ei();r=r===void 0?null:r;var i=void 0;if(Sr!==null){var a=Sr.memoizedState;if(i=a.destroy,r!==null&&Nv(r,a.deps)){s.memoizedState=Af(t,n,i,r);return}}Jn.flags|=e,s.memoizedState=Af(1|t,n,i,r)}function Jk(e,t){return em(8390656,8,e,t)}function Ev(e,t){return Lg(2048,8,e,t)}function t_(e,t){return Lg(4,2,e,t)}function n_(e,t){return Lg(4,4,e,t)}function r_(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 s_(e,t,n){return n=n!=null?n.concat([e]):null,Lg(4,4,r_.bind(null,t,e),n)}function _v(){}function i_(e,t){var n=Ei();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Nv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function o_(e,t){var n=Ei();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Nv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function a_(e,t,n){return sc&21?(Qi(n,t)||(n=fE(),Jn.lanes|=n,ic|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,_s=!0),e.memoizedState=n)}function _O(e,t){var n=un;un=n!==0&&4>n?n:4,e(!0);var r=Yy.transition;Yy.transition={};try{e(!1),t()}finally{un=n,Yy.transition=r}}function l_(){return Ei().memoizedState}function PO(e,t,n){var r=Qa(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},c_(e))u_(t,n);else if(n=VE(e,t,n,r),n!==null){var s=hs();Ji(n,e,r,s),d_(n,t,r)}}function AO(e,t,n){var r=Qa(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(c_(e))u_(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,l=i(a,n);if(s.hasEagerState=!0,s.eagerState=l,Qi(l,a)){var c=t.interleaved;c===null?(s.next=s,wv(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=VE(e,t,s,r),n!==null&&(s=hs(),Ji(n,e,r,s),d_(n,t,r))}}function c_(e){var t=e.alternate;return e===Jn||t!==null&&t===Jn}function u_(e,t){ef=Om=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function d_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,iv(e,n)}}var Mm={readContext:Ci,useCallback:Qr,useContext:Qr,useEffect:Qr,useImperativeHandle:Qr,useInsertionEffect:Qr,useLayoutEffect:Qr,useMemo:Qr,useReducer:Qr,useRef:Qr,useState:Qr,useDebugValue:Qr,useDeferredValue:Qr,useTransition:Qr,useMutableSource:Qr,useSyncExternalStore:Qr,useId:Qr,unstable_isNewReconciler:!1},IO={readContext:Ci,useCallback:function(e,t){return go().memoizedState=[e,t===void 0?null:t],e},useContext:Ci,useEffect:Jk,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,em(4194308,4,r_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return em(4194308,4,e,t)},useInsertionEffect:function(e,t){return em(4,2,e,t)},useMemo:function(e,t){var n=go();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=go();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=PO.bind(null,Jn,e),[r.memoizedState,e]},useRef:function(e){var t=go();return e={current:e},t.memoizedState=e},useState:Xk,useDebugValue:_v,useDeferredValue:function(e){return go().memoizedState=e},useTransition:function(){var e=Xk(!1),t=e[0];return e=_O.bind(null,e[1]),go().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Jn,s=go();if(Kn){if(n===void 0)throw Error(je(407));n=n()}else{if(n=t(),Rr===null)throw Error(je(349));sc&30||GE(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Jk(JE.bind(null,r,i,e),[e]),r.flags|=2048,Af(9,XE.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=go(),t=Rr.identifierPrefix;if(Kn){var n=na,r=ta;n=(r&~(1<<32-Xi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=_f++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=EO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},TO={readContext:Ci,useCallback:i_,useContext:Ci,useEffect:Ev,useImperativeHandle:s_,useInsertionEffect:t_,useLayoutEffect:n_,useMemo:o_,useReducer:Gy,useRef:e_,useState:function(){return Gy(Pf)},useDebugValue:_v,useDeferredValue:function(e){var t=Ei();return a_(t,Sr.memoizedState,e)},useTransition:function(){var e=Gy(Pf)[0],t=Ei().memoizedState;return[e,t]},useMutableSource:qE,useSyncExternalStore:YE,useId:l_,unstable_isNewReconciler:!1},RO={readContext:Ci,useCallback:i_,useContext:Ci,useEffect:Ev,useImperativeHandle:s_,useInsertionEffect:t_,useLayoutEffect:n_,useMemo:o_,useReducer:Xy,useRef:e_,useState:function(){return Xy(Pf)},useDebugValue:_v,useDeferredValue:function(e){var t=Ei();return Sr===null?t.memoizedState=e:a_(t,Sr.memoizedState,e)},useTransition:function(){var e=Xy(Pf)[0],t=Ei().memoizedState;return[e,t]},useMutableSource:qE,useSyncExternalStore:YE,useId:l_,unstable_isNewReconciler:!1};function Bi(e,t){if(e&&e.defaultProps){t=Qn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function _w(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Qn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Og={isMounted:function(e){return(e=e._reactInternals)?hc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=hs(),s=Qa(e),i=oa(r,s);i.payload=t,n!=null&&(i.callback=n),t=Xa(e,i,s),t!==null&&(Ji(t,e,s,r),Qh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=hs(),s=Qa(e),i=oa(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Xa(e,i,s),t!==null&&(Ji(t,e,s,r),Qh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=hs(),r=Qa(e),s=oa(n,r);s.tag=2,t!=null&&(s.callback=t),t=Xa(e,s,r),t!==null&&(Ji(t,e,r,n),Qh(t,e,r))}};function Qk(e,t,n,r,s,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!kf(n,r)||!kf(s,i):!0}function f_(e,t,n){var r=!1,s=il,i=t.contextType;return typeof i=="object"&&i!==null?i=Ci(i):(s=Ls(t)?nc:ns.current,r=t.contextTypes,i=(r=r!=null)?bu(e,s):il),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Og,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Zk(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&&Og.enqueueReplaceState(t,t.state,null)}function Pw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},bv(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=Ci(i):(i=Ls(t)?nc:ns.current,s.context=bu(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(_w(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Og.enqueueReplaceState(s,s.state,null),Rm(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Nu(e,t){try{var n="",r=t;do n+=aL(r),r=r.return;while(r);var s=n}catch(i){s=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:e,source:t,stack:s,digest:null}}function Jy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Aw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var LO=typeof WeakMap=="function"?WeakMap:Map;function p_(e,t,n){n=oa(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Dm||(Dm=!0,zw=r),Aw(e,t)},n}function h_(e,t,n){n=oa(-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(){Aw(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Aw(e,t),typeof r!="function"&&(Ja===null?Ja=new Set([this]):Ja.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function eS(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new LO;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=YO.bind(null,e,t,n),t.then(e,e))}function tS(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=oa(-1,1),t.tag=2,Xa(n,t,1))),n.lanes|=1),e)}var OO=ha.ReactCurrentOwner,_s=!1;function fs(e,t,n,r){t.child=e===null?WE(t,null,n,r):ku(t,e.child,n,r)}function rS(e,t,n,r,s){n=n.render;var i=t.ref;return uu(t,s),r=jv(e,t,n,r,i,s),n=Cv(),e!==null&&!_s?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ua(e,t,s)):(Kn&&n&&pv(t),t.flags|=1,fs(e,t,r,s),t.child)}function sS(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!Mv(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,m_(e,t,i,r,s)):(e=sm(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:kf,n(a,r)&&e.ref===t.ref)return ua(e,t,s)}return t.flags|=1,e=Za(i,r),e.ref=t.ref,e.return=t,t.child=e}function m_(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(kf(i,r)&&e.ref===t.ref)if(_s=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(_s=!0);else return t.lanes=e.lanes,ua(e,t,s)}return Iw(e,t,n,r,s)}function g_(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tn(Zc,Gs),Gs|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Tn(Zc,Gs),Gs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Tn(Zc,Gs),Gs|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Tn(Zc,Gs),Gs|=r;return fs(e,t,s,n),t.child}function y_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Iw(e,t,n,r,s){var i=Ls(n)?nc:ns.current;return i=bu(t,i),uu(t,s),n=jv(e,t,n,r,i,s),r=Cv(),e!==null&&!_s?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ua(e,t,s)):(Kn&&r&&pv(t),t.flags|=1,fs(e,t,n,s),t.child)}function iS(e,t,n,r,s){if(Ls(n)){var i=!0;_m(t)}else i=!1;if(uu(t,s),t.stateNode===null)tm(e,t),f_(t,n,r),Pw(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Ci(d):(d=Ls(n)?nc:ns.current,d=bu(t,d));var f=n.getDerivedStateFromProps,u=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";u||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Zk(t,a,r,d),$a=!1;var p=t.memoizedState;a.state=p,Rm(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Rs.current||$a?(typeof f=="function"&&(_w(t,n,f,r),c=t.memoizedState),(l=$a||Qk(t,n,l,r,p,c,d))?(u||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,UE(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Bi(t.type,l),a.props=d,u=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ci(c):(c=Ls(n)?nc:ns.current,c=bu(t,c));var m=n.getDerivedStateFromProps;(f=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==u||p!==c)&&Zk(t,a,r,c),$a=!1,p=t.memoizedState,a.state=p,Rm(t,r,a,s);var g=t.memoizedState;l!==u||p!==g||Rs.current||$a?(typeof m=="function"&&(_w(t,n,m,r),g=t.memoizedState),(d=$a||Qk(t,n,d,r,p,g,c)||!1)?(f||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),a.props=r,a.state=g,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return Tw(e,t,n,r,i,s)}function Tw(e,t,n,r,s,i){y_(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Vk(t,n,!1),ua(e,t,i);r=t.stateNode,OO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=ku(t,e.child,null,i),t.child=ku(t,null,l,i)):fs(e,t,l,i),t.memoizedState=r.state,s&&Vk(t,n,!0),t.child}function x_(e){var t=e.stateNode;t.pendingContext?Wk(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Wk(e,t.context,!1),vv(e,t.containerInfo)}function oS(e,t,n,r,s){return vu(),mv(s),t.flags|=256,fs(e,t,n,r),t.child}var Rw={dehydrated:null,treeContext:null,retryLane:0};function Lw(e){return{baseLanes:e,cachePool:null,transitions:null}}function w_(e,t,n){var r=t.pendingProps,s=Xn.current,i=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),Tn(Xn,s&1),e===null)return Cw(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Dg(a,r,0,null),e=Xl(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Lw(n),t.memoizedState=Rw,e):Pv(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return MO(e,t,a,r,l,s,n);if(i){i=r.fallback,a=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Za(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=Za(l,i):(i=Xl(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?Lw(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=Rw,r}return i=e.child,e=i.sibling,r=Za(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Pv(e,t){return t=Dg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function hh(e,t,n,r){return r!==null&&mv(r),ku(t,e.child,null,n),e=Pv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function MO(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=Jy(Error(je(422))),hh(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Dg({mode:"visible",children:r.children},s,0,null),i=Xl(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&ku(t,e.child,null,a),t.child.memoizedState=Lw(a),t.memoizedState=Rw,i);if(!(t.mode&1))return hh(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(je(419)),r=Jy(i,r,void 0),hh(e,t,a,r)}if(l=(a&e.childLanes)!==0,_s||l){if(r=Rr,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,ca(e,s),Ji(r,e,s,-1))}return Ov(),r=Jy(Error(je(421))),hh(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=GO.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Qs=Ga(s.nextSibling),ei=t,Kn=!0,Ui=null,e!==null&&(bi[vi++]=ta,bi[vi++]=na,bi[vi++]=rc,ta=e.id,na=e.overflow,rc=t),t=Pv(t,r.children),t.flags|=4096,t)}function aS(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ew(e.return,t,n)}function Qy(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function b_(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(fs(e,t,r.children,n),r=Xn.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&&aS(e,n,t);else if(e.tag===19)aS(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(Tn(Xn,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&&Lm(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Qy(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Lm(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Qy(t,!0,n,null,i);break;case"together":Qy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function tm(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ua(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ic|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(je(153));if(t.child!==null){for(e=t.child,n=Za(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Za(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function $O(e,t,n){switch(t.tag){case 3:x_(t),vu();break;case 5:KE(t);break;case 1:Ls(t.type)&&_m(t);break;case 4:vv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;Tn(Im,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Tn(Xn,Xn.current&1),t.flags|=128,null):n&t.child.childLanes?w_(e,t,n):(Tn(Xn,Xn.current&1),e=ua(e,t,n),e!==null?e.sibling:null);Tn(Xn,Xn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return b_(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),Tn(Xn,Xn.current),r)break;return null;case 22:case 23:return t.lanes=0,g_(e,t,n)}return ua(e,t,n)}var v_,Ow,k_,S_;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}};Ow=function(){};k_=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Kl(Co.current);var i=null;switch(n){case"input":s=rw(e,s),r=rw(e,r),i=[];break;case"select":s=Qn({},s,{value:void 0}),r=Qn({},r,{value:void 0}),i=[];break;case"textarea":s=ow(e,s),r=ow(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Cm)}lw(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"&&(mf.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(mf.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Dn("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};S_=function(e,t,n,r){n!==r&&(t.flags|=4)};function Cd(e,t){if(!Kn)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 Zr(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 DO(e,t,n){var r=t.pendingProps;switch(hv(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zr(t),null;case 1:return Ls(t.type)&&Em(),Zr(t),null;case 3:return r=t.stateNode,Su(),zn(Rs),zn(ns),Sv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(fh(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ui!==null&&(Ww(Ui),Ui=null))),Ow(e,t),Zr(t),null;case 5:kv(t);var s=Kl(Ef.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(je(166));return Zr(t),null}if(e=Kl(Co.current),fh(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[vo]=t,r[jf]=i,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<Hd.length;s++)Dn(Hd[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":gk(r,i),Dn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Dn("invalid",r);break;case"textarea":xk(r,i),Dn("invalid",r)}lw(n,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&dh(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&dh(r.textContent,l,e),s=["children",""+l]):mf.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Dn("scroll",r)}switch(n){case"input":rh(r),yk(r,i,!0);break;case"textarea":rh(r),wk(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Cm)}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=JC(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[vo]=t,e[jf]=r,v_(e,t,!1,!1),t.stateNode=e;e:{switch(a=cw(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<Hd.length;s++)Dn(Hd[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":gk(e,r),s=rw(e,r),Dn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Qn({},r,{value:void 0}),Dn("invalid",e);break;case"textarea":xk(e,r),s=ow(e,r),Dn("invalid",e);break;default:s=r}lw(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?eE(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&QC(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&gf(e,c):typeof c=="number"&&gf(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(mf.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Dn("scroll",e):c!=null&&Zb(e,i,c,a))}switch(n){case"input":rh(e),yk(e,r,!1);break;case"textarea":rh(e),wk(e);break;case"option":r.value!=null&&e.setAttribute("value",""+sl(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ou(e,!!r.multiple,i,!1):r.defaultValue!=null&&ou(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Cm)}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 Zr(t),null;case 6:if(e&&t.stateNode!=null)S_(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(je(166));if(n=Kl(Ef.current),Kl(Co.current),fh(t)){if(r=t.stateNode,n=t.memoizedProps,r[vo]=t,(i=r.nodeValue!==n)&&(e=ei,e!==null))switch(e.tag){case 3:dh(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&dh(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[vo]=t,t.stateNode=r}return Zr(t),null;case 13:if(zn(Xn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Kn&&Qs!==null&&t.mode&1&&!(t.flags&128))HE(),vu(),t.flags|=98560,i=!1;else if(i=fh(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(je(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(je(317));i[vo]=t}else vu(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Zr(t),i=!1}else Ui!==null&&(Ww(Ui),Ui=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Xn.current&1?jr===0&&(jr=3):Ov())),t.updateQueue!==null&&(t.flags|=4),Zr(t),null);case 4:return Su(),Ow(e,t),e===null&&Sf(t.stateNode.containerInfo),Zr(t),null;case 10:return xv(t.type._context),Zr(t),null;case 17:return Ls(t.type)&&Em(),Zr(t),null;case 19:if(zn(Xn),i=t.memoizedState,i===null)return Zr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Cd(i,!1);else{if(jr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Lm(e),a!==null){for(t.flags|=128,Cd(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Tn(Xn,Xn.current&1|2),t.child}e=e.sibling}i.tail!==null&&pr()>ju&&(t.flags|=128,r=!0,Cd(i,!1),t.lanes=4194304)}else{if(!r)if(e=Lm(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Cd(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Kn)return Zr(t),null}else 2*pr()-i.renderingStartTime>ju&&n!==1073741824&&(t.flags|=128,r=!0,Cd(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=pr(),t.sibling=null,n=Xn.current,Tn(Xn,r?n&1|2:n&1),t):(Zr(t),null);case 22:case 23:return Lv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Gs&1073741824&&(Zr(t),t.subtreeFlags&6&&(t.flags|=8192)):Zr(t),null;case 24:return null;case 25:return null}throw Error(je(156,t.tag))}function FO(e,t){switch(hv(t),t.tag){case 1:return Ls(t.type)&&Em(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Su(),zn(Rs),zn(ns),Sv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kv(t),null;case 13:if(zn(Xn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(je(340));vu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zn(Xn),null;case 4:return Su(),null;case 10:return xv(t.type._context),null;case 22:case 23:return Lv(),null;case 24:return null;default:return null}}var mh=!1,es=!1,zO=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function Qc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ir(e,t,r)}else n.current=null}function Mw(e,t,n){try{n()}catch(r){ir(e,t,r)}}var lS=!1;function HO(e,t){if(ww=Sm,e=_E(),fv(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,f=0,u=e,p=null;t:for(;;){for(var m;u!==n||s!==0&&u.nodeType!==3||(l=a+s),u!==i||r!==0&&u.nodeType!==3||(c=a+r),u.nodeType===3&&(a+=u.nodeValue.length),(m=u.firstChild)!==null;)p=u,u=m;for(;;){if(u===e)break t;if(p===n&&++d===s&&(l=a),p===i&&++f===r&&(c=a),(m=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(bw={focusedElem:e,selectionRange:n},Sm=!1,Ke=t;Ke!==null;)if(t=Ke,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ke=e;else for(;Ke!==null;){t=Ke;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var b=g.memoizedProps,v=g.memoizedState,y=t.stateNode,k=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:Bi(t.type,b),v);y.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(je(163))}}catch(j){ir(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Ke=e;break}Ke=t.return}return g=lS,lS=!1,g}function tf(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Mw(t,n,i)}s=s.next}while(s!==r)}}function Mg(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 $w(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 N_(e){var t=e.alternate;t!==null&&(e.alternate=null,N_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[vo],delete t[jf],delete t[Sw],delete t[SO],delete t[NO])),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 j_(e){return e.tag===5||e.tag===3||e.tag===4}function cS(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||j_(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 Dw(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=Cm));else if(r!==4&&(e=e.child,e!==null))for(Dw(e,t,n),e=e.sibling;e!==null;)Dw(e,t,n),e=e.sibling}function Fw(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(Fw(e,t,n),e=e.sibling;e!==null;)Fw(e,t,n),e=e.sibling}var $r=null,Wi=!1;function Aa(e,t,n){for(n=n.child;n!==null;)C_(e,t,n),n=n.sibling}function C_(e,t,n){if(jo&&typeof jo.onCommitFiberUnmount=="function")try{jo.onCommitFiberUnmount(_g,n)}catch{}switch(n.tag){case 5:es||Qc(n,t);case 6:var r=$r,s=Wi;$r=null,Aa(e,t,n),$r=r,Wi=s,$r!==null&&(Wi?(e=$r,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):$r.removeChild(n.stateNode));break;case 18:$r!==null&&(Wi?(e=$r,n=n.stateNode,e.nodeType===8?Uy(e.parentNode,n):e.nodeType===1&&Uy(e,n),bf(e)):Uy($r,n.stateNode));break;case 4:r=$r,s=Wi,$r=n.stateNode.containerInfo,Wi=!0,Aa(e,t,n),$r=r,Wi=s;break;case 0:case 11:case 14:case 15:if(!es&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Mw(n,t,a),s=s.next}while(s!==r)}Aa(e,t,n);break;case 1:if(!es&&(Qc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ir(n,t,l)}Aa(e,t,n);break;case 21:Aa(e,t,n);break;case 22:n.mode&1?(es=(r=es)||n.memoizedState!==null,Aa(e,t,n),es=r):Aa(e,t,n);break;default:Aa(e,t,n)}}function uS(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new zO),t.forEach(function(r){var s=XO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Di(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:$r=l.stateNode,Wi=!1;break e;case 3:$r=l.stateNode.containerInfo,Wi=!0;break e;case 4:$r=l.stateNode.containerInfo,Wi=!0;break e}l=l.return}if($r===null)throw Error(je(160));C_(i,a,s),$r=null,Wi=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){ir(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)E_(t,e),t=t.sibling}function E_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Di(t,e),ho(e),r&4){try{tf(3,e,e.return),Mg(3,e)}catch(b){ir(e,e.return,b)}try{tf(5,e,e.return)}catch(b){ir(e,e.return,b)}}break;case 1:Di(t,e),ho(e),r&512&&n!==null&&Qc(n,n.return);break;case 5:if(Di(t,e),ho(e),r&512&&n!==null&&Qc(n,n.return),e.flags&32){var s=e.stateNode;try{gf(s,"")}catch(b){ir(e,e.return,b)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&GC(s,i),cw(l,a);var d=cw(l,i);for(a=0;a<c.length;a+=2){var f=c[a],u=c[a+1];f==="style"?eE(s,u):f==="dangerouslySetInnerHTML"?QC(s,u):f==="children"?gf(s,u):Zb(s,f,u,d)}switch(l){case"input":sw(s,i);break;case"textarea":XC(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?ou(s,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?ou(s,!!i.multiple,i.defaultValue,!0):ou(s,!!i.multiple,i.multiple?[]:"",!1))}s[jf]=i}catch(b){ir(e,e.return,b)}}break;case 6:if(Di(t,e),ho(e),r&4){if(e.stateNode===null)throw Error(je(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){ir(e,e.return,b)}}break;case 3:if(Di(t,e),ho(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{bf(t.containerInfo)}catch(b){ir(e,e.return,b)}break;case 4:Di(t,e),ho(e);break;case 13:Di(t,e),ho(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Tv=pr())),r&4&&uS(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(es=(d=es)||f,Di(t,e),es=d):Di(t,e),ho(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Ke=e,f=e.child;f!==null;){for(u=Ke=f;Ke!==null;){switch(p=Ke,m=p.child,p.tag){case 0:case 11:case 14:case 15:tf(4,p,p.return);break;case 1:Qc(p,p.return);var g=p.stateNode;if(typeof g.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(b){ir(r,n,b)}}break;case 5:Qc(p,p.return);break;case 22:if(p.memoizedState!==null){fS(u);continue}}m!==null?(m.return=p,Ke=m):fS(u)}f=f.sibling}e:for(f=null,u=e;;){if(u.tag===5){if(f===null){f=u;try{s=u.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=u.stateNode,c=u.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ZC("display",a))}catch(b){ir(e,e.return,b)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=d?"":u.memoizedProps}catch(b){ir(e,e.return,b)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===e)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===e)break e;for(;u.sibling===null;){if(u.return===null||u.return===e)break e;f===u&&(f=null),u=u.return}f===u&&(f=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Di(t,e),ho(e),r&4&&uS(e);break;case 21:break;default:Di(t,e),ho(e)}}function ho(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(j_(n)){var r=n;break e}n=n.return}throw Error(je(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(gf(s,""),r.flags&=-33);var i=cS(e);Fw(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=cS(e);Dw(e,l,a);break;default:throw Error(je(161))}}catch(c){ir(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function BO(e,t,n){Ke=e,__(e)}function __(e,t,n){for(var r=(e.mode&1)!==0;Ke!==null;){var s=Ke,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||mh;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||es;l=mh;var d=es;if(mh=a,(es=c)&&!d)for(Ke=s;Ke!==null;)a=Ke,c=a.child,a.tag===22&&a.memoizedState!==null?pS(s):c!==null?(c.return=a,Ke=c):pS(s);for(;i!==null;)Ke=i,__(i),i=i.sibling;Ke=s,mh=l,es=d}dS(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Ke=i):dS(e)}}function dS(e){for(;Ke!==null;){var t=Ke;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:es||Mg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!es)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Bi(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Gk(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Gk(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var u=f.dehydrated;u!==null&&bf(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(je(163))}es||t.flags&512&&$w(t)}catch(p){ir(t,t.return,p)}}if(t===e){Ke=null;break}if(n=t.sibling,n!==null){n.return=t.return,Ke=n;break}Ke=t.return}}function fS(e){for(;Ke!==null;){var t=Ke;if(t===e){Ke=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Ke=n;break}Ke=t.return}}function pS(e){for(;Ke!==null;){var t=Ke;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Mg(4,t)}catch(c){ir(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){ir(t,s,c)}}var i=t.return;try{$w(t)}catch(c){ir(t,i,c)}break;case 5:var a=t.return;try{$w(t)}catch(c){ir(t,a,c)}}}catch(c){ir(t,t.return,c)}if(t===e){Ke=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Ke=l;break}Ke=t.return}}var WO=Math.ceil,$m=ha.ReactCurrentDispatcher,Av=ha.ReactCurrentOwner,ji=ha.ReactCurrentBatchConfig,Yt=0,Rr=null,xr=null,Fr=0,Gs=0,Zc=pl(0),jr=0,If=null,ic=0,$g=0,Iv=0,nf=null,Es=null,Tv=0,ju=1/0,Jo=null,Dm=!1,zw=null,Ja=null,gh=!1,Wa=null,Fm=0,rf=0,Hw=null,nm=-1,rm=0;function hs(){return Yt&6?pr():nm!==-1?nm:nm=pr()}function Qa(e){return e.mode&1?Yt&2&&Fr!==0?Fr&-Fr:CO.transition!==null?(rm===0&&(rm=fE()),rm):(e=un,e!==0||(e=window.event,e=e===void 0?16:wE(e.type)),e):1}function Ji(e,t,n,r){if(50<rf)throw rf=0,Hw=null,Error(je(185));sp(e,n,r),(!(Yt&2)||e!==Rr)&&(e===Rr&&(!(Yt&2)&&($g|=n),jr===4&&za(e,Fr)),Os(e,r),n===1&&Yt===0&&!(t.mode&1)&&(ju=pr()+500,Rg&&hl()))}function Os(e,t){var n=e.callbackNode;CL(e,t);var r=km(e,e===Rr?Fr:0);if(r===0)n!==null&&kk(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&kk(n),t===1)e.tag===0?jO(hS.bind(null,e)):DE(hS.bind(null,e)),vO(function(){!(Yt&6)&&hl()}),n=null;else{switch(pE(r)){case 1:n=sv;break;case 4:n=uE;break;case 16:n=vm;break;case 536870912:n=dE;break;default:n=vm}n=M_(n,P_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function P_(e,t){if(nm=-1,rm=0,Yt&6)throw Error(je(327));var n=e.callbackNode;if(du()&&e.callbackNode!==n)return null;var r=km(e,e===Rr?Fr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=zm(e,r);else{t=r;var s=Yt;Yt|=2;var i=I_();(Rr!==e||Fr!==t)&&(Jo=null,ju=pr()+500,Gl(e,t));do try{KO();break}catch(l){A_(e,l)}while(!0);yv(),$m.current=i,Yt=s,xr!==null?t=0:(Rr=null,Fr=0,t=jr)}if(t!==0){if(t===2&&(s=hw(e),s!==0&&(r=s,t=Bw(e,s))),t===1)throw n=If,Gl(e,0),za(e,r),Os(e,pr()),n;if(t===6)za(e,r);else{if(s=e.current.alternate,!(r&30)&&!VO(s)&&(t=zm(e,r),t===2&&(i=hw(e),i!==0&&(r=i,t=Bw(e,i))),t===1))throw n=If,Gl(e,0),za(e,r),Os(e,pr()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(je(345));case 2:zl(e,Es,Jo);break;case 3:if(za(e,r),(r&130023424)===r&&(t=Tv+500-pr(),10<t)){if(km(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){hs(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=kw(zl.bind(null,e,Es,Jo),t);break}zl(e,Es,Jo);break;case 4:if(za(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Xi(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}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*WO(r/1960))-r,10<r){e.timeoutHandle=kw(zl.bind(null,e,Es,Jo),r);break}zl(e,Es,Jo);break;case 5:zl(e,Es,Jo);break;default:throw Error(je(329))}}}return Os(e,pr()),e.callbackNode===n?P_.bind(null,e):null}function Bw(e,t){var n=nf;return e.current.memoizedState.isDehydrated&&(Gl(e,t).flags|=256),e=zm(e,t),e!==2&&(t=Es,Es=n,t!==null&&Ww(t)),e}function Ww(e){Es===null?Es=e:Es.push.apply(Es,e)}function VO(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!Qi(i(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function za(e,t){for(t&=~Iv,t&=~$g,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Xi(t),r=1<<n;e[n]=-1,t&=~r}}function hS(e){if(Yt&6)throw Error(je(327));du();var t=km(e,0);if(!(t&1))return Os(e,pr()),null;var n=zm(e,t);if(e.tag!==0&&n===2){var r=hw(e);r!==0&&(t=r,n=Bw(e,r))}if(n===1)throw n=If,Gl(e,0),za(e,t),Os(e,pr()),n;if(n===6)throw Error(je(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,zl(e,Es,Jo),Os(e,pr()),null}function Rv(e,t){var n=Yt;Yt|=1;try{return e(t)}finally{Yt=n,Yt===0&&(ju=pr()+500,Rg&&hl())}}function oc(e){Wa!==null&&Wa.tag===0&&!(Yt&6)&&du();var t=Yt;Yt|=1;var n=ji.transition,r=un;try{if(ji.transition=null,un=1,e)return e()}finally{un=r,ji.transition=n,Yt=t,!(Yt&6)&&hl()}}function Lv(){Gs=Zc.current,zn(Zc)}function Gl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,bO(n)),xr!==null)for(n=xr.return;n!==null;){var r=n;switch(hv(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Em();break;case 3:Su(),zn(Rs),zn(ns),Sv();break;case 5:kv(r);break;case 4:Su();break;case 13:zn(Xn);break;case 19:zn(Xn);break;case 10:xv(r.type._context);break;case 22:case 23:Lv()}n=n.return}if(Rr=e,xr=e=Za(e.current,null),Fr=Gs=t,jr=0,If=null,Iv=$g=ic=0,Es=nf=null,Ul!==null){for(t=0;t<Ul.length;t++)if(n=Ul[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}n.pending=r}Ul=null}return e}function A_(e,t){do{var n=xr;try{if(yv(),Zh.current=Mm,Om){for(var r=Jn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Om=!1}if(sc=0,Ir=Sr=Jn=null,ef=!1,_f=0,Av.current=null,n===null||n.return===null){jr=1,If=t,xr=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=Fr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,u=f.tag;if(!(f.mode&1)&&(u===0||u===11||u===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var m=tS(a);if(m!==null){m.flags&=-257,nS(m,a,l,i,t),m.mode&1&&eS(i,d,t),t=m,c=d;var g=t.updateQueue;if(g===null){var b=new Set;b.add(c),t.updateQueue=b}else g.add(c);break e}else{if(!(t&1)){eS(i,d,t),Ov();break e}c=Error(je(426))}}else if(Kn&&l.mode&1){var v=tS(a);if(v!==null){!(v.flags&65536)&&(v.flags|=256),nS(v,a,l,i,t),mv(Nu(c,l));break e}}i=c=Nu(c,l),jr!==4&&(jr=2),nf===null?nf=[i]:nf.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=p_(i,c,t);Yk(i,y);break e;case 1:l=c;var k=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof k.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ja===null||!Ja.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=h_(i,l,t);Yk(i,j);break e}}i=i.return}while(i!==null)}R_(n)}catch(_){t=_,xr===n&&n!==null&&(xr=n=n.return);continue}break}while(!0)}function I_(){var e=$m.current;return $m.current=Mm,e===null?Mm:e}function Ov(){(jr===0||jr===3||jr===2)&&(jr=4),Rr===null||!(ic&268435455)&&!($g&268435455)||za(Rr,Fr)}function zm(e,t){var n=Yt;Yt|=2;var r=I_();(Rr!==e||Fr!==t)&&(Jo=null,Gl(e,t));do try{UO();break}catch(s){A_(e,s)}while(!0);if(yv(),Yt=n,$m.current=r,xr!==null)throw Error(je(261));return Rr=null,Fr=0,jr}function UO(){for(;xr!==null;)T_(xr)}function KO(){for(;xr!==null&&!yL();)T_(xr)}function T_(e){var t=O_(e.alternate,e,Gs);e.memoizedProps=e.pendingProps,t===null?R_(e):xr=t,Av.current=null}function R_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=FO(n,t),n!==null){n.flags&=32767,xr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{jr=6,xr=null;return}}else if(n=DO(n,t,Gs),n!==null){xr=n;return}if(t=t.sibling,t!==null){xr=t;return}xr=t=e}while(t!==null);jr===0&&(jr=5)}function zl(e,t,n){var r=un,s=ji.transition;try{ji.transition=null,un=1,qO(e,t,n,r)}finally{ji.transition=s,un=r}return null}function qO(e,t,n,r){do du();while(Wa!==null);if(Yt&6)throw Error(je(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(je(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(EL(e,i),e===Rr&&(xr=Rr=null,Fr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||gh||(gh=!0,M_(vm,function(){return du(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ji.transition,ji.transition=null;var a=un;un=1;var l=Yt;Yt|=4,Av.current=null,HO(e,n),E_(n,e),pO(bw),Sm=!!ww,bw=ww=null,e.current=n,BO(n),xL(),Yt=l,un=a,ji.transition=i}else e.current=n;if(gh&&(gh=!1,Wa=e,Fm=s),i=e.pendingLanes,i===0&&(Ja=null),vL(n.stateNode),Os(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(Dm)throw Dm=!1,e=zw,zw=null,e;return Fm&1&&e.tag!==0&&du(),i=e.pendingLanes,i&1?e===Hw?rf++:(rf=0,Hw=e):rf=0,hl(),null}function du(){if(Wa!==null){var e=pE(Fm),t=ji.transition,n=un;try{if(ji.transition=null,un=16>e?16:e,Wa===null)var r=!1;else{if(e=Wa,Wa=null,Fm=0,Yt&6)throw Error(je(331));var s=Yt;for(Yt|=4,Ke=e.current;Ke!==null;){var i=Ke,a=i.child;if(Ke.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Ke=d;Ke!==null;){var f=Ke;switch(f.tag){case 0:case 11:case 15:tf(8,f,i)}var u=f.child;if(u!==null)u.return=f,Ke=u;else for(;Ke!==null;){f=Ke;var p=f.sibling,m=f.return;if(N_(f),f===d){Ke=null;break}if(p!==null){p.return=m,Ke=p;break}Ke=m}}}var g=i.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var v=b.sibling;b.sibling=null,b=v}while(b!==null)}}Ke=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Ke=a;else e:for(;Ke!==null;){if(i=Ke,i.flags&2048)switch(i.tag){case 0:case 11:case 15:tf(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,Ke=y;break e}Ke=i.return}}var k=e.current;for(Ke=k;Ke!==null;){a=Ke;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,Ke=w;else e:for(a=k;Ke!==null;){if(l=Ke,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Mg(9,l)}}catch(_){ir(l,l.return,_)}if(l===a){Ke=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Ke=j;break e}Ke=l.return}}if(Yt=s,hl(),jo&&typeof jo.onPostCommitFiberRoot=="function")try{jo.onPostCommitFiberRoot(_g,e)}catch{}r=!0}return r}finally{un=n,ji.transition=t}}return!1}function mS(e,t,n){t=Nu(n,t),t=p_(e,t,1),e=Xa(e,t,1),t=hs(),e!==null&&(sp(e,1,t),Os(e,t))}function ir(e,t,n){if(e.tag===3)mS(e,e,n);else for(;t!==null;){if(t.tag===3){mS(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ja===null||!Ja.has(r))){e=Nu(n,e),e=h_(t,e,1),t=Xa(t,e,1),e=hs(),t!==null&&(sp(t,1,e),Os(t,e));break}}t=t.return}}function YO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=hs(),e.pingedLanes|=e.suspendedLanes&n,Rr===e&&(Fr&n)===n&&(jr===4||jr===3&&(Fr&130023424)===Fr&&500>pr()-Tv?Gl(e,0):Iv|=n),Os(e,t)}function L_(e,t){t===0&&(e.mode&1?(t=oh,oh<<=1,!(oh&130023424)&&(oh=4194304)):t=1);var n=hs();e=ca(e,t),e!==null&&(sp(e,t,n),Os(e,n))}function GO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),L_(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(je(314))}r!==null&&r.delete(t),L_(e,n)}var O_;O_=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Rs.current)_s=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return _s=!1,$O(e,t,n);_s=!!(e.flags&131072)}else _s=!1,Kn&&t.flags&1048576&&FE(t,Am,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;tm(e,t),e=t.pendingProps;var s=bu(t,ns.current);uu(t,n),s=jv(null,t,r,e,s,n);var i=Cv();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ls(r)?(i=!0,_m(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,bv(t),s.updater=Og,t.stateNode=s,s._reactInternals=t,Pw(t,r,e,n),t=Tw(null,t,r,!0,i,n)):(t.tag=0,Kn&&i&&pv(t),fs(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(tm(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=QO(r),e=Bi(r,e),s){case 0:t=Iw(null,t,r,e,n);break e;case 1:t=iS(null,t,r,e,n);break e;case 11:t=rS(null,t,r,e,n);break e;case 14:t=sS(null,t,r,Bi(r.type,e),n);break e}throw Error(je(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),Iw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),iS(e,t,r,s,n);case 3:e:{if(x_(t),e===null)throw Error(je(387));r=t.pendingProps,i=t.memoizedState,s=i.element,UE(e,t),Rm(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Nu(Error(je(423)),t),t=oS(e,t,r,n,s);break e}else if(r!==s){s=Nu(Error(je(424)),t),t=oS(e,t,r,n,s);break e}else for(Qs=Ga(t.stateNode.containerInfo.firstChild),ei=t,Kn=!0,Ui=null,n=WE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vu(),r===s){t=ua(e,t,n);break e}fs(e,t,r,n)}t=t.child}return t;case 5:return KE(t),e===null&&Cw(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,vw(r,s)?a=null:i!==null&&vw(r,i)&&(t.flags|=32),y_(e,t),fs(e,t,a,n),t.child;case 6:return e===null&&Cw(t),null;case 13:return w_(e,t,n);case 4:return vv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ku(t,null,r,n):fs(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),rS(e,t,r,s,n);case 7:return fs(e,t,t.pendingProps,n),t.child;case 8:return fs(e,t,t.pendingProps.children,n),t.child;case 12:return fs(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,Tn(Im,r._currentValue),r._currentValue=a,i!==null)if(Qi(i.value,a)){if(i.children===s.children&&!Rs.current){t=ua(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=oa(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Ew(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(je(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),Ew(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}fs(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,uu(t,n),s=Ci(s),r=r(s),t.flags|=1,fs(e,t,r,n),t.child;case 14:return r=t.type,s=Bi(r,t.pendingProps),s=Bi(r.type,s),sS(e,t,r,s,n);case 15:return m_(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),tm(e,t),t.tag=1,Ls(r)?(e=!0,_m(t)):e=!1,uu(t,n),f_(t,r,s),Pw(t,r,s,n),Tw(null,t,r,!0,e,n);case 19:return b_(e,t,n);case 22:return g_(e,t,n)}throw Error(je(156,t.tag))};function M_(e,t){return cE(e,t)}function JO(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 Ni(e,t,n,r){return new JO(e,t,n,r)}function Mv(e){return e=e.prototype,!(!e||!e.isReactComponent)}function QO(e){if(typeof e=="function")return Mv(e)?1:0;if(e!=null){if(e=e.$$typeof,e===tv)return 11;if(e===nv)return 14}return 2}function Za(e,t){var n=e.alternate;return n===null?(n=Ni(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 sm(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Mv(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Wc:return Xl(n.children,s,i,t);case ev:a=8,s|=8;break;case Zx:return e=Ni(12,n,t,s|2),e.elementType=Zx,e.lanes=i,e;case ew:return e=Ni(13,n,t,s),e.elementType=ew,e.lanes=i,e;case tw:return e=Ni(19,n,t,s),e.elementType=tw,e.lanes=i,e;case KC:return Dg(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case VC:a=10;break e;case UC:a=9;break e;case tv:a=11;break e;case nv:a=14;break e;case Ma:a=16,r=null;break e}throw Error(je(130,e==null?e:typeof e,""))}return t=Ni(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Xl(e,t,n,r){return e=Ni(7,e,r,t),e.lanes=n,e}function Dg(e,t,n,r){return e=Ni(22,e,r,t),e.elementType=KC,e.lanes=n,e.stateNode={isHidden:!1},e}function Zy(e,t,n){return e=Ni(6,e,null,t),e.lanes=n,e}function ex(e,t,n){return t=Ni(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ZO(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=Ly(0),this.expirationTimes=Ly(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ly(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function $v(e,t,n,r,s,i,a,l,c){return e=new ZO(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ni(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},bv(i),e}function eM(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function $_(e){if(!e)return il;e=e._reactInternals;e:{if(hc(e)!==e||e.tag!==1)throw Error(je(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ls(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(je(171))}if(e.tag===1){var n=e.type;if(Ls(n))return $E(e,n,t)}return t}function D_(e,t,n,r,s,i,a,l,c){return e=$v(n,r,!0,e,s,i,a,l,c),e.context=$_(null),n=e.current,r=hs(),s=Qa(n),i=oa(r,s),i.callback=t??null,Xa(n,i,s),e.current.lanes=s,sp(e,s,r),Os(e,r),e}function Fg(e,t,n,r){var s=t.current,i=hs(),a=Qa(s);return n=$_(n),t.context===null?t.context=n:t.pendingContext=n,t=oa(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Xa(s,t,a),e!==null&&(Ji(e,s,a,i),Qh(e,s,a)),a}function Hm(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 gS(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Dv(e,t){gS(e,t),(e=e.alternate)&&gS(e,t)}function tM(){return null}var F_=typeof reportError=="function"?reportError:function(e){console.error(e)};function Fv(e){this._internalRoot=e}zg.prototype.render=Fv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(je(409));Fg(e,t,null,null)};zg.prototype.unmount=Fv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;oc(function(){Fg(null,e,null,null)}),t[la]=null}};function zg(e){this._internalRoot=e}zg.prototype.unstable_scheduleHydration=function(e){if(e){var t=gE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Fa.length&&t!==0&&t<Fa[n].priority;n++);Fa.splice(n,0,e),n===0&&xE(e)}};function zv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Hg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function yS(){}function nM(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=Hm(a);i.call(d)}}var a=D_(t,r,e,0,null,!1,!1,"",yS);return e._reactRootContainer=a,e[la]=a.current,Sf(e.nodeType===8?e.parentNode:e),oc(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Hm(c);l.call(d)}}var c=$v(e,0,!1,null,null,!1,!1,"",yS);return e._reactRootContainer=c,e[la]=c.current,Sf(e.nodeType===8?e.parentNode:e),oc(function(){Fg(t,c,n,r)}),c}function Bg(e,t,n,r,s){var i=n._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var c=Hm(a);l.call(c)}}Fg(t,a,e,s)}else a=nM(n,t,e,s,r);return Hm(a)}hE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=zd(t.pendingLanes);n!==0&&(iv(t,n|1),Os(t,pr()),!(Yt&6)&&(ju=pr()+500,hl()))}break;case 13:oc(function(){var r=ca(e,1);if(r!==null){var s=hs();Ji(r,e,1,s)}}),Dv(e,1)}};ov=function(e){if(e.tag===13){var t=ca(e,134217728);if(t!==null){var n=hs();Ji(t,e,134217728,n)}Dv(e,134217728)}};mE=function(e){if(e.tag===13){var t=Qa(e),n=ca(e,t);if(n!==null){var r=hs();Ji(n,e,t,r)}Dv(e,t)}};gE=function(){return un};yE=function(e,t){var n=un;try{return un=e,t()}finally{un=n}};dw=function(e,t,n){switch(t){case"input":if(sw(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=Tg(r);if(!s)throw Error(je(90));YC(r),sw(r,s)}}}break;case"textarea":XC(e,n);break;case"select":t=n.value,t!=null&&ou(e,!!n.multiple,t,!1)}};rE=Rv;sE=oc;var rM={usingClientEntryPoint:!1,Events:[op,qc,Tg,tE,nE,Rv]},Ed={findFiberByHostInstance:Vl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},sM={bundleType:Ed.bundleType,version:Ed.version,rendererPackageName:Ed.rendererPackageName,rendererConfig:Ed.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ha.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=aE(e),e===null?null:e.stateNode},findFiberByHostInstance:Ed.findFiberByHostInstance||tM,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 yh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yh.isDisabled&&yh.supportsFiber)try{_g=yh.inject(sM),jo=yh}catch{}}si.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=rM;si.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zv(t))throw Error(je(200));return eM(e,t,null,n)};si.createRoot=function(e,t){if(!zv(e))throw Error(je(299));var n=!1,r="",s=F_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=$v(e,1,!1,null,null,n,!1,r,s),e[la]=t.current,Sf(e.nodeType===8?e.parentNode:e),new Fv(t)};si.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(je(188)):(e=Object.keys(e).join(","),Error(je(268,e)));return e=aE(t),e=e===null?null:e.stateNode,e};si.flushSync=function(e){return oc(e)};si.hydrate=function(e,t,n){if(!Hg(t))throw Error(je(200));return Bg(null,e,t,!0,n)};si.hydrateRoot=function(e,t,n){if(!zv(e))throw Error(je(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=F_;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=D_(t,null,e,1,n??null,s,!1,i,a),e[la]=t.current,Sf(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 zg(t)};si.render=function(e,t,n){if(!Hg(t))throw Error(je(200));return Bg(null,e,t,!1,n)};si.unmountComponentAtNode=function(e){if(!Hg(e))throw Error(je(40));return e._reactRootContainer?(oc(function(){Bg(null,null,e,!1,function(){e._reactRootContainer=null,e[la]=null})}),!0):!1};si.unstable_batchedUpdates=Rv;si.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Hg(n))throw Error(je(200));if(e==null||e._reactInternals===void 0)throw Error(je(38));return Bg(e,t,n,!1,r)};si.version="18.3.1-next-f1338f8080-20240426";function z_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(z_)}catch(e){console.error(e)}}z_(),zC.exports=si;var Dr=zC.exports,xS=Dr;Jx.createRoot=xS.createRoot,Jx.hydrateRoot=xS.hydrateRoot;const H_=h.createContext(null);function Vw(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function iM(){const e=Vw(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function oM({children:e}){const[t,n]=h.useState(iM);h.useEffect(()=>{const i=()=>n(Vw(window.location.pathname));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const r=h.useCallback(i=>{const a=i.startsWith("/")?i:`/${i}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Vw(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(H_.Provider,{value:s,children:e})}function Ro(){const e=h.useContext(H_);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function aM(){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 wS={};function Uw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&wS[t[0]]||(typeof t[0]=="string"&&(wS[t[0]]=new Date),aM(...t))}const B_=(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,B_(e,n))}function vS(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,B_(e,r))}function lM(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],s=t.options?t.options.fallbackLng:!1,i=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=t.services.backendConnector.state[`${l}|${c}`];return d===-1||d===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(i,e)))}function cM(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Uw("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,e))return!1}}):lM(e,t,n)}const uM=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,dM={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},fM=e=>dM[e],pM=e=>e.replace(uM,fM);let Kw={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:pM};function hM(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Kw={...Kw,...e}}function mM(){return Kw}let W_;function gM(e){W_=e}function yM(){return W_}const xM={type:"3rdParty",init(e){hM(e.options.react),gM(e)}},wM=h.createContext();class bM{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const vM=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function Ln(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=h.useContext(wM)||{},i=n||r||yM();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new bM),!i){Uw("You will need to pass in an i18next instance by using initReactI18next");const w=(_,E)=>typeof E=="string"?E:E&&typeof E=="object"&&typeof E.defaultValue=="string"?E.defaultValue:Array.isArray(_)?_[_.length-1]:_,j=[w,{},!1];return j.t=w,j.i18n={},j.ready=!1,j}i.options.react&&i.options.react.wait!==void 0&&Uw("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...mM(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let d=e||s||i.options&&i.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(d);const f=(i.isInitialized||i.initializedStoreOnce)&&d.every(w=>cM(w,i,a));function u(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],c)}const[p,m]=h.useState(u);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const b=vM(g),v=h.useRef(!0);h.useEffect(()=>{const{bindI18n:w,bindI18nStore:j}=a;v.current=!0,!f&&!l&&(t.lng?vS(i,t.lng,d,()=>{v.current&&m(u)}):bS(i,d,()=>{v.current&&m(u)})),f&&b&&b!==g&&v.current&&m(u);function _(){v.current&&m(u)}return w&&i&&i.on(w,_),j&&i&&i.store.on(j,_),()=>{v.current=!1,w&&i&&w.split(" ").forEach(E=>i.off(E,_)),j&&i&&j.split(" ").forEach(E=>i.store.off(E,_))}},[i,g]);const y=h.useRef(!0);h.useEffect(()=>{v.current&&!y.current&&m(u),y.current=!1},[i,c]);const k=[p,i,f];if(k.t=p,k.i18n=i,k.ready=f,f||!f&&!l)return k;throw new Promise(w=>{t.lng?vS(i,t.lng,d,()=>w()):bS(i,d,()=>w())})}const V_="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",kM=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],SM=[{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 NM(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function jM({authUser:e,onLogout:t}){const{path:n,navigate:r}=Ro(),{t:s}=Ln(),[i,a]=h.useState(!1);return h.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),o.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[o.jsxs("div",{className:"af-brand",children:[o.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:o.jsx("img",{src:V_,alt:"",width:"36",height:"36",decoding:"async"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),o.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),o.jsx("nav",{className:"af-nav",children:kM.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(NM(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[o.jsx("span",{className:"material-symbols-outlined",children:l.icon}),o.jsx("span",{children:s(l.labelKey)})]},l.to))}),o.jsxs("div",{className:"af-sidebar-footer",children:[o.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[o.jsx("span",{className:"material-symbols-outlined",children:"person"}),o.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?o.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,o.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:o.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!i&&SM.map(l=>{const c=s(l.labelKey);return o.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:o.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const U_="agentflow.pipelineRecent",CM=50,EM=15;function _M(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function K_(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(U_);return e?_M(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 xh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=K_(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,CM);try{localStorage.setItem(U_,JSON.stringify(i))}catch{}}function PM(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 qw(e,t){const n=Date.now(),r=Math.max(0,n-e),s=Math.floor(r/1e3);if(s<60)return t("flow:time.justNow");const i=Math.floor(s/60);if(i<60)return t("flow:time.minutesAgo",{n:i});const a=Math.floor(i/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,d=new Date(c);if(d.setDate(d.getDate()-1),l.toDateString()===d.toDateString())return t("flow:time.yesterday");const f=Math.floor(a/24);return f<7?t("flow:time.daysAgo",{n:f}):`${l.getMonth()+1}/${l.getDate()}`}function AM(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 IM(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:PM(n,s.flowId),kind:"executed",at:s.at});for(const s of t)r.push({flowId:s.flowId,flowSource:s.flowSource,kind:"opened",at:s.at});return r.sort((s,i)=>i.at-s.at),r.slice(0,EM)}var Xs=Uint8Array,eu=Uint16Array,TM=Int32Array,q_=new Xs([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]),Y_=new Xs([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]),RM=new Xs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),G_=function(e,t){for(var n=new eu(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new TM(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},X_=G_(q_,2),J_=X_.b,LM=X_.r;J_[28]=258,LM[258]=28;var OM=G_(Y_,0),MM=OM.b,Yw=new eu(32768);for(var Fn=0;Fn<32768;++Fn){var Ia=(Fn&43690)>>1|(Fn&21845)<<1;Ia=(Ia&52428)>>2|(Ia&13107)<<2,Ia=(Ia&61680)>>4|(Ia&3855)<<4,Yw[Fn]=((Ia&65280)>>8|(Ia&255)<<8)>>1}var sf=function(e,t,n){for(var r=e.length,s=0,i=new eu(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new eu(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new eu(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],f=t-e[s],u=a[e[s]-1]++<<f,p=u|(1<<f)-1;u<=p;++u)l[Yw[u]>>c]=d}else for(l=new eu(r),s=0;s<r;++s)e[s]&&(l[s]=Yw[a[e[s]-1]++]>>15-e[s]);return l},lp=new Xs(288);for(var Fn=0;Fn<144;++Fn)lp[Fn]=8;for(var Fn=144;Fn<256;++Fn)lp[Fn]=9;for(var Fn=256;Fn<280;++Fn)lp[Fn]=7;for(var Fn=280;Fn<288;++Fn)lp[Fn]=8;var Q_=new Xs(32);for(var Fn=0;Fn<32;++Fn)Q_[Fn]=5;var $M=sf(lp,9,1),DM=sf(Q_,5,1),tx=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Fi=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},nx=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},FM=function(e){return(e+7)/8|0},Hv=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Xs(e.subarray(t,n))},zM=["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"],wi=function(e,t,n){var r=new Error(t||zM[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,wi),!n)throw r;return r},HM=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new Xs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new Xs(s*3));var d=function(xe){var Te=n.length;if(xe>Te){var Ae=new Xs(Math.max(Te*2,xe));Ae.set(n),n=Ae}},f=t.f||0,u=t.p||0,p=t.b||0,m=t.l,g=t.d,b=t.m,v=t.n,y=s*8;do{if(!m){f=Fi(e,u,1);var k=Fi(e,u+1,3);if(u+=3,k)if(k==1)m=$M,g=DM,b=9,v=5;else if(k==2){var E=Fi(e,u,31)+257,O=Fi(e,u+10,15)+4,H=E+Fi(e,u+5,31)+1;u+=14;for(var L=new Xs(H),F=new Xs(19),D=0;D<O;++D)F[RM[D]]=Fi(e,u+D*3,7);u+=O*3;for(var R=tx(F),W=(1<<R)-1,M=sf(F,R,1),D=0;D<H;){var $=M[Fi(e,u,W)];u+=$&15;var w=$>>4;if(w<16)L[D++]=w;else{var T=0,z=0;for(w==16?(z=3+Fi(e,u,3),u+=2,T=L[D-1]):w==17?(z=3+Fi(e,u,7),u+=3):w==18&&(z=11+Fi(e,u,127),u+=7);z--;)L[D++]=T}}var A=L.subarray(0,E),P=L.subarray(E);b=tx(A),v=tx(P),m=sf(A,b,1),g=sf(P,v,1)}else wi(1);else{var w=FM(u)+4,j=e[w-4]|e[w-3]<<8,_=w+j;if(_>s){c&&wi(0);break}l&&d(p+j),n.set(e.subarray(w,_),p),t.b=p+=j,t.p=u=_*8,t.f=f;continue}if(u>y){c&&wi(0);break}}l&&d(p+131072);for(var C=(1<<b)-1,G=(1<<v)-1,Z=u;;Z=u){var T=m[nx(e,u)&C],V=T>>4;if(u+=T&15,u>y){c&&wi(0);break}if(T||wi(2),V<256)n[p++]=V;else if(V==256){Z=u,m=null;break}else{var ne=V-254;if(V>264){var D=V-257,ce=q_[D];ne=Fi(e,u,(1<<ce)-1)+J_[D],u+=ce}var fe=g[nx(e,u)&G],he=fe>>4;fe||wi(3),u+=fe&15;var P=MM[he];if(he>3){var ce=Y_[he];P+=nx(e,u)&(1<<ce)-1,u+=ce}if(u>y){c&&wi(0);break}l&&d(p+131072);var oe=p+ne;if(p<P){var we=i-P,_e=Math.min(P,oe);for(we+p<0&&wi(3);p<_e;++p)n[p]=r[we+p]}for(;p<oe;++p)n[p]=n[p-P]}}t.l=m,t.p=Z,t.b=p,t.f=f,m&&(f=1,t.m=b,t.d=g,t.n=v)}while(!f);return p!=n.length&&a?Hv(n,0,p):n.subarray(0,p)},BM=new Xs(0),ko=function(e,t){return e[t]|e[t+1]<<8},Ki=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},rx=function(e,t){return Ki(e,t)+Ki(e,t+4)*4294967296};function WM(e,t){return HM(e,{i:2},t&&t.out,t&&t.dictionary)}var Gw=typeof TextDecoder<"u"&&new TextDecoder,VM=0;try{Gw.decode(BM,{stream:!0}),VM=1}catch{}var UM=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:Hv(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 KM(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(Gw)return Gw.decode(e);var s=UM(e),i=s.s,n=s.r;return n.length&&wi(8),i}}var qM=function(e,t){return t+30+ko(e,t+26)+ko(e,t+28)},YM=function(e,t,n){var r=ko(e,t+28),s=KM(e.subarray(t+46,t+46+r),!(ko(e,t+8)&2048)),i=t+46+r,a=Ki(e,t+20),l=n&&a==4294967295?GM(e,i):[a,Ki(e,t+24),Ki(e,t+42)],c=l[0],d=l[1],f=l[2];return[ko(e,t+10),c,d,s,i+ko(e,t+30)+ko(e,t+32),f]},GM=function(e,t){for(;ko(e,t)!=1;t+=4+ko(e,t+2));return[rx(e,t+12),rx(e,t+4),rx(e,t+20)]};function XM(e,t){for(var n={},r=e.length-22;Ki(e,r)!=101010256;--r)(!r||e.length-r>65558)&&wi(13);var s=ko(e,r+8);if(!s)return{};var i=Ki(e,r+16),a=i==4294967295||s==65535;if(a){var l=Ki(e,r-12);a=Ki(e,l)==101075792,a&&(s=Ki(e,l+32),i=Ki(e,l+48))}for(var c=0;c<s;++c){var d=YM(e,i,a),f=d[0],u=d[1],p=d[2],m=d[3],g=d[4],b=d[5],v=qM(e,b);i=g,f?f==8?n[m]=WM(e.subarray(v,v+u),{out:new Xs(p)}):wi(14,"unknown compression type "+f):n[m]=Hv(e,v,v+u)}return n}const JM=8*1024*1024,QM=500;function ZM(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 e$(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function t$(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 r$(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=XM(t),r=new Map;let s=0,i=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const f=ZM(c);if(!f||e$(f))continue;const u=(d==null?void 0:d.length)??0;if(s+=u,s>JM||(i+=1,i>QM))return null;r.set(f,u)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=t$(c);d!==null&&a.add(d)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return n$.test(l)?l:null}catch{return null}}const sx=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function s$({file:e,onClose:t,onImported:n}){const{t:r}=Ln(),s=h.useId(),i=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(""),[d,f]=h.useState("user"),[u,p]=h.useState(!1),[m,g]=h.useState(""),[b,v]=h.useState(null),y=b??e;h.useEffect(()=>{const _=requestAnimationFrame(()=>{var E;return(E=i.current)==null?void 0:E.focus()});return()=>cancelAnimationFrame(_)},[]),h.useEffect(()=>{let _=!1;return(async()=>{const E=y.name||"",O=E.toLowerCase();let H="";if(O.endsWith(".zip")){if(H=await r$(y)||"",!H){const L=E.replace(/\.zip$/i,"");sx.test(L)&&(H=L)}}else if(O.endsWith(".yaml")||O.endsWith(".yml")){const L=E.replace(/\.ya?ml$/i,"");sx.test(L)&&(H=L)}_||c(H)})(),()=>{_=!0}},[y]);const k=l.trim(),w=k.length>0&&sx.test(k);async function j(_){if(_.preventDefault(),!(!w||u)){p(!0),g("");try{const E=new FormData;E.set("flowId",k),E.set("targetSpace",d),E.set("file",y,y.name);const O=await fetch("/api/flows/import",{method:"POST",body:E}),H=await O.json().catch(()=>({}));if(!O.ok){g(typeof H.error=="string"?H.error:r("project:importModal.importFailed"));return}n({id:H.flowId,source:H.flowSource??"user"})}catch(E){g(String((E==null?void 0:E.message)||E))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),o.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:_=>{var O;const E=(O=_.target.files)==null?void 0:O[0];E&&v(E),_.target.value=""}}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:_=>c(_.target.value),"aria-invalid":k.length>0&&!w}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),o.jsx("div",{className:"af-import-repick",children:o.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var _;return(_=a.current)==null?void 0:_.click()},children:r("project:importModal.changeFile")})}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:r("project:importModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||u,children:r(u?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const i$=/^[a-zA-Z][a-zA-Z0-9_-]*$/,kS="af:newPipelineGuide";function o$({open:e,onClose:t,onCreated:n}){const{t:r}=Ln(),s=h.useId(),i=h.useRef(null),[a,l]=h.useState(""),[c,d]=h.useState(""),[f,u]=h.useState("user"),[p,m]=h.useState(!1),[g,b]=h.useState(""),[v,y]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),d(""),u("user"),b(""),m(!1),localStorage.getItem(kS)==="true"&&y(!0);const O=requestAnimationFrame(()=>{var H;return(H=i.current)==null?void 0:H.focus()});return()=>cancelAnimationFrame(O)},[e]);const k=()=>{localStorage.removeItem(kS),y(!1)};if(!e)return null;const w=a.trim(),j=w.length>0&&i$.test(w);async function _(E){if(E.preventDefault(),!(!j||p)){m(!0),b(""),k();try{const O=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:w,description:c.trim(),targetSpace:f})}),H=await O.json().catch(()=>({}));if(!O.ok){b(typeof H.error=="string"?H.error:r("project:newPipelineModal.createFailed"));return}n({id:H.flowId,source:H.flowSource??"user"})}catch(O){b(String((O==null?void 0:O.message)||O))}finally{m(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&(k(),t())},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),v?o.jsx("div",{className:"af-new-pipeline-guide",children:o.jsxs("div",{className:"af-new-pipeline-guide-content",children:[o.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),o.jsxs("div",{className:"af-new-pipeline-guide-text",children:[o.jsx("p",{children:o.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),o.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),o.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:_,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:E=>l(E.target.value),"aria-invalid":w.length>0&&!j}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(v?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(v?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:E=>d(E.target.value)}),v?o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?o.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||p,children:r(p?"project:newPipelineModal.creating":v?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const Z_="agentflow.pipelineViewPreference";function eP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function tP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(Z_)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function a$(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(Z_,JSON.stringify(e))}catch{}}function Bm(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function l$(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function nP(e,t,n,r=!1){if(!e)return;const s=tP();s[eP(e,t,r)]={view:Bm(n),at:Date.now()},a$(s)}function c$(e,t="workspace"){if(!(e!=null&&e.id))return Bm(t);const r=tP()[eP(e.id,e.source??"user",!!e.archived)],s=Bm((r==null?void 0:r.view)||t);return s==="pipeline"&&!l$(e)?"workspace":s}function Tf(e,t="workspace"){const n=Bm(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 wh(e,t="workspace"){return Tf(e,c$(e,t))}function u$(e,t){const n=String(e||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),r=String(t||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=Number.isFinite(n[i])?n[i]:0,l=Number.isFinite(r[i])?r[i]:0;if(a!==l)return a>l?1:-1}return 0}function Xw(e){return String((e==null?void 0:e.version)||"").trim()}function d$(e){const t=Xw(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 f$({onChanged:e}){const[t,n]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=h.useState([]),[i,a]=h.useState(""),[l,c]=h.useState("keyword"),[d,f]=h.useState([]),[u,p]=h.useState({}),[m,g]=h.useState(""),[b,v]=h.useState(""),[y,k]=h.useState(""),w=h.useCallback(async()=>{v("");try{const[L,F]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),D=await L.json().catch(()=>({}));L.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 R=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+F.status);s(Array.isArray(R.skills)?R.skills:[]),p({})}catch(L){v(String(L.message||L))}},[]);h.useEffect(()=>{w()},[w]);const j=h.useCallback(async()=>{const L=i.trim();if(L){g("search"),v(""),k("");try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(L)}&mode=${encodeURIComponent(l)}`),D=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof D.error=="string"?D.error:"HTTP "+F.status);f(Array.isArray(D.items)?D.items:[])}catch(F){v(String(F.message||F))}finally{g("")}}},[i,l]),_=h.useCallback(async(L,F=!1)=>{const D=L&&typeof L=="object"?L:null,R=String(D?D.slug||D.name||D.collection||D.skillId||D.id:L||"").trim();if(R){g(`install:${R}`),v(""),k("");try{const W=D?{slug:D.slug||"",skillId:D.skillId||"",collection:D.collection||"",collectionName:D.collection&&D.name||"",target:"global",agent:"codex",force:F}:{slug:R,target:"global",agent:"codex",force:F},M=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+M.status);k(F?`已更新 ${R}`:`已安装 ${R}`),await w(),typeof e=="function"&&await e()}catch(W){v(String(W.message||W))}finally{g("")}}},[w,e]),E=h.useCallback(async()=>{if(r.length!==0){g("check-updates"),v(""),k("");try{const L=await Promise.all(r.map(async R=>{const W=String(R.name||"").trim();if(!W)return null;try{const M=await fetch(`/api/skillhub/search?q=${encodeURIComponent(W)}&mode=keyword`),$=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+M.status);const T=Array.isArray($.items)?$.items:[],z=T.find(G=>G.slug===W||G.name===W||G.id===W)||T[0],A=Xw(R),P=String((z==null?void 0:z.version)||"").trim();let C="unknown";return z?A&&P?C=u$(A,P)<0?"update":"current":P&&(C="remote-only"):C="missing",[W,{state:C,latestVersion:P,installedVersion:A,summary:(z==null?void 0:z.summary)||""}]}catch(M){return[W,{state:"error",error:String(M.message||M),installedVersion:Xw(R)}]}})),F={};for(const R of L)R&&(F[R[0]]=R[1]);p(F);const D=Object.values(F).filter(R=>R.state==="update").length;k(D>0?`发现 ${D} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[r]),O=h.useCallback(async L=>{const F=String(L||"").trim();if(F){g(`uninstall:${F}`),v(""),k("");try{const D=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:F,target:"global",agent:"codex"})}),R=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+D.status);k(`已卸载 ${F}`),await w(),typeof e=="function"&&await e()}catch(D){v(String(D.message||D))}finally{g("")}}},[w,e]),H=h.useCallback(async()=>{g("update-cli"),v(""),k("");try{const L=await fetch("/api/skillhub/update",{method:"POST"}),F=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof F.error=="string"?F.error:"HTTP "+L.status);k("SkillHub CLI 已更新"),await w()}catch(L){v(String(L.message||L))}finally{g("")}},[w]);return o.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"搜索、安装、更新和卸载 Codex 全局 skills。"})]}),o.jsxs("div",{className:"af-set-skillhub-head-actions",children:[o.jsxs("div",{className:"af-set-skillhub-status",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),o.jsx("span",{children:t.loggedIn?`已登录 ${t.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(t.available?" af-set-badge--ok":" af-set-badge--err"),children:t.available?`v${t.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:w,disabled:!!m,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:E,disabled:!!m||r.length===0,children:m==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:H,disabled:!!m,children:m==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),o.jsxs("div",{className:"af-set-skillhub-search",children:[o.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:l,onChange:L=>{c(L.target.value),f([])},children:[o.jsx("option",{value:"keyword",children:"关键词"}),o.jsx("option",{value:"skillId",children:"Skill ID"}),o.jsx("option",{value:"collectionId",children:"Collection ID"})]}),o.jsx("input",{className:"af-set-input af-set-input--sm",value:i,onChange:L=>a(L.target.value),onKeyDown:L=>{L.key==="Enter"&&j()},placeholder:l==="collectionId"?"输入 collection id,例如 1":l==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>j(),disabled:!i.trim()||m==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),m==="search"?"搜索中…":"搜索"]})]}),b?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:b}):null,y?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:y}):null,o.jsxs("div",{className:"af-set-skillhub-grid",children:[o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"已安装"}),o.jsx("span",{children:r.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:r.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 Codex 全局 skills"}):r.map(L=>{const F=u[L.name],D=!F||F.state==="update"||F.state==="remote-only"||F.state==="unknown"||F.state==="error",R=m===`install:${L.name}`?"更新中…":(F==null?void 0:F.state)==="current"?"已最新":(F==null?void 0:F.state)==="update"&&F.latestVersion?`更新到 v${F.latestVersion}`:(F==null?void 0:F.state)==="remote-only"&&F.latestVersion?`安装 v${F.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:L.displayName||L.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:d$(L)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:F?F.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",F.installedVersion?`v${F.installedVersion} -> `:"","v",F.latestVersion]}):F.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",F.latestVersion||F.installedVersion]}):F.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",F.latestVersion,",本地版本未知"]}):F.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):F.state==="error"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>_(L.name,!0),disabled:!!m||!D,children:R}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>O(L.name),disabled:!!m,children:"卸载"})]})]},`${L.agent}:${L.path}:${L.name}`)})})]}),o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"搜索结果"}),o.jsx("span",{children:d.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(L=>{const F=L.slug||L.name,D=L.kind==="collection"||L.collection,R=!D&&r.some(W=>W.name===F||W.name===L.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:L.name||F}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[D?`collection:${L.collection}`:F,L.skillId?` · id:${L.skillId}`:"",L.version?` · ${L.version}`:""]}),L.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:L.summary}):null]}),o.jsx("button",{type:"button",className:R?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>_(L,R),disabled:!!m,children:R?"更新":D?"安装合集":"安装"})]},L.id||F)})})]})]})]})}function el(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 p$(e){return{version:1,collections:el({collections:e})}}function ol(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 rP(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 sP(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function iP(e,t,n){const r=ol(e,n);if(r.length===0)return"empty";const s=r.filter(i=>t.has(i)).length;return s===0?"none":s===r.length?"all":"partial"}function h$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=el({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return ol(s,t)}function oP(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=el({collections:r}),l=h$(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const d=localStorage.getItem(e);if(d!==null){const f=JSON.parse(d);if(Array.isArray(f)){const u=new Set(s),p=f.map(String).filter(y=>u.has(y));if(s.length>0&&p.length===s.length)return c;const m=new Set(p),g=new Set(l),b=l.length>0&&l.every(y=>m.has(y)),v=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const k=ol(y,n);return k.length>0&&k.every(w=>m.has(w))});return l.length>0&&v&&!b?c:p}}}catch{}return c}function _d(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 m$(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 Jw(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 g$="project:defaultCardDesc";function lP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(g$)}function y$(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fr({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return o.jsx("span",{className:t,children:s});const i=new RegExp(`(${y$(r)})`,"gi"),a=s.split(i);return o.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?o.jsx("mark",{className:"af-search-hit",children:l},c):o.jsx("span",{children:l},c))})}function x$(e,t,n){const r=[String(e.id),lP(e,n),aP(e),Jw(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function w$(e,t,n){return t?x$(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 ix(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function SS(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 NS(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const v$=["all","agent","control","provide","marketplace"],k$=["all","agent","control","provide"],cP="agentflow.projects.activityPanelOpen",Qw="agentflow.projects.activitySelected";function S$(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(cP);return e!=="0"}function jS(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function N$(){return typeof localStorage>"u"?"":localStorage.getItem(Qw)||""}function bh(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Vn(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 Ta(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function uP(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 dP(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 Zw(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 CS(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Zw(e,t))}function j$(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function ES(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 C$(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 ox(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function E$(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 _$(e,t){const n=e.map(f=>f.id),r=new Set(n),s=new Map(n.map(f=>[f,0])),i=new Map(n.map(f=>[f,[]]));t.forEach(f=>{var u;!r.has(f.sourceId)||!r.has(f.targetId)||(s.set(f.targetId,(s.get(f.targetId)||0)+1),(u=i.get(f.sourceId))==null||u.push(f.targetId))});const a=new Map,l=n.filter(f=>(s.get(f)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(f=>a.set(f,0));for(let f=0;f<l.length;f+=1){const u=l[f],p=(a.get(u)||0)+1;for(const m of i.get(u)||[])(!a.has(m)||p>a.get(m))&&(a.set(m,p),l.push(m))}n.forEach((f,u)=>{a.has(f)||a.set(f,u%3)});const c=new Map,d=new Map;return n.forEach(f=>{const u=a.get(f)||0,p=c.get(u)||0;c.set(u,p+1),d.set(f,{x:u*190,y:p*86})}),d}function P$(e){var b,v,y,k;const t=uP(e),n=dP(e),r=new Map(t.map((w,j)=>[Zw(w,j),CS(w,j)])),s=t.map((w,j)=>({id:Zw(w,j),title:CS(w,j),meta:j$(w)})),i=n.map((w,j)=>{const _=ES(w,"source"),E=ES(w,"target");return{key:(w==null?void 0:w.id)||`${_}-${E}-${j}`,sourceId:_,targetId:E,source:r.get(_)||_||"?",target:r.get(E)||E||"?",label:C$(w)}}),a=(v=(b=e==null?void 0:e.snippet)==null?void 0:b.ui)!=null&&v.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=_$(s,i),d=s.map(w=>{const j=E$(a[w.id])||c.get(w.id)||{x:0,y:0},_=l[w.id]&&typeof l[w.id]=="object"?l[w.id]:{},E=Number(_.width),O=Number(_.height),H=Math.max(132,Math.min(210,Number.isFinite(E)?E*.62:150)),L=Math.max(48,Math.min(76,Number.isFinite(O)?O*.46:54));return{...w,x:j.x,y:j.y,width:H,height:L}}),f=new Map(d.map(w=>[w.id,w])),u=i.map(w=>{const j=f.get(w.sourceId),_=f.get(w.targetId);if(!j||!_)return null;const E=j.x+j.width,O=j.y+j.height/2,H=_.x,L=_.y+_.height/2,F=Math.max(48,Math.abs(H-E)*.45);return{...w,path:`M ${E} ${O} C ${E+F} ${O}, ${H-F} ${L}, ${H} ${L}`,labelX:(E+H)/2,labelY:(O+L)/2}}).filter(Boolean),p=d.reduce((w,j)=>({minX:Math.min(w.minX,j.x),minY:Math.min(w.minY,j.y),maxX:Math.max(w.maxX,j.x+j.width),maxY:Math.max(w.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,g=`${p.minX-m} ${p.minY-m} ${Math.max(360,p.maxX-p.minX+m*2)} ${Math.max(180,p.maxY-p.minY+m*2)}`;return{nodes:s,edges:i,diagram:{nodes:d,edges:u,viewBox:g}}}function Tc({resourceKind:e="",authUser:t=null}){var hn,er,ws,qr,oi,Bs;const{t:n}=Ln(),{navigate:r,path:s}=Ro(),[i,a]=h.useState(e||"all"),[l,c]=h.useState([]),[d,f]=h.useState([]),[u,p]=h.useState([]),[m,g]=h.useState([]),[b,v]=h.useState([]),[y,k]=h.useState(""),[w,j]=h.useState(!1),[_,E]=h.useState([]),[O,H]=h.useState(""),[L,F]=h.useState(""),[D,R]=h.useState(!1),[W,M]=h.useState(!1),[$,T]=h.useState(!1),[z,A]=h.useState(null),[P,C]=h.useState(!1),[G,Z]=h.useState(""),[V,ne]=h.useState(S$),[ce,fe]=h.useState(N$),[he,oe]=h.useState("all"),[we,_e]=h.useState(""),[xe,Te]=h.useState("overview"),[Ae,et]=h.useState({}),[ct,Xe]=h.useState(""),[mt,He]=h.useState({}),[dt,gn]=h.useState(""),[yn,On]=h.useState(""),[rn,Yn]=h.useState({}),[Mn,ue]=h.useState(""),[ve,Be]=h.useState(""),[ot,at]=h.useState(""),[Lt,nt]=h.useState(""),[dn,Qt]=h.useState(""),[ar,Cn]=h.useState(!1),[fn,xn]=h.useState(""),[lr,be]=h.useState({hiddenBuiltins:[],promoted:[]}),Me=h.useRef(0),tt=h.useRef(0),zt=h.useRef(0),ie=h.useCallback(async()=>{var ge,Re;const K=++tt.current;H("");try{const Le=await fetch("/api/flows");if(K!==tt.current)return;if(!Le.ok)throw new Error("HTTP "+Le.status);const Ve=await Le.json();if(K!==tt.current)return;c(Array.isArray(Ve)?Ve:[])}catch(Le){if(K!==tt.current)return;c([]),H(String(Le.message||Le))}try{const Le=await fetch("/api/pipeline-recent-runs");if(K!==tt.current)return;if(Le.ok){const Ve=await Le.json();if(K!==tt.current)return;E(Array.isArray(Ve.runs)?Ve.runs:[])}else E([])}catch{if(K!==tt.current)return;E([])}if(t!=null&&t.isAdmin)try{const Le=await fetch("/api/admin/builtin-flows");if(K!==tt.current)return;const Ve=await Le.json().catch(()=>({}));Le.ok&&be({hiddenBuiltins:Array.isArray((ge=Ve==null?void 0:Ve.config)==null?void 0:ge.hiddenBuiltins)?Ve.config.hiddenBuiltins:[],promoted:Array.isArray((Re=Ve==null?void 0:Ve.config)==null?void 0:Re.promoted)?Ve.config.promoted:[]})}catch{if(K!==tt.current)return;be({hiddenBuiltins:[],promoted:[]})}else be({hiddenBuiltins:[],promoted:[]});R(!0)},[t==null?void 0:t.isAdmin]),Ie=h.useCallback(async(K,ge)=>{if(!(t!=null&&t.isAdmin)||!(K!=null&&K.id))return;const Re=`${ge}:${K.source}:${K.id}`;xn(Re),H("");try{const Le=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:ge,flowId:K.id,ownerUserId:K.ownerUserId||t.userId})}),Ve=await Le.json().catch(()=>({}));if(!Le.ok)throw new Error(Ve.error||"更新内置配置失败");await ie()}catch(Le){H(String(Le.message||Le))}finally{xn("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,ie]),We=h.useCallback(async()=>{const K=++zt.current;F(""),M(!1);const ge=e==="my-nodes"?"/api/nodes?scope=owned":"/api/nodes",Re=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),g([]),_e("");try{const[Le,Ve,Zt,Ot]=await Promise.all([fetch(ge),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(Re)]),mn=await Le.json().catch(()=>({})),Yr=await Ve.json().catch(()=>({})),os=await Zt.json().catch(()=>({})),Ws=await Ot.json().catch(()=>({}));if(!Le.ok)throw new Error(mn.error||"Nodes HTTP "+Le.status);if(!Ve.ok)throw new Error(Yr.error||"Skills HTTP "+Ve.status);if(!Zt.ok)throw new Error(os.error||"Collections HTTP "+Zt.status);if(!Ot.ok)throw new Error(Ws.error||"Flow snippets HTTP "+Ot.status);if(K!==zt.current)return;f(Array.isArray(mn.nodes)?mn.nodes:Array.isArray(mn)?mn:[]),p(Array.isArray(Yr.skills)?Yr.skills:[]),v(el(os)),g(Array.isArray(Ws.snippets)?Ws.snippets:[])}catch(Le){if(K!==zt.current)return;f([]),p([]),g([]),v([]),F(String(Le.message||Le))}finally{if(K!==zt.current)return;M(!0)}},[e]);h.useEffect(()=>{R(!1),ie(),We()},[ie,We]),h.useEffect(()=>{try{localStorage.setItem(cP,V?"1":"0")}catch{}},[V]),h.useEffect(()=>{try{ce?localStorage.setItem(Qw,ce):localStorage.removeItem(Qw)}catch{}},[ce]),h.useEffect(()=>{let K=!1;return fetch("/api/ui-context").then(ge=>ge.json()).then(ge=>{K||Cn(!!ge.hideCommunityLinks)}).catch(()=>{}),()=>{K=!0}},[]);const Ht=h.useCallback(async K=>{const ge=el({collections:K});j(!0),F("");try{const Re=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p$(ge))}),Le=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(Le.error||"Collections HTTP "+Re.status);v(el(Le))}catch(Re){F(String(Re.message||Re))}finally{j(!1)}},[]),pn=h.useCallback(()=>{const K=y.trim();if(!K)return;const ge=K.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Re=new Set(b.map(Ot=>Ot.id));let Le=ge,Ve=2;for(;Re.has(Le);)Le=`${ge}-${Ve++}`;const Zt=Date.now();Ht([...b,{id:Le,name:K,skillKeys:[],createdAt:Zt,updatedAt:Zt}]),k(""),oe(`collection:${Le}`)},[y,Ht,b]),cr=h.useCallback(K=>{const ge=b.find(Le=>Le.id===K);if(ge!=null&&ge.builtin)return;const Re=b.filter(Le=>Le.id!==K);he===`collection:${K}`&&oe("all"),Ht(Re)},[he,Ht,b]),zs=h.useCallback((K,ge,Re)=>{const Le=String(ge||"").trim();if(!Le)return;const Ve=Date.now(),Zt=b.map(Ot=>{if(Ot.id!==K)return Ot;const mn=new Set(Ot.skillKeys||[]);return Re?mn.add(Le):mn.delete(Le),{...Ot,skillKeys:Array.from(mn),updatedAt:Ve}});Ht(Zt)},[Ht,b]),is=h.useCallback(async K=>{const ge=K==null?void 0:K.packageId,Re=K==null?void 0:K.version;if(!ge||!Re||!window.confirm(n("project:deleteMyNodeConfirm",{id:ge,version:Re})))return;const Le=Vn(K);Be(Le),at(""),F("");try{const Ve=new URLSearchParams({id:ge,version:Re}),Zt=await fetch(`/api/marketplace/node?${Ve.toString()}`,{method:"DELETE"}),Ot=await Zt.json().catch(()=>({}));if(!Zt.ok||(Ot==null?void 0:Ot.ok)===!1){const mn=Array.isArray(Ot==null?void 0:Ot.usage)&&Ot.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Ot.usage.length})}`:"";throw new Error(((Ot==null?void 0:Ot.error)||"Delete failed")+mn)}at(n("project:deleteMyNodeSuccess",{id:ge,version:Re})),He(mn=>{const Yr={...mn};return delete Yr[Le],Yr}),Yn(mn=>{const Yr={};for(const[os,Ws]of Object.entries(mn))os.startsWith(`${Le}:`)||(Yr[os]=Ws);return Yr}),_e(""),await We()}catch(Ve){at(String(Ve.message||Ve))}finally{Be("")}},[We,n]),hr=h.useCallback(async K=>{const ge=K==null?void 0:K.id,Re=(K==null?void 0:K.version)||"1.0.0";if(!ge||!Re||!window.confirm(n("project:deleteMyFlowConfirm",{id:ge,version:Re})))return;const Le=Ta(K);nt(Le),Qt(""),F("");try{const Ve=new URLSearchParams({id:ge,version:Re}),Zt=await fetch(`/api/marketplace/flow-snippet?${Ve.toString()}`,{method:"DELETE"}),Ot=await Zt.json().catch(()=>({}));if(!Zt.ok||(Ot==null?void 0:Ot.ok)===!1)throw new Error((Ot==null?void 0:Ot.error)||"Delete failed");Qt(n("project:deleteMyFlowSuccess",{id:ge,version:Re})),_e(""),await We()}catch(Ve){Qt(String(Ve.message||Ve))}finally{nt("")}},[We,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){a(e),oe("all"),_e(""),Te("overview");return}a(K=>K==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const K=new URLSearchParams(window.location.search);let ge=!1;if(K.get("tab")==="nodes"){r("/nodes");return}if(K.get("tab")==="my-nodes"){r("/my-nodes");return}if(K.get("tab")==="my-flows"){r("/my-flows");return}if(K.get("tab")==="skills"){r("/skills");return}if(K.get("tab")==="archived"&&(a("archived"),K.delete("tab"),ge=!0),K.get("new")==="1"&&(T(!0),K.delete("new"),ge=!0),ge){const Re=K.toString();window.history.replaceState({},"",Re?`/projects?${Re}`:"/projects")}},[s,r]);const Zn=h.useMemo(()=>IM(_,K_(),l),[_,l,s]),Wr=h.useMemo(()=>Zn.filter(K=>b$(G,K)),[Zn,G]),it=G.trim().toLowerCase(),Vr=h.useMemo(()=>i==="archived"?l.filter(K=>K.archived):l.filter(K=>!K.archived),[l,i]),_i=h.useMemo(()=>Vr.filter(K=>w$(K,it,n)),[Vr,it,n]),ya=h.useMemo(()=>new Set((lr.promoted||[]).map(K=>String((K==null?void 0:K.id)||"").trim()).filter(Boolean)),[lr.promoted]),ys=h.useMemo(()=>(lr.hiddenBuiltins||[]).map(K=>String(K||"").trim()).filter(Boolean),[lr.hiddenBuiltins]),Pe=i==="nodes"||i==="my-nodes",sn=i==="my-nodes",mr=i==="my-flows",ht=h.useMemo(()=>d.filter(K=>sn&&K.source!=="marketplace"?!1:(he==="all"||(he==="marketplace"?K.source==="marketplace":K.type===he))&&ix(G,[K.id,K.label,K.displayName,K.description,K.type,K.source,K.packageId,K.version])),[d,sn,G,he]),Oe=h.useMemo(()=>{const K=new Map;for(const ge of b)K.set(ge.id,new Set(ge.skillKeys||[]));return K},[b]),Ur=h.useMemo(()=>[{id:"all",label:"全部"},...b.map(K=>({id:`collection:${K.id}`,label:K.name,count:K.skillKeys.length,collection:K})),{id:"ungrouped",label:"未分组"}],[b]),Gn=h.useMemo(()=>u.filter(K=>{var Le;const ge=Vn(K);let Re=he==="all";if(he.startsWith("collection:")){const Ve=he.slice(11);Re=!!((Le=Oe.get(Ve))!=null&&Le.has(ge))}else he==="ungrouped"&&(Re=!Array.from(Oe.values()).some(Ve=>Ve.has(ge)));return Re&&ix(G,[K.name,K.id,K.description,K.sourceLabel,K.source,K.path])}),[u,G,he,Oe]),Kr=h.useMemo(()=>m.filter(K=>ix(G,[K.id,K.name,K.displayName,K.description,K.version,K.packageDir,Array.isArray(K.tags)?K.tags.join(" "):""])),[m,G]),Cr=Pe||mr||i==="skills",ut=h.useMemo(()=>ht.find(K=>Vn(K)===we)||ht[0]||null,[ht,we]),Ut=h.useMemo(()=>Gn.find(K=>Vn(K)===we)||Gn[0]||null,[Gn,we]),on=h.useMemo(()=>Kr.find(K=>Ta(K)===we)||Kr[0]||null,[Kr,we]),Er=Ut?Ae[Vn(Ut)]:null,Ze=ut?mt[Vn(ut)]:null,gr=ut&&yn?rn[`${Vn(ut)}:${yn}`]:null,Hs=n(Pe?"project:searchNodes":mr?"project:searchFlows":i==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(i!=="skills"||!Ut)return;const K=Vn(Ut);if(Ae[K])return;let ge=!1;return Xe(K),fetch(`/api/skills/detail?key=${encodeURIComponent(K)}`).then(Re=>Re.json().then(Le=>({ok:Re.ok,json:Le}))).then(({ok:Re,json:Le})=>{ge||Re&&Le.skill&&et(Ve=>({...Ve,[K]:Le.skill}))}).catch(()=>{}).finally(()=>{ge||Xe("")}),()=>{ge=!0}},[i,Ut,Ae]),h.useEffect(()=>{if(!Pe||!ut)return;const K=Vn(ut);if(mt[K])return;let ge=!1;return gn(K),fetch(`/api/nodes/detail?id=${encodeURIComponent(ut.id)}`).then(Re=>Re.json().then(Le=>({ok:Re.ok,json:Le}))).then(({ok:Re,json:Le})=>{ge||Re&&He(Ve=>({...Ve,[K]:Le}))}).catch(()=>{}).finally(()=>{ge||gn("")}),()=>{ge=!0}},[Pe,ut,mt]),h.useEffect(()=>{if(!Pe)return;const K=Array.isArray(Ze==null?void 0:Ze.files)?Ze.files:[];On(ge=>{var Re;return ge&&K.some(Le=>Le.path===ge)?ge:((Re=K[0])==null?void 0:Re.path)||""})},[Pe,Ze]),h.useEffect(()=>{if(!Pe||!ut||!yn)return;const K=`${Vn(ut)}:${yn}`;if(rn[K])return;let ge=!1;return ue(K),fetch(`/api/nodes/file?id=${encodeURIComponent(ut.id)}&path=${encodeURIComponent(yn)}`).then(Re=>Re.json().then(Le=>({ok:Re.ok,json:Le}))).then(({ok:Re,json:Le})=>{ge||Re&&Yn(Ve=>({...Ve,[K]:Le}))}).catch(()=>{}).finally(()=>{ge||ue("")}),()=>{ge=!0}},[Pe,ut,yn,rn]),h.useEffect(()=>{at("")},[we,i]);const xa=K=>{r(wh(K,"workspace"))},xs=K=>{fe(jS(K)),r(wh({id:K.flowId,source:K.flowSource,archived:!!K.archived},"workspace"))},Mo=h.useCallback(K=>{var ge,Re;K.preventDefault(),K.stopPropagation(),(Re=(ge=K.dataTransfer)==null?void 0:ge.types)!=null&&Re.includes("Files")&&(Me.current+=1,C(!0))},[]),vr=h.useCallback(K=>{K.preventDefault(),K.stopPropagation(),Me.current-=1,Me.current<=0&&(Me.current=0,C(!1))},[]),$o=h.useCallback(K=>{K.preventDefault(),K.stopPropagation()},[]),Pi=h.useCallback(K=>{var Le,Ve;K.preventDefault(),K.stopPropagation(),Me.current=0,C(!1);const ge=(Ve=(Le=K.dataTransfer)==null?void 0:Le.files)==null?void 0:Ve[0];if(!ge)return;const Re=ge.name.toLowerCase();!Re.endsWith(".yaml")&&!Re.endsWith(".yml")&&!Re.endsWith(".zip")||A(ge)},[]);return o.jsxs("div",{className:"af-projects"+(P?" af-projects--drop-target":""),onDragEnter:Mo,onDragLeave:vr,onDragOver:$o,onDrop:Pi,children:[o.jsxs("header",{className:"af-projects-top",children:[e?o.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):o.jsxs("div",{className:"af-projects-tabs",children:[o.jsx("button",{type:"button",className:i==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>a("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:i==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>a("archived"),children:n("project:archived")})]}),o.jsxs("div",{className:"af-projects-top-right",children:[o.jsxs("div",{className:"af-search-wrap",children:[o.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),o.jsx("input",{className:"af-search"+(G.trim()?" af-search--has-clear":""),type:"search",placeholder:Hs,"aria-label":Hs,autoComplete:"off",value:G,onChange:K=>Z(K.target.value),onKeyDown:K=>{K.key==="Escape"&&(Z(""),K.currentTarget.blur())}}),G.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Z(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Cr?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>We(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(V?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":V,"aria-controls":"af-recent-activity-panel",onClick:()=>ne(K=>!K),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>T(!0),children:n("project:createNew")})]})]})]}),o.jsxs("div",{className:"af-projects-body",children:[o.jsxs("section",{className:"af-projects-main",children:[o.jsxs("header",{className:"af-projects-section-head",children:[o.jsx("h2",{className:"af-projects-h2",children:n(i==="my-nodes"?"project:myNodes":i==="my-flows"?"project:myFlows":i==="nodes"?"project:globalNodes":i==="skills"?"project:globalSkills":i==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:it?n("project:filterResult",{count:i==="nodes"||i==="my-nodes"?ht.length:i==="my-flows"?Kr.length:i==="skills"?Gn.length:_i.length}):i==="my-nodes"?n("project:myNodesHint",{count:ht.length}):i==="my-flows"?n("project:myFlowsHint",{count:Kr.length}):i==="nodes"?n("project:nodesHint",{count:d.length}):i==="skills"?n("project:skillsHint",{count:u.length}):n(i==="archived"?"project:archivedHint":"project:activeHint")}),O?o.jsx("p",{className:"af-err af-projects-api-hint",children:O}):null,L&&Cr?o.jsx("p",{className:"af-err af-projects-api-hint",children:L}):null]}),Cr?o.jsxs("div",{className:"af-resource-toolbar",children:[i==="skills"?o.jsx(f$,{onChanged:We}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:mr?"schema":Pe?sn?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(mr?"project:myFlowsPurposeTitle":sn?"project:myNodesPurposeTitle":Pe?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(mr?"project:myFlowsPurposeDesc":sn?"project:myNodesPurposeDesc":Pe?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),mr?null:o.jsx("div",{className:"af-resource-filter-row",children:(Pe?(sn?k$:v$).map(K=>({id:K,label:n(`project:resourceFilter.${K}`)})):Ur).map(K=>K.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(he===K.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{oe(K.id),_e("")},children:[K.label,o.jsx("em",{children:K.count}),K.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),K.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:w,"aria-label":`删除 ${K.collection.name}`,onClick:()=>cr(K.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},K.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(he===K.id?" af-resource-filter--active":""),onClick:()=>{oe(K.id),_e("")},children:K.label},K.id))}),i==="skills"?o.jsx("div",{className:"af-skill-collections-manager",children:o.jsxs("div",{className:"af-skill-collections-create",children:[o.jsx("input",{className:"af-set-input af-set-input--sm",value:y,onChange:K=>k(K.target.value),onKeyDown:K=>{K.key==="Enter"&&pn()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!y.trim()||w,onClick:()=>pn(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Pe?o.jsx("div",{className:"af-resource-grid",children:ht.length>0?ht.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(ut&&Vn(K)===Vn(ut)?" af-resource-card--active":""),onClick:()=>_e(Vn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:_d(K.type==="control"?"secondary":K.type==="provide"?"primary":"muted"),children:o.jsx(fr,{query:G,children:K.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(fr,{query:G,children:SS(K.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(fr,{query:G,children:K.label||K.displayName||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(fr,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(fr,{query:G,children:K.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(K.inputs||{}).length,outputs:Object.keys(K.outputs||{}).length})})]}),K.packageId?o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),o.jsx("span",{className:"af-path-text",children:o.jsx(fr,{query:G,children:`${K.packageId}${K.version?` / ${K.version}`:""}`})})]}):null]},`${K.id}:${K.source||""}:${K.packageId||""}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:it?n("project:noNodeMatch",{query:G.trim()}):n(sn?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):mr?o.jsx("div",{className:"af-resource-grid",children:Kr.length>0?Kr.map(K=>{const ge=uP(K),Re=dP(K),Le=Number.isFinite(Number(K.nodeCount))?Number(K.nodeCount):ge.length,Ve=Number.isFinite(Number(K.edgeCount))?Number(K.edgeCount):Re.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(on&&Ta(K)===Ta(on)?" af-resource-card--active":""),onClick:()=>_e(Ta(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:_d("primary"),children:o.jsx(fr,{query:G,children:K.version?`v${K.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(fr,{query:G,children:K.displayName||K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(fr,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Le,edges:Ve})}),o.jsx("span",{children:o.jsx(fr,{query:G,children:K.id})})]}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),o.jsx("span",{className:"af-path-text",children:o.jsx(fr,{query:G,children:NS(K)})})]})]},Ta(K))}):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:it?n("project:noFlowSnippetMatch",{query:G.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i==="skills"?o.jsx("div",{className:"af-resource-grid",children:Gn.length>0?Gn.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Ut&&Vn(K)===Vn(Ut)?" af-resource-card--active":""),onClick:()=>_e(Vn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:_d(K.source==="builtin"?"muted":"primary"),children:o.jsx(fr,{query:G,children:K.sourceLabel||K.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(fr,{query:G,children:K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(fr,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),o.jsx("span",{className:"af-path-text",children:o.jsx(fr,{query:G,children:K.path||K.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[b.filter(ge=>ge.skillKeys.includes(Vn(K))).slice(0,3).map(ge=>o.jsx("span",{children:ge.name},ge.id)),b.filter(ge=>ge.skillKeys.includes(Vn(K))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},K.key||`${K.source}:${K.name}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:it?n("project:noSkillMatch",{query:G.trim()}):n("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):o.jsxs(o.Fragment,{children:[t!=null&&t.isAdmin&&i==="all"&&ys.length>0?o.jsxs("div",{className:"af-project-admin-panel",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已隐藏内置"}),o.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),o.jsx("div",{className:"af-project-admin-hidden-list",children:ys.map(K=>{const ge=fn===`show-builtin:builtin:${K}`;return o.jsxs("button",{type:"button",disabled:ge,onClick:()=>Ie({id:K,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:K}),o.jsx("em",{children:ge?"恢复中":"恢复"})]},K)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[_i.length>0?_i.map(K=>{const ge=(t==null?void 0:t.isAdmin)&&K.source==="user"&&!K.archived&&!ya.has(K.id),Re=(t==null?void 0:t.isAdmin)&&K.source==="admin",Le=(t==null?void 0:t.isAdmin)&&K.source==="builtin",Ve=fn.endsWith(`:${K.source}:${K.id}`);return o.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>xa(K),onKeyDown:Zt=>{(Zt.key==="Enter"||Zt.key===" ")&&(Zt.preventDefault(),xa(K))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:_d(Jw(K.source,n).tone),children:o.jsx(fr,{query:G,children:Jw(K.source,n).label})}),K.archived?o.jsx("span",{className:_d("muted"),children:o.jsx(fr,{query:G,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(fr,{query:G,children:K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(fr,{query:G,children:lP(K,n)})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),o.jsx("span",{className:"af-path-text",children:o.jsx(fr,{query:G,children:aP(K)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Zt=>Zt.stopPropagation(),onKeyDown:Zt=>Zt.stopPropagation(),children:[ge?o.jsx("button",{type:"button",disabled:Ve,onClick:()=>Ie(K,"promote"),children:"设为内置"}):null,Re?o.jsx("button",{type:"button",disabled:Ve,onClick:()=>Ie(K,"unpromote"),children:"取消内置"}):null,Le?o.jsx("button",{type:"button",disabled:Ve,onClick:()=>Ie(K,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${K.id}:${K.source??"user"}:${K.archived?"a":""}`)}):D?Vr.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:i==="archived"?n("project:noArchived"):l.length>0?n("project:noActive"):n(O?"project:loadFailed":"project:noPipelines")}),!O&&l.length===0&&i==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:G.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>T(!0),children:[o.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),o.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),ar?null:o.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[o.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),o.jsxs("span",{className:"af-hub-card__eyebrow",children:[o.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),o.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),o.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),Cr?o.jsx("aside",{className:"af-resource-detail","aria-label":n(Pe?"project:nodeDetail":mr?"project:flowDetail":"project:skillDetail"),children:Pe&&ut?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h3",{children:ut.label||ut.displayName||ut.id}),o.jsx("p",{children:ut.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(K=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(xe===K?" af-resource-detail-tab--active":""),onClick:()=>Te(K),children:n(`project:nodeDetailTabs.${K}`)},K))}),dt===Vn(ut)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):xe==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:ut.description||((hn=Ze==null?void 0:Ze.node)==null?void 0:hn.description)||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailType")}),o.jsx("dd",{children:ut.type||((er=Ze==null?void 0:Ze.node)==null?void 0:er.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:SS(ut.source,n)})]}),ut.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:ut.packageId})]}):null,ut.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:ut.version})]}):null,ut.packageDir||Ze!=null&&Ze.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:ut.packageDir||(Ze==null?void 0:Ze.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Ze==null?void 0:Ze.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),sn&&ut.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myNodeManagement")}),o.jsx("p",{children:n("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:ve===Vn(ut),onClick:()=>is(ut),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),ve===Vn(ut)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),ot?o.jsx("p",{className:"af-resource-action-message",children:ot}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:nodesMeaning")})]})]}):xe==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeInputs")}),bh(((ws=Ze==null?void 0:Ze.node)==null?void 0:ws.inputs)||ut.inputs).length>0?bh(((qr=Ze==null?void 0:Ze.node)==null?void 0:qr.inputs)||ut.inputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),bh(((oi=Ze==null?void 0:Ze.node)==null?void 0:oi.outputs)||ut.outputs).length>0?bh(((Bs=Ze==null?void 0:Ze.node)==null?void 0:Bs.outputs)||ut.outputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):xe==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),Ze!=null&&Ze.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Ze.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Ze!=null&&Ze.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:Ze.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):xe==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Ze==null?void 0:Ze.files)&&Ze.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Ze.files.map(K=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(yn===K.path?" af-node-file-item--active":""),onClick:()=>On(K.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:K.path})]},K.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[Mn===`${Vn(ut)}:${yn}`?n("project:loadingResources"):gr!=null&&gr.binary?n("project:binaryFile"):(gr==null?void 0:gr.content)||n("project:selectNodeFile"),gr!=null&&gr.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(Ze==null?void 0:Ze.usage)&&Ze.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Ze.usage.map(K=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:K.flowId}),o.jsxs("span",{children:[K.flowSource,K.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:K.instances.map(ge=>ge.label||ge.instanceId).join(", ")})]},`${K.flowSource}:${K.flowId}:${K.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):mr&&on?(()=>{const K=P$(on);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"schema"}),o.jsxs("div",{children:[o.jsx("h3",{children:on.displayName||on.name||on.id}),o.jsx("p",{children:on.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:on.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:on.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:NS(on)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(on.nodeCount))?Number(on.nodeCount):K.nodes.length,edges:Number.isFinite(Number(on.edgeCount))?Number(on.edgeCount):K.edges.length})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myFlowManagement")}),o.jsx("p",{children:n("project:deleteMyFlowHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Lt===Ta(on),onClick:()=>hr(on),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),Lt===Ta(on)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),dn?o.jsx("p",{className:"af-resource-action-message",children:dn}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),K.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:K.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:o.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),o.jsx("g",{className:"af-flow-snippet-map__edges",children:K.diagram.edges.map(ge=>o.jsxs("g",{children:[o.jsx("path",{d:ge.path}),ge.label?o.jsx("text",{x:ge.labelX,y:ge.labelY-5,textAnchor:"middle",children:ox(ge.label,18)}):null]},ge.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:K.diagram.nodes.map((ge,Re)=>o.jsxs("g",{transform:`translate(${ge.x} ${ge.y})`,children:[o.jsx("rect",{width:ge.width,height:ge.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:ge.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:ge.height/2+4,textAnchor:"middle",children:Re+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:ge.height/2-3,children:ox(ge.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:ge.height/2+16,children:ox(ge.meta||ge.id,20)})]},ge.id))})]})}):o.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),o.jsxs("details",{className:"af-flow-snippet-json",children:[o.jsx("summary",{children:n("project:flowSnippetJson")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(on.snippet||{},null,2)})]})]})]})})():i==="skills"&&Ut?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:Ut.name||Ut.id}),o.jsx("p",{children:Ut.sourceLabel||Ut.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Ut.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:Ut.sourceLabel||Ut.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Ut.path||Ut.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),b.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:b.map(K=>{const ge=Vn(Ut),Re=K.skillKeys.includes(ge);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Re,disabled:w,onChange:Le=>zs(K.id,ge,Le.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:K.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[K.skillKeys.length," skills"]})]})]},K.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:ct===Vn(Ut)?n("project:loadingResources"):(Er==null?void 0:Er.body)||(Er==null?void 0:Er.content)||n("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(V?"":" af-activity--hidden"),"aria-hidden":!V,"aria-label":n("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:Wr.length===0?o.jsx("p",{className:"af-activity-empty",children:Zn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Wr.map(K=>{const ge=ce===jS(K);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(ge?" af-activity-row--active":""),"aria-current":ge?"page":void 0,onClick:()=>xs(K),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(fr,{query:G,children:K.flowId})}),o.jsx("span",{className:"af-activity-time",children:qw(K.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:m$(K.kind),children:K.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[K.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",qw(K.at,n)]})]})]},`${K.kind}-${K.flowId}-${K.flowSource}-${K.at}`)})})]})]}),o.jsx(o$,{open:$,onClose:()=>T(!1),onCreated:async K=>{T(!1),await ie();const ge=K.source??"user";r(wh({id:K.id,source:ge},"workspace"))}}),z?o.jsx(s$,{file:z,onClose:()=>A(null),onImported:async K=>{A(null),await ie();const ge=K.source??"user";r(wh({id:K.id,source:ge},"workspace"))}},`${z.name}-${z.size}-${z.lastModified}`):null]})}function br(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=br(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var A$={value:()=>{}};function Wg(){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 im(n)}function im(e){this._=e}function I$(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}})}im.prototype=Wg.prototype={constructor:im,on:function(e,t){var n=this._,r=I$(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=T$(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(s=(e=r[i]).type)n[s]=_S(n[s],e.name,t);else if(t==null)for(s in n)n[s]=_S(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 im(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function T$(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function _S(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=A$,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var eb="http://www.w3.org/1999/xhtml";const PS={svg:"http://www.w3.org/2000/svg",xhtml:eb,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),PS.hasOwnProperty(t)?{space:PS[t],local:e}:e}function R$(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===eb&&t.documentElement.namespaceURI===eb?t.createElement(e):t.createElementNS(n,e)}}function L$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fP(e){var t=Vg(e);return(t.local?L$:R$)(t)}function O$(){}function Bv(e){return e==null?O$:function(){return this.querySelector(e)}}function M$(e){typeof e!="function"&&(e=Bv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=new Array(a),c,d,f=0;f<a;++f)(c=i[f])&&(d=e.call(c,c.__data__,f,i))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new ri(r,this._parents)}function $$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function D$(){return[]}function pP(e){return e==null?D$:function(){return this.querySelectorAll(e)}}function F$(e){return function(){return $$(e.apply(this,arguments))}}function z$(e){typeof e=="function"?e=F$(e):e=pP(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var a=t[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&(r.push(e.call(c,c.__data__,d,a)),s.push(c));return new ri(r,s)}function hP(e){return function(){return this.matches(e)}}function mP(e){return function(t){return t.matches(e)}}var H$=Array.prototype.find;function B$(e){return function(){return H$.call(this.children,e)}}function W$(){return this.firstElementChild}function V$(e){return this.select(e==null?W$:B$(typeof e=="function"?e:mP(e)))}var U$=Array.prototype.filter;function K$(){return Array.from(this.children)}function q$(e){return function(){return U$.call(this.children,e)}}function Y$(e){return this.selectAll(e==null?K$:q$(typeof e=="function"?e:mP(e)))}function G$(e){typeof e!="function"&&(e=hP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new ri(r,this._parents)}function gP(e){return new Array(e.length)}function X$(){return new ri(this._enter||this._groups.map(gP),this._parents)}function Wm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Wm.prototype={constructor:Wm,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 J$(e){return function(){return e}}function Q$(e,t,n,r,s,i){for(var a=0,l,c=t.length,d=i.length;a<d;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Wm(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function Z$(e,t,n,r,s,i,a){var l,c,d=new Map,f=t.length,u=i.length,p=new Array(f),m;for(l=0;l<f;++l)(c=t[l])&&(p[l]=m=a.call(c,c.__data__,l,t)+"",d.has(m)?s[l]=c:d.set(m,c));for(l=0;l<u;++l)m=a.call(e,i[l],l,i)+"",(c=d.get(m))?(r[l]=c,c.__data__=i[l],d.delete(m)):n[l]=new Wm(e,i[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(p[l])===c&&(s[l]=c)}function eD(e){return e.__data__}function tD(e,t){if(!arguments.length)return Array.from(this,eD);var n=t?Z$:Q$,r=this._parents,s=this._groups;typeof e!="function"&&(e=J$(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),d=0;d<i;++d){var f=r[d],u=s[d],p=u.length,m=nD(e.call(f,f&&f.__data__,d,r)),g=m.length,b=l[d]=new Array(g),v=a[d]=new Array(g),y=c[d]=new Array(p);n(f,u,b,v,y,m,t);for(var k=0,w=0,j,_;k<g;++k)if(j=b[k]){for(k>=w&&(w=k+1);!(_=v[w])&&++w<g;);j._next=_||null}}return a=new ri(a,r),a._enter=l,a._exit=c,a}function nD(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rD(){return new ri(this._exit||this._groups.map(gP),this._parents)}function sD(e,t,n){var r=this.enter(),s=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),r&&s?r.merge(s).order():s}function iD(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,a=Math.min(s,i),l=new Array(s),c=0;c<a;++c)for(var d=n[c],f=r[c],u=d.length,p=l[c]=new Array(u),m,g=0;g<u;++g)(m=d[g]||f[g])&&(p[g]=m);for(;c<s;++c)l[c]=n[c];return new ri(l,this._parents)}function oD(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],a;--s>=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function aD(e){e||(e=lD);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,c=s[i]=new Array(l),d,f=0;f<l;++f)(d=a[f])&&(c[f]=d);c.sort(t)}return new ri(s,this._parents).order()}function lD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function cD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function uD(){return Array.from(this)}function dD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var a=r[s];if(a)return a}return null}function fD(){let e=0;for(const t of this)++e;return e}function pD(){return!this.node()}function hD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,a=s.length,l;i<a;++i)(l=s[i])&&e.call(l,l.__data__,i,s);return this}function mD(e){return function(){this.removeAttribute(e)}}function gD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yD(e,t){return function(){this.setAttribute(e,t)}}function xD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wD(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 vD(e,t){var n=Vg(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?gD:mD:typeof t=="function"?n.local?bD:wD:n.local?xD:yD)(n,t))}function yP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function kD(e){return function(){this.style.removeProperty(e)}}function SD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ND(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function jD(e,t,n){return arguments.length>1?this.each((t==null?kD:typeof t=="function"?ND:SD)(e,t,n??"")):Cu(this.node(),e)}function Cu(e,t){return e.style.getPropertyValue(t)||yP(e).getComputedStyle(e,null).getPropertyValue(t)}function CD(e){return function(){delete this[e]}}function ED(e,t){return function(){this[e]=t}}function _D(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function PD(e,t){return arguments.length>1?this.each((t==null?CD:typeof t=="function"?_D:ED)(e,t)):this.node()[e]}function xP(e){return e.trim().split(/^|\s+/)}function Wv(e){return e.classList||new wP(e)}function wP(e){this._node=e,this._names=xP(e.getAttribute("class")||"")}wP.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 bP(e,t){for(var n=Wv(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function vP(e,t){for(var n=Wv(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function AD(e){return function(){bP(this,e)}}function ID(e){return function(){vP(this,e)}}function TD(e,t){return function(){(t.apply(this,arguments)?bP:vP)(this,e)}}function RD(e,t){var n=xP(e+"");if(arguments.length<2){for(var r=Wv(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?TD:t?AD:ID)(n,t))}function LD(){this.textContent=""}function OD(e){return function(){this.textContent=e}}function MD(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $D(e){return arguments.length?this.each(e==null?LD:(typeof e=="function"?MD:OD)(e)):this.node().textContent}function DD(){this.innerHTML=""}function FD(e){return function(){this.innerHTML=e}}function zD(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function HD(e){return arguments.length?this.each(e==null?DD:(typeof e=="function"?zD:FD)(e)):this.node().innerHTML}function BD(){this.nextSibling&&this.parentNode.appendChild(this)}function WD(){return this.each(BD)}function VD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function UD(){return this.each(VD)}function KD(e){var t=typeof e=="function"?e:fP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function qD(){return null}function YD(e,t){var n=typeof e=="function"?e:fP(e),r=t==null?qD:typeof t=="function"?t:Bv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function GD(){var e=this.parentNode;e&&e.removeChild(this)}function XD(){return this.each(GD)}function JD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function QD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ZD(e){return this.select(e?QD:JD)}function eF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tF(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 rF(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function sF(e,t,n){return function(){var r=this.__on,s,i=tF(t);if(r){for(var a=0,l=r.length;a<l;++a)if((s=r[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function iF(e,t,n){var r=nF(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<i;++s)if((a=r[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?sF:rF,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function kP(e,t,n){var r=yP(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 oF(e,t){return function(){return kP(this,e,t)}}function aF(e,t){return function(){return kP(this,e,t.apply(this,arguments))}}function lF(e,t){return this.each((typeof t=="function"?aF:oF)(e,t))}function*cF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,a;s<i;++s)(a=r[s])&&(yield a)}var SP=[null];function ri(e,t){this._groups=e,this._parents=t}function cp(){return new ri([[document.documentElement]],SP)}function uF(){return this}ri.prototype=cp.prototype={constructor:ri,select:M$,selectAll:z$,selectChild:V$,selectChildren:Y$,filter:G$,data:tD,enter:X$,exit:rD,join:sD,merge:iD,selection:uF,order:oD,sort:aD,call:cD,nodes:uD,node:dD,size:fD,empty:pD,each:hD,attr:vD,style:jD,property:PD,classed:RD,text:$D,html:HD,raise:WD,lower:UD,append:KD,insert:YD,remove:XD,clone:ZD,datum:eF,on:iF,dispatch:lF,[Symbol.iterator]:cF};function Js(e){return typeof e=="string"?new ri([[document.querySelector(e)]],[document.documentElement]):new ri([[e]],SP)}function dF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Vi(e,t){if(e=dF(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 fF={passive:!1},Rf={capture:!0,passive:!1};function ax(e){e.stopImmediatePropagation()}function fu(e){e.preventDefault(),e.stopImmediatePropagation()}function NP(e){var t=e.document.documentElement,n=Js(e).on("dragstart.drag",fu,Rf);"onselectstart"in t?n.on("selectstart.drag",fu,Rf):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function jP(e,t){var n=e.document.documentElement,r=Js(e).on("dragstart.drag",null);t&&(r.on("click.drag",fu,Rf),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 vh=e=>()=>e;function tb(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}tb.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pF(e){return!e.ctrlKey&&!e.button}function hF(){return this.parentNode}function mF(e,t){return t??{x:e.x,y:e.y}}function gF(){return navigator.maxTouchPoints||"ontouchstart"in this}function CP(){var e=pF,t=hF,n=mF,r=gF,s={},i=Wg("start","drag","end"),a=0,l,c,d,f,u=0;function p(j){j.on("mousedown.drag",m).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,fF).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(j,_){if(!(f||!e.call(this,j,_))){var E=w(this,t.call(this,j,_),j,_,"mouse");E&&(Js(j.view).on("mousemove.drag",g,Rf).on("mouseup.drag",b,Rf),NP(j.view),ax(j),d=!1,l=j.clientX,c=j.clientY,E("start",j))}}function g(j){if(fu(j),!d){var _=j.clientX-l,E=j.clientY-c;d=_*_+E*E>u}s.mouse("drag",j)}function b(j){Js(j.view).on("mousemove.drag mouseup.drag",null),jP(j.view,d),fu(j),s.mouse("end",j)}function v(j,_){if(e.call(this,j,_)){var E=j.changedTouches,O=t.call(this,j,_),H=E.length,L,F;for(L=0;L<H;++L)(F=w(this,O,j,_,E[L].identifier,E[L]))&&(ax(j),F("start",j,E[L]))}}function y(j){var _=j.changedTouches,E=_.length,O,H;for(O=0;O<E;++O)(H=s[_[O].identifier])&&(fu(j),H("drag",j,_[O]))}function k(j){var _=j.changedTouches,E=_.length,O,H;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),O=0;O<E;++O)(H=s[_[O].identifier])&&(ax(j),H("end",j,_[O]))}function w(j,_,E,O,H,L){var F=i.copy(),D=Vi(L||E,_),R,W,M;if((M=n.call(j,new tb("beforestart",{sourceEvent:E,target:p,identifier:H,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:F}),O))!=null)return R=M.x-D[0]||0,W=M.y-D[1]||0,function $(T,z,A){var P=D,C;switch(T){case"start":s[H]=$,C=a++;break;case"end":delete s[H],--a;case"drag":D=Vi(A||z,_),C=a;break}F.call(T,j,new tb(T,{sourceEvent:z,subject:M,target:p,identifier:H,active:C,x:D[0]+R,y:D[1]+W,dx:D[0]-P[0],dy:D[1]-P[1],dispatch:F}),O)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:vh(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:vh(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:vh(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:vh(!!j),p):r},p.on=function(){var j=i.on.apply(i,arguments);return j===i?p:j},p.clickDistance=function(j){return arguments.length?(u=(j=+j)*j,p):Math.sqrt(u)},p}function Vv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function EP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function up(){}var Lf=.7,Vm=1/Lf,pu="\\s*([+-]?\\d+)\\s*",Of="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Eo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",yF=/^#([0-9a-f]{3,8})$/,xF=new RegExp(`^rgb\\(${pu},${pu},${pu}\\)$`),wF=new RegExp(`^rgb\\(${Eo},${Eo},${Eo}\\)$`),bF=new RegExp(`^rgba\\(${pu},${pu},${pu},${Of}\\)$`),vF=new RegExp(`^rgba\\(${Eo},${Eo},${Eo},${Of}\\)$`),kF=new RegExp(`^hsl\\(${Of},${Eo},${Eo}\\)$`),SF=new RegExp(`^hsla\\(${Of},${Eo},${Eo},${Of}\\)$`),AS={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};Vv(up,ac,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:IS,formatHex:IS,formatHex8:NF,formatHsl:jF,formatRgb:TS,toString:TS});function IS(){return this.rgb().formatHex()}function NF(){return this.rgb().formatHex8()}function jF(){return _P(this).formatHsl()}function TS(){return this.rgb().formatRgb()}function ac(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=yF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?RS(t):n===3?new Ps(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kh(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=xF.exec(e))?new Ps(t[1],t[2],t[3],1):(t=wF.exec(e))?new Ps(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bF.exec(e))?kh(t[1],t[2],t[3],t[4]):(t=vF.exec(e))?kh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kF.exec(e))?MS(t[1],t[2]/100,t[3]/100,1):(t=SF.exec(e))?MS(t[1],t[2]/100,t[3]/100,t[4]):AS.hasOwnProperty(e)?RS(AS[e]):e==="transparent"?new Ps(NaN,NaN,NaN,0):null}function RS(e){return new Ps(e>>16&255,e>>8&255,e&255,1)}function kh(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ps(e,t,n,r)}function CF(e){return e instanceof up||(e=ac(e)),e?(e=e.rgb(),new Ps(e.r,e.g,e.b,e.opacity)):new Ps}function nb(e,t,n,r){return arguments.length===1?CF(e):new Ps(e,t,n,r??1)}function Ps(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Vv(Ps,nb,EP(up,{brighter(e){return e=e==null?Vm:Math.pow(Vm,e),new Ps(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lf:Math.pow(Lf,e),new Ps(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ps(Jl(this.r),Jl(this.g),Jl(this.b),Um(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:LS,formatHex:LS,formatHex8:EF,formatRgb:OS,toString:OS}));function LS(){return`#${ql(this.r)}${ql(this.g)}${ql(this.b)}`}function EF(){return`#${ql(this.r)}${ql(this.g)}${ql(this.b)}${ql((isNaN(this.opacity)?1:this.opacity)*255)}`}function OS(){const e=Um(this.opacity);return`${e===1?"rgb(":"rgba("}${Jl(this.r)}, ${Jl(this.g)}, ${Jl(this.b)}${e===1?")":`, ${e})`}`}function Um(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Jl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ql(e){return e=Jl(e),(e<16?"0":"")+e.toString(16)}function MS(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new qi(e,t,n,r)}function _P(e){if(e instanceof qi)return new qi(e.h,e.s,e.l,e.opacity);if(e instanceof up||(e=ac(e)),!e)return new qi;if(e instanceof qi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-s,c=(i+s)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?i+s:2-i-s,a*=60):l=c>0&&c<1?0:a,new qi(a,l,c,e.opacity)}function _F(e,t,n,r){return arguments.length===1?_P(e):new qi(e,t,n,r??1)}function qi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Vv(qi,_F,EP(up,{brighter(e){return e=e==null?Vm:Math.pow(Vm,e),new qi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lf:Math.pow(Lf,e),new qi(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 Ps(lx(e>=240?e-240:e+120,s,r),lx(e,s,r),lx(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new qi($S(this.h),Sh(this.s),Sh(this.l),Um(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=Um(this.opacity);return`${e===1?"hsl(":"hsla("}${$S(this.h)}, ${Sh(this.s)*100}%, ${Sh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function $S(e){return e=(e||0)%360,e<0?e+360:e}function Sh(e){return Math.max(0,Math.min(1,e||0))}function lx(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 Uv=e=>()=>e;function PF(e,t){return function(n){return e+n*t}}function AF(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 IF(e){return(e=+e)==1?PP:function(t,n){return n-t?AF(t,n,e):Uv(isNaN(t)?n:t)}}function PP(e,t){var n=t-e;return n?PF(e,n):Uv(isNaN(e)?t:e)}const Km=function e(t){var n=IF(t);function r(s,i){var a=n((s=nb(s)).r,(i=nb(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),d=PP(s.opacity,i.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return r.gamma=e,r}(1);function TF(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function RF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LF(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)s[a]=of(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=s[a](l);return i}}function OF(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function wo(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function MF(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]=of(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var rb=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cx=new RegExp(rb.source,"g");function $F(e){return function(){return e}}function DF(e){return function(t){return e(t)+""}}function AP(e,t){var n=rb.lastIndex=cx.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=rb.exec(e))&&(s=cx.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:wo(r,s)})),n=cx.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?DF(c[0].x):$F(t):(t=c.length,function(d){for(var f=0,u;f<t;++f)l[(u=c[f]).i]=u.x(d);return l.join("")})}function of(e,t){var n=typeof t,r;return t==null||n==="boolean"?Uv(t):(n==="number"?wo:n==="string"?(r=ac(t))?(t=r,Km):AP:t instanceof ac?Km:t instanceof Date?OF:RF(t)?TF:Array.isArray(t)?LF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?MF:wo)(e,t)}var DS=180/Math.PI,sb={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function IP(e,t,n,r,s,i){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*DS,skewX:Math.atan(c)*DS,scaleX:a,scaleY:l}}var Nh;function FF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?sb:IP(t.a,t.b,t.c,t.d,t.e,t.f)}function zF(e){return e==null||(Nh||(Nh=document.createElementNS("http://www.w3.org/2000/svg","g")),Nh.setAttribute("transform",e),!(e=Nh.transform.baseVal.consolidate()))?sb:(e=e.matrix,IP(e.a,e.b,e.c,e.d,e.e,e.f))}function TP(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function i(d,f,u,p,m,g){if(d!==u||f!==p){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:wo(d,u)},{i:b-2,x:wo(f,p)})}else(u||p)&&m.push("translate("+u+t+p+n)}function a(d,f,u,p){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),p.push({i:u.push(s(u)+"rotate(",null,r)-2,x:wo(d,f)})):f&&u.push(s(u)+"rotate("+f+r)}function l(d,f,u,p){d!==f?p.push({i:u.push(s(u)+"skewX(",null,r)-2,x:wo(d,f)}):f&&u.push(s(u)+"skewX("+f+r)}function c(d,f,u,p,m,g){if(d!==u||f!==p){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:wo(d,u)},{i:b-2,x:wo(f,p)})}else(u!==1||p!==1)&&m.push(s(m)+"scale("+u+","+p+")")}return function(d,f){var u=[],p=[];return d=e(d),f=e(f),i(d.translateX,d.translateY,f.translateX,f.translateY,u,p),a(d.rotate,f.rotate,u,p),l(d.skewX,f.skewX,u,p),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,u,p),d=f=null,function(m){for(var g=-1,b=p.length,v;++g<b;)u[(v=p[g]).i]=v.x(m);return u.join("")}}}var HF=TP(FF,"px, ","px)","deg)"),BF=TP(zF,", ",")",")"),WF=1e-12;function FS(e){return((e=Math.exp(e))+1/e)/2}function VF(e){return((e=Math.exp(e))-1/e)/2}function UF(e){return((e=Math.exp(2*e))-1)/(e+1)}const om=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],d=i[2],f=a[0],u=a[1],p=a[2],m=f-l,g=u-c,b=m*m+g*g,v,y;if(b<WF)y=Math.log(p/d)/t,v=function(O){return[l+O*m,c+O*g,d*Math.exp(t*O*y)]};else{var k=Math.sqrt(b),w=(p*p-d*d+r*b)/(2*d*n*k),j=(p*p-d*d-r*b)/(2*p*n*k),_=Math.log(Math.sqrt(w*w+1)-w),E=Math.log(Math.sqrt(j*j+1)-j);y=(E-_)/t,v=function(O){var H=O*y,L=FS(_),F=d/(n*k)*(L*UF(t*H+_)-VF(_));return[l+F*m,c+F*g,d*L/FS(t*H+_)]}}return v.duration=y*1e3*t/Math.SQRT2,v}return s.rho=function(i){var a=Math.max(.001,+i),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Eu=0,Bd=0,Pd=0,RP=1e3,qm,Wd,Ym=0,lc=0,Ug=0,Mf=typeof performance=="object"&&performance.now?performance:Date,LP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Kv(){return lc||(LP(KF),lc=Mf.now()+Ug)}function KF(){lc=0}function Gm(){this._call=this._time=this._next=null}Gm.prototype=OP.prototype={constructor:Gm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Kv():+n)+(t==null?0:+t),!this._next&&Wd!==this&&(Wd?Wd._next=this:qm=this,Wd=this),this._call=e,this._time=n,ib()},stop:function(){this._call&&(this._call=null,this._time=1/0,ib())}};function OP(e,t,n){var r=new Gm;return r.restart(e,t,n),r}function qF(){Kv(),++Eu;for(var e=qm,t;e;)(t=lc-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Eu}function zS(){lc=(Ym=Mf.now())+Ug,Eu=Bd=0;try{qF()}finally{Eu=0,GF(),lc=0}}function YF(){var e=Mf.now(),t=e-Ym;t>RP&&(Ug-=t,Ym=e)}function GF(){for(var e,t=qm,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:qm=n);Wd=e,ib(r)}function ib(e){if(!Eu){Bd&&(Bd=clearTimeout(Bd));var t=e-lc;t>24?(e<1/0&&(Bd=setTimeout(zS,e-Mf.now()-Ug)),Pd&&(Pd=clearInterval(Pd))):(Pd||(Ym=Mf.now(),Pd=setInterval(YF,RP)),Eu=1,LP(zS))}}function HS(e,t,n){var r=new Gm;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var XF=Wg("start","end","cancel","interrupt"),JF=[],MP=0,BS=1,ob=2,am=3,WS=4,ab=5,lm=6;function Kg(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;QF(e,n,{name:t,index:r,group:s,on:XF,tween:JF,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:MP})}function qv(e,t){var n=to(e,t);if(n.state>MP)throw new Error("too late; already scheduled");return n}function Lo(e,t){var n=to(e,t);if(n.state>am)throw new Error("too late; already running");return n}function to(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function QF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=OP(i,0,n.time);function i(d){n.state=BS,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var f,u,p,m;if(n.state!==BS)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===am)return HS(a);m.state===WS?(m.state=lm,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=lm,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(HS(function(){n.state===am&&(n.state=WS,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=ob,n.on.call("start",e,e.__data__,n.index,n.group),n.state===ob){for(n.state=am,s=new Array(p=n.tween.length),f=0,u=-1;f<p;++f)(m=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++u]=m);s.length=u+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=ab,1),u=-1,p=s.length;++u<p;)s[u].call(e,f);n.state===ab&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=lm,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function cm(e,t){var n=e.__transition,r,s,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}s=r.state>ob&&r.state<ab,r.state=lm,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function ZF(e){return this.each(function(){cm(this,e)})}function ez(e,t){var n,r;return function(){var s=Lo(this,e),i=s.tween;if(i!==n){r=n=i;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}s.tween=r}}function tz(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=Lo(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}i.tween=s}}function nz(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=to(this.node(),n).tween,s=0,i=r.length,a;s<i;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?ez:tz)(n,e,t))}function Yv(e,t,n){var r=e._id;return e.each(function(){var s=Lo(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return to(s,r).value[t]}}function $P(e,t){var n;return(typeof t=="number"?wo:t instanceof ac?Km:(n=ac(t))?(t=n,Km):AP)(e,t)}function rz(e){return function(){this.removeAttribute(e)}}function sz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iz(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttribute(e);return a===s?null:a===r?i:i=t(r=a,n)}}function oz(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?i:i=t(r=a,n)}}function az(e,t,n){var r,s,i;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l)))}}function lz(e,t,n){var r,s,i;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l)))}}function cz(e,t){var n=Vg(e),r=n==="transform"?BF:$P;return this.attrTween(e,typeof t=="function"?(n.local?lz:az)(n,r,Yv(this,"attr."+e,t)):t==null?(n.local?sz:rz)(n):(n.local?oz:iz)(n,r,t))}function uz(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dz(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fz(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&dz(e,i)),n}return s._value=t,s}function pz(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&uz(e,i)),n}return s._value=t,s}function hz(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=Vg(e);return this.tween(n,(r.local?fz:pz)(r,t))}function mz(e,t){return function(){qv(this,e).delay=+t.apply(this,arguments)}}function gz(e,t){return t=+t,function(){qv(this,e).delay=t}}function yz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mz:gz)(t,e)):to(this.node(),t).delay}function xz(e,t){return function(){Lo(this,e).duration=+t.apply(this,arguments)}}function wz(e,t){return t=+t,function(){Lo(this,e).duration=t}}function bz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xz:wz)(t,e)):to(this.node(),t).duration}function vz(e,t){if(typeof t!="function")throw new Error;return function(){Lo(this,e).ease=t}}function kz(e){var t=this._id;return arguments.length?this.each(vz(t,e)):to(this.node(),t).ease}function Sz(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Lo(this,e).ease=n}}function Nz(e){if(typeof e!="function")throw new Error;return this.each(Sz(this._id,e))}function jz(e){typeof e!="function"&&(e=hP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new da(r,this._parents,this._name,this._id)}function Cz(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),a=new Array(r),l=0;l<i;++l)for(var c=t[l],d=n[l],f=c.length,u=a[l]=new Array(f),p,m=0;m<f;++m)(p=c[m]||d[m])&&(u[m]=p);for(;l<r;++l)a[l]=t[l];return new da(a,this._parents,this._name,this._id)}function Ez(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 _z(e,t,n){var r,s,i=Ez(t)?qv:Lo;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function Pz(e,t){var n=this._id;return arguments.length<2?to(this.node(),n).on.on(e):this.each(_z(n,e,t))}function Az(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Iz(){return this.on("end.remove",Az(this._id))}function Tz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bv(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,d=i[a]=new Array(c),f,u,p=0;p<c;++p)(f=l[p])&&(u=e.call(f,f.__data__,p,l))&&("__data__"in f&&(u.__data__=f.__data__),d[p]=u,Kg(d[p],t,n,p,d,to(f,n)));return new da(i,this._parents,t,n)}function Rz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pP(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],d=c.length,f,u=0;u<d;++u)if(f=c[u]){for(var p=e.call(f,f.__data__,u,c),m,g=to(f,n),b=0,v=p.length;b<v;++b)(m=p[b])&&Kg(m,t,n,b,p,g);i.push(p),a.push(f)}return new da(i,a,t,n)}var Lz=cp.prototype.constructor;function Oz(){return new Lz(this._groups,this._parents)}function Mz(e,t){var n,r,s;return function(){var i=Cu(this,e),a=(this.style.removeProperty(e),Cu(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function DP(e){return function(){this.style.removeProperty(e)}}function $z(e,t,n){var r,s=n+"",i;return function(){var a=Cu(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function Dz(e,t,n){var r,s,i;return function(){var a=Cu(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Cu(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function Fz(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=Lo(this,e),d=c.on,f=c.value[i]==null?l||(l=DP(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(a,s=f),c.on=r}}function zz(e,t,n){var r=(e+="")=="transform"?HF:$P;return t==null?this.styleTween(e,Mz(e,r)).on("end.style."+e,DP(e)):typeof t=="function"?this.styleTween(e,Dz(e,r,Yv(this,"style."+e,t))).each(Fz(this._id,e)):this.styleTween(e,$z(e,r,t),n).on("end.style."+e,null)}function Hz(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Bz(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&Hz(e,a,n)),r}return i._value=t,i}function Wz(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,Bz(e,t,n??""))}function Vz(e){return function(){this.textContent=e}}function Uz(e){return function(){var t=e(this);this.textContent=t??""}}function Kz(e){return this.tween("text",typeof e=="function"?Uz(Yv(this,"text",e)):Vz(e==null?"":e+""))}function qz(e){return function(t){this.textContent=e.call(this,t)}}function Yz(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&qz(s)),t}return r._value=e,r}function Gz(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,Yz(e))}function Xz(){for(var e=this._name,t=this._id,n=FP(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)if(c=a[d]){var f=to(c,t);Kg(c,e,n,d,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new da(r,this._parents,e,n)}function Jz(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,a){var l={value:a},c={value:function(){--s===0&&i()}};n.each(function(){var d=Lo(this,r),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&i()})}var Qz=0;function da(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function FP(){return++Qz}var Go=cp.prototype;da.prototype={constructor:da,select:Tz,selectAll:Rz,selectChild:Go.selectChild,selectChildren:Go.selectChildren,filter:jz,merge:Cz,selection:Oz,transition:Xz,call:Go.call,nodes:Go.nodes,node:Go.node,size:Go.size,empty:Go.empty,each:Go.each,on:Pz,attr:cz,attrTween:hz,style:zz,styleTween:Wz,text:Kz,textTween:Gz,remove:Iz,tween:nz,delay:yz,duration:bz,ease:kz,easeVarying:Nz,end:Jz,[Symbol.iterator]:Go[Symbol.iterator]};function Zz(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var e3={time:null,delay:0,duration:250,ease:Zz};function t3(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 da?(t=e._id,e=e._name):(t=FP(),(n=e3).time=Kv(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&Kg(c,e,t,d,a,n||t3(c,t));return new da(r,this._parents,e,t)}cp.prototype.interrupt=ZF;cp.prototype.transition=n3;const jh=e=>()=>e;function r3(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 ra(e,t,n){this.k=e,this.x=t,this.y=n}ra.prototype={constructor:ra,scale:function(e){return e===1?this:new ra(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ra(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 qg=new ra(1,0,0);zP.prototype=ra.prototype;function zP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qg;return e.__zoom}function ux(e){e.stopImmediatePropagation()}function Ad(e){e.preventDefault(),e.stopImmediatePropagation()}function s3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function i3(){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 VS(){return this.__zoom||qg}function o3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function a3(){return navigator.maxTouchPoints||"ontouchstart"in this}function l3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function HP(){var e=s3,t=i3,n=l3,r=o3,s=a3,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=om,d=Wg("start","zoom","end"),f,u,p,m=500,g=150,b=0,v=10;function y(M){M.property("__zoom",VS).on("wheel.zoom",H,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,$,T,z){var A=M.selection?M.selection():M;A.property("__zoom",VS),M!==A?_(M,$,T,z):A.interrupt().each(function(){E(this,arguments).event(z).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},y.scaleBy=function(M,$,T,z){y.scaleTo(M,function(){var A=this.__zoom.k,P=typeof $=="function"?$.apply(this,arguments):$;return A*P},T,z)},y.scaleTo=function(M,$,T,z){y.transform(M,function(){var A=t.apply(this,arguments),P=this.__zoom,C=T==null?j(A):typeof T=="function"?T.apply(this,arguments):T,G=P.invert(C),Z=typeof $=="function"?$.apply(this,arguments):$;return n(w(k(P,Z),C,G),A,a)},T,z)},y.translateBy=function(M,$,T,z){y.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof T=="function"?T.apply(this,arguments):T),t.apply(this,arguments),a)},null,z)},y.translateTo=function(M,$,T,z,A){y.transform(M,function(){var P=t.apply(this,arguments),C=this.__zoom,G=z==null?j(P):typeof z=="function"?z.apply(this,arguments):z;return n(qg.translate(G[0],G[1]).scale(C.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof T=="function"?-T.apply(this,arguments):-T),P,a)},z,A)};function k(M,$){return $=Math.max(i[0],Math.min(i[1],$)),$===M.k?M:new ra($,M.x,M.y)}function w(M,$,T){var z=$[0]-T[0]*M.k,A=$[1]-T[1]*M.k;return z===M.x&&A===M.y?M:new ra(M.k,z,A)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function _(M,$,T,z){M.on("start.zoom",function(){E(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,P=arguments,C=E(A,P).event(z),G=t.apply(A,P),Z=T==null?j(G):typeof T=="function"?T.apply(A,P):T,V=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),ne=A.__zoom,ce=typeof $=="function"?$.apply(A,P):$,fe=c(ne.invert(Z).concat(V/ne.k),ce.invert(Z).concat(V/ce.k));return function(he){if(he===1)he=ce;else{var oe=fe(he),we=V/oe[2];he=new ra(we,Z[0]-oe[0]*we,Z[1]-oe[1]*we)}C.zoom(null,he)}})}function E(M,$,T){return!T&&M.__zooming||new O(M,$)}function O(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}O.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,$){return this.mouse&&M!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var $=Js(this.that).datum();d.call(M,this.that,new r3(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),$)}};function H(M,...$){if(!e.apply(this,arguments))return;var T=E(this,$).event(M),z=this.__zoom,A=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),P=Vi(M);if(T.wheel)(T.mouse[0][0]!==P[0]||T.mouse[0][1]!==P[1])&&(T.mouse[1]=z.invert(T.mouse[0]=P)),clearTimeout(T.wheel);else{if(z.k===A)return;T.mouse=[P,z.invert(P)],cm(this),T.start()}Ad(M),T.wheel=setTimeout(C,g),T.zoom("mouse",n(w(k(z,A),T.mouse[0],T.mouse[1]),T.extent,a));function C(){T.wheel=null,T.end()}}function L(M,...$){if(p||!e.apply(this,arguments))return;var T=M.currentTarget,z=E(this,$,!0).event(M),A=Js(M.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",V,!0),P=Vi(M,T),C=M.clientX,G=M.clientY;NP(M.view),ux(M),z.mouse=[P,this.__zoom.invert(P)],cm(this),z.start();function Z(ne){if(Ad(ne),!z.moved){var ce=ne.clientX-C,fe=ne.clientY-G;z.moved=ce*ce+fe*fe>b}z.event(ne).zoom("mouse",n(w(z.that.__zoom,z.mouse[0]=Vi(ne,T),z.mouse[1]),z.extent,a))}function V(ne){A.on("mousemove.zoom mouseup.zoom",null),jP(ne.view,z.moved),Ad(ne),z.event(ne).end()}}function F(M,...$){if(e.apply(this,arguments)){var T=this.__zoom,z=Vi(M.changedTouches?M.changedTouches[0]:M,this),A=T.invert(z),P=T.k*(M.shiftKey?.5:2),C=n(w(k(T,P),z,A),t.apply(this,$),a);Ad(M),l>0?Js(this).transition().duration(l).call(_,C,z,M):Js(this).call(y.transform,C,z,M)}}function D(M,...$){if(e.apply(this,arguments)){var T=M.touches,z=T.length,A=E(this,$,M.changedTouches.length===z).event(M),P,C,G,Z;for(ux(M),C=0;C<z;++C)G=T[C],Z=Vi(G,this),Z=[Z,this.__zoom.invert(Z),G.identifier],A.touch0?!A.touch1&&A.touch0[2]!==Z[2]&&(A.touch1=Z,A.taps=0):(A.touch0=Z,P=!0,A.taps=1+!!f);f&&(f=clearTimeout(f)),P&&(A.taps<2&&(u=Z[0],f=setTimeout(function(){f=null},m)),cm(this),A.start())}}function R(M,...$){if(this.__zooming){var T=E(this,$).event(M),z=M.changedTouches,A=z.length,P,C,G,Z;for(Ad(M),P=0;P<A;++P)C=z[P],G=Vi(C,this),T.touch0&&T.touch0[2]===C.identifier?T.touch0[0]=G:T.touch1&&T.touch1[2]===C.identifier&&(T.touch1[0]=G);if(C=T.that.__zoom,T.touch1){var V=T.touch0[0],ne=T.touch0[1],ce=T.touch1[0],fe=T.touch1[1],he=(he=ce[0]-V[0])*he+(he=ce[1]-V[1])*he,oe=(oe=fe[0]-ne[0])*oe+(oe=fe[1]-ne[1])*oe;C=k(C,Math.sqrt(he/oe)),G=[(V[0]+ce[0])/2,(V[1]+ce[1])/2],Z=[(ne[0]+fe[0])/2,(ne[1]+fe[1])/2]}else if(T.touch0)G=T.touch0[0],Z=T.touch0[1];else return;T.zoom("touch",n(w(C,G,Z),T.extent,a))}}function W(M,...$){if(this.__zooming){var T=E(this,$).event(M),z=M.changedTouches,A=z.length,P,C;for(ux(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),P=0;P<A;++P)C=z[P],T.touch0&&T.touch0[2]===C.identifier?delete T.touch0:T.touch1&&T.touch1[2]===C.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(C=Vi(C,this),Math.hypot(u[0]-C[0],u[1]-C[1])<v)){var G=Js(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:jh(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:jh(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:jh(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:jh([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),y):t},y.scaleExtent=function(M){return arguments.length?(i[0]=+M[0],i[1]=+M[1],y):[i[0],i[1]]},y.translateExtent=function(M){return arguments.length?(a[0][0]=+M[0][0],a[1][0]=+M[1][0],a[0][1]=+M[0][1],a[1][1]=+M[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(M){return arguments.length?(n=M,y):n},y.duration=function(M){return arguments.length?(l=+M,y):l},y.interpolate=function(M){return arguments.length?(c=M,y):c},y.on=function(){var M=d.on.apply(d,arguments);return M===d?y:M},y.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,y):Math.sqrt(b)},y.tapDistance=function(M){return arguments.length?(v=+M,y):v},y}const Io={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."},$f=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],BP=["Enter"," ","Escape"],WP={"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 _u;(function(e){e.Strict="strict",e.Loose="loose"})(_u||(_u={}));var Ql;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ql||(Ql={}));var Df;(function(e){e.Partial="partial",e.Full="full"})(Df||(Df={}));const VP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ha;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ha||(Ha={}));var Ms;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ms||(Ms={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const US={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top};function UP(e){return e===null?null:e?"valid":"invalid"}const KP=e=>"id"in e&&"source"in e&&"target"in e,c3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),dp=(e,t=[0,0])=>{const{width:n,height:r}=ma(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},u3=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Gv(s)?s:t.nodeLookup.get(s.id));const l=a?Xm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Yg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Gg(n)},fp=(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=Yg(n,Xm(s)),r=!0)}),r?Gg(n):{x:0,y:0,width:0,height:0}},Xv=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...hp(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:u=!0,hidden:p=!1}=d;if(a&&!u||p)continue;const m=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=Ff(l,Au(d)),v=(m??0)*(g??0),y=i&&b>0;(!d.internals.handleBounds||y||b>=v||d.dragging)&&c.push(d)}return c},d3=(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 f3(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 p3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=f3(e,a),c=fp(l),d=Jv(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function qP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??r;let u=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Io.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(u=[[c,d],[c+m,d+g]])}else l&&Iu(a.extent)&&(u=[[a.extent[0][0]+c,a.extent[0][1]+d],[a.extent[1][0]+c,a.extent[1][1]+d]]);const p=Iu(u)?cc(t,u,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Io.error015())),{position:{x:p.x-c+(a.measured.width??0)*f[0],y:p.y-d+(a.measured.height??0)*f[1]},positionAbsolute:p}}async function h3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const m=i.has(p.id),g=!m&&p.parentId&&a.find(b=>b.id===p.parentId);(m||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),f=d3(a,c);for(const p of c)l.has(p.id)&&!f.find(g=>g.id===p.id)&&f.push(p);if(!s)return{edges:f,nodes:a};const u=await s({nodes:a,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:a}:{edges:[],nodes:[]}:u}const Pu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),cc=(e={x:0,y:0},t,n)=>({x:Pu(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Pu(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function YP(e,t,n){const{width:r,height:s}=ma(n),{x:i,y:a}=n.internals.positionAbsolute;return cc(e,[[i,a],[i+r,a+s]],t)}const KS=(e,t,n)=>e<t?Pu(Math.abs(e-t),1,t)/t:e>n?-Pu(Math.abs(e-n),1,t)/t:0,GP=(e,t,n=15,r=40)=>{const s=KS(e.x,r,t.width-r)*n,i=KS(e.y,r,t.height-r)*n;return[s,i]},Yg=(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)}),lb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Gg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Au=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Gv(e)?e.internals.positionAbsolute:dp(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Xm=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Gv(e)?e.internals.positionAbsolute:dp(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},XP=(e,t)=>Gg(Yg(lb(e),lb(t))),Ff=(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)},qS=e=>Yi(e.width)&&Yi(e.height)&&Yi(e.x)&&Yi(e.y),Yi=e=>!isNaN(e)&&isFinite(e),m3=(e,t)=>{},pp=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),hp=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?pp(l,a):l},Jm=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Rc(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 g3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Rc(e,n),s=Rc(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Rc(e.top??e.y??0,n),s=Rc(e.bottom??e.y??0,n),i=Rc(e.left??e.x??0,t),a=Rc(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function y3(e,t,n,r,s,i){const{x:a,y:l}=Jm(e,[t,n,r]),{x:c,y:d}=Jm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=s-c,u=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(u)}}const Jv=(e,t,n,r,s,i)=>{const a=g3(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),f=Pu(d,r,s),u=e.x+e.width/2,p=e.y+e.height/2,m=t/2-u*f,g=n/2-p*f,b=y3(e,m,g,f,t,n),v={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:m-v.left+v.right,y:g-v.top+v.bottom,zoom:f}},zf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Iu(e){return e!=null&&e!=="parent"}function ma(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 JP(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 QP(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const l=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function YS(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function x3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function w3(e){return{...WP,...e||{}}}function af(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Gi(e),l=hp({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?pp(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const Qv=e=>({width:e.offsetWidth,height:e.offsetHeight}),ZP=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 eA(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 tA=e=>"clientX"in e,Gi=(e,t)=>{var i,a;const n=tA(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},GS=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...Qv(a)}})};function nA({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,d=t*.125+i*.375+l*.375+r*.125,f=Math.abs(c-e),u=Math.abs(d-t);return[c,d,f,u]}function Ch(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function XS({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Je.Left:return[t-Ch(t-r,i),n];case Je.Right:return[t+Ch(r-t,i),n];case Je.Top:return[t,n-Ch(n-s,i)];case Je.Bottom:return[t,n+Ch(s-n,i)]}}function rA({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top,curvature:a=.25}){const[l,c]=XS({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,f]=XS({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[u,p,m,g]=nA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${r},${s}`,u,p,m,g]}function sA({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,s,a]}function v3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const a=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function k3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Yg(Xm(e),Xm(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Ff(a,Gg(i))>0}const S3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,N3=(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)),Hf=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||S3;let s;return KP(e)?s={...e}:s={...e,id:r(e)},N3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function iA({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=sA({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const JS={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},j3=({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},QS=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function C3({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:r=Je.Top,center:s,offset:i,stepPosition:a}){const l=JS[t],c=JS[r],d={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},u=j3({source:d,sourcePosition:t,target:f}),p=u.x!==0?"x":"y",m=u[p];let g=[],b,v;const y={x:0,y:0},k={x:0,y:0},[,,w,j]=sA({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??d.x+(f.x-d.x)*a,v=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,v=s.y??d.y+(f.y-d.y)*a);const H=[{x:b,y:d.y},{x:b,y:f.y}],L=[{x:d.x,y:v},{x:f.x,y:v}];l[p]===m?g=p==="x"?H:L:g=p==="x"?L:H}else{const H=[{x:d.x,y:f.y}],L=[{x:f.x,y:d.y}];if(p==="x"?g=l.x===m?L:H:g=l.y===m?H:L,t===r){const M=Math.abs(e[p]-n[p]);if(M<=i){const $=Math.min(i-1,i-M);l[p]===m?y[p]=(d[p]>e[p]?-1:1)*$:k[p]=(f[p]>n[p]?-1:1)*$}}if(t!==r){const M=p==="x"?"y":"x",$=l[p]===c[M],T=d[M]>f[M],z=d[M]<f[M];(l[p]===1&&(!$&&T||$&&z)||l[p]!==1&&(!$&&z||$&&T))&&(g=p==="x"?H:L)}const F={x:d.x+y.x,y:d.y+y.y},D={x:f.x+k.x,y:f.y+k.y},R=Math.max(Math.abs(F.x-g[0].x),Math.abs(D.x-g[0].x)),W=Math.max(Math.abs(F.y-g[0].y),Math.abs(D.y-g[0].y));R>=W?(b=(F.x+D.x)/2,v=g[0].y):(b=g[0].x,v=(F.y+D.y)/2)}const _={x:d.x+y.x,y:d.y+y.y},E={x:f.x+k.x,y:f.y+k.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],b,v,w,j]}function E3(e,t,n,r){const s=Math.min(QS(e,t)/2,QS(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${a+s*c}Q ${i},${a} ${i+s*l},${a}`}function cb({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[u,p,m,g,b]=C3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:d,stepPosition:f});let v=`M${u[0].x} ${u[0].y}`;for(let y=1;y<u.length-1;y++)v+=E3(u[y-1],u[y],u[y+1],a);return v+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[v,p,m,g,b]}function ZS(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function _3(e){var u;const{sourceNode:t,targetNode:n}=e;if(!ZS(t)||!ZS(n))return null;const r=t.internals.handleBounds||eN(t.handles),s=n.internals.handleBounds||eN(n.handles),i=tN((r==null?void 0:r.source)??[],e.sourceHandle),a=tN(e.connectionMode===_u.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!a)return(u=e.onError)==null||u.call(e,"008",Io.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Je.Bottom,c=(a==null?void 0:a.position)||Je.Top,d=uc(t,i,l),f=uc(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function eN(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 uc(e,t,n=Je.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ma(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:s+a/2,y:i};case Je.Right:return{x:s+a,y:i+l/2};case Je.Bottom:return{x:s+a/2,y:i+l};case Je.Left:return{x:s,y:i+l/2}}}function tN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function ub(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function P3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=ub(c,t);i.has(d)||(a.push({id:d,color:c.color||n,...c}),i.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const oA=1e3,A3=10,Zv={nodeOrigin:[0,0],nodeExtent:$f,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},I3={...Zv,checkEquality:!0};function e0(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function T3(e,t,n){const r=e0(Zv,n);for(const s of e.values())if(s.parentId)n0(s,e,t,r);else{const i=dp(s,r.nodeOrigin),a=Iu(s.extent)?s.extent:r.nodeExtent,l=cc(i,a,ma(s));s.internals.positionAbsolute=l}}function R3(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function t0(e){return e==="manual"}function db(e,t,n,r={}){var f,u;const s=e0(I3,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!t0(s.zIndexMode)?oA:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let m=a.get(p.id);if(s.checkEquality&&p===(m==null?void 0:m.internals.userNode))t.set(p.id,m);else{const g=dp(p,s.nodeOrigin),b=Iu(p.extent)?p.extent:s.nodeExtent,v=cc(g,b,ma(p));m={...s.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(u=p.measured)==null?void 0:u.height},internals:{positionAbsolute:v,handleBounds:R3(p,m),z:aA(p,l,s.zIndexMode),userNode:p}},t.set(p.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),p.parentId&&n0(m,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function L3(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 n0(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=e0(Zv,r),d=e.parentId,f=t.get(d);if(!f){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}L3(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*A3),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const u=i&&!t0(c)?oA:0,{x:p,y:m,z:g}=O3(e,f,a,l,u,c),{positionAbsolute:b}=e.internals,v=p!==b.x||m!==b.y;(v||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:p,y:m}:b,z:g}})}function aA(e,t,n){const r=Yi(e.zIndex)?e.zIndex:0;return t0(n)?r:r+(e.selected?t:0)}function O3(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=ma(e),d=dp(e,n),f=Iu(e.extent)?cc(d,e.extent,c):d;let u=cc({x:a+f.x,y:l+f.y},r,c);e.extent==="parent"&&(u=YP(u,c,t));const p=aA(e,s,i),m=t.internals.z??0;return{x:u.x,y:u.y,z:m>=p?m+1:p}}function r0(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const d=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??Au(c),f=XP(d,l.rect);i.set(l.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},d)=>{var w;const f=c.internals.positionAbsolute,u=ma(c),p=c.origin??r,m=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,g=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,b=Math.max(u.width,Math.round(l.width)),v=Math.max(u.height,Math.round(l.height)),y=(b-u.width)*p[0],k=(v-u.height)*p[1];(m>0||g>0||y||k)&&(s.push({id:d,type:"position",position:{x:c.position.x-m+y,y:c.position.y-g+k}}),(w=n.get(d))==null||w.forEach(j=>{e.some(_=>_.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+m,y:j.position.y+g}})})),(u.width<l.width||u.height<l.height||m||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:b+(m?p[0]*m-y:0),height:v+(g?p[1]*g-k:0)}})}),s}function M3(e,t,n,r,s,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:u}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const m of e.values()){const g=t.get(m.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=Qv(m.nodeElement),v=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!g.internals.handleBounds||m.force))){const k=m.nodeElement.getBoundingClientRect(),w=Iu(g.extent)?g.extent:i;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=YP(j,b,t.get(g.parentId)):w&&(j=cc(j,w,b));const _={...g,measured:b,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:GS("source",m.nodeElement,k,u,g.id),target:GS("target",m.nodeElement,k,u,g.id)}}};t.set(g.id,_),g.parentId&&n0(_,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,v&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:Au(_,s)}))}}if(p.length>0){const m=r0(p,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function $3({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function nN(e,t,n,r,s,i){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),i){a=`${s}-${e}-${i}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function lA(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${i}-${l}`,f=`${i}-${l}--${s}-${a}`;nN("source",c,f,e,s,a),nN("target",c,d,e,i,l),t.set(r.id,r)}}function cA(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:cA(n,t):!1}function rN(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 D3(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!cA(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&s.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function dx({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[d,f]of t){const u=(a=n.get(d))==null?void 0:a.internals.userNode;u&&s.push({...u,position:f.position,dragging:r})}if(!e)return[s[0],s];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function F3({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=pp(i,t);return{x:a.x-i.x,y:a.y-i.y}}function z3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,c=!1,d={x:0,y:0},f=null,u=!1,p=null,m=!1,g=!1,b=null;function v({noDragClassName:k,handleSelector:w,domNode:j,isSelectable:_,nodeId:E,nodeClickDistance:O=0}){p=Js(j);function H({x:R,y:W}){const{nodeLookup:M,nodeExtent:$,snapGrid:T,snapToGrid:z,nodeOrigin:A,onNodeDrag:P,onSelectionDrag:C,onError:G,updateNodePositions:Z}=t();i={x:R,y:W};let V=!1;const ne=l.size>1,ce=ne&&$?lb(fp(l)):null,fe=ne&&z?F3({dragItems:l,snapGrid:T,x:R,y:W}):null;for(const[he,oe]of l){if(!M.has(he))continue;let we={x:R-oe.distance.x,y:W-oe.distance.y};z&&(we=fe?{x:Math.round(we.x+fe.x),y:Math.round(we.y+fe.y)}:pp(we,T));let _e=null;if(ne&&$&&!oe.extent&&ce){const{positionAbsolute:Ae}=oe.internals,et=Ae.x-ce.x+$[0][0],ct=Ae.x+oe.measured.width-ce.x2+$[1][0],Xe=Ae.y-ce.y+$[0][1],mt=Ae.y+oe.measured.height-ce.y2+$[1][1];_e=[[et,Xe],[ct,mt]]}const{position:xe,positionAbsolute:Te}=qP({nodeId:he,nextPosition:we,nodeLookup:M,nodeExtent:_e||$,nodeOrigin:A,onError:G});V=V||oe.position.x!==xe.x||oe.position.y!==xe.y,oe.position=xe,oe.internals.positionAbsolute=Te}if(g=g||V,!!V&&(Z(l,!0),b&&(r||P||!E&&C))){const[he,oe]=dx({nodeId:E,dragItems:l,nodeLookup:M});r==null||r(b,l,he,oe),P==null||P(b,he,oe),E||C==null||C(b,oe)}}async function L(){if(!f)return;const{transform:R,panBy:W,autoPanSpeed:M,autoPanOnNodeDrag:$}=t();if(!$){c=!1,cancelAnimationFrame(a);return}const[T,z]=GP(d,f,M);(T!==0||z!==0)&&(i.x=(i.x??0)-T/R[2],i.y=(i.y??0)-z/R[2],await W({x:T,y:z})&&H(i)),a=requestAnimationFrame(L)}function F(R){var ne;const{nodeLookup:W,multiSelectionActive:M,nodesDraggable:$,transform:T,snapGrid:z,snapToGrid:A,selectNodesOnDrag:P,onNodeDragStart:C,onSelectionDragStart:G,unselectNodesAndEdges:Z}=t();u=!0,(!P||!_)&&!M&&E&&((ne=W.get(E))!=null&&ne.selected||Z()),_&&P&&E&&(e==null||e(E));const V=af(R.sourceEvent,{transform:T,snapGrid:z,snapToGrid:A,containerBounds:f});if(i=V,l=D3(W,$,V,E),l.size>0&&(n||C||!E&&G)){const[ce,fe]=dx({nodeId:E,dragItems:l,nodeLookup:W});n==null||n(R.sourceEvent,l,ce,fe),C==null||C(R.sourceEvent,ce,fe),E||G==null||G(R.sourceEvent,fe)}}const D=CP().clickDistance(O).on("start",R=>{const{domNode:W,nodeDragThreshold:M,transform:$,snapGrid:T,snapToGrid:z}=t();f=(W==null?void 0:W.getBoundingClientRect())||null,m=!1,g=!1,b=R.sourceEvent,M===0&&F(R),i=af(R.sourceEvent,{transform:$,snapGrid:T,snapToGrid:z,containerBounds:f}),d=Gi(R.sourceEvent,f)}).on("drag",R=>{const{autoPanOnNodeDrag:W,transform:M,snapGrid:$,snapToGrid:T,nodeDragThreshold:z,nodeLookup:A}=t(),P=af(R.sourceEvent,{transform:M,snapGrid:$,snapToGrid:T,containerBounds:f});if(b=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||E&&!A.has(E))&&(m=!0),!m){if(!c&&W&&u&&(c=!0,L()),!u){const C=Gi(R.sourceEvent,f),G=C.x-d.x,Z=C.y-d.y;Math.sqrt(G*G+Z*Z)>z&&F(R)}(i.x!==P.xSnapped||i.y!==P.ySnapped)&&l&&u&&(d=Gi(R.sourceEvent,f),H(P))}}).on("end",R=>{if(!(!u||m)&&(c=!1,u=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:W,updateNodePositions:M,onNodeDragStop:$,onSelectionDragStop:T}=t();if(g&&(M(l,!1),g=!1),s||$||!E&&T){const[z,A]=dx({nodeId:E,dragItems:l,nodeLookup:W,dragging:!1});s==null||s(R.sourceEvent,l,z,A),$==null||$(R.sourceEvent,z,A),E||T==null||T(R.sourceEvent,A)}}}).filter(R=>{const W=R.target;return!R.button&&(!k||!rN(W,`.${k}`,j))&&(!w||rN(W,w,j))});p.call(D)}function y(){p==null||p.on(".drag",null)}return{update:v,destroy:y}}function H3(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Ff(s,Au(i))>0&&r.push(i);return r}const B3=250;function W3(e,t,n,r){var l,c;let s=[],i=1/0;const a=H3(e,n,t+B3);for(const d of a){const f=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((c=d.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of f){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:p,y:m}=uc(d,u,u.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(m-e.y,2));g>t||(g<i?(s=[{...u,x:p,y:m}],i=g):g===i&&s.push({...u,x:p,y:m}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(f=>f.type===d)??s[0]}return s[0]}function uA(e,t,n,r,s,i=!1){var d,f,u;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((f=a.internals.handleBounds)==null?void 0:f.source)??[],...((u=a.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...uc(a,c,c.position,!0)}:c}function dA(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function V3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const fA=()=>!0;function U3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:u,panBy:p,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:v,isValidConnection:y=fA,onReconnectEnd:k,updateConnection:w,getTransform:j,getFromHandle:_,autoPanSpeed:E,dragThreshold:O=1,handleDomNode:H}){const L=ZP(e.target);let F=0,D;const{x:R,y:W}=Gi(e),M=dA(i,H),$=l==null?void 0:l.getBoundingClientRect();let T=!1;if(!$||!M)return;const z=uA(s,M,r,c,t);if(!z)return;let A=Gi(e,$),P=!1,C=null,G=!1,Z=null;function V(){if(!f||!$)return;const[xe,Te]=GP(A,$,E);p({x:xe,y:Te}),F=requestAnimationFrame(V)}const ne={...z,nodeId:s,type:M,position:z.position},ce=c.get(s);let he={inProgress:!0,isValid:null,from:uc(ce,ne,Je.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:ce,to:A,toHandle:null,toPosition:US[ne.position],toNode:null,pointer:A};function oe(){T=!0,w(he),g==null||g(e,{nodeId:s,handleId:r,handleType:M})}O===0&&oe();function we(xe){if(!T){const{x:mt,y:He}=Gi(xe),dt=mt-R,gn=He-W;if(!(dt*dt+gn*gn>O*O))return;oe()}if(!_()||!ne){_e(xe);return}const Te=j();A=Gi(xe,$),D=W3(hp(A,Te,!1,[1,1]),n,c,ne),P||(V(),P=!0);const Ae=pA(xe,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:L,lib:d,flowId:u,nodeLookup:c});Z=Ae.handleDomNode,C=Ae.connection,G=V3(!!D,Ae.isValid);const et=c.get(s),ct=et?uc(et,ne,Je.Left,!0):he.from,Xe={...he,from:ct,isValid:G,to:Ae.toHandle&&G?Jm({x:Ae.toHandle.x,y:Ae.toHandle.y},Te):A,toHandle:Ae.toHandle,toPosition:G&&Ae.toHandle?Ae.toHandle.position:US[ne.position],toNode:Ae.toHandle?c.get(Ae.toHandle.nodeId):null,pointer:A};w(Xe),he=Xe}function _e(xe){if(!("touches"in xe&&xe.touches.length>0)){if(T){(D||Z)&&C&&G&&(b==null||b(C));const{inProgress:Te,...Ae}=he,et={...Ae,toPosition:he.toHandle?he.toPosition:null};v==null||v(xe,et),i&&(k==null||k(xe,et))}m(),cancelAnimationFrame(F),P=!1,G=!1,C=null,Z=null,L.removeEventListener("mousemove",we),L.removeEventListener("mouseup",_e),L.removeEventListener("touchmove",we),L.removeEventListener("touchend",_e)}}L.addEventListener("mousemove",we),L.addEventListener("mouseup",_e),L.addEventListener("touchmove",we),L.addEventListener("touchend",_e)}function pA(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:d=fA,nodeLookup:f}){const u=i==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:g}=Gi(e),b=a.elementFromPoint(m,g),v=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:p,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const k=dA(void 0,v),w=v.getAttribute("data-nodeid"),j=v.getAttribute("data-handleid"),_=v.classList.contains("connectable"),E=v.classList.contains("connectableend");if(!w||!k)return y;const O={source:u?w:r,sourceHandle:u?j:s,target:u?r:w,targetHandle:u?s:j};y.connection=O;const L=_&&E&&(n===_u.Strict?u&&k==="source"||!u&&k==="target":w!==r||j!==s);y.isValid=L&&d(O),y.toHandle=uA(w,k,j,f,n,!0)}return y}const fb={onPointerDown:U3,isValid:pA};function K3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Js(e);function i({translateExtent:l,width:c,height:d,zoomStep:f=1,pannable:u=!0,zoomable:p=!0,inversePan:m=!1}){const g=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const j=n(),_=w.sourceEvent.ctrlKey&&zf()?10:1,E=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*f,O=j[2]*Math.pow(2,E*_);t.scaleTo(O)};let b=[0,0];const v=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},y=w=>{const j=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const _=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],E=[_[0]-b[0],_[1]-b[1]];b=_;const O=r()*Math.max(j[2],Math.log(j[2]))*(m?-1:1),H={x:j[0]-E[0]*O,y:j[1]-E[1]*O},L=[[0,0],[c,d]];t.setViewportConstrained({x:H.x,y:H.y,zoom:j[2]},L,l)},k=HP().on("start",v).on("zoom",u?y:null).on("zoom.wheel",p?g:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:Vi}}const Xg=e=>({x:e.x,y:e.y,zoom:e.k}),fx=({x:e,y:t,zoom:n})=>qg.translate(e,t).scale(n),tu=(e,t)=>e.target.closest(`.${t}`),hA=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),q3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,px=(e,t=0,n=q3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},mA=e=>{const t=e.ctrlKey&&zf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Y3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(tu(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&a){const v=Vi(f),y=mA(f),k=u*Math.pow(2,y);r.scaleTo(n,k,v,f);return}const p=f.deltaMode===1?20:1;let m=s===Ql.Vertical?0:f.deltaX*p,g=s===Ql.Horizontal?0:f.deltaY*p;!zf()&&f.shiftKey&&s!==Ql.Vertical&&(m=f.deltaY*p,g=0),r.translateBy(n,-(m/u)*i,-(g/u)*i,{internal:!0});const b=Xg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,b),e.panScrollTimeout=setTimeout(()=>{d==null||d(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,b))}}function G3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=tu(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function X3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Xg(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 J3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&hA(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((l=i.sourceEvent)!=null&&l.internal)&&(s==null||s(i.sourceEvent,Xg(i.transform)))}}function Q3({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&hA(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Xg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function Z3({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return u=>{var v;const p=e||t,m=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(tu(u,`${d}-flow__node`)||tu(u,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||f&&!g||tu(u,l)&&g||tu(u,c)&&(!g||s&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((v=u.touches)==null?void 0:v.length)>1)return u.preventDefault(),!1;if(!p&&!s&&!m&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&b}}function e5({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),u=HP().scaleExtent([t,n]).translateExtent(r),p=Js(e).call(u);k({x:s.x,y:s.y,zoom:Pu(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=p.on("wheel.zoom"),g=p.on("dblclick.zoom");u.wheelDelta(mA);function b(D,R){return p?new Promise(W=>{u==null||u.interpolate((R==null?void 0:R.interpolate)==="linear"?of:om).transform(px(p,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>W(!0)),D)}):Promise.resolve(!1)}function v({noWheelClassName:D,noPanClassName:R,onPaneContextMenu:W,userSelectionActive:M,panOnScroll:$,panOnDrag:T,panOnScrollMode:z,panOnScrollSpeed:A,preventScrolling:P,zoomOnPinch:C,zoomOnScroll:G,zoomOnDoubleClick:Z,zoomActivationKeyPressed:V,lib:ne,onTransformChange:ce,connectionInProgress:fe,paneClickDistance:he,selectionOnDrag:oe}){M&&!d.isZoomingOrPanning&&y();const we=$&&!V&&!M;u.clickDistance(oe?1/0:!Yi(he)||he<0?0:he);const _e=we?Y3({zoomPanValues:d,noWheelClassName:D,d3Selection:p,d3Zoom:u,panOnScrollMode:z,panOnScrollSpeed:A,zoomOnPinch:C,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):G3({noWheelClassName:D,preventScrolling:P,d3ZoomHandler:m});if(p.on("wheel.zoom",_e,{passive:!1}),!M){const Te=X3({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});u.on("start",Te);const Ae=J3({zoomPanValues:d,panOnDrag:T,onPaneContextMenu:!!W,onPanZoom:i,onTransformChange:ce});u.on("zoom",Ae);const et=Q3({zoomPanValues:d,panOnDrag:T,panOnScroll:$,onPaneContextMenu:W,onPanZoomEnd:l,onDraggingChange:c});u.on("end",et)}const xe=Z3({zoomActivationKeyPressed:V,panOnDrag:T,zoomOnScroll:G,panOnScroll:$,zoomOnDoubleClick:Z,zoomOnPinch:C,userSelectionActive:M,noPanClassName:R,noWheelClassName:D,lib:ne,connectionInProgress:fe});u.filter(xe),Z?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function k(D,R,W){const M=fx(D),$=u==null?void 0:u.constrain()(M,R,W);return $&&await b($),new Promise(T=>T($))}async function w(D,R){const W=fx(D);return await b(W,R),new Promise(M=>M(W))}function j(D){if(p){const R=fx(D),W=p.property("__zoom");(W.k!==D.zoom||W.x!==D.x||W.y!==D.y)&&(u==null||u.transform(p,R,null,{sync:!0}))}}function _(){const D=p?zP(p.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function E(D,R){return p?new Promise(W=>{u==null||u.interpolate((R==null?void 0:R.interpolate)==="linear"?of:om).scaleTo(px(p,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>W(!0)),D)}):Promise.resolve(!1)}function O(D,R){return p?new Promise(W=>{u==null||u.interpolate((R==null?void 0:R.interpolate)==="linear"?of:om).scaleBy(px(p,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>W(!0)),D)}):Promise.resolve(!1)}function H(D){u==null||u.scaleExtent(D)}function L(D){u==null||u.translateExtent(D)}function F(D){const R=!Yi(D)||D<0?0:D;u==null||u.clickDistance(R)}return{update:v,destroy:y,setViewport:w,setViewportConstrained:k,getViewport:_,scaleTo:E,scaleBy:O,setScaleExtent:H,setTranslateExtent:L,syncViewport:j,setClickDistance:F}}var Tu;(function(e){e.Line="line",e.Handle="handle"})(Tu||(Tu={}));function t5({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&i&&(c[1]=c[1]*-1),c}function sN(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 Ra(e,t){return Math.max(0,t-e)}function La(e,t){return Math.max(0,e-t)}function Eh(e,t,n){return Math.max(0,t-e,e-n)}function iN(e,t){return e?!t:t}function n5(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:u}=t,p=f&&u,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:v,minHeight:y,maxHeight:k}=r,{x:w,y:j,width:_,height:E,aspectRatio:O}=e;let H=Math.floor(f?m-e.pointerX:0),L=Math.floor(u?g-e.pointerY:0);const F=_+(c?-H:H),D=E+(d?-L:L),R=-i[0]*_,W=-i[1]*E;let M=Eh(F,b,v),$=Eh(D,y,k);if(a){let A=0,P=0;c&&H<0?A=Ra(w+H+R,a[0][0]):!c&&H>0&&(A=La(w+F+R,a[1][0])),d&&L<0?P=Ra(j+L+W,a[0][1]):!d&&L>0&&(P=La(j+D+W,a[1][1])),M=Math.max(M,A),$=Math.max($,P)}if(l){let A=0,P=0;c&&H>0?A=La(w+H,l[0][0]):!c&&H<0&&(A=Ra(w+F,l[1][0])),d&&L>0?P=La(j+L,l[0][1]):!d&&L<0&&(P=Ra(j+D,l[1][1])),M=Math.max(M,A),$=Math.max($,P)}if(s){if(f){const A=Eh(F/O,y,k)*O;if(M=Math.max(M,A),a){let P=0;!c&&!d||c&&!d&&p?P=La(j+W+F/O,a[1][1])*O:P=Ra(j+W+(c?H:-H)/O,a[0][1])*O,M=Math.max(M,P)}if(l){let P=0;!c&&!d||c&&!d&&p?P=Ra(j+F/O,l[1][1])*O:P=La(j+(c?H:-H)/O,l[0][1])*O,M=Math.max(M,P)}}if(u){const A=Eh(D*O,b,v)/O;if($=Math.max($,A),a){let P=0;!c&&!d||d&&!c&&p?P=La(w+D*O+R,a[1][0])/O:P=Ra(w+(d?L:-L)*O+R,a[0][0])/O,$=Math.max($,P)}if(l){let P=0;!c&&!d||d&&!c&&p?P=Ra(w+D*O,l[1][0])/O:P=La(w+(d?L:-L)*O,l[0][0])/O,$=Math.max($,P)}}}L=L+(L<0?$:-$),H=H+(H<0?M:-M),s&&(p?F>D*O?L=(iN(c,d)?-H:H)/O:H=(iN(c,d)?-L:L)*O:f?(L=H/O,d=c):(H=L*O,c=d));const T=c?w+H:w,z=d?j+L:j;return{width:_+(c?-H:H),height:E+(d?-L:L),x:i[0]*H*(c?-1:1)+T,y:i[1]*L*(d?-1:1)+z}}const gA={width:0,height:0,x:0,y:0},r5={...gA,pointerX:0,pointerY:0,aspectRatio:1};function s5(e){return[[0,0],[e.measured.width,e.measured.height]]}function i5(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,c=n[1]*a;return[[r-l,s-c],[r+i-l,s+a-c]]}function o5({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Js(e);let a={controlDirection:sN("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:f,keepAspectRatio:u,resizeDirection:p,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:v}){let y={...gA},k={...r5};a={boundaries:f,resizeDirection:p,keepAspectRatio:u,controlDirection:sN(d)};let w,j=null,_=[],E,O,H,L=!1;const F=CP().on("start",D=>{const{nodeLookup:R,transform:W,snapGrid:M,snapToGrid:$,nodeOrigin:T,paneDomNode:z}=n();if(w=R.get(t),!w)return;j=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:P}=af(D.sourceEvent,{transform:W,snapGrid:M,snapToGrid:$,containerBounds:j});y={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},k={...y,pointerX:A,pointerY:P,aspectRatio:y.width/y.height},E=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(E=R.get(w.parentId),O=E&&w.extent==="parent"?s5(E):void 0),_=[],H=void 0;for(const[C,G]of R)if(G.parentId===t&&(_.push({id:C,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const Z=i5(G,w,G.origin??T);H?H=[[Math.min(Z[0][0],H[0][0]),Math.min(Z[0][1],H[0][1])],[Math.max(Z[1][0],H[1][0]),Math.max(Z[1][1],H[1][1])]]:H=Z}m==null||m(D,{...y})}).on("drag",D=>{const{transform:R,snapGrid:W,snapToGrid:M,nodeOrigin:$}=n(),T=af(D.sourceEvent,{transform:R,snapGrid:W,snapToGrid:M,containerBounds:j}),z=[];if(!w)return;const{x:A,y:P,width:C,height:G}=y,Z={},V=w.origin??$,{width:ne,height:ce,x:fe,y:he}=n5(k,a.controlDirection,T,a.boundaries,a.keepAspectRatio,V,O,H),oe=ne!==C,we=ce!==G,_e=fe!==A&&oe,xe=he!==P&&we;if(!_e&&!xe&&!oe&&!we)return;if((_e||xe||V[0]===1||V[1]===1)&&(Z.x=_e?fe:y.x,Z.y=xe?he:y.y,y.x=Z.x,y.y=Z.y,_.length>0)){const ct=fe-A,Xe=he-P;for(const mt of _)mt.position={x:mt.position.x-ct+V[0]*(ne-C),y:mt.position.y-Xe+V[1]*(ce-G)},z.push(mt)}if((oe||we)&&(Z.width=oe&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ne:y.width,Z.height=we&&(!a.resizeDirection||a.resizeDirection==="vertical")?ce:y.height,y.width=Z.width,y.height=Z.height),E&&w.expandParent){const ct=V[0]*(Z.width??0);Z.x&&Z.x<ct&&(y.x=ct,k.x=k.x-(Z.x-ct));const Xe=V[1]*(Z.height??0);Z.y&&Z.y<Xe&&(y.y=Xe,k.y=k.y-(Z.y-Xe))}const Te=t5({width:y.width,prevWidth:C,height:y.height,prevHeight:G,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Ae={...y,direction:Te};(v==null?void 0:v(D,Ae))!==!1&&(L=!0,g==null||g(D,Ae),r(Z,z))}).on("end",D=>{L&&(b==null||b(D,{...y}),s==null||s({...y}),L=!1)});i.call(F)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var yA={exports:{}},xA={},wA={exports:{}},bA={};/**
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 Ru=h;function a5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var l5=typeof Object.is=="function"?Object.is:a5,c5=Ru.useState,u5=Ru.useEffect,d5=Ru.useLayoutEffect,f5=Ru.useDebugValue;function p5(e,t){var n=t(),r=c5({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return d5(function(){s.value=n,s.getSnapshot=t,hx(s)&&i({inst:s})},[e,n,t]),u5(function(){return hx(s)&&i({inst:s}),e(function(){hx(s)&&i({inst:s})})},[e]),f5(n),n}function hx(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!l5(e,n)}catch{return!0}}function h5(e,t){return t()}var m5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h5:p5;bA.useSyncExternalStore=Ru.useSyncExternalStore!==void 0?Ru.useSyncExternalStore:m5;wA.exports=bA;var vA=wA.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 Jg=h,g5=vA;function y5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var x5=typeof Object.is=="function"?Object.is:y5,w5=g5.useSyncExternalStore,b5=Jg.useRef,v5=Jg.useEffect,k5=Jg.useMemo,S5=Jg.useDebugValue;xA.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=b5(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=k5(function(){function c(m){if(!d){if(d=!0,f=m,m=r(m),s!==void 0&&a.hasValue){var g=a.value;if(s(g,m))return u=g}return u=m}if(g=u,x5(f,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(f=m,g):(f=m,u=b)}var d=!1,f,u,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=w5(e,i[0],i[1]);return v5(function(){a.hasValue=!0,a.value=l},[l]),S5(l),l};yA.exports=xA;var N5=yA.exports;const j5=dl(N5),C5={},oN=e=>{let t;const n=new Set,r=(f,u)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const m=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(C5?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},E5=e=>e?oN(e):oN,{useDebugValue:_5}=lt,{useSyncExternalStoreWithSelector:P5}=j5,A5=e=>e;function kA(e,t=A5,n){const r=P5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return _5(r),r}const aN=(e,t)=>{const n=E5(e),r=(s,i=t)=>kA(n,s,i);return Object.assign(r,n),r},I5=(e,t)=>e?aN(e,t):aN;function qn(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 Qg=h.createContext(null),T5=Qg.Provider,SA=Io.error001();function Vt(e,t){const n=h.useContext(Qg);if(n===null)throw new Error(SA);return kA(n,e,t)}function Hn(){const e=h.useContext(Qg);if(e===null)throw new Error(SA);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const lN={display:"none"},R5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},NA="react-flow__node-desc",jA="react-flow__edge-desc",L5="react-flow__aria-live",O5=e=>e.ariaLiveMessage,M5=e=>e.ariaLabelConfig;function $5({rfId:e}){const t=Vt(O5);return o.jsx("div",{id:`${L5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:R5,children:t})}function D5({rfId:e,disableKeyboardA11y:t}){const n=Vt(M5);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${NA}-${e}`,style:lN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${jA}-${e}`,style:lN,children:n["edge.a11yDescription.default"]}),!t&&o.jsx($5,{rfId:e})]})}const Lu=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:br(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});Lu.displayName="Panel";function F5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Lu,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const z5=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}},_h=e=>e.id;function H5(e,t){return qn(e.selectedNodes.map(_h),t.selectedNodes.map(_h))&&qn(e.selectedEdges.map(_h),t.selectedEdges.map(_h))}function B5({onSelectionChange:e}){const t=Hn(),{selectedNodes:n,selectedEdges:r}=Vt(z5,H5);return h.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const W5=e=>!!e.onSelectionChangeHandlers;function V5({onSelectionChange:e}){const t=Vt(W5);return e||t?o.jsx(B5,{onSelectionChange:e}):null}const pb=typeof window<"u"?h.useLayoutEffect:h.useEffect,CA=[0,0],U5={x:0,y:0,zoom:1},K5=["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"],cN=[...K5,"rfId"],q5=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}),uN={translateExtent:$f,nodeOrigin:CA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Y5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Vt(q5,qn),d=Hn();pb(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=uN,l()}),[]);const f=h.useRef(uN);return pb(()=>{for(const u of cN){const p=e[u],m=f.current[u];p!==m&&(typeof e[u]>"u"||(u==="nodes"?t(p):u==="edges"?n(p):u==="minZoom"?r(p):u==="maxZoom"?s(p):u==="translateExtent"?i(p):u==="nodeExtent"?a(p):u==="ariaLabelConfig"?d.setState({ariaLabelConfig:w3(p)}):u==="fitView"?d.setState({fitViewQueued:p}):u==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[u]:p})))}f.current=e},cN.map(u=>e[u])),null}function dN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function G5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=dN(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=dN())!=null&&r.matches?"dark":"light"}const fN=typeof document<"u"?document:null;function Bf(e=null,t={target:fN,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),s=h.useRef(!1),i=h.useRef(new Set([])),[a,l]=h.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),f=d.reduce((u,p)=>u.concat(...p),[]);return[d,f]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??fN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var v,y;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&eA(m))return!1;const b=hN(m.code,l);if(i.current.add(m[b]),pN(a,i.current,!1)){const k=((y=(v=m.composedPath)==null?void 0:v.call(m))==null?void 0:y[0])||m.target,w=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!w)&&m.preventDefault(),r(!0)}},u=m=>{const g=hN(m.code,l);pN(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[g]),m.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function pN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function hN(e,t){return t.includes(e)?"code":"key"}const X5=()=>{const e=Hn();return h.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),c=Jv(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,u=n.snapToGrid??i;return hp(d,r,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=Jm(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function EA(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const c of a)J5(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function J5(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 Qm(e,t){return EA(e,t)}function s0(e,t){return EA(e,t)}function Hl(e,t){return{id:e,type:"select",selected:t}}function nu(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Hl(i.id,a)))}return r}function mN({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function gN(e){return{id:e.id,type:"remove"}}const yN=e=>c3(e),Q5=e=>KP(e);function _A(e){return h.forwardRef(e)}function xN(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>Z5(()=>n(s=>s+BigInt(1))));return pb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function Z5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const PA=h.createContext(null);function eH({children:e}){const t=Hn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:u,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let v=mN({items:b,lookup:p});for(const y of g.values())v=y(v);f&&d(b),v.length>0?u==null||u(v):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:k,setNodes:w}=t.getState();y&&w(k)})},[]),r=xN(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:p}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;f?d(m):u&&u(mN({items:m,lookup:p}))},[]),i=xN(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(PA.Provider,{value:a,children:e})}function tH(){const e=h.useContext(PA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const nH=e=>!!e.panZoom;function mc(){const e=X5(),t=Hn(),n=tH(),r=Vt(nH),s=h.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var y,k;const{nodeLookup:p,nodeOrigin:m}=t.getState(),g=yN(u)?u:p.get(u.id),b=g.parentId?QP(g.position,g.measured,g.parentId,p,m):g.position,v={...g,position:b,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((k=g.measured)==null?void 0:k.height)??g.height};return Au(v)},d=(u,p,m={replace:!1})=>{a(g=>g.map(b=>{if(b.id===u){const v=typeof p=="function"?p(b):p;return m.replace&&yN(v)?v:{...b,...v}}return b}))},f=(u,p,m={replace:!1})=>{l(g=>g.map(b=>{if(b.id===u){const v=typeof p=="function"?p(b):p;return m.replace&&Q5(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var p;return(p=i(u))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(p=>({...p}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const p=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...p])},addEdges:u=>{const p=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:u=[],edges:p=[],transform:m}=t.getState(),[g,b,v]=m;return{nodes:u.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:b,zoom:v}}},deleteElements:async({nodes:u=[],edges:p=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:k,onDelete:w,onBeforeDelete:j}=t.getState(),{nodes:_,edges:E}=await h3({nodesToRemove:u,edgesToRemove:p,nodes:m,edges:g,onBeforeDelete:j}),O=E.length>0,H=_.length>0;if(O){const L=E.map(gN);v==null||v(E),k(L)}if(H){const L=_.map(gN);b==null||b(_),y(L)}return(H||O)&&(w==null||w({nodes:_,edges:E})),{deletedNodes:_,deletedEdges:E}},getIntersectingNodes:(u,p=!0,m)=>{const g=qS(u),b=g?u:c(u),v=m!==void 0;return b?(m||t.getState().nodes).filter(y=>{const k=t.getState().nodeLookup.get(y.id);if(k&&!g&&(y.id===u.id||!k.internals.positionAbsolute))return!1;const w=Au(v?y:k),j=Ff(w,b);return p&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(u,p,m=!0)=>{const b=qS(u)?u:c(u);if(!b)return!1;const v=Ff(b,p);return m&&v>0||v>=p.width*p.height||v>=b.width*b.height},updateNode:d,updateNodeData:(u,p,m={replace:!1})=>{d(u,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},updateEdge:f,updateEdgeData:(u,p,m={replace:!1})=>{f(u,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},getNodesBounds:u=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return u3(u,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:u,id:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}-${u}${p?`-${p}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}${u?p?`-${u}-${p}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const p=t.getState().fitViewResolver??x3();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const wN=e=>e.selected,rH=typeof window<"u"?window:void 0;function sH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Hn(),{deleteElements:r}=mc(),s=Bf(e,{actInsideInputWithModifier:!1}),i=Bf(t,{target:rH});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(wN),edges:a.filter(wN)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function iH(e){const t=Hn();h.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=Qv(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Io.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 Zg={position:"absolute",width:"100%",height:"100%",top:0,left:0},oH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function aH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Ql.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:v,onViewportChange:y,isControlledViewport:k,paneClickDistance:w,selectionOnDrag:j}){const _=Hn(),E=h.useRef(null),{userSelectionActive:O,lib:H,connectionInProgress:L}=Vt(oH,qn),F=Bf(p),D=h.useRef();iH(E);const R=h.useCallback(W=>{y==null||y({x:W[0],y:W[1],zoom:W[2]}),k||_.setState({transform:W})},[y,k]);return h.useEffect(()=>{if(E.current){D.current=e5({domNode:E.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,onDraggingChange:T=>_.setState(z=>z.paneDragging===T?z:{paneDragging:T}),onPanZoomStart:(T,z)=>{const{onViewportChangeStart:A,onMoveStart:P}=_.getState();P==null||P(T,z),A==null||A(z)},onPanZoom:(T,z)=>{const{onViewportChange:A,onMove:P}=_.getState();P==null||P(T,z),A==null||A(z)},onPanZoomEnd:(T,z)=>{const{onViewportChangeEnd:A,onMoveEnd:P}=_.getState();P==null||P(T,z),A==null||A(z)}});const{x:W,y:M,zoom:$}=D.current.getViewport();return _.setState({panZoom:D.current,transform:[W,M,$],domNode:E.current.closest(".react-flow")}),()=>{var T;(T=D.current)==null||T.destroy()}}},[]),h.useEffect(()=>{var W;(W=D.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:m,noPanClassName:v,userSelectionActive:O,noWheelClassName:b,lib:H,onTransformChange:R,connectionInProgress:L,selectionOnDrag:j,paneClickDistance:w})},[e,t,n,r,s,i,a,l,F,m,v,O,b,H,R,L,j,w]),o.jsx("div",{className:"react-flow__renderer",ref:E,style:Zg,children:g})}const lH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function cH(){const{userSelectionActive:e,userSelectionRect:t}=Vt(lH,qn);return e&&t?o.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const mx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},uH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function dH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Df.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:m,children:g}){const b=Hn(),{userSelectionActive:v,elementsSelectable:y,dragging:k,connectionInProgress:w}=Vt(uH,qn),j=y&&(e||v),_=h.useRef(null),E=h.useRef(),O=h.useRef(new Set),H=h.useRef(new Set),L=h.useRef(!1),F=A=>{if(L.current||w){L.current=!1;return}c==null||c(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)},R=f?A=>f(A):void 0,W=A=>{L.current&&(A.stopPropagation(),L.current=!1)},M=A=>{var ce,fe;const{domNode:P}=b.getState();if(E.current=P==null?void 0:P.getBoundingClientRect(),!E.current)return;const C=A.target===_.current;if(!C&&!!A.target.closest(".nokey")||!e||!(i&&C||t)||A.button!==0||!A.isPrimary)return;(fe=(ce=A.target)==null?void 0:ce.setPointerCapture)==null||fe.call(ce,A.pointerId),L.current=!1;const{x:V,y:ne}=Gi(A.nativeEvent,E.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:ne,x:V,y:ne}}),C||(A.stopPropagation(),A.preventDefault())},$=A=>{const{userSelectionRect:P,transform:C,nodeLookup:G,edgeLookup:Z,connectionLookup:V,triggerNodeChanges:ne,triggerEdgeChanges:ce,defaultEdgeOptions:fe,resetSelectedElements:he}=b.getState();if(!E.current||!P)return;const{x:oe,y:we}=Gi(A.nativeEvent,E.current),{startX:_e,startY:xe}=P;if(!L.current){const Xe=t?0:s;if(Math.hypot(oe-_e,we-xe)<=Xe)return;he(),a==null||a(A)}L.current=!0;const Te={startX:_e,startY:xe,x:oe<_e?oe:_e,y:we<xe?we:xe,width:Math.abs(oe-_e),height:Math.abs(we-xe)},Ae=O.current,et=H.current;O.current=new Set(Xv(G,Te,C,n===Df.Partial,!0).map(Xe=>Xe.id)),H.current=new Set;const ct=(fe==null?void 0:fe.selectable)??!0;for(const Xe of O.current){const mt=V.get(Xe);if(mt)for(const{edgeId:He}of mt.values()){const dt=Z.get(He);dt&&(dt.selectable??ct)&&H.current.add(He)}}if(!YS(Ae,O.current)){const Xe=nu(G,O.current,!0);ne(Xe)}if(!YS(et,H.current)){const Xe=nu(Z,H.current);ce(Xe)}b.setState({userSelectionRect:Te,userSelectionActive:!0,nodesSelectionActive:!1})},T=A=>{var P,C;A.button===0&&((C=(P=A.target)==null?void 0:P.releasePointerCapture)==null||C.call(P,A.pointerId),!v&&A.target===_.current&&b.getState().userSelectionRect&&(F==null||F(A)),b.setState({userSelectionActive:!1,userSelectionRect:null}),L.current&&(l==null||l(A),b.setState({nodesSelectionActive:O.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:br(["react-flow__pane",{draggable:z,dragging:k,selection:e}]),onClick:j?void 0:mx(F,_),onContextMenu:mx(D,_),onWheel:mx(R,_),onPointerEnter:j?void 0:u,onPointerMove:j?$:p,onPointerUp:j?T:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?W:void 0,onPointerLeave:m,ref:_,style:Zg,children:[g,o.jsx(cH,{})]})}function hb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",Io.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function AA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=Hn(),[c,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=z3({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{hb({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,t,i,e,s,a]),c}const fH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function IA(){const e=Hn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),u=new Map,p=fH(a),m=s?i[0]:5,g=s?i[1]:5,b=n.direction.x*m*n.factor,v=n.direction.y*g*n.factor;for(const[,y]of d){if(!p(y))continue;let k={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+v};s&&(k=pp(k,i));const{position:w,positionAbsolute:j}=qP({nodeId:y.id,nextPosition:k,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});y.position=w,y.internals.positionAbsolute=j,u.set(y.id,y)}c(u)},[])}const i0=h.createContext(null),pH=i0.Provider;i0.Consumer;const TA=()=>h.useContext(i0),hH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),mH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===_u.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:f&&d}};function gH({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:u,...p},m){var $,T;const g=a||null,b=e==="target",v=Hn(),y=TA(),{connectOnClick:k,noPanClassName:w,rfId:j}=Vt(hH,qn),{connectingFrom:_,connectingTo:E,clickConnecting:O,isPossibleEndHandle:H,connectionInProcess:L,clickConnectionInProcess:F,valid:D}=Vt(mH(y,g,e),qn);y||(T=($=v.getState()).onError)==null||T.call($,"010",Io.error010());const R=z=>{const{defaultEdgeOptions:A,onConnect:P,hasDefaultEdges:C}=v.getState(),G={...A,...z};if(C){const{edges:Z,setEdges:V}=v.getState();V(Hf(G,Z))}P==null||P(G),l==null||l(G)},W=z=>{if(!y)return;const A=tA(z.nativeEvent);if(s&&(A&&z.button===0||!A)){const P=v.getState();fb.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:P.autoPanOnConnect,connectionMode:P.connectionMode,connectionRadius:P.connectionRadius,domNode:P.domNode,nodeLookup:P.nodeLookup,lib:P.lib,isTarget:b,handleId:g,nodeId:y,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:(...C)=>{var G,Z;return(Z=(G=v.getState()).onConnectEnd)==null?void 0:Z.call(G,...C)},updateConnection:P.updateConnection,onConnect:R,isValidConnection:n||((...C)=>{var G,Z;return((Z=(G=v.getState()).isValidConnection)==null?void 0:Z.call(G,...C))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}A?f==null||f(z):u==null||u(z)},M=z=>{const{onClickConnectStart:A,onClickConnectEnd:P,connectionClickStartHandle:C,connectionMode:G,isValidConnection:Z,lib:V,rfId:ne,nodeLookup:ce,connection:fe}=v.getState();if(!y||!C&&!s)return;if(!C){A==null||A(z.nativeEvent,{nodeId:y,handleId:g,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const he=ZP(z.target),oe=n||Z,{connection:we,isValid:_e}=fb.isValid(z.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:G,fromNodeId:C.nodeId,fromHandleId:C.id||null,fromType:C.type,isValidConnection:oe,flowId:ne,doc:he,lib:V,nodeLookup:ce});_e&&we&&R(we);const xe=structuredClone(fe);delete xe.inProgress,xe.toPosition=xe.toHandle?xe.toHandle.position:null,P==null||P(z,xe),v.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${j}-${y}-${g}-${e}`,className:br(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:O,connectingfrom:_,connectingto:E,valid:D,connectionindicator:r&&(!L||H)&&(L||F?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:k?M:void 0,ref:m,...p,children:c})}const Ds=h.memo(_A(gH));function yH({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Ds,{type:"source",position:n,isConnectable:t})]})}function xH({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:r=Je.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Ds,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Ds,{type:"source",position:r,isConnectable:t})]})}function wH(){return null}function bH({data:e,isConnectable:t,targetPosition:n=Je.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Ds,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Zm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},bN={input:yH,default:xH,output:bH,group:wH};function vH(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 kH=e=>{const{width:t,height:n,x:r,y:s}=fp(e.nodeLookup,{filter:i=>!!i.selected});return{width:Yi(t)?t:null,height:Yi(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 SH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Hn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Vt(kH,qn),c=IA(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&i!==null;if(AA({nodeRef:d,disabled:!f}),!f)return null;const u=e?m=>{const g=r.getState().nodes.filter(b=>b.selected);e(m,g)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(Zm,m.key)&&(m.preventDefault(),c({direction:Zm[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:br(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const vN=typeof window<"u"?window:void 0,NH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function RA({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:u,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:k,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:_,panOnScrollMode:E,zoomOnDoubleClick:O,panOnDrag:H,defaultViewport:L,translateExtent:F,minZoom:D,maxZoom:R,preventScrolling:W,onSelectionContextMenu:M,noWheelClassName:$,noPanClassName:T,disableKeyboardA11y:z,onViewportChange:A,isControlledViewport:P}){const{nodesSelectionActive:C,userSelectionActive:G}=Vt(NH,qn),Z=Bf(d,{target:vN}),V=Bf(b,{target:vN}),ne=V||H,ce=V||j,fe=f&&ne!==!0,he=Z||G||fe;return sH({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(aH,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:k,zoomOnPinch:w,panOnScroll:ce,panOnScrollSpeed:_,panOnScrollMode:E,zoomOnDoubleClick:O,panOnDrag:!Z&&ne,defaultViewport:L,translateExtent:F,minZoom:D,maxZoom:R,zoomActivationKeyCode:v,preventScrolling:W,noWheelClassName:$,noPanClassName:T,onViewportChange:A,isControlledViewport:P,paneClickDistance:l,selectionOnDrag:fe,children:o.jsxs(dH,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:ne,isSelecting:!!he,selectionMode:u,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:fe,children:[e,C&&o.jsx(SH,{onSelectionContextMenu:M,noPanClassName:T,disableKeyboardA11y:z})]})})}RA.displayName="FlowRenderer";const jH=h.memo(RA),CH=e=>t=>e?Xv(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 EH(e){return Vt(h.useCallback(CH(e),[e]),qn)}const _H=e=>e.updateNodeInternals;function PH(){const e=Vt(_H),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function AH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Hn(),i=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),d=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{i.current&&!e.hidden&&(!f||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(i.current){const u=d.current!==t,p=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||p||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function IH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:u,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:v,nodeClickDistance:y,onError:k}){const{node:w,internals:j,isParent:_}=Vt(oe=>{const we=oe.nodeLookup.get(e),_e=oe.parentLookup.has(e);return{node:we,internals:we.internals,isParent:_e}},qn);let E=w.type||"default",O=(v==null?void 0:v[E])||bN[E];O===void 0&&(k==null||k("003",Io.error003(E)),E="default",O=(v==null?void 0:v.default)||bN.default);const H=!!(w.draggable||l&&typeof w.draggable>"u"),L=!!(w.selectable||c&&typeof w.selectable>"u"),F=!!(w.connectable||d&&typeof w.connectable>"u"),D=!!(w.focusable||f&&typeof w.focusable>"u"),R=Hn(),W=JP(w),M=AH({node:w,nodeType:E,hasDimensions:W,resizeObserver:u}),$=AA({nodeRef:M,disabled:w.hidden||!H,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:L,nodeClickDistance:y}),T=IA();if(w.hidden)return null;const z=ma(w),A=vH(w),P=L||H||t||n||r||s,C=n?oe=>n(oe,{...j.userNode}):void 0,G=r?oe=>r(oe,{...j.userNode}):void 0,Z=s?oe=>s(oe,{...j.userNode}):void 0,V=i?oe=>i(oe,{...j.userNode}):void 0,ne=a?oe=>a(oe,{...j.userNode}):void 0,ce=oe=>{const{selectNodesOnDrag:we,nodeDragThreshold:_e}=R.getState();L&&(!we||!H||_e>0)&&hb({id:e,store:R,nodeRef:M}),t&&t(oe,{...j.userNode})},fe=oe=>{if(!(eA(oe.nativeEvent)||g)){if(BP.includes(oe.key)&&L){const we=oe.key==="Escape";hb({id:e,store:R,unselect:we,nodeRef:M})}else if(H&&w.selected&&Object.prototype.hasOwnProperty.call(Zm,oe.key)){oe.preventDefault();const{ariaLabelConfig:we}=R.getState();R.setState({ariaLiveMessage:we["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),T({direction:Zm[oe.key],factor:oe.shiftKey?4:1})}}},he=()=>{var et;if(g||!((et=M.current)!=null&&et.matches(":focus-visible")))return;const{transform:oe,width:we,height:_e,autoPanOnNodeFocus:xe,setCenter:Te}=R.getState();if(!xe)return;Xv(new Map([[e,w]]),{x:0,y:0,width:we,height:_e},oe,!0).length>0||Te(w.position.x+z.width/2,w.position.y+z.height/2,{zoom:oe[2]})};return o.jsx("div",{className:br(["react-flow__node",`react-flow__node-${E}`,{[m]:H},w.className,{selected:w.selected,selectable:L,parent:_,draggable:H,dragging:$}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:W?"visible":"hidden",...w.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:C,onMouseMove:G,onMouseLeave:Z,onContextMenu:V,onClick:ce,onDoubleClick:ne,onKeyDown:D?fe:void 0,tabIndex:D?0:void 0,onFocus:D?he:void 0,role:w.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${NA}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(pH,{value:e,children:o.jsx(O,{id:e,data:w.data,type:E,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:L,draggable:H,deletable:w.deletable??!0,isConnectable:F,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:$,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...z})})})}var TH=h.memo(IH);const RH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function LA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Vt(RH,qn),a=EH(e.onlyRenderVisibleElements),l=PH();return o.jsx("div",{className:"react-flow__nodes",style:Zg,children:a.map(c=>o.jsx(TH,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}LA.displayName="NodeRenderer";const LH=h.memo(LA);function OH(e){return Vt(h.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&k3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),qn)}const MH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},$H=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},kN={[Ms.Arrow]:MH,[Ms.ArrowClosed]:$H};function DH(e){const t=Hn();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(kN,e)?kN[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Io.error009(e)),null)},[e])}const FH=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=DH(t);return c?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(c,{color:n,strokeWidth:a})}):null},OA=({defaultColor:e,rfId:t})=>{const n=Vt(i=>i.edges),r=Vt(i=>i.defaultEdgeOptions),s=h.useMemo(()=>P3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(FH,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};OA.displayName="MarkerDefinitions";var zH=h.memo(OA);function MA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[u,p]=h.useState({x:1,y:0,width:0,height:0}),m=br(["react-flow__edge-textwrapper",d]),g=h.useRef(null);return h.useEffect(()=>{if(g.current){const b=g.current.getBBox();p({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...f,children:[s&&o.jsx("rect",{width:u.width+2*a[0],x:-a[0],y:-a[1],height:u.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}MA.displayName="EdgeText";const HH=h.memo(MA);function ey({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...f,d:e,fill:"none",className:br(["react-flow__edge-path",f.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Yi(t)&&Yi(n)?o.jsx(HH,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function SN({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 $A({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top}){const[a,l]=SN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=SN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,u,p,m]=nA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${s}`,f,u,p,m]}function DA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:y})=>{const[k,w,j]=$A({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),_=e.isInternal?void 0:t;return o.jsx(ey,{id:_,path:k,labelX:w,labelY:j,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:y})})}const BH=DA({isInternal:!1}),FA=DA({isInternal:!0});BH.displayName="SimpleBezierEdge";FA.displayName="SimpleBezierEdgeInternal";function zA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,sourcePosition:m=Je.Bottom,targetPosition:g=Je.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:k})=>{const[w,j,_]=cb({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),E=e.isInternal?void 0:t;return o.jsx(ey,{id:E,path:w,labelX:j,labelY:_,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:b,markerStart:v,interactionWidth:k})})}const HA=zA({isInternal:!1}),BA=zA({isInternal:!0});HA.displayName="SmoothStepEdge";BA.displayName="SmoothStepEdgeInternal";function WA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(HA,{...n,id:r,pathOptions:h.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const WH=WA({isInternal:!1}),VA=WA({isInternal:!0});WH.displayName="StepEdge";VA.displayName="StepEdgeInternal";function UA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[v,y,k]=iA({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(ey,{id:w,path:v,labelX:y,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:g,interactionWidth:b})})}const VH=UA({isInternal:!1}),KA=UA({isInternal:!0});VH.displayName="StraightEdge";KA.displayName="StraightEdgeInternal";function qA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Je.Bottom,targetPosition:l=Je.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:k})=>{const[w,j,_]=rA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),E=e.isInternal?void 0:t;return o.jsx(ey,{id:E,path:w,labelX:j,labelY:_,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:k})})}const UH=qA({isInternal:!1}),YA=qA({isInternal:!0});UH.displayName="BezierEdge";YA.displayName="BezierEdgeInternal";const NN={default:YA,straight:KA,step:VA,smoothstep:BA,simplebezier:FA},jN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},KH=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,qH=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,CN="react-flow__edgeupdater";function EN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:br([CN,`${CN}-${l}`]),cx:KH(t,r,e),cy:qH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function YH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:u,setReconnecting:p,setUpdateHover:m}){const g=Hn(),b=(j,_)=>{if(j.button!==0)return;const{autoPanOnConnect:E,domNode:O,connectionMode:H,connectionRadius:L,lib:F,onConnectStart:D,cancelConnection:R,nodeLookup:W,rfId:M,panBy:$,updateConnection:T}=g.getState(),z=_.type==="target",A=(G,Z)=>{p(!1),u==null||u(G,n,_.type,Z)},P=G=>d==null?void 0:d(n,G),C=(G,Z)=>{p(!0),f==null||f(j,n,_.type),D==null||D(G,Z)};fb.onPointerDown(j.nativeEvent,{autoPanOnConnect:E,connectionMode:H,connectionRadius:L,domNode:O,handleId:_.id,nodeId:_.nodeId,nodeLookup:W,isTarget:z,edgeUpdaterType:_.type,lib:F,flowId:M,cancelConnection:R,panBy:$,isValidConnection:(...G)=>{var Z,V;return((V=(Z=g.getState()).isValidConnection)==null?void 0:V.call(Z,...G))??!0},onConnect:P,onConnectStart:C,onConnectEnd:(...G)=>{var Z,V;return(V=(Z=g.getState()).onConnectEnd)==null?void 0:V.call(Z,...G)},onReconnectEnd:A,updateConnection:T,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},v=j=>b(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=j=>b(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>m(!0),w=()=>m(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(EN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:v,onMouseEnter:k,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(EN,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:k,onMouseOut:w,type:"target"})]})}function GH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:v,onError:y,disableKeyboardA11y:k}){let w=Vt(Te=>Te.edgeLookup.get(e));const j=Vt(Te=>Te.defaultEdgeOptions);w=j?{...j,...w}:w;let _=w.type||"default",E=(b==null?void 0:b[_])||NN[_];E===void 0&&(y==null||y("011",Io.error011(_)),_="default",E=(b==null?void 0:b.default)||NN.default);const O=!!(w.focusable||t&&typeof w.focusable>"u"),H=typeof u<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),L=!!(w.selectable||r&&typeof w.selectable>"u"),F=h.useRef(null),[D,R]=h.useState(!1),[W,M]=h.useState(!1),$=Hn(),{zIndex:T,sourceX:z,sourceY:A,targetX:P,targetY:C,sourcePosition:G,targetPosition:Z}=Vt(h.useCallback(Te=>{const Ae=Te.nodeLookup.get(w.source),et=Te.nodeLookup.get(w.target);if(!Ae||!et)return{zIndex:w.zIndex,...jN};const ct=_3({id:e,sourceNode:Ae,targetNode:et,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:Te.connectionMode,onError:y});return{zIndex:v3({selected:w.selected,zIndex:w.zIndex,sourceNode:Ae,targetNode:et,elevateOnSelect:Te.elevateEdgesOnSelect,zIndexMode:Te.zIndexMode}),...ct||jN}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),qn),V=h.useMemo(()=>w.markerStart?`url('#${ub(w.markerStart,g)}')`:void 0,[w.markerStart,g]),ne=h.useMemo(()=>w.markerEnd?`url('#${ub(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||z===null||A===null||P===null||C===null)return null;const ce=Te=>{var Xe;const{addSelectedEdges:Ae,unselectNodesAndEdges:et,multiSelectionActive:ct}=$.getState();L&&($.setState({nodesSelectionActive:!1}),w.selected&&ct?(et({nodes:[],edges:[w]}),(Xe=F.current)==null||Xe.blur()):Ae([e])),s&&s(Te,w)},fe=i?Te=>{i(Te,{...w})}:void 0,he=a?Te=>{a(Te,{...w})}:void 0,oe=l?Te=>{l(Te,{...w})}:void 0,we=c?Te=>{c(Te,{...w})}:void 0,_e=d?Te=>{d(Te,{...w})}:void 0,xe=Te=>{var Ae;if(!k&&BP.includes(Te.key)&&L){const{unselectNodesAndEdges:et,addSelectedEdges:ct}=$.getState();Te.key==="Escape"?((Ae=F.current)==null||Ae.blur(),et({edges:[w]})):ct([e])}};return o.jsx("svg",{style:{zIndex:T},children:o.jsxs("g",{className:br(["react-flow__edge",`react-flow__edge-${_}`,w.className,v,{selected:w.selected,animated:w.animated,inactive:!L&&!s,updating:D,selectable:L}]),onClick:ce,onDoubleClick:fe,onContextMenu:he,onMouseEnter:oe,onMouseMove:we,onMouseLeave:_e,onKeyDown:O?xe:void 0,tabIndex:O?0:void 0,role:w.ariaRole??(O?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":O?`${jA}-${g}`:void 0,ref:F,...w.domAttributes,children:[!W&&o.jsx(E,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:L,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:P,targetY:C,sourcePosition:G,targetPosition:Z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:V,markerEnd:ne,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),H&&o.jsx(YH,{edge:w,isReconnectable:H,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,sourceX:z,sourceY:A,targetX:P,targetY:C,sourcePosition:G,targetPosition:Z,setUpdateHover:R,setReconnecting:M})]})})}var XH=h.memo(GH);const JH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function GA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:k,onError:w}=Vt(JH,qn),j=OH(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(zH,{defaultColor:e,rfId:n}),j.map(_=>o.jsx(XH,{id:_,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:k,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:u,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:r,disableKeyboardA11y:b},_))]})}GA.displayName="EdgeRenderer";const QH=h.memo(GA),ZH=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function e4({children:e}){const t=Vt(ZH);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function t4(e){const t=mc(),n=h.useRef(!1);h.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 r4(e){const t=Vt(n4),n=Hn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function s4(e){return e.connection.inProgress?{...e.connection,to:hp(e.connection.to,e.transform)}:{...e.connection}}function i4(e){return s4}function o4(e){const t=i4();return Vt(t,qn)}const a4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function l4({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Vt(a4,qn);return!(i&&s&&c)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:br(["react-flow__connection",UP(l)]),children:o.jsx(XA,{style:t,type:n,CustomComponent:r,isValid:l})})})}const XA=({style:e,type:t=Ha.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:u,toPosition:p,pointer:m}=o4();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:p,connectionStatus:UP(r),toNode:f,toHandle:u,pointer:m});let g="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case Ha.Bezier:[g]=rA(b);break;case Ha.SimpleBezier:[g]=$A(b);break;case Ha.Step:[g]=cb({...b,borderRadius:0});break;case Ha.SmoothStep:[g]=cb(b);break;default:[g]=iA(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};XA.displayName="ConnectionLine";const c4={};function _N(e=c4){h.useRef(e),Hn(),h.useEffect(()=>{},[e])}function u4(){Hn(),h.useRef(!1),h.useEffect(()=>{},[])}function JA({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:p,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:k,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:_,panActivationKeyCode:E,zoomActivationKeyCode:O,deleteKeyCode:H,onlyRenderVisibleElements:L,elementsSelectable:F,defaultViewport:D,translateExtent:R,minZoom:W,maxZoom:M,preventScrolling:$,defaultMarkerColor:T,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:P,panOnScrollSpeed:C,panOnScrollMode:G,zoomOnDoubleClick:Z,panOnDrag:V,onPaneClick:ne,onPaneMouseEnter:ce,onPaneMouseMove:fe,onPaneMouseLeave:he,onPaneScroll:oe,onPaneContextMenu:we,paneClickDistance:_e,nodeClickDistance:xe,onEdgeContextMenu:Te,onEdgeMouseEnter:Ae,onEdgeMouseMove:et,onEdgeMouseLeave:ct,reconnectRadius:Xe,onReconnect:mt,onReconnectStart:He,onReconnectEnd:dt,noDragClassName:gn,noWheelClassName:yn,noPanClassName:On,disableKeyboardA11y:rn,nodeExtent:Yn,rfId:Mn,viewport:ue,onViewportChange:ve}){return _N(e),_N(t),u4(),t4(n),r4(ue),o.jsx(jH,{onPaneClick:ne,onPaneMouseEnter:ce,onPaneMouseMove:fe,onPaneMouseLeave:he,onPaneContextMenu:we,onPaneScroll:oe,paneClickDistance:_e,deleteKeyCode:H,selectionKeyCode:k,selectionOnDrag:w,selectionMode:j,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:_,panActivationKeyCode:E,zoomActivationKeyCode:O,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:Z,panOnScroll:P,panOnScrollSpeed:C,panOnScrollMode:G,panOnDrag:V,defaultViewport:D,translateExtent:R,minZoom:W,maxZoom:M,onSelectionContextMenu:u,preventScrolling:$,noDragClassName:gn,noWheelClassName:yn,noPanClassName:On,disableKeyboardA11y:rn,onViewportChange:ve,isControlledViewport:!!ue,children:o.jsxs(e4,{children:[o.jsx(QH,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:mt,onReconnectStart:He,onReconnectEnd:dt,onlyRenderVisibleElements:L,onEdgeContextMenu:Te,onEdgeMouseEnter:Ae,onEdgeMouseMove:et,onEdgeMouseLeave:ct,reconnectRadius:Xe,defaultMarkerColor:T,noPanClassName:On,disableKeyboardA11y:rn,rfId:Mn}),o.jsx(l4,{style:b,type:g,component:v,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(LH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:xe,onlyRenderVisibleElements:L,noPanClassName:On,noDragClassName:gn,disableKeyboardA11y:rn,nodeExtent:Yn,rfId:Mn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}JA.displayName="GraphView";const d4=h.memo(JA),PN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:u,zIndexMode:p="basic"}={})=>{const m=new Map,g=new Map,b=new Map,v=new Map,y=r??t??[],k=n??e??[],w=f??[0,0],j=u??$f;lA(b,v,y);const{nodesInitialized:_}=db(k,m,g,{nodeOrigin:w,nodeExtent:j,zIndexMode:p});let E=[0,0,1];if(a&&s&&i){const O=fp(m,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:H,y:L,zoom:F}=Jv(O,s,i,c,d,(l==null?void 0:l.padding)??.1);E=[H,L,F]}return{rfId:"1",width:s??0,height:i??0,transform:E,nodes:k,nodesInitialized:_,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:$f,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:_u.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...VP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:m3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:WP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},f4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p})=>I5((m,g)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:k,fitViewResolver:w,width:j,height:_,minZoom:E,maxZoom:O}=g();y&&(await p3({nodes:v,width:j,height:_,panZoom:y,minZoom:E,maxZoom:O},k),w==null||w.resolve(!0),m({fitViewResolver:null}))}return{...PN({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:v=>{const{nodeLookup:y,parentLookup:k,nodeOrigin:w,elevateNodesOnSelect:j,fitViewQueued:_,zIndexMode:E,nodesSelectionActive:O}=g(),{nodesInitialized:H,hasSelectedNodes:L}=db(v,y,k,{nodeOrigin:w,nodeExtent:u,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:E}),F=O&&L;_&&H?(b(),m({nodes:v,nodesInitialized:H,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):m({nodes:v,nodesInitialized:H,nodesSelectionActive:F})},setEdges:v=>{const{connectionLookup:y,edgeLookup:k}=g();lA(y,k,v),m({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:k}=g();k(v),m({hasDefaultNodes:!0})}if(y){const{setEdges:k}=g();k(y),m({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:k,parentLookup:w,domNode:j,nodeOrigin:_,nodeExtent:E,debug:O,fitViewQueued:H,zIndexMode:L}=g(),{changes:F,updatedInternals:D}=M3(v,k,w,j,_,E,L);D&&(T3(k,w,{nodeOrigin:_,nodeExtent:E,zIndexMode:L}),H?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(F==null?void 0:F.length)>0&&(O&&console.log("React Flow: trigger node changes",F),y==null||y(F)))},updateNodePositions:(v,y=!1)=>{const k=[];let w=[];const{nodeLookup:j,triggerNodeChanges:_,connection:E,updateConnection:O,onNodesChangeMiddlewareMap:H}=g();for(const[L,F]of v){const D=j.get(L),R=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(F!=null&&F.position)),W={id:L,type:"position",position:R?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:y};if(D&&E.inProgress&&E.fromNode.id===D.id){const M=uc(D,E.fromHandle,Je.Left,!0);O({...E,from:M})}R&&D.parentId&&k.push({id:L,parentId:D.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),w.push(W)}if(k.length>0){const{parentLookup:L,nodeOrigin:F}=g(),D=r0(k,j,L,F);w.push(...D)}for(const L of H.values())w=L(w);_(w)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:k,nodes:w,hasDefaultNodes:j,debug:_}=g();if(v!=null&&v.length){if(j){const E=Qm(v,w);k(E)}_&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:k,edges:w,hasDefaultEdges:j,debug:_}=g();if(v!=null&&v.length){if(j){const E=s0(v,w);k(E)}_&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:k,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:_}=g();if(y){const E=v.map(O=>Hl(O,!0));j(E);return}j(nu(w,new Set([...v]),!0)),_(nu(k))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:k,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:_}=g();if(y){const E=v.map(O=>Hl(O,!0));_(E);return}_(nu(k,new Set([...v]))),j(nu(w,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:k,nodes:w,nodeLookup:j,triggerNodeChanges:_,triggerEdgeChanges:E}=g(),O=v||w,H=y||k,L=[];for(const D of O){if(!D.selected)continue;const R=j.get(D.id);R&&(R.selected=!1),L.push(Hl(D.id,!1))}const F=[];for(const D of H)D.selected&&F.push(Hl(D.id,!1));_(L),E(F)},setMinZoom:v=>{const{panZoom:y,maxZoom:k}=g();y==null||y.setScaleExtent([v,k]),m({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:k}=g();y==null||y.setScaleExtent([k,v]),m({maxZoom:v})},setTranslateExtent:v=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(v),m({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:k,triggerEdgeChanges:w,elementsSelectable:j}=g();if(!j)return;const _=y.reduce((O,H)=>H.selected?[...O,Hl(H.id,!1)]:O,[]),E=v.reduce((O,H)=>H.selected?[...O,Hl(H.id,!1)]:O,[]);k(_),w(E)},setNodeExtent:v=>{const{nodes:y,nodeLookup:k,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:_,nodeExtent:E,zIndexMode:O}=g();v[0][0]===E[0][0]&&v[0][1]===E[0][1]&&v[1][0]===E[1][0]&&v[1][1]===E[1][1]||(db(y,k,w,{nodeOrigin:j,nodeExtent:v,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:O}),m({nodeExtent:v}))},panBy:v=>{const{transform:y,width:k,height:w,panZoom:j,translateExtent:_}=g();return $3({delta:v,panZoom:j,transform:y,translateExtent:_,width:k,height:w})},setCenter:async(v,y,k)=>{const{width:w,height:j,maxZoom:_,panZoom:E}=g();if(!E)return Promise.resolve(!1);const O=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:_;return await E.setViewport({x:w/2-v*O,y:j/2-y*O,zoom:O},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...VP}})},updateConnection:v=>{m({connection:v})},reset:()=>m({...PN()})}},Object.is);function ty({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p,children:m}){const[g]=h.useState(()=>f4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:u,zIndexMode:p}));return o.jsx(T5,{value:g,children:o.jsx(eH,{children:m})})}function p4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m}){return h.useContext(Qg)?o.jsx(o.Fragment,{children:e}):o.jsx(ty,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m,children:e})}const h4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function m4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:u,onMoveEnd:p,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:k,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:_,onNodeDoubleClick:E,onNodeDragStart:O,onNodeDrag:H,onNodeDragStop:L,onNodesDelete:F,onEdgesDelete:D,onDelete:R,onSelectionChange:W,onSelectionDragStart:M,onSelectionDrag:$,onSelectionDragStop:T,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:P,onBeforeDelete:C,connectionMode:G,connectionLineType:Z=Ha.Bezier,connectionLineStyle:V,connectionLineComponent:ne,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:oe=!1,selectionMode:we=Df.Full,panActivationKeyCode:_e="Space",multiSelectionKeyCode:xe=zf()?"Meta":"Control",zoomActivationKeyCode:Te=zf()?"Meta":"Control",snapToGrid:Ae,snapGrid:et,onlyRenderVisibleElements:ct=!1,selectNodesOnDrag:Xe,nodesDraggable:mt,autoPanOnNodeFocus:He,nodesConnectable:dt,nodesFocusable:gn,nodeOrigin:yn=CA,edgesFocusable:On,edgesReconnectable:rn,elementsSelectable:Yn=!0,defaultViewport:Mn=U5,minZoom:ue=.5,maxZoom:ve=2,translateExtent:Be=$f,preventScrolling:ot=!0,nodeExtent:at,defaultMarkerColor:Lt="#b1b1b7",zoomOnScroll:nt=!0,zoomOnPinch:dn=!0,panOnScroll:Qt=!1,panOnScrollSpeed:ar=.5,panOnScrollMode:Cn=Ql.Free,zoomOnDoubleClick:fn=!0,panOnDrag:xn=!0,onPaneClick:lr,onPaneMouseEnter:be,onPaneMouseMove:Me,onPaneMouseLeave:tt,onPaneScroll:zt,onPaneContextMenu:ie,paneClickDistance:Ie=1,nodeClickDistance:We=0,children:Ht,onReconnect:pn,onReconnectStart:cr,onReconnectEnd:zs,onEdgeContextMenu:is,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Wr,onEdgeMouseLeave:it,reconnectRadius:Vr=10,onNodesChange:_i,onEdgesChange:ya,noDragClassName:ys="nodrag",noWheelClassName:Pe="nowheel",noPanClassName:sn="nopan",fitView:mr,fitViewOptions:ht,connectOnClick:Oe,attributionPosition:Ur,proOptions:Gn,defaultEdgeOptions:Kr,elevateNodesOnSelect:Cr=!0,elevateEdgesOnSelect:ut=!1,disableKeyboardA11y:Ut=!1,autoPanOnConnect:on,autoPanOnNodeDrag:Er,autoPanSpeed:Ze,connectionRadius:gr,isValidConnection:Hs,onError:xa,style:xs,id:Mo,nodeDragThreshold:vr,connectionDragThreshold:$o,viewport:Pi,onViewportChange:hn,width:er,height:ws,colorMode:qr="light",debug:oi,onScroll:Bs,ariaLabelConfig:K,zIndexMode:ge="basic",...Re},Le){const Ve=Mo||"1",Zt=G5(qr),Ot=h.useCallback(mn=>{mn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bs==null||Bs(mn)},[Bs]);return o.jsx("div",{"data-testid":"rf__wrapper",...Re,onScroll:Ot,style:{...xs,...h4},ref:Le,className:br(["react-flow",s,Zt]),id:Mo,role:"application",children:o.jsxs(p4,{nodes:e,edges:t,width:er,height:ws,fitView:mr,fitViewOptions:ht,minZoom:ue,maxZoom:ve,nodeOrigin:yn,nodeExtent:at,zIndexMode:ge,children:[o.jsx(Y5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:mt,autoPanOnNodeFocus:He,nodesConnectable:dt,nodesFocusable:gn,edgesFocusable:On,edgesReconnectable:rn,elementsSelectable:Yn,elevateNodesOnSelect:Cr,elevateEdgesOnSelect:ut,minZoom:ue,maxZoom:ve,nodeExtent:at,onNodesChange:_i,onEdgesChange:ya,snapToGrid:Ae,snapGrid:et,connectionMode:G,translateExtent:Be,connectOnClick:Oe,defaultEdgeOptions:Kr,fitView:mr,fitViewOptions:ht,onNodesDelete:F,onEdgesDelete:D,onDelete:R,onNodeDragStart:O,onNodeDrag:H,onNodeDragStop:L,onSelectionDrag:$,onSelectionDragStart:M,onSelectionDragStop:T,onMove:f,onMoveStart:u,onMoveEnd:p,noPanClassName:sn,nodeOrigin:yn,rfId:Ve,autoPanOnConnect:on,autoPanOnNodeDrag:Er,autoPanSpeed:Ze,onError:xa,connectionRadius:gr,isValidConnection:Hs,selectNodesOnDrag:Xe,nodeDragThreshold:vr,connectionDragThreshold:$o,onBeforeDelete:C,debug:oi,ariaLabelConfig:K,zIndexMode:ge}),o.jsx(d4,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:_,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:a,connectionLineType:Z,connectionLineStyle:V,connectionLineComponent:ne,connectionLineContainerStyle:ce,selectionKeyCode:he,selectionOnDrag:oe,selectionMode:we,deleteKeyCode:fe,multiSelectionKeyCode:xe,panActivationKeyCode:_e,zoomActivationKeyCode:Te,onlyRenderVisibleElements:ct,defaultViewport:Mn,translateExtent:Be,minZoom:ue,maxZoom:ve,preventScrolling:ot,zoomOnScroll:nt,zoomOnPinch:dn,zoomOnDoubleClick:fn,panOnScroll:Qt,panOnScrollSpeed:ar,panOnScrollMode:Cn,panOnDrag:xn,onPaneClick:lr,onPaneMouseEnter:be,onPaneMouseMove:Me,onPaneMouseLeave:tt,onPaneScroll:zt,onPaneContextMenu:ie,paneClickDistance:Ie,nodeClickDistance:We,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:P,onReconnect:pn,onReconnectStart:cr,onReconnectEnd:zs,onEdgeContextMenu:is,onEdgeDoubleClick:hr,onEdgeMouseEnter:Zn,onEdgeMouseMove:Wr,onEdgeMouseLeave:it,reconnectRadius:Vr,defaultMarkerColor:Lt,noDragClassName:ys,noWheelClassName:Pe,noPanClassName:sn,rfId:Ve,disableKeyboardA11y:Ut,nodeExtent:at,viewport:Pi,onViewportChange:hn}),o.jsx(V5,{onSelectionChange:W}),Ht,o.jsx(F5,{proOptions:Gn,position:Ur}),o.jsx(D5,{rfId:Ve,disableKeyboardA11y:Ut})]})})}var o0=_A(m4);function a0(){const e=Hn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function QA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Qm(s,i)),[]);return[t,n,r]}function ZA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>s0(s,i)),[]);return[t,n,r]}function g4({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:br(["react-flow__background-pattern",n,r])})}function y4({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:br(["react-flow__background-pattern","dots",t])})}var tl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(tl||(tl={}));const x4={[tl.Dots]:1,[tl.Lines]:1,[tl.Cross]:6},w4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function eI({id:e,variant:t=tl.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:f}){const u=h.useRef(null),{transform:p,patternId:m}=Vt(w4,qn),g=r||x4[t],b=t===tl.Dots,v=t===tl.Cross,y=Array.isArray(n)?n:[n,n],k=[y[0]*p[2]||1,y[1]*p[2]||1],w=g*p[2],j=Array.isArray(i)?i:[i,i],_=v?[w,w]:k,E=[j[0]*p[2]||1+_[0]/2,j[1]*p[2]||1+_[1]/2],O=`${m}${e||""}`;return o.jsxs("svg",{className:br(["react-flow__background",d]),style:{...c,...Zg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[o.jsx("pattern",{id:O,x:p[0]%k[0],y:p[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:b?o.jsx(y4,{radius:w/2,className:f}):o.jsx(g4,{dimensions:_,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${O})`})]})}eI.displayName="Background";const l0=h.memo(eI);function b4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function v4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function k4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function S4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function N4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Ph({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:br(["react-flow__controls-button",t]),...n,children:e})}const j4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function tI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:f,position:u="bottom-left",orientation:p="vertical","aria-label":m}){const g=Hn(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:k}=Vt(j4,qn),{zoomIn:w,zoomOut:j,fitView:_}=mc(),E=()=>{w(),i==null||i()},O=()=>{j(),a==null||a()},H=()=>{_(s),l==null||l()},L=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},F=p==="horizontal"?"horizontal":"vertical";return o.jsxs(Lu,{className:br(["react-flow__controls",F,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??k["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(Ph,{onClick:E,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(b4,{})}),o.jsx(Ph,{onClick:O,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:v,children:o.jsx(v4,{})})]}),n&&o.jsx(Ph,{className:"react-flow__controls-fitview",onClick:H,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:o.jsx(k4,{})}),r&&o.jsx(Ph,{className:"react-flow__controls-interactive",onClick:L,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:b?o.jsx(N4,{}):o.jsx(S4,{})}),f]})}tI.displayName="Controls";const C4=h.memo(tI);function E4({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:u,selected:p,onClick:m}){const{background:g,backgroundColor:b}=i||{},v=a||g||b;return o.jsx("rect",{className:br(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:v,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?y=>m(y,e):void 0})}const _4=h.memo(E4),P4=e=>e.nodes.map(t=>t.id),gx=e=>e instanceof Function?e:()=>e;function A4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=_4,onClick:a}){const l=Vt(P4,qn),c=gx(t),d=gx(e),f=gx(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(T4,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:u},p))})}function I4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:f,y:u,width:p,height:m}=Vt(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:y,y:k}=b.internals.positionAbsolute,{width:w,height:j}=ma(v);return{node:v,x:y,y:k,width:w,height:j}},qn);return!d||d.hidden||!JP(d)?null:o.jsx(l,{x:f,y:u,width:p,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:c,id:d.id})}const T4=h.memo(I4);var R4=h.memo(A4);const L4=200,O4=150,M4=e=>!e.hidden,$4=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?XP(fp(e.nodeLookup,{filter:M4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},D4="react-flow__minimap-desc";function nI({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:u,position:p="bottom-right",onClick:m,onNodeClick:g,pannable:b=!1,zoomable:v=!1,ariaLabel:y,inversePan:k,zoomStep:w=1,offsetScale:j=5}){const _=Hn(),E=h.useRef(null),{boundingRect:O,viewBB:H,rfId:L,panZoom:F,translateExtent:D,flowWidth:R,flowHeight:W,ariaLabelConfig:M}=Vt($4,qn),$=(e==null?void 0:e.width)??L4,T=(e==null?void 0:e.height)??O4,z=O.width/$,A=O.height/T,P=Math.max(z,A),C=P*$,G=P*T,Z=j*P,V=O.x-(C-O.width)/2-Z,ne=O.y-(G-O.height)/2-Z,ce=C+Z*2,fe=G+Z*2,he=`${D4}-${L}`,oe=h.useRef(0),we=h.useRef();oe.current=P,h.useEffect(()=>{if(E.current&&F)return we.current=K3({domNode:E.current,panZoom:F,getTransform:()=>_.getState().transform,getViewScale:()=>oe.current}),()=>{var Ae;(Ae=we.current)==null||Ae.destroy()}},[F]),h.useEffect(()=>{var Ae;(Ae=we.current)==null||Ae.update({translateExtent:D,width:R,height:W,inversePan:k,pannable:b,zoomStep:w,zoomable:v})},[b,v,k,w,D,R,W]);const _e=m?Ae=>{var Xe;const[et,ct]=((Xe=we.current)==null?void 0:Xe.pointer(Ae))||[0,0];m(Ae,{x:et,y:ct})}:void 0,xe=g?h.useCallback((Ae,et)=>{const ct=_.getState().nodeLookup.get(et).internals.userNode;g(Ae,ct)},[]):void 0,Te=y??M["minimap.ariaLabel"];return o.jsx(Lu,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*P: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:br(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:$,height:T,viewBox:`${V} ${ne} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:E,onClick:_e,children:[Te&&o.jsx("title",{id:he,children:Te}),o.jsx(R4,{onClick:xe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-Z},${ne-Z}h${ce+Z*2}v${fe+Z*2}h${-ce-Z*2}z
66
- M${H.x},${H.y}h${H.width}v${H.height}h${-H.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}nI.displayName="MiniMap";const F4=h.memo(nI),z4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,H4={[Tu.Line]:"right",[Tu.Handle]:"bottom-right"};function B4({nodeId:e,position:t,variant:n=Tu.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:v,onResizeEnd:y}){const k=TA(),w=typeof e=="string"?e:k,j=Hn(),_=h.useRef(null),E=n===Tu.Handle,O=Vt(h.useCallback(z4(E&&m),[E,m]),qn),H=h.useRef(null),L=t??H4[n];h.useEffect(()=>{if(!(!_.current||!w))return H.current||(H.current=o5({domNode:_.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:D,transform:R,snapGrid:W,snapToGrid:M,nodeOrigin:$,domNode:T}=j.getState();return{nodeLookup:D,transform:R,snapGrid:W,snapToGrid:M,nodeOrigin:$,paneDomNode:T}},onChange:(D,R)=>{const{triggerNodeChanges:W,nodeLookup:M,parentLookup:$,nodeOrigin:T}=j.getState(),z=[],A={x:D.x,y:D.y},P=M.get(w);if(P&&P.expandParent&&P.parentId){const C=P.origin??T,G=D.width??P.measured.width??0,Z=D.height??P.measured.height??0,V={id:P.id,parentId:P.parentId,rect:{width:G,height:Z,...QP({x:D.x??P.position.x,y:D.y??P.position.y},{width:G,height:Z},P.parentId,M,C)}},ne=r0([V],M,$,T);z.push(...ne),A.x=D.x?Math.max(C[0]*G,D.x):void 0,A.y=D.y?Math.max(C[1]*Z,D.y):void 0}if(A.x!==void 0&&A.y!==void 0){const C={id:w,type:"position",position:{...A}};z.push(C)}if(D.width!==void 0&&D.height!==void 0){const G={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};z.push(G)}for(const C of R){const G={...C,type:"position"};z.push(G)}W(z)},onEnd:({width:D,height:R})=>{const W={id:w,type:"dimensions",resizing:!1,dimensions:{width:D,height:R}};j.getState().triggerNodeChanges([W])}})),H.current.update({controlPosition:L,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:p,onResizeStart:b,onResize:v,onResizeEnd:y,shouldResize:g}),()=>{var D;(D=H.current)==null||D.destroy()}},[L,l,c,d,f,u,b,v,y,g]);const F=L.split("-");return o.jsx("div",{className:br(["react-flow__resize-control","nodrag",...F,n,r]),ref:_,style:{...s,scale:O,...a&&{[E?"backgroundColor":"borderColor"]:a}},children:i})}const rI=h.memo(B4);function W4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const V4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,U4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,K4={};function AN(e,t){return(K4.jsx?U4:V4).test(e)}const q4=/[ \t\n\f\r]/g;function Y4(e){return typeof e=="object"?e.type==="text"?IN(e.value):!1:IN(e)}function IN(e){return e.replace(q4,"")===""}let mp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};mp.prototype.normal={};mp.prototype.property={};mp.prototype.space=void 0;function sI(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new mp(n,r,t)}function mb(e){return e.toLowerCase()}class Fs{constructor(t,n){this.attribute=n,this.property=t}}Fs.prototype.attribute="";Fs.prototype.booleanish=!1;Fs.prototype.boolean=!1;Fs.prototype.commaOrSpaceSeparated=!1;Fs.prototype.commaSeparated=!1;Fs.prototype.defined=!1;Fs.prototype.mustUseProperty=!1;Fs.prototype.number=!1;Fs.prototype.overloadedBoolean=!1;Fs.prototype.property="";Fs.prototype.spaceSeparated=!1;Fs.prototype.space=void 0;let G4=0;const _t=gc(),yr=gc(),gb=gc(),Ee=gc(),In=gc(),hu=gc(),Ys=gc();function gc(){return 2**++G4}const yb=Object.freeze(Object.defineProperty({__proto__:null,boolean:_t,booleanish:yr,commaOrSpaceSeparated:Ys,commaSeparated:hu,number:Ee,overloadedBoolean:gb,spaceSeparated:In},Symbol.toStringTag,{value:"Module"})),yx=Object.keys(yb);class c0 extends Fs{constructor(t,n,r,s){let i=-1;if(super(t,n),TN(this,"space",s),typeof r=="number")for(;++i<yx.length;){const a=yx[i];TN(this,yx[i],(r&yb[a])===yb[a])}}}c0.prototype.defined=!0;function TN(e,t,n){n&&(e[t]=n)}function Wu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new c0(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[mb(r)]=r,n[mb(i.attribute)]=r}return new mp(t,n,e.space)}const iI=Wu({properties:{ariaActiveDescendant:null,ariaAtomic:yr,ariaAutoComplete:null,ariaBusy:yr,ariaChecked:yr,ariaColCount:Ee,ariaColIndex:Ee,ariaColSpan:Ee,ariaControls:In,ariaCurrent:null,ariaDescribedBy:In,ariaDetails:null,ariaDisabled:yr,ariaDropEffect:In,ariaErrorMessage:null,ariaExpanded:yr,ariaFlowTo:In,ariaGrabbed:yr,ariaHasPopup:null,ariaHidden:yr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:In,ariaLevel:Ee,ariaLive:null,ariaModal:yr,ariaMultiLine:yr,ariaMultiSelectable:yr,ariaOrientation:null,ariaOwns:In,ariaPlaceholder:null,ariaPosInSet:Ee,ariaPressed:yr,ariaReadOnly:yr,ariaRelevant:null,ariaRequired:yr,ariaRoleDescription:In,ariaRowCount:Ee,ariaRowIndex:Ee,ariaRowSpan:Ee,ariaSelected:yr,ariaSetSize:Ee,ariaSort:null,ariaValueMax:Ee,ariaValueMin:Ee,ariaValueNow:Ee,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function oI(e,t){return t in e?e[t]:t}function aI(e,t){return oI(e,t.toLowerCase())}const X4=Wu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hu,acceptCharset:In,accessKey:In,action:null,allow:null,allowFullScreen:_t,allowPaymentRequest:_t,allowUserMedia:_t,alt:null,as:null,async:_t,autoCapitalize:null,autoComplete:In,autoFocus:_t,autoPlay:_t,blocking:In,capture:null,charSet:null,checked:_t,cite:null,className:In,cols:Ee,colSpan:null,content:null,contentEditable:yr,controls:_t,controlsList:In,coords:Ee|hu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_t,defer:_t,dir:null,dirName:null,disabled:_t,download:gb,draggable:yr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_t,formTarget:null,headers:In,height:Ee,hidden:gb,high:Ee,href:null,hrefLang:null,htmlFor:In,httpEquiv:In,id:null,imageSizes:null,imageSrcSet:null,inert:_t,inputMode:null,integrity:null,is:null,isMap:_t,itemId:null,itemProp:In,itemRef:In,itemScope:_t,itemType:In,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_t,low:Ee,manifest:null,max:null,maxLength:Ee,media:null,method:null,min:null,minLength:Ee,multiple:_t,muted:_t,name:null,nonce:null,noModule:_t,noValidate:_t,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:_t,optimum:Ee,pattern:null,ping:In,placeholder:null,playsInline:_t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_t,referrerPolicy:null,rel:In,required:_t,reversed:_t,rows:Ee,rowSpan:Ee,sandbox:In,scope:null,scoped:_t,seamless:_t,selected:_t,shadowRootClonable:_t,shadowRootDelegatesFocus:_t,shadowRootMode:null,shape:null,size:Ee,sizes:null,slot:null,span:Ee,spellCheck:yr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ee,step:null,style:null,tabIndex:Ee,target:null,title:null,translate:null,type:null,typeMustMatch:_t,useMap:null,value:yr,width:Ee,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:In,axis:null,background:null,bgColor:null,border:Ee,borderColor:null,bottomMargin:Ee,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_t,declare:_t,event:null,face:null,frame:null,frameBorder:null,hSpace:Ee,leftMargin:Ee,link:null,longDesc:null,lowSrc:null,marginHeight:Ee,marginWidth:Ee,noResize:_t,noHref:_t,noShade:_t,noWrap:_t,object:null,profile:null,prompt:null,rev:null,rightMargin:Ee,rules:null,scheme:null,scrolling:yr,standby:null,summary:null,text:null,topMargin:Ee,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ee,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_t,disableRemotePlayback:_t,prefix:null,property:null,results:Ee,security:null,unselectable:null},space:"html",transform:aI}),J4=Wu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ys,accentHeight:Ee,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ee,amplitude:Ee,arabicForm:null,ascent:Ee,attributeName:null,attributeType:null,azimuth:Ee,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ee,by:null,calcMode:null,capHeight:Ee,className:In,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ee,diffuseConstant:Ee,direction:null,display:null,dur:null,divisor:Ee,dominantBaseline:null,download:_t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ee,enableBackground:null,end:null,event:null,exponent:Ee,externalResourcesRequired:null,fill:null,fillOpacity:Ee,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hu,g2:hu,glyphName:hu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ee,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ee,horizOriginX:Ee,horizOriginY:Ee,id:null,ideographic:Ee,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ee,k:Ee,k1:Ee,k2:Ee,k3:Ee,k4:Ee,kernelMatrix:Ys,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ee,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ee,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ee,overlineThickness:Ee,paintOrder:null,panose1:null,path:null,pathLength:Ee,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:In,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ee,pointsAtY:Ee,pointsAtZ:Ee,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ys,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ys,rev:Ys,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ys,requiredFeatures:Ys,requiredFonts:Ys,requiredFormats:Ys,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ee,specularExponent:Ee,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ee,strikethroughThickness:Ee,string:null,stroke:null,strokeDashArray:Ys,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ee,strokeOpacity:Ee,strokeWidth:null,style:null,surfaceScale:Ee,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ys,tabIndex:Ee,tableValues:null,target:null,targetX:Ee,targetY:Ee,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ys,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ee,underlineThickness:Ee,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ee,values:null,vAlphabetic:Ee,vMathematical:Ee,vectorEffect:null,vHanging:Ee,vIdeographic:Ee,version:null,vertAdvY:Ee,vertOriginX:Ee,vertOriginY:Ee,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ee,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oI}),lI=Wu({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()}}),cI=Wu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:aI}),uI=Wu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Q4={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"},Z4=/[A-Z]/g,RN=/-[a-z]/g,eB=/^data[-\w.:]+$/i;function tB(e,t){const n=mb(t);let r=t,s=Fs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&eB.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(RN,rB);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!RN.test(i)){let a=i.replace(Z4,nB);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=c0}return new s(r,t)}function nB(e){return"-"+e.toLowerCase()}function rB(e){return e.charAt(1).toUpperCase()}const sB=sI([iI,X4,lI,cI,uI],"html"),u0=sI([iI,J4,lI,cI,uI],"svg");function iB(e){return e.join(" ").trim()}var d0={},LN=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,oB=/\n/g,aB=/^\s*/,lB=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,cB=/^:\s*/,uB=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,dB=/^[;\s]*/,fB=/^\s+|\s+$/g,pB=`
67
- `,ON="/",MN="*",Wl="",hB="comment",mB="declaration";function gB(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(oB);b&&(n+=b.length);var v=g.lastIndexOf(pB);r=~v?g.length-v:r+g.length}function i(){var g={line:n,column:r};return function(b){return b.position=new a(g),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 c(g){var b=g.exec(e);if(b){var v=b[0];return s(v),e=e.slice(v.length),b}}function d(){c(aB)}function f(g){var b;for(g=g||[];b=u();)b!==!1&&g.push(b);return g}function u(){var g=i();if(!(ON!=e.charAt(0)||MN!=e.charAt(1))){for(var b=2;Wl!=e.charAt(b)&&(MN!=e.charAt(b)||ON!=e.charAt(b+1));)++b;if(b+=2,Wl===e.charAt(b-1))return l("End of comment missing");var v=e.slice(2,b-2);return r+=2,s(v),e=e.slice(b),r+=2,g({type:hB,comment:v})}}function p(){var g=i(),b=c(lB);if(b){if(u(),!c(cB))return l("property missing ':'");var v=c(uB),y=g({type:mB,property:$N(b[0].replace(LN,Wl)),value:v?$N(v[0].replace(LN,Wl)):Wl});return c(dB),y}}function m(){var g=[];f(g);for(var b;b=p();)b!==!1&&(g.push(b),f(g));return g}return d(),m()}function $N(e){return e?e.replace(fB,Wl):Wl}var yB=gB,xB=hf&&hf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(d0,"__esModule",{value:!0});d0.default=bB;const wB=xB(yB);function bB(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,wB.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var ny={};Object.defineProperty(ny,"__esModule",{value:!0});ny.camelCase=void 0;var vB=/^--[a-zA-Z0-9_-]+$/,kB=/-([a-z])/g,SB=/^[^-]+$/,NB=/^-(webkit|moz|ms|o|khtml)-/,jB=/^-(ms)-/,CB=function(e){return!e||SB.test(e)||vB.test(e)},EB=function(e,t){return t.toUpperCase()},DN=function(e,t){return"".concat(t,"-")},_B=function(e,t){return t===void 0&&(t={}),CB(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(jB,DN):e=e.replace(NB,DN),e.replace(kB,EB))};ny.camelCase=_B;var PB=hf&&hf.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},AB=PB(d0),IB=ny;function xb(e,t){var n={};return!e||typeof e!="string"||(0,AB.default)(e,function(r,s){r&&s&&(n[(0,IB.camelCase)(r,t)]=s)}),n}xb.default=xb;var TB=xb;const RB=dl(TB),dI=fI("end"),f0=fI("start");function fI(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 LB(e){const t=f0(e),n=dI(e);if(t&&n)return{start:t,end:n}}function lf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?FN(e.position):"start"in e||"end"in e?FN(e):"line"in e||"column"in e?wb(e):""}function wb(e){return zN(e&&e.line)+":"+zN(e&&e.column)}function FN(e){return wb(e&&e.start)+"-"+wb(e&&e.end)}function zN(e){return e&&typeof e=="number"?e:1}class rs extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=lf(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}rs.prototype.file="";rs.prototype.name="";rs.prototype.reason="";rs.prototype.message="";rs.prototype.stack="";rs.prototype.column=void 0;rs.prototype.line=void 0;rs.prototype.ancestors=void 0;rs.prototype.cause=void 0;rs.prototype.fatal=void 0;rs.prototype.place=void 0;rs.prototype.ruleId=void 0;rs.prototype.source=void 0;const p0={}.hasOwnProperty,OB=new Map,MB=/[A-Z]/g,$B=new Set(["table","tbody","thead","tfoot","tr"]),DB=new Set(["td","th"]),pI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function FB(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=qB(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=KB(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"?u0:sB,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=hI(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function hI(e,t,n){if(t.type==="element")return zB(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return HB(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return WB(e,t,n);if(t.type==="mdxjsEsm")return BB(e,t);if(t.type==="root")return VB(e,t,n);if(t.type==="text")return UB(e,t)}function zB(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=u0,e.schema=s),e.ancestors.push(t);const i=gI(e,t.tagName,!1),a=YB(e,t);let l=m0(e,t);return $B.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!Y4(c):!0})),mI(e,a,i,t),h0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function HB(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)}Wf(e,t.position)}function BB(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Wf(e,t.position)}function WB(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=u0,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:gI(e,t.name,!0),a=GB(e,t),l=m0(e,t);return mI(e,a,i,t),h0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function VB(e,t,n){const r={};return h0(r,m0(e,t)),e.create(t,e.Fragment,r,n)}function UB(e,t){return t.value}function mI(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function h0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function KB(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function qB(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=f0(r);return t(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function YB(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&p0.call(t.properties,s)){const i=XB(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&DB.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function GB(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Wf(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else Wf(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function m0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:OB;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=hI(e,i,a);l!==void 0&&n.push(l)}return n}function XB(e,t,n){const r=tB(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?W4(n):iB(n)),r.property==="style"){let s=typeof n=="object"?n:JB(e,String(n));return e.stylePropertyNameCase==="css"&&(s=QB(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?Q4[r.property]||r.property:r.attribute,n]}}function JB(e,t){try{return RB(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new rs("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=pI+"#cannot-parse-style-attribute",s}}function gI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=AN(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=AN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return p0.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Wf(e)}function Wf(e,t){const n=new rs("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=pI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function QB(e){const t={};let n;for(n in e)p0.call(e,n)&&(t[ZB(n)]=e[n]);return t}function ZB(e){let t=e.replace(MB,e6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function e6(e){return"-"+e.toLowerCase()}const xx={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"]},t6={};function n6(e,t){const n=t6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return yI(e,r,s)}function yI(e,t,n){if(r6(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 HN(e.children,t,n)}return Array.isArray(e)?HN(e,t,n):""}function HN(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=yI(e[s],t,n);return r.join("")}function r6(e){return!!(e&&typeof e=="object")}const BN=document.createElement("i");function g0(e){const t="&"+e+";";BN.innerHTML=t;const n=BN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function To(e,t,n,r){const s=e.length;let i=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function ki(e,t){return e.length>0?(To(e,e.length,0,t),e):t}const WN={}.hasOwnProperty;function s6(e){const t={};let n=-1;for(;++n<e.length;)i6(t,e[n]);return t}function i6(e,t){let n;for(n in t){const s=(WN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){WN.call(s,a)||(s[a]=[]);const l=i[a];o6(s[a],Array.isArray(l)?l:l?[l]:[])}}}function o6(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);To(e,0,0,r)}function xI(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 mu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const So=ml(/[A-Za-z]/),Zs=ml(/[\dA-Za-z]/),a6=ml(/[#-'*+\--9=?A-Z^-~]/);function bb(e){return e!==null&&(e<32||e===127)}const vb=ml(/\d/),l6=ml(/[\dA-Fa-f]/),c6=ml(/[!-/:-@[-`{-~]/);function bt(e){return e!==null&&e<-2}function $s(e){return e!==null&&(e<0||e===32)}function tn(e){return e===-2||e===-1||e===32}const u6=ml(new RegExp("\\p{P}|\\p{S}","u")),d6=ml(/\s/);function ml(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Vu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Zs(e.charCodeAt(n+1))&&Zs(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Rn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return tn(c)?(e.enter(n),l(c)):t(c)}function l(c){return tn(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const f6={tokenize:p6};function p6(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Rn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return bt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const h6={tokenize:m6},VN={tokenize:g6};function m6(e){const t=this,n=[];let r=0,s,i,a;return l;function l(w){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,d)(w)}return d(w)}function c(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const j=t.events.length;let _=j,E;for(;_--;)if(t.events[_][0]==="exit"&&t.events[_][1].type==="chunkFlow"){E=t.events[_][1].end;break}y(r);let O=j;for(;O<t.events.length;)t.events[O][1].end={...E},O++;return To(t.events,_+1,0,t.events.slice(j)),t.events.length=O,d(w)}return l(w)}function d(w){if(r===n.length){if(!s)return p(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(VN,f,u)(w)}function f(w){return s&&k(),y(r),p(w)}function u(w){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(w)}function p(w){return t.containerState={},e.attempt(VN,m,g)(w)}function m(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){s&&k(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(w)}function b(w){if(w===null){v(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return bt(w)?(e.consume(w),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),b)}function v(w,j){const _=t.sliceStream(w);if(j&&_.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(_),t.parser.lazy[w.start.line]){let E=s.events.length;for(;E--;)if(s.events[E][1].start.offset<a&&(!s.events[E][1].end||s.events[E][1].end.offset>a))return;const O=t.events.length;let H=O,L,F;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(L){F=t.events[H][1].end;break}L=!0}for(y(r),E=O;E<t.events.length;)t.events[E][1].end={...F},E++;To(t.events,H+1,0,t.events.slice(O)),t.events.length=E}}function y(w){let j=n.length;for(;j-- >w;){const _=n[j];t.containerState=_[1],_[0].exit.call(t,e)}n.length=w}function k(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function g6(e,t,n){return Rn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function UN(e){if(e===null||$s(e)||d6(e))return 1;if(u6(e))return 2}function y0(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const kb={name:"attention",resolveAll:y6,tokenize:x6};function y6(e,t){let n=-1,r,s,i,a,l,c,d,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const u={...e[r][1].end},p={...e[n][1].start};KN(u,-c),KN(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=ki(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=ki(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=ki(d,y0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=ki(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,d=ki(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,To(e,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function x6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=UN(r);let i;return a;function a(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const d=e.exit("attentionSequence"),f=UN(c),u=!f||f===2&&s||n.includes(c),p=!s||s===2&&f||n.includes(r);return d._open=!!(i===42?u:u&&(s||!p)),d._close=!!(i===42?p:p&&(f||!u)),t(c)}}function KN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const w6={name:"autolink",tokenize:b6};function b6(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(m){return So(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||Zs(m)?(r=1,l(m)):d(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||Zs(m))&&r++<32?(e.consume(m),l):(r=0,d(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||bb(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),f):a6(m)?(e.consume(m),d):n(m)}function f(m){return Zs(m)?u(m):n(m)}function u(m){return m===46?(e.consume(m),r=0,f):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||Zs(m))&&r++<63){const g=m===45?p:u;return e.consume(m),g}return n(m)}}const ry={partial:!0,tokenize:v6};function v6(e,t,n){return r;function r(i){return tn(i)?Rn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||bt(i)?t(i):n(i)}}const wI={continuation:{tokenize:S6},exit:N6,name:"blockQuote",tokenize:k6};function k6(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return tn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function S6(e,t,n){const r=this;return s;function s(a){return tn(a)?Rn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(wI,t,n)(a)}}function N6(e){e.exit("blockQuote")}const bI={name:"characterEscape",tokenize:j6};function j6(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return c6(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const vI={name:"characterReference",tokenize:C6};function C6(e,t,n){const r=this;let s=0,i,a;return l;function l(u){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),c}function c(u){return u===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(u),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=Zs,f(u))}function d(u){return u===88||u===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(u),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=l6,f):(e.enter("characterReferenceValue"),i=7,a=vb,f(u))}function f(u){if(u===59&&s){const p=e.exit("characterReferenceValue");return a===Zs&&!g0(r.sliceSerialize(p))?n(u):(e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(u)&&s++<i?(e.consume(u),f):n(u)}}const qN={partial:!0,tokenize:_6},YN={concrete:!0,name:"codeFenced",tokenize:E6};function E6(e,t,n){const r=this,s={partial:!0,tokenize:_};let i=0,a=0,l;return c;function c(E){return d(E)}function d(E){const O=r.events[r.events.length-1];return i=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,l=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(E)}function f(E){return E===l?(a++,e.consume(E),f):a<3?n(E):(e.exit("codeFencedFenceSequence"),tn(E)?Rn(e,u,"whitespace")(E):u(E))}function u(E){return E===null||bt(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(qN,b,j)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(E))}function p(E){return E===null||bt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(E)):tn(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Rn(e,m,"whitespace")(E)):E===96&&E===l?n(E):(e.consume(E),p)}function m(E){return E===null||bt(E)?u(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(E))}function g(E){return E===null||bt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),u(E)):E===96&&E===l?n(E):(e.consume(E),g)}function b(E){return e.attempt(s,j,v)(E)}function v(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),y}function y(E){return i>0&&tn(E)?Rn(e,k,"linePrefix",i+1)(E):k(E)}function k(E){return E===null||bt(E)?e.check(qN,b,j)(E):(e.enter("codeFlowValue"),w(E))}function w(E){return E===null||bt(E)?(e.exit("codeFlowValue"),k(E)):(e.consume(E),w)}function j(E){return e.exit("codeFenced"),t(E)}function _(E,O,H){let L=0;return F;function F($){return E.enter("lineEnding"),E.consume($),E.exit("lineEnding"),D}function D($){return E.enter("codeFencedFence"),tn($)?Rn(E,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):R($)}function R($){return $===l?(E.enter("codeFencedFenceSequence"),W($)):H($)}function W($){return $===l?(L++,E.consume($),W):L>=a?(E.exit("codeFencedFenceSequence"),tn($)?Rn(E,M,"whitespace")($):M($)):H($)}function M($){return $===null||bt($)?(E.exit("codeFencedFence"),O($)):H($)}}}function _6(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const wx={name:"codeIndented",tokenize:A6},P6={partial:!0,tokenize:I6};function A6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),Rn(e,i,"linePrefix",5)(d)}function i(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):bt(d)?e.attempt(P6,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||bt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function I6(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Rn(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):bt(a)?s(a):n(a)}}const T6={name:"codeText",previous:L6,resolve:R6,tokenize:O6};function R6(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 L6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function O6(e,t,n){let r=0,s,i;return a;function a(u){return e.enter("codeText"),e.enter("codeTextSequence"),l(u)}function l(u){return u===96?(e.consume(u),r++,l):(e.exit("codeTextSequence"),c(u))}function c(u){return u===null?n(u):u===32?(e.enter("space"),e.consume(u),e.exit("space"),c):u===96?(i=e.enter("codeTextSequence"),s=0,f(u)):bt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(u))}function d(u){return u===null||u===32||u===96||bt(u)?(e.exit("codeTextData"),c(u)):(e.consume(u),d)}function f(u){return u===96?(e.consume(u),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(u)):(i.type="codeTextData",d(u))}}class M6{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Id(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Id(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Id(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);Id(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Id(this.left,n.reverse())}}}function Id(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 kI(e){const t={};let n=-1,r,s,i,a,l,c,d;const f=new M6(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,$6(f,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=f.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return To(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function $6(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let f,u,p=-1,m=n,g=0,b=0;const v=[b];for(;m;){for(;e.get(++s)[1]!==m;);i.push(s),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(b=p+1,v.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):v.pop(),p=v.length;p--;){const y=l.slice(v[p],v[p+1]),k=i.pop();c.push([k,k+y.length-1]),e.splice(k,2,y)}for(c.reverse(),p=-1;++p<c.length;)d[g+c[p][0]]=g+c[p][1],g+=c[p][1]-c[p][0]-1;return d}const D6={resolve:z6,tokenize:H6},F6={partial:!0,tokenize:B6};function z6(e){return kI(e),e}function H6(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):bt(l)?e.check(F6,a,i)(l):(e.consume(l),s)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function B6(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Rn(e,i,"linePrefix")}function i(a){if(a===null||bt(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 SI(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let f=0;return u;function u(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),p):y===null||y===32||y===41||bb(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(y))}function p(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||bt(y)?n(y):(e.consume(y),y===92?g:m)}function g(y){return y===60||y===62||y===92?(e.consume(y),m):m(y)}function b(y){return!f&&(y===null||y===41||$s(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):f<d&&y===40?(e.consume(y),f++,b):y===41?(e.consume(y),f--,b):y===null||y===32||y===40||bb(y)?n(y):(e.consume(y),y===92?v:b)}function v(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function NI(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(i),f}function f(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(i),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):bt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||bt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),c||(c=!tn(m)),m===92?p:u)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,u):u(m)}}function jI(e,t,n,r,s,i){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(i),d(p))}function d(p){return p===a?(e.exit(i),c(a)):p===null?n(p):bt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Rn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||bt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?u:f)}function u(p){return p===a||p===92?(e.consume(p),f):f(p)}}function cf(e,t){let n;return r;function r(s){return bt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):tn(s)?Rn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const W6={name:"definition",tokenize:U6},V6={partial:!0,tokenize:K6};function U6(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return NI.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=mu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return $s(m)?cf(e,d)(m):d(m)}function d(m){return SI(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(V6,u,u)(m)}function u(m){return tn(m)?Rn(e,p,"whitespace")(m):p(m)}function p(m){return m===null||bt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function K6(e,t,n){return r;function r(l){return $s(l)?cf(e,s)(l):n(l)}function s(l){return jI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return tn(l)?Rn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||bt(l)?t(l):n(l)}}const q6={name:"hardBreakEscape",tokenize:Y6};function Y6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return bt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const G6={name:"headingAtx",resolve:X6,tokenize:J6};function X6(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},To(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function J6(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||$s(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||bt(f)?(e.exit("atxHeading"),t(f)):tn(f)?Rn(e,l,"whitespace")(f):(e.enter("atxHeadingText"),d(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function d(f){return f===null||f===35||$s(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const Q6=["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"],GN=["pre","script","style","textarea"],Z6={concrete:!0,name:"htmlFlow",resolveTo:n8,tokenize:r8},e8={partial:!0,tokenize:i8},t8={partial:!0,tokenize:s8};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 r8(e,t,n){const r=this;let s,i,a,l,c;return d;function d(V){return f(V)}function f(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),u}function u(V){return V===33?(e.consume(V),p):V===47?(e.consume(V),i=!0,b):V===63?(e.consume(V),s=3,r.interrupt?t:C):So(V)?(e.consume(V),a=String.fromCharCode(V),v):n(V)}function p(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,g):So(V)?(e.consume(V),s=4,r.interrupt?t:C):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:C):n(V)}function g(V){const ne="CDATA[";return V===ne.charCodeAt(l++)?(e.consume(V),l===ne.length?r.interrupt?t:R:g):n(V)}function b(V){return So(V)?(e.consume(V),a=String.fromCharCode(V),v):n(V)}function v(V){if(V===null||V===47||V===62||$s(V)){const ne=V===47,ce=a.toLowerCase();return!ne&&!i&&GN.includes(ce)?(s=1,r.interrupt?t(V):R(V)):Q6.includes(a.toLowerCase())?(s=6,ne?(e.consume(V),y):r.interrupt?t(V):R(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):i?k(V):w(V))}return V===45||Zs(V)?(e.consume(V),a+=String.fromCharCode(V),v):n(V)}function y(V){return V===62?(e.consume(V),r.interrupt?t:R):n(V)}function k(V){return tn(V)?(e.consume(V),k):F(V)}function w(V){return V===47?(e.consume(V),F):V===58||V===95||So(V)?(e.consume(V),j):tn(V)?(e.consume(V),w):F(V)}function j(V){return V===45||V===46||V===58||V===95||Zs(V)?(e.consume(V),j):_(V)}function _(V){return V===61?(e.consume(V),E):tn(V)?(e.consume(V),_):w(V)}function E(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),c=V,O):tn(V)?(e.consume(V),E):H(V)}function O(V){return V===c?(e.consume(V),c=null,L):V===null||bt(V)?n(V):(e.consume(V),O)}function H(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||$s(V)?_(V):(e.consume(V),H)}function L(V){return V===47||V===62||tn(V)?w(V):n(V)}function F(V){return V===62?(e.consume(V),D):n(V)}function D(V){return V===null||bt(V)?R(V):tn(V)?(e.consume(V),D):n(V)}function R(V){return V===45&&s===2?(e.consume(V),T):V===60&&s===1?(e.consume(V),z):V===62&&s===4?(e.consume(V),G):V===63&&s===3?(e.consume(V),C):V===93&&s===5?(e.consume(V),P):bt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(e8,Z,W)(V)):V===null||bt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),R)}function W(V){return e.check(t8,M,Z)(V)}function M(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),$}function $(V){return V===null||bt(V)?W(V):(e.enter("htmlFlowData"),R(V))}function T(V){return V===45?(e.consume(V),C):R(V)}function z(V){return V===47?(e.consume(V),a="",A):R(V)}function A(V){if(V===62){const ne=a.toLowerCase();return GN.includes(ne)?(e.consume(V),G):R(V)}return So(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),A):R(V)}function P(V){return V===93?(e.consume(V),C):R(V)}function C(V){return V===62?(e.consume(V),G):V===45&&s===2?(e.consume(V),C):R(V)}function G(V){return V===null||bt(V)?(e.exit("htmlFlowData"),Z(V)):(e.consume(V),G)}function Z(V){return e.exit("htmlFlow"),t(V)}}function s8(e,t,n){const r=this;return s;function s(a){return bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function i8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(ry,t,n)}}const o8={name:"htmlText",tokenize:a8};function a8(e,t,n){const r=this;let s,i,a;return l;function l(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),c}function c(C){return C===33?(e.consume(C),d):C===47?(e.consume(C),_):C===63?(e.consume(C),w):So(C)?(e.consume(C),H):n(C)}function d(C){return C===45?(e.consume(C),f):C===91?(e.consume(C),i=0,g):So(C)?(e.consume(C),k):n(C)}function f(C){return C===45?(e.consume(C),m):n(C)}function u(C){return C===null?n(C):C===45?(e.consume(C),p):bt(C)?(a=u,z(C)):(e.consume(C),u)}function p(C){return C===45?(e.consume(C),m):u(C)}function m(C){return C===62?T(C):C===45?p(C):u(C)}function g(C){const G="CDATA[";return C===G.charCodeAt(i++)?(e.consume(C),i===G.length?b:g):n(C)}function b(C){return C===null?n(C):C===93?(e.consume(C),v):bt(C)?(a=b,z(C)):(e.consume(C),b)}function v(C){return C===93?(e.consume(C),y):b(C)}function y(C){return C===62?T(C):C===93?(e.consume(C),y):b(C)}function k(C){return C===null||C===62?T(C):bt(C)?(a=k,z(C)):(e.consume(C),k)}function w(C){return C===null?n(C):C===63?(e.consume(C),j):bt(C)?(a=w,z(C)):(e.consume(C),w)}function j(C){return C===62?T(C):w(C)}function _(C){return So(C)?(e.consume(C),E):n(C)}function E(C){return C===45||Zs(C)?(e.consume(C),E):O(C)}function O(C){return bt(C)?(a=O,z(C)):tn(C)?(e.consume(C),O):T(C)}function H(C){return C===45||Zs(C)?(e.consume(C),H):C===47||C===62||$s(C)?L(C):n(C)}function L(C){return C===47?(e.consume(C),T):C===58||C===95||So(C)?(e.consume(C),F):bt(C)?(a=L,z(C)):tn(C)?(e.consume(C),L):T(C)}function F(C){return C===45||C===46||C===58||C===95||Zs(C)?(e.consume(C),F):D(C)}function D(C){return C===61?(e.consume(C),R):bt(C)?(a=D,z(C)):tn(C)?(e.consume(C),D):L(C)}function R(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),s=C,W):bt(C)?(a=R,z(C)):tn(C)?(e.consume(C),R):(e.consume(C),M)}function W(C){return C===s?(e.consume(C),s=void 0,$):C===null?n(C):bt(C)?(a=W,z(C)):(e.consume(C),W)}function M(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||$s(C)?L(C):(e.consume(C),M)}function $(C){return C===47||C===62||$s(C)?L(C):n(C)}function T(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function z(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),A}function A(C){return tn(C)?Rn(e,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):P(C)}function P(C){return e.enter("htmlTextData"),a(C)}}const x0={name:"labelEnd",resolveAll:d8,resolveTo:f8,tokenize:p8},l8={tokenize:h8},c8={tokenize:m8},u8={tokenize:g8};function d8(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&To(e,0,e.length,n),e}function f8(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=ki(l,e.slice(i+1,i+r+3)),l=ki(l,[["enter",f,t]]),l=ki(l,y0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=ki(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=ki(l,e.slice(a+1)),l=ki(l,[["exit",c,t]]),To(e,i,e.length,l),e}function p8(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?u(p):(a=r.parser.defined.includes(mu(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(l8,f,a?f:u)(p):p===91?e.attempt(c8,f,a?d:u)(p):a?f(p):u(p)}function d(p){return e.attempt(u8,f,u)(p)}function f(p){return t(p)}function u(p){return i._balanced=!0,n(p)}}function h8(e,t,n){return r;function r(u){return e.enter("resource"),e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),s}function s(u){return $s(u)?cf(e,i)(u):i(u)}function i(u){return u===41?f(u):SI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return $s(u)?cf(e,c)(u):f(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?jI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):f(u)}function d(u){return $s(u)?cf(e,f)(u):f(u)}function f(u){return u===41?(e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),e.exit("resource"),t):n(u)}}function m8(e,t,n){const r=this;return s;function s(l){return NI.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(mu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function g8(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const y8={name:"labelStartImage",resolveAll:x0.resolveAll,tokenize:x8};function x8(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const w8={name:"labelStartLink",resolveAll:x0.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"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const bx={name:"lineEnding",tokenize:v8};function v8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Rn(e,t,"linePrefix")}}const um={name:"thematicBreak",tokenize:k8};function k8(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||bt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),tn(d)?Rn(e,l,"whitespace")(d):l(d))}}const Cs={continuation:{tokenize:C8},exit:_8,name:"list",tokenize:j8},S8={partial:!0,tokenize:P8},N8={partial:!0,tokenize:E8};function j8(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:vb(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(um,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return vb(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(ry,r.interrupt?n:f,e.attempt(S8,p,u))}function f(m){return r.containerState.initialBlankLine=!0,i++,p(m)}function u(m){return tn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function C8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ry,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Rn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!tn(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(N8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Rn(e,e.attempt(Cs,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function E8(e,t,n){const r=this;return Rn(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function _8(e){e.exit(this.containerState.type)}function P8(e,t,n){const r=this;return Rn(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!tn(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const XN={name:"setextUnderline",resolveTo:A8,tokenize:I8};function A8(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function I8(e,t,n){const r=this;let s;return i;function i(d){let f=r.events.length,u;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){u=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||u)?(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"),tn(d)?Rn(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||bt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const T8={tokenize:R8};function R8(e){const t=this,n=e.attempt(ry,r,e.attempt(this.parser.constructs.flowInitial,s,Rn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(D6,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const L8={resolveAll:EI()},O8=CI("string"),M8=CI("text");function CI(e){return{resolveAll:EI(e==="text"?$8:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(f){return d(f)?i(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return d(f)?(n.exit("data"),i(f)):(n.consume(f),c)}function d(f){if(f===null)return!0;const u=s[f];let p=-1;if(u)for(;++p<u.length;){const m=u[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function EI(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function $8(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,a=-1,l=0,c;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const D8={42:Cs,43:Cs,45:Cs,48:Cs,49:Cs,50:Cs,51:Cs,52:Cs,53:Cs,54:Cs,55:Cs,56:Cs,57:Cs,62:wI},F8={91:W6},z8={[-2]:wx,[-1]:wx,32:wx},H8={35:G6,42:um,45:[XN,um],60:Z6,61:XN,95:um,96:YN,126:YN},B8={38:vI,92:bI},W8={[-5]:bx,[-4]:bx,[-3]:bx,33:y8,38:vI,42:kb,60:[w6,o8],91:w8,92:[q6,bI],93:x0,95:kb,96:T6},V8={null:[kb,L8]},U8={null:[42,95]},K8={null:[]},q8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:U8,contentInitial:F8,disable:K8,document:D8,flow:H8,flowInitial:z8,insideSpan:V8,string:B8,text:W8},Symbol.toStringTag,{value:"Module"}));function Y8(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],l=[];const c={attempt:O(_),check:O(E),consume:k,enter:w,exit:j,interrupt:O(E,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:u};let f=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function u(D){return a=ki(a,D),v(),a[a.length-1]!==null?[]:(H(t,0),d.events=y0(i,d.events,d),d.events)}function p(D,R){return X8(m(D),R)}function m(D){return G8(a,D)}function g(){const{_bufferIndex:D,_index:R,line:W,column:M,offset:$}=r;return{_bufferIndex:D,_index:R,line:W,column:M,offset:$}}function b(D){s[D.line]=D.column,F()}function v(){let D;for(;r._index<a.length;){const R=a[r._index];if(typeof R=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<R.length;)y(R.charCodeAt(r._bufferIndex));else y(R)}}function y(D){f=f(D)}function k(D){bt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,F()):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 w(D,R){const W=R||{};return W.type=D,W.start=g(),d.events.push(["enter",W,d]),l.push(W),W}function j(D){const R=l.pop();return R.end=g(),d.events.push(["exit",R,d]),R}function _(D,R){H(D,R.from)}function E(D,R){R.restore()}function O(D,R){return W;function W(M,$,T){let z,A,P,C;return Array.isArray(M)?Z(M):"tokenize"in M?Z([M]):G(M);function G(fe){return he;function he(oe){const we=oe!==null&&fe[oe],_e=oe!==null&&fe.null,xe=[...Array.isArray(we)?we:we?[we]:[],...Array.isArray(_e)?_e:_e?[_e]:[]];return Z(xe)(oe)}}function Z(fe){return z=fe,A=0,fe.length===0?T:V(fe[A])}function V(fe){return he;function he(oe){return C=L(),P=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?ce():fe.tokenize.call(R?Object.assign(Object.create(d),R):d,c,ne,ce)(oe)}}function ne(fe){return D(P,C),$}function ce(fe){return C.restore(),++A<z.length?V(z[A]):T}}}function H(D,R){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&To(d.events,R,d.events.length-R,D.resolve(d.events.slice(R),d)),D.resolveTo&&(d.events=D.resolveTo(d.events,d))}function L(){const D=g(),R=d.previous,W=d.currentConstruct,M=d.events.length,$=Array.from(l);return{from:M,restore:T};function T(){r=D,d.previous=R,d.currentConstruct=W,d.events.length=M,l=$,F()}}function F(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function G8(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function X8(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
68
- `;break}case-3:{a=`\r
69
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(i)}s=i===-2,r.push(a)}return r.join("")}function J8(e){const r={constructs:s6([q8,...(e||{}).extensions||[]]),content:s(f6),defined:[],document:s(h6),flow:s(T8),lazy:{},string:s(O8),text:s(M8)};return r;function s(i){return a;function a(l){return Y8(r,i,l)}}}function Q8(e){for(;!kI(e););return e}const JN=/[\0\t\n\r]/g;function Z8(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let d,f,u,p,m;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t="",n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(JN.lastIndex=u,d=JN.exec(i),p=d&&d.index!==void 0?d.index:i.length,m=i.charCodeAt(p),!d){t=i.slice(u);break}if(m===10&&u===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),u<p&&(c.push(i.slice(u,p)),e+=p-u),m){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}u=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const eW=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tW(e){return e.replace(eW,nW)}function nW(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return xI(n.slice(i?2:1),i?16:10)}return g0(n)||e}const _I={}.hasOwnProperty;function rW(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),sW(n)(Q8(J8(n).document().write(Z8()(e,t,!0))))}function sW(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(dt),autolinkProtocol:L,autolinkEmail:L,atxHeading:i(ct),blockQuote:i(_e),characterEscape:L,characterReference:L,codeFenced:i(xe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(xe,a),codeText:i(Te,a),codeTextData:L,data:L,codeFlowValue:L,definition:i(Ae),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(et),hardBreakEscape:i(Xe),hardBreakTrailing:i(Xe),htmlFlow:i(mt,a),htmlFlowData:L,htmlText:i(mt,a),htmlTextData:L,image:i(He),label:a,link:i(dt),listItem:i(yn),listItemValue:p,listOrdered:i(gn,u),listUnordered:i(gn),paragraph:i(On),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ct),strong:i(rn),thematicBreak:i(Mn)},exit:{atxHeading:c(),atxHeadingSequence:_,autolink:c(),autolinkEmail:we,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:fe,characterReference:he,codeFenced:c(v),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:F,codeIndented:c(y),codeText:c($),codeTextData:F,data:F,definition:c(),definitionDestinationString:j,definitionLabelString:k,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(R),hardBreakTrailing:c(R),htmlFlow:c(W),htmlFlowData:F,htmlText:c(M),htmlTextData:F,image:c(z),label:P,labelText:A,lineEnding:D,link:c(T),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:C,resourceTitleString:G,resource:Z,setextHeading:c(H),setextHeadingLineSequence:O,setextHeadingText:E,strong:c(),thematicBreak:c()}};PI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ue){let ve={type:"root",children:[]};const Be={stack:[ve],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:f,data:n},ot=[];let at=-1;for(;++at<ue.length;)if(ue[at][1].type==="listOrdered"||ue[at][1].type==="listUnordered")if(ue[at][0]==="enter")ot.push(at);else{const Lt=ot.pop();at=s(ue,Lt,at)}for(at=-1;++at<ue.length;){const Lt=t[ue[at][0]];_I.call(Lt,ue[at][1].type)&&Lt[ue[at][1].type].call(Object.assign({sliceSerialize:ue[at][2].sliceSerialize},Be),ue[at][1])}if(Be.tokenStack.length>0){const Lt=Be.tokenStack[Be.tokenStack.length-1];(Lt[1]||QN).call(Be,void 0,Lt[0])}for(ve.position={start:Oa(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:Oa(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},at=-1;++at<t.transforms.length;)ve=t.transforms[at](ve)||ve;return ve}function s(ue,ve,Be){let ot=ve-1,at=-1,Lt=!1,nt,dn,Qt,ar;for(;++ot<=Be;){const Cn=ue[ot];switch(Cn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Cn[0]==="enter"?at++:at--,ar=void 0;break}case"lineEndingBlank":{Cn[0]==="enter"&&(nt&&!ar&&!at&&!Qt&&(Qt=ot),ar=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ar=void 0}if(!at&&Cn[0]==="enter"&&Cn[1].type==="listItemPrefix"||at===-1&&Cn[0]==="exit"&&(Cn[1].type==="listUnordered"||Cn[1].type==="listOrdered")){if(nt){let fn=ot;for(dn=void 0;fn--;){const xn=ue[fn];if(xn[1].type==="lineEnding"||xn[1].type==="lineEndingBlank"){if(xn[0]==="exit")continue;dn&&(ue[dn][1].type="lineEndingBlank",Lt=!0),xn[1].type="lineEnding",dn=fn}else if(!(xn[1].type==="linePrefix"||xn[1].type==="blockQuotePrefix"||xn[1].type==="blockQuotePrefixWhitespace"||xn[1].type==="blockQuoteMarker"||xn[1].type==="listItemIndent"))break}Qt&&(!dn||Qt<dn)&&(nt._spread=!0),nt.end=Object.assign({},dn?ue[dn][1].start:Cn[1].end),ue.splice(dn||ot,0,["exit",nt,Cn[2]]),ot++,Be++}if(Cn[1].type==="listItemPrefix"){const fn={type:"listItem",_spread:!1,start:Object.assign({},Cn[1].start),end:void 0};nt=fn,ue.splice(ot,0,["enter",fn,Cn[2]]),ot++,Be++,Qt=void 0,ar=!0}}}return ue[ve][1]._spread=Lt,Be}function i(ue,ve){return Be;function Be(ot){l.call(this,ue(ot),ot),ve&&ve.call(this,ot)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ue,ve,Be){this.stack[this.stack.length-1].children.push(ue),this.stack.push(ue),this.tokenStack.push([ve,Be||void 0]),ue.position={start:Oa(ve.start),end:void 0}}function c(ue){return ve;function ve(Be){ue&&ue.call(this,Be),d.call(this,Be)}}function d(ue,ve){const Be=this.stack.pop(),ot=this.tokenStack.pop();if(ot)ot[0].type!==ue.type&&(ve?ve.call(this,ue,ot[0]):(ot[1]||QN).call(this,ue,ot[0]));else throw new Error("Cannot close `"+ue.type+"` ("+lf({start:ue.start,end:ue.end})+"): it’s not open");Be.position.end=Oa(ue.end)}function f(){return n6(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function p(ue){if(this.data.expectingFirstListItemValue){const ve=this.stack[this.stack.length-2];ve.start=Number.parseInt(this.sliceSerialize(ue),10),this.data.expectingFirstListItemValue=void 0}}function m(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.lang=ue}function g(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.meta=ue}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue.replace(/(\r?\n|\r)$/g,"")}function k(ue){const ve=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ve,Be.identifier=mu(this.sliceSerialize(ue)).toLowerCase()}function w(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ue}function j(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ue}function _(ue){const ve=this.stack[this.stack.length-1];if(!ve.depth){const Be=this.sliceSerialize(ue).length;ve.depth=Be}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function O(ue){const ve=this.stack[this.stack.length-1];ve.depth=this.sliceSerialize(ue).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function L(ue){const Be=this.stack[this.stack.length-1].children;let ot=Be[Be.length-1];(!ot||ot.type!=="text")&&(ot=Yn(),ot.position={start:Oa(ue.start),end:void 0},Be.push(ot)),this.stack.push(ot)}function F(ue){const ve=this.stack.pop();ve.value+=this.sliceSerialize(ue),ve.position.end=Oa(ue.end)}function D(ue){const ve=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=ve.children[ve.children.length-1];Be.position.end=Oa(ue.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ve.type)&&(L.call(this,ue),F.call(this,ue))}function R(){this.data.atHardBreak=!0}function W(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function M(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function $(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function T(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ve,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function z(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ve,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function A(ue){const ve=this.sliceSerialize(ue),Be=this.stack[this.stack.length-2];Be.label=tW(ve),Be.identifier=mu(ve).toLowerCase()}function P(){const ue=this.stack[this.stack.length-1],ve=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const ot=ue.children;Be.children=ot}else Be.alt=ve}function C(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ue}function G(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ue}function Z(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function ne(ue){const ve=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ve,Be.identifier=mu(this.sliceSerialize(ue)).toLowerCase(),this.data.referenceType="full"}function ce(ue){this.data.characterReferenceType=ue.type}function fe(ue){const ve=this.sliceSerialize(ue),Be=this.data.characterReferenceType;let ot;Be?(ot=xI(ve,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ot=g0(ve);const at=this.stack[this.stack.length-1];at.value+=ot}function he(ue){const ve=this.stack.pop();ve.position.end=Oa(ue.end)}function oe(ue){F.call(this,ue);const ve=this.stack[this.stack.length-1];ve.url=this.sliceSerialize(ue)}function we(ue){F.call(this,ue);const ve=this.stack[this.stack.length-1];ve.url="mailto:"+this.sliceSerialize(ue)}function _e(){return{type:"blockquote",children:[]}}function xe(){return{type:"code",lang:null,meta:null,value:""}}function Te(){return{type:"inlineCode",value:""}}function Ae(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function et(){return{type:"emphasis",children:[]}}function ct(){return{type:"heading",depth:0,children:[]}}function Xe(){return{type:"break"}}function mt(){return{type:"html",value:""}}function He(){return{type:"image",title:null,url:"",alt:null}}function dt(){return{type:"link",title:null,url:"",children:[]}}function gn(ue){return{type:"list",ordered:ue.type==="listOrdered",start:null,spread:ue._spread,children:[]}}function yn(ue){return{type:"listItem",spread:ue._spread,checked:null,children:[]}}function On(){return{type:"paragraph",children:[]}}function rn(){return{type:"strong",children:[]}}function Yn(){return{type:"text",value:""}}function Mn(){return{type:"thematicBreak"}}}function Oa(e){return{line:e.line,column:e.column,offset:e.offset}}function PI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?PI(e,r):iW(e,r)}}function iW(e,t){let n;for(n in t)if(_I.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 QN(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 oW(e){const t=this;t.parser=n;function n(r){return rW(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function aW(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 lW(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function cW(e,t){const n=t.value?t.value+`
71
- `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function uW(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dW(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fW(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Vu(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=i+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const d={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,d),e.applyData(t,d)}function pW(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 hW(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function AI(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),i=s[0];i&&i.type==="text"?i.value="["+i.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function mW(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AI(e,t);const s={src:Vu(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function gW(e,t){const n={src:Vu(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 yW(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 xW(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AI(e,t);const s={href:Vu(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function wW(e,t){const n={href:Vu(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?vW(n):II(t),i={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let u;f&&f.type==="element"&&f.tagName==="p"?u=f:(u={type:"element",tagName:"p",properties:{},children:[]},r.unshift(u)),u.children.length>0&&u.children.unshift({type:"text",value:" "}),u.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const f=r[l];(s||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),f.type==="element"&&f.tagName==="p"&&!s?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const d={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,d),e.applyData(t,d)}function vW(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=II(n[r])}return t}function II(e){const t=e.spread;return t??e.children.length>1}function kW(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function SW(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NW(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function jW(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CW(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=f0(t.children[1]),c=dI(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function EW(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const d=[];for(;++c<l;){const u=t.children[c],p={},m=a?a[c]:void 0;m&&(p.align=m);let g={type:"element",tagName:i,properties:p,children:[]};u&&(g.children=e.all(u),e.patch(u,g),g=e.applyData(u,g)),d.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,f),e.applyData(t,f)}function _W(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ZN=9,ej=32;function PW(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(tj(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(tj(t.slice(s),s>0,!1)),i.join("")}function tj(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===ZN||i===ej;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===ZN||i===ej;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function AW(e,t){const n={type:"text",value:PW(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function IW(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const TW={blockquote:aW,break:lW,code:cW,delete:uW,emphasis:dW,footnoteReference:fW,heading:pW,html:hW,imageReference:mW,image:gW,inlineCode:yW,linkReference:xW,link:wW,listItem:bW,list:kW,paragraph:SW,root:NW,strong:jW,table:CW,tableCell:_W,tableRow:EW,text:AW,thematicBreak:IW,toml:Ah,yaml:Ah,definition:Ah,footnoteDefinition:Ah};function Ah(){}const TI=-1,sy=0,uf=1,eg=2,w0=3,b0=4,v0=5,k0=6,RI=7,LI=8,nj=typeof self=="object"?self:globalThis,RW=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=t[s];switch(i){case sy:case TI:return n(a,s);case uf:{const l=n([],s);for(const c of a)l.push(r(c));return l}case eg:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case w0:return n(new Date(a),s);case b0:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case v0:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case k0:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case RI:{const{name:l,message:c}=a;return n(new nj[l](c),s)}case LI: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[i](a),s)};return r},rj=e=>RW(new Map,e)(0),Lc="",{toString:LW}={},{keys:OW}=Object,Td=e=>{const t=typeof e;if(t!=="object"||!e)return[sy,t];const n=LW.call(e).slice(8,-1);switch(n){case"Array":return[uf,Lc];case"Object":return[eg,Lc];case"Date":return[w0,Lc];case"RegExp":return[b0,Lc];case"Map":return[v0,Lc];case"Set":return[k0,Lc];case"DataView":return[uf,n]}return n.includes("Array")?[uf,n]:n.includes("Error")?[RI,n]:[eg,n]},Ih=([e,t])=>e===sy&&(t==="function"||t==="symbol"),MW=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},i=a=>{if(n.has(a))return n.get(a);let[l,c]=Td(a);switch(l){case sy:{let f=a;switch(c){case"bigint":l=LI,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return s([TI],a)}return s([l,f],a)}case uf:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const f=[],u=s([l,f],a);for(const p of a)f.push(i(p));return u}case eg:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const f=[],u=s([l,f],a);for(const p of OW(a))(e||!Ih(Td(a[p])))&&f.push([i(p),i(a[p])]);return u}case w0:return s([l,a.toISOString()],a);case b0:{const{source:f,flags:u}=a;return s([l,{source:f,flags:u}],a)}case v0:{const f=[],u=s([l,f],a);for(const[p,m]of a)(e||!(Ih(Td(p))||Ih(Td(m))))&&f.push([i(p),i(m)]);return u}case k0:{const f=[],u=s([l,f],a);for(const p of a)(e||!Ih(Td(p)))&&f.push(i(p));return u}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},sj=(e,{json:t,lossy:n}={})=>{const r=[];return MW(!(t||n),!!t,new Map,r)(e),r},tg=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?rj(sj(e,t)):structuredClone(e):(e,t)=>rj(sj(e,t));function $W(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 DW(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function FW(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||$W,r=e.options.footnoteBackLabel||DW,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[c]);if(!d)continue;const f=e.all(d),u=String(d.identifier).toUpperCase(),p=Vu(u.toLowerCase());let m=0;const g=[],b=e.footnoteCounts.get(u);for(;b!==void 0&&++m<=b;){g.length>0&&g.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,m);typeof k=="string"&&(k={type:"text",value:k}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const v=f[f.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const k=v.children[v.children.length-1];k&&k.type==="text"?k.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...g)}else f.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...tg(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 OI=function(e){if(e==null)return WW;if(typeof e=="function")return iy(e);if(typeof e=="object")return Array.isArray(e)?zW(e):HW(e);if(typeof e=="string")return BW(e);throw new Error("Expected function, string, or object as test")};function zW(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=OI(e[n]);return iy(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function HW(e){const t=e;return iy(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function BW(e){return iy(t);function t(n){return n&&n.type===e}}function iy(e){return t;function t(n,r,s){return!!(VW(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function WW(){return!0}function VW(e){return e!==null&&typeof e=="object"&&"type"in e}const MI=[],UW=!0,ij=!1,KW="skip";function qW(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=OI(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,f){const u=c&&typeof c=="object"?c:{};if(typeof u.type=="string"){const m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=MI,g,b,v;if((!t||i(c,d,f[f.length-1]||void 0))&&(m=YW(n(c,f)),m[0]===ij))return m;if("children"in c&&c.children){const y=c;if(y.children&&m[0]!==KW)for(b=(r?y.children.length:-1)+a,v=f.concat(y);b>-1&&b<y.children.length;){const k=y.children[b];if(g=l(k,b,v)(),g[0]===ij)return g;b=typeof g[1]=="number"?g[1]:b+a}}return m}}}function YW(e){return Array.isArray(e)?e:typeof e=="number"?[UW,e]:e==null?MI:[e]}function $I(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),qW(e,i,l,s);function l(c,d){const f=d[d.length-1],u=f?f.children.indexOf(c):void 0;return a(c,u,f)}}const Sb={}.hasOwnProperty,GW={};function XW(e,t){const n=t||GW,r=new Map,s=new Map,i=new Map,a={...TW,...n.handlers},l={all:d,applyData:QW,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:JW,wrap:e9};return $I(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const u=f.type==="definition"?r:s,p=String(f.identifier).toUpperCase();u.has(p)||u.set(p,f)}}),l;function c(f,u){const p=f.type,m=l.handlers[p];if(Sb.call(l.handlers,p)&&m)return m(l,f,u);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in f){const{children:b,...v}=f,y=tg(v);return y.children=l.all(f),y}return tg(f)}return(l.options.unknownHandler||ZW)(l,f,u)}function d(f){const u=[];if("children"in f){const p=f.children;let m=-1;for(;++m<p.length;){const g=l.one(p[m],f);if(g){if(m&&p[m-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=oj(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=oj(b.value))}Array.isArray(g)?u.push(...g):u.push(g)}}}return u}}function JW(e,t){e.position&&(t.position=LB(e))}function QW(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,tg(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function ZW(e,t){const n=t.data||{},r="value"in t&&!(Sb.call(n,"hProperties")||Sb.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 e9(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 oj(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function aj(e,t){const n=XW(e,t),r=n.one(e,void 0),s=FW(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
79
- `},s),i}function t9(e,t){return e&&"run"in e?async function(n,r){const s=aj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return aj(n,{file:r,...e||t})}}function lj(e){if(e)throw e}var dm=Object.prototype.hasOwnProperty,DI=Object.prototype.toString,cj=Object.defineProperty,uj=Object.getOwnPropertyDescriptor,dj=function(t){return typeof Array.isArray=="function"?Array.isArray(t):DI.call(t)==="[object Array]"},fj=function(t){if(!t||DI.call(t)!=="[object Object]")return!1;var n=dm.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&dm.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||dm.call(t,s)},pj=function(t,n){cj&&n.name==="__proto__"?cj(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},hj=function(t,n){if(n==="__proto__")if(dm.call(t,n)){if(uj)return uj(t,n).value}else return;return t[n]},n9=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=hj(l,n),s=hj(t,n),l!==s&&(f&&s&&(fj(s)||(i=dj(s)))?(i?(i=!1,a=r&&dj(r)?r:[]):a=r&&fj(r)?r:{},pj(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&pj(l,{name:n,newValue:s}));return l};const vx=dl(n9);function Nb(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 r9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...d){const f=e[++i];let u=-1;if(c){a(c);return}for(;++u<s.length;)(d[u]===null||d[u]===void 0)&&(d[u]=s[u]);s=d,f?s9(f,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 s9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(d){const f=d;if(l&&n)throw f;return s(f)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const yo={basename:i9,dirname:o9,extname:a9,join:l9,sep:"/"};function i9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');gp(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else a<0&&(i=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function o9(e){if(gp(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 a9(e){gp(e);let t=e.length,n=-1,r=0,s=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function l9(...e){let t=-1,n;for(;++t<e.length;)gp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":c9(n)}function c9(e){gp(e);const t=e.codePointAt(0)===47;let n=u9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function u9(e,t){let n="",r=0,s=-1,i=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function gp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const d9={cwd:f9};function f9(){return"/"}function jb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function p9(e){if(typeof e=="string")e=new URL(e);else if(!jb(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 h9(e)}function h9(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 kx=["history","path","basename","stem","extname","dirname"];class FI{constructor(t){let n;t?jb(t)?n={path:t}:typeof t=="string"||m9(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":d9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<kx.length;){const i=kx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)kx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?yo.basename(this.path):void 0}set basename(t){Nx(t,"basename"),Sx(t,"basename"),this.path=yo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?yo.dirname(this.path):void 0}set dirname(t){mj(this.basename,"dirname"),this.path=yo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?yo.extname(this.path):void 0}set extname(t){if(Sx(t,"extname"),mj(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=yo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jb(t)&&(t=p9(t)),Nx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?yo.basename(this.path,this.extname):void 0}set stem(t){Nx(t,"stem"),Sx(t,"stem"),this.path=yo.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 rs(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 Sx(e,t){if(e&&e.includes(yo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+yo.sep+"`")}function Nx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function mj(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function m9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const g9=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},y9={}.hasOwnProperty;class S0 extends g9{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=r9()}copy(){const t=new S0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(vx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ex("data",this.frozen),this.namespace[t]=n,this):y9.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ex("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=Th(t),r=this.parser||this.Parser;return jx("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),jx("process",this.parser||this.Parser),Cx("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=Th(t),c=r.parse(l);r.run(c,l,function(f,u,p){if(f||!u||!p)return d(f);const m=u,g=r.stringify(m,p);b9(g)?p.value=g:p.result=g,d(f,p)});function d(f,u){f||!u?a(f):i?i(u):n(void 0,u)}}}processSync(t){let n=!1,r;return this.freeze(),jx("processSync",this.parser||this.Parser),Cx("processSync",this.compiler||this.Compiler),this.process(t,s),yj("processSync","process",n),r;function s(i,a){n=!0,lj(i),r=a}}run(t,n,r){gj(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const c=Th(n);s.run(t,c,d);function d(f,u,p){const m=u||t;f?l(f):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),yj("runSync","run",r),s;function i(a,l){lj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Th(n),s=this.compiler||this.Compiler;return Cx("stringify",s),gj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Ex("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...u]=d;c(f,u)}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=vx(!0,s.settings,d.settings))}function l(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const u=d[f];i(u)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,f){let u=-1,p=-1;for(;++u<r.length;)if(r[u][0]===d){p=u;break}if(p===-1)r.push([d,...f]);else if(f.length>0){let[m,...g]=f;const b=r[p][1];Nb(b)&&Nb(m)&&(m=vx(!0,b,m)),r[p]=[d,m,...g]}}}}const x9=new S0().freeze();function jx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Cx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ex(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 gj(e){if(!Nb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Th(e){return w9(e)?e:new FI(e)}function w9(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function b9(e){return typeof e=="string"||v9(e)}function v9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k9="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",xj=[],wj={allowDangerousHtml:!0},S9=/^(https?|ircs?|mailto|xmpp)$/i,N9=[{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 yp(e){const t=j9(e),n=C9(e);return E9(t.runSync(t.parse(n),n),e)}function j9(e){const t=e.rehypePlugins||xj,n=e.remarkPlugins||xj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...wj}:wj;return x9().use(oW).use(n).use(t9,r).use(t)}function C9(e){const t=e.children||"",n=new FI;return typeof t=="string"&&(n.value=t),n}function E9(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||_9;for(const f of N9)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+k9+f.id,void 0);return $I(e,d),FB(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(f,u,p){if(f.type==="raw"&&p&&typeof u=="number")return a?p.children.splice(u,1):p.children[u]={type:"text",value:f.value},u;if(f.type==="element"){let m;for(m in xx)if(Object.hasOwn(xx,m)&&Object.hasOwn(f.properties,m)){const g=f.properties[m],b=xx[m];(b===null||b.includes(f.tagName))&&(f.properties[m]=c(String(g||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!m&&r&&typeof u=="number"&&(m=!r(f,u,p)),m&&p&&typeof u=="number")return l&&f.children?p.children.splice(u,1,...f.children):p.children.splice(u,1),u}}}function _9(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||S9.test(e.slice(0,t))?e:""}function P9(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function ng(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>ng(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${ng(t[r])}`).join(",")}}`}function bj(e){return ng({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 Vf(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function vj(e){return ng({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 kj(e,t){return!P9(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function Sj(e,t=!1){const n=new Map;for(const r of e){const s=Vf(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function A9(e,t,n,r){const s=new Map(e.map(k=>[k.id,k])),i=new Set(n.map(k=>k.id)),a=new Set,l=[],c=[],d=n.map(k=>{const w=s.get(k.id);return w?bj(w)===bj(k)?(a.add(k.id),w):(c.push(k.id),kj(k,w)):(l.push(k.id),k)}),f=Sj(t),u=Sj(r,!0),p=new Set,m=[],g=[],b=r.map(k=>{const w=Vf(k),j=f.get(w);return j?vj(j)===vj(k)?(p.add(w),j):(g.push(w),kj(k,j)):(m.push(w),k)}),v=e.filter(k=>!i.has(k.id)).map(k=>k.id),y=t.map(k=>Vf(k)).filter(k=>!u.has(k));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:v,addedEdgeKeys:m,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:v.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:y.length,edgeReused:p.size,nextEdgeCount:u.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function zI(e){return typeof e>"u"||e===null}function I9(e){return typeof e=="object"&&e!==null}function T9(e){return Array.isArray(e)?e:zI(e)?[]:[e]}function R9(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function L9(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function O9(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var M9=zI,$9=I9,D9=T9,F9=L9,z9=O9,H9=R9,Nr={isNothing:M9,isObject:$9,toArray:D9,repeat:F9,isNegativeZero:z9,extend:H9};function HI(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 Uf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=HI(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Uf.prototype=Object.create(Error.prototype);Uf.prototype.constructor=Uf;Uf.prototype.toString=function(t){return this.name+": "+HI(this,t)};var ps=Uf;function _x(e,t,n,r,s){var i="",a="",l=Math.floor(s/2)-1;return r-t>l&&(i=" ... ",t=r-l+i.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function Px(e,t){return Nr.repeat(" ",t-e.length)+e}function B9(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],i,a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=_x(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),u),l=Nr.repeat(" ",t.indent)+Px((e.line-c+1).toString(),f)+" | "+d.str+`
82
- `+l;for(d=_x(e.buffer,r[a],s[a],e.position,u),l+=Nr.repeat(" ",t.indent)+Px((e.line+1).toString(),f)+" | "+d.str+`
83
- `,l+=Nr.repeat("-",t.indent+f+3+d.pos)+`^
84
- `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=_x(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),u),l+=Nr.repeat(" ",t.indent)+Px((e.line+c+1).toString(),f)+" | "+d.str+`
85
- `;return l.replace(/\n$/,"")}var W9=B9,V9=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],U9=["scalar","sequence","mapping"];function K9(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function q9(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(V9.indexOf(n)===-1)throw new ps('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=K9(t.styleAliases||null),U9.indexOf(this.kind)===-1)throw new ps('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var zr=q9;function Nj(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(i,a){i.tag===r.tag&&i.kind===r.kind&&i.multi===r.multi&&(s=a)}),n[s]=r}),n}function Y9(){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 Cb(e){return this.extend(e)}Cb.prototype.extend=function(t){var n=[],r=[];if(t instanceof zr)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 ps("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof zr))throw new ps("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new ps("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new ps("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(i){if(!(i instanceof zr))throw new ps("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Cb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=Nj(s,"implicit"),s.compiledExplicit=Nj(s,"explicit"),s.compiledTypeMap=Y9(s.compiledImplicit,s.compiledExplicit),s};var BI=Cb,WI=new zr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),VI=new zr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),UI=new zr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),KI=new BI({explicit:[WI,VI,UI]});function G9(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function X9(){return null}function J9(e){return e===null}var qI=new zr("tag:yaml.org,2002:null",{kind:"scalar",resolve:G9,construct:X9,predicate:J9,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Q9(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 Z9(e){return e==="true"||e==="True"||e==="TRUE"}function eV(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var YI=new zr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Q9,construct:Z9,predicate:eV,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 tV(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function nV(e){return 48<=e&&e<=55}function rV(e){return 48<=e&&e<=57}function sV(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(!tV(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(!rV(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function iV(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 oV(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Nr.isNegativeZero(e)}var GI=new zr("tag:yaml.org,2002:int",{kind:"scalar",resolve:sV,construct:iV,predicate:oV,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"]}}),aV=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function lV(e){return!(e===null||!aV.test(e)||e[e.length-1]==="_")}function cV(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 uV=/^[-+]?[0-9]+e/;function dV(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(Nr.isNegativeZero(e))return"-0.0";return n=e.toString(10),uV.test(n)?n.replace("e",".e"):n}function fV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Nr.isNegativeZero(e))}var XI=new zr("tag:yaml.org,2002:float",{kind:"scalar",resolve:lV,construct:cV,predicate:fV,represent:dV,defaultStyle:"lowercase"}),JI=KI.extend({implicit:[qI,YI,GI,XI]}),QI=JI,ZI=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),eT=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 pV(e){return e===null?!1:ZI.exec(e)!==null||eT.exec(e)!==null}function hV(e){var t,n,r,s,i,a,l,c=0,d=null,f,u,p;if(t=ZI.exec(e),t===null&&(t=eT.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(i=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],u=+(t[11]||0),d=(f*60+u)*6e4,t[9]==="-"&&(d=-d)),p=new Date(Date.UTC(n,r,s,i,a,l,c)),d&&p.setTime(p.getTime()-d),p}function mV(e){return e.toISOString()}var tT=new zr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:pV,construct:hV,instanceOf:Date,represent:mV});function gV(e){return e==="<<"||e===null}var nT=new zr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:gV}),N0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
- \r`;function yV(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=N0;for(n=0;n<s;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function xV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=N0,a=0,l=[];for(t=0;t<s;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|i.indexOf(r.charAt(t));return n=s%4*6,n===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):n===18?(l.push(a>>10&255),l.push(a>>2&255)):n===12&&l.push(a>>4&255),new Uint8Array(l)}function wV(e){var t="",n=0,r,s,i=e.length,a=N0;for(r=0;r<i;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return s=i%3,s===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):s===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):s===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function bV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var rT=new zr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:yV,construct:xV,predicate:bV,represent:wV}),vV=Object.prototype.hasOwnProperty,kV=Object.prototype.toString;function SV(e){if(e===null)return!0;var t=[],n,r,s,i,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,kV.call(s)!=="[object Object]")return!1;for(i in s)if(vV.call(s,i))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function NV(e){return e!==null?e:[]}var sT=new zr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:SV,construct:NV}),jV=Object.prototype.toString;function CV(e){if(e===null)return!0;var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],jV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function EV(e){if(e===null)return[];var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),i[t]=[s[0],r[s[0]]];return i}var iT=new zr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:CV,construct:EV}),_V=Object.prototype.hasOwnProperty;function PV(e){if(e===null)return!0;var t,n=e;for(t in n)if(_V.call(n,t)&&n[t]!==null)return!1;return!0}function AV(e){return e!==null?e:{}}var oT=new zr("tag:yaml.org,2002:set",{kind:"mapping",resolve:PV,construct:AV}),j0=QI.extend({implicit:[tT,nT],explicit:[rT,sT,iT,oT]}),al=Object.prototype.hasOwnProperty,rg=1,aT=2,lT=3,sg=4,Ax=1,IV=2,jj=3,TV=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,RV=/[\x85\u2028\u2029]/,LV=/[,\[\]\{\}]/,cT=/^(?:!|!!|![a-z\-]+!)$/i,uT=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Cj(e){return Object.prototype.toString.call(e)}function _o(e){return e===10||e===13}function Zl(e){return e===9||e===32}function As(e){return e===9||e===32||e===10||e===13}function ru(e){return e===44||e===91||e===93||e===123||e===125}function OV(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function MV(e){return e===120?2:e===117?4:e===85?8:0}function $V(e){return 48<=e&&e<=57?e-48:-1}function Ej(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 DV(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function dT(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var fT=new Array(256),pT=new Array(256);for(var Oc=0;Oc<256;Oc++)fT[Oc]=Ej(Oc)?1:0,pT[Oc]=Ej(Oc);function FV(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||j0,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 hT(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=W9(n),new ps(t,n)}function st(e,t){throw hT(e,t)}function ig(e,t){e.onWarning&&e.onWarning.call(null,hT(e,t))}var _j={YAML:function(t,n,r){var s,i,a;t.version!==null&&st(t,"duplication of %YAML directive"),r.length!==1&&st(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&st(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&st(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&ig(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&st(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],cT.test(s)||st(t,"ill-formed tag handle (first argument) of the TAG directive"),al.call(t.tagMap,s)&&st(t,'there is a previously declared suffix for "'+s+'" tag handle'),uT.test(i)||st(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{st(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function nl(e,t,n,r){var s,i,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,i=l.length;s<i;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||st(e,"expected valid JSON character");else TV.test(l)&&st(e,"the stream contains non-printable characters");e.result+=l}}function Pj(e,t,n,r){var s,i,a,l;for(Nr.isObject(n)||st(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)i=s[a],al.call(t,i)||(dT(t,i,n[i]),r[i]=!0)}function su(e,t,n,r,s,i,a,l,c){var d,f;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,f=s.length;d<f;d+=1)Array.isArray(s[d])&&st(e,"nested arrays are not supported inside keys"),typeof s=="object"&&Cj(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&Cj(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,f=i.length;d<f;d+=1)Pj(e,t,i[d],n);else Pj(e,t,i,n);else!e.json&&!al.call(n,s)&&al.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,st(e,"duplicated mapping key")),dT(t,s,i),delete n[s];return t}function C0(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++):st(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function wr(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;Zl(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(C0(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&&ig(e,"deficient indentation"),r}function oy(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||As(n)))}function E0(e,t){t===1?e.result+=" ":t>1&&(e.result+=Nr.repeat(`
88
- `,t-1))}function zV(e,t,n){var r,s,i,a,l,c,d,f,u=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),As(m)||ru(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(s=e.input.charCodeAt(e.position+1),As(s)||n&&ru(s)))return!1;for(e.kind="scalar",e.result="",i=a=e.position,l=!1;m!==0;){if(m===58){if(s=e.input.charCodeAt(e.position+1),As(s)||n&&ru(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),As(r))break}else{if(e.position===e.lineStart&&oy(e)||n&&ru(m))break;if(_o(m))if(c=e.line,d=e.lineStart,f=e.lineIndent,wr(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(nl(e,i,a,!1),E0(e,e.line-c),i=a=e.position,l=!1),Zl(m)||(a=e.position+1),m=e.input.charCodeAt(++e.position)}return nl(e,i,a,!1),e.result?!0:(e.kind=u,e.result=p,!1)}function HV(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(nl(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)?(nl(e,r,s,!0),E0(e,wr(e,!1,t)),r=s=e.position):e.position===e.lineStart&&oy(e)?st(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);st(e,"unexpected end of the stream within a single quoted scalar")}function BV(e,t){var n,r,s,i,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return nl(e,n,e.position,!0),e.position++,!0;if(l===92){if(nl(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),_o(l))wr(e,!1,t);else if(l<256&&fT[l])e.result+=pT[l],e.position++;else if((a=MV(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=OV(l))>=0?i=(i<<4)+a:st(e,"expected hexadecimal character");e.result+=DV(i),e.position++}else st(e,"unknown escape sequence");n=r=e.position}else _o(l)?(nl(e,n,r,!0),E0(e,wr(e,!1,t)),n=r=e.position):e.position===e.lineStart&&oy(e)?st(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}st(e,"unexpected end of the stream within a double quoted scalar")}function WV(e,t){var n=!0,r,s,i,a=e.tag,l,c=e.anchor,d,f,u,p,m,g=Object.create(null),b,v,y,k;if(k=e.input.charCodeAt(e.position),k===91)f=93,m=!1,l=[];else if(k===123)f=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),k=e.input.charCodeAt(++e.position);k!==0;){if(wr(e,!0,t),k=e.input.charCodeAt(e.position),k===f)return e.position++,e.tag=a,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;n?k===44&&st(e,"expected the node content, but found ','"):st(e,"missed comma between flow collection entries"),v=b=y=null,u=p=!1,k===63&&(d=e.input.charCodeAt(e.position+1),As(d)&&(u=p=!0,e.position++,wr(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Ou(e,t,rg,!1,!0),v=e.tag,b=e.result,wr(e,!0,t),k=e.input.charCodeAt(e.position),(p||e.line===r)&&k===58&&(u=!0,k=e.input.charCodeAt(++e.position),wr(e,!0,t),Ou(e,t,rg,!1,!0),y=e.result),m?su(e,l,g,v,b,y,r,s,i):u?l.push(su(e,null,g,v,b,y,r,s,i)):l.push(b),wr(e,!0,t),k=e.input.charCodeAt(e.position),k===44?(n=!0,k=e.input.charCodeAt(++e.position)):n=!1}st(e,"unexpected end of the stream within a flow collection")}function VV(e,t){var n,r,s=Ax,i=!1,a=!1,l=t,c=0,d=!1,f,u;if(u=e.input.charCodeAt(e.position),u===124)r=!1;else if(u===62)r=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)Ax===s?s=u===43?jj:IV:st(e,"repeat of a chomping mode identifier");else if((f=$V(u))>=0)f===0?st(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?st(e,"repeat of an indentation width identifier"):(l=t+f-1,a=!0);else break;if(Zl(u)){do u=e.input.charCodeAt(++e.position);while(Zl(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!_o(u)&&u!==0)}for(;u!==0;){for(C0(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),_o(u)){c++;continue}if(e.lineIndent<l){s===jj?e.result+=Nr.repeat(`
89
- `,i?1+c:c):s===Ax&&i&&(e.result+=`
90
- `);break}for(r?Zl(u)?(d=!0,e.result+=Nr.repeat(`
91
- `,i?1+c:c)):d?(d=!1,e.result+=Nr.repeat(`
92
- `,c+1)):c===0?i&&(e.result+=" "):e.result+=Nr.repeat(`
93
- `,c):e.result+=Nr.repeat(`
94
- `,i?1+c:c),i=!0,a=!0,c=0,n=e.position;!_o(u)&&u!==0;)u=e.input.charCodeAt(++e.position);nl(e,n,e.position,!1)}return!0}function Aj(e,t){var n,r=e.tag,s=e.anchor,i=[],a,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,st(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!As(a))));){if(l=!0,e.position++,wr(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Ou(e,t,lT,!1,!0),i.push(e.result),wr(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)st(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=i,!0):!1}function UV(e,t,n){var r,s,i,a,l,c,d=e.tag,f=e.anchor,u={},p=Object.create(null),m=null,g=null,b=null,v=!1,y=!1,k;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),k=e.input.charCodeAt(e.position);k!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,st(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(k===63||k===58)&&As(r))k===63?(v&&(su(e,u,p,m,g,null,a,l,c),m=g=b=null),y=!0,v=!0,s=!0):v?(v=!1,s=!0):st(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,k=r;else{if(a=e.line,l=e.lineStart,c=e.position,!Ou(e,n,aT,!1,!0))break;if(e.line===i){for(k=e.input.charCodeAt(e.position);Zl(k);)k=e.input.charCodeAt(++e.position);if(k===58)k=e.input.charCodeAt(++e.position),As(k)||st(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(su(e,u,p,m,g,null,a,l,c),m=g=b=null),y=!0,v=!1,s=!1,m=e.tag,g=e.result;else if(y)st(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(y)st(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===i||e.lineIndent>t)&&(v&&(a=e.line,l=e.lineStart,c=e.position),Ou(e,t,sg,!0,s)&&(v?g=e.result:b=e.result),v||(su(e,u,p,m,g,b,a,l,c),m=g=b=null),wr(e,!0,-1),k=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&k!==0)st(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&su(e,u,p,m,g,null,a,l,c),y&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=u),y}function KV(e){var t,n=!1,r=!1,s,i,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&st(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):st(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!As(a);)a===33&&(r?st(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),cT.test(s)||st(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),LV.test(i)&&st(e,"tag suffix cannot contain flow indicator characters")}i&&!uT.test(i)&&st(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{st(e,"tag name is malformed: "+i)}return n?e.tag=i:al.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:st(e,'undeclared tag handle "'+s+'"'),!0}function qV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&st(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!As(n)&&!ru(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function YV(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&&!As(r)&&!ru(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),al.call(e.anchorMap,n)||st(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],wr(e,!0,-1),!0}function Ou(e,t,n,r,s){var i,a,l,c=1,d=!1,f=!1,u,p,m,g,b,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=a=l=sg===n||lT===n,r&&wr(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;KV(e)||qV(e);)wr(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||s),(c===1||sg===n)&&(rg===n||aT===n?b=t:b=t+1,v=e.position-e.lineStart,c===1?l&&(Aj(e,v)||UV(e,v,b))||WV(e,b)?f=!0:(a&&VV(e,b)||HV(e,b)||BV(e,b)?f=!0:YV(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&st(e,"alias node should not have any properties")):zV(e,b,rg===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&Aj(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&st(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,p=e.implicitTypes.length;u<p;u+=1)if(g=e.implicitTypes[u],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(al.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,m=e.typeMap.multi[e.kind||"fallback"],u=0,p=m.length;u<p;u+=1)if(e.tag.slice(0,m[u].tag.length)===m[u].tag){g=m[u];break}g||st(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&st(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)):st(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function GV(e){var t=e.position,n,r,s,i=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(wr(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(i=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!As(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&st(e,"directive name must not be less than one character in length");a!==0;){for(;Zl(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&&!As(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&C0(e),al.call(_j,r)?_j[r](e,r,s):ig(e,'unknown document directive "'+r+'"')}if(wr(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,wr(e,!0,-1)):i&&st(e,"directives end mark is expected"),Ou(e,e.lineIndent-1,sg,!1,!0),wr(e,!0,-1),e.checkLineBreaks&&RV.test(e.input.slice(t,e.position))&&ig(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&oy(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,wr(e,!0,-1));return}if(e.position<e.length-1)st(e,"end of the stream or a document separator is expected");else return}function mT(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 FV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,st(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;)GV(n);return n.documents}function XV(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=mT(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function JV(e,t){var n=mT(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new ps("expected a single document in the stream, but found more")}}var QV=XV,ZV=JV,gT={loadAll:QV,load:ZV},yT=Object.prototype.toString,xT=Object.prototype.hasOwnProperty,_0=65279,eU=9,Kf=10,tU=13,nU=32,rU=33,sU=34,Eb=35,iU=37,oU=38,aU=39,lU=42,wT=44,cU=45,og=58,uU=61,dU=62,fU=63,pU=64,bT=91,vT=93,hU=96,kT=123,mU=124,ST=125,ss={};ss[0]="\\0";ss[7]="\\a";ss[8]="\\b";ss[9]="\\t";ss[10]="\\n";ss[11]="\\v";ss[12]="\\f";ss[13]="\\r";ss[27]="\\e";ss[34]='\\"';ss[92]="\\\\";ss[133]="\\N";ss[160]="\\_";ss[8232]="\\L";ss[8233]="\\P";var gU=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],yU=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function xU(e,t){var n,r,s,i,a,l,c;if(t===null)return{};for(n={},r=Object.keys(t),s=0,i=r.length;s<i;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),c=e.compiledTypeMap.fallback[a],c&&xT.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function wU(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 ps("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Nr.repeat("0",r-t.length)+t}var bU=1,qf=2;function vU(e){this.schema=e.schema||j0,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Nr.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=xU(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==='"'?qf:bU,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 Ij(e,t){for(var n=Nr.repeat(" ",t),r=0,s=-1,i="",a,l=e.length;r<l;)s=e.indexOf(`
96
- `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
- `&&(i+=n),i+=a;return i}function _b(e,t){return`
98
- `+Nr.repeat(" ",e.indent*t)}function kU(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 ag(e){return e===nU||e===eU}function Yf(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==_0||65536<=e&&e<=1114111}function Tj(e){return Yf(e)&&e!==_0&&e!==tU&&e!==Kf}function Rj(e,t,n){var r=Tj(e),s=r&&!ag(e);return(n?r:r&&e!==wT&&e!==bT&&e!==vT&&e!==kT&&e!==ST)&&e!==Eb&&!(t===og&&!s)||Tj(t)&&!ag(t)&&e===Eb||t===og&&s}function SU(e){return Yf(e)&&e!==_0&&!ag(e)&&e!==cU&&e!==fU&&e!==og&&e!==wT&&e!==bT&&e!==vT&&e!==kT&&e!==ST&&e!==Eb&&e!==oU&&e!==lU&&e!==rU&&e!==mU&&e!==uU&&e!==dU&&e!==aU&&e!==sU&&e!==iU&&e!==pU&&e!==hU}function NU(e){return!ag(e)&&e!==og}function Vd(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 NT(e){var t=/^\n* /;return t.test(e)}var jT=1,Pb=2,CT=3,ET=4,Fc=5;function jU(e,t,n,r,s,i,a,l){var c,d=0,f=null,u=!1,p=!1,m=r!==-1,g=-1,b=SU(Vd(e,0))&&NU(Vd(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Vd(e,c),!Yf(d))return Fc;b=b&&Rj(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Vd(e,c),d===Kf)u=!0,m&&(p=p||c-g-1>r&&e[g+1]!==" ",g=c);else if(!Yf(d))return Fc;b=b&&Rj(d,f,l),f=d}p=p||m&&c-g-1>r&&e[g+1]!==" "}return!u&&!p?b&&!a&&!s(e)?jT:i===qf?Fc:Pb:n>9&&NT(e)?Fc:a?i===qf?Fc:Pb:p?ET:CT}function CU(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===qf?'""':"''";if(!e.noCompatMode&&(gU.indexOf(t)!==-1||yU.test(t)))return e.quotingType===qf?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return kU(e,d)}switch(jU(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case jT:return t;case Pb:return"'"+t.replace(/'/g,"''")+"'";case CT:return"|"+Lj(t,e.indent)+Oj(Ij(t,i));case ET:return">"+Lj(t,e.indent)+Oj(Ij(EU(t,a),i));case Fc:return'"'+_U(t)+'"';default:throw new ps("impossible error: invalid scalar style")}}()}function Lj(e,t){var n=NT(e)?String(t):"",r=e[e.length-1]===`
99
- `,s=r&&(e[e.length-2]===`
100
- `||e===`
101
- `),i=s?"+":r?"":"-";return n+i+`
102
- `}function Oj(e){return e[e.length-1]===`
103
- `?e.slice(0,-1):e}function EU(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,Mj(e.slice(0,d),t)}(),s=e[0]===`
105
- `||e[0]===" ",i,a;a=n.exec(e);){var l=a[1],c=a[2];i=c[0]===" ",r+=l+(!s&&!i&&c!==""?`
106
- `:"")+Mj(c,t),s=i}return r}function Mj(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,i,a=0,l=0,c="";r=n.exec(e);)l=r.index,l-s>t&&(i=a>s?a:l,c+=`
107
- `+e.slice(s,i),s=i+1),a=l;return c+=`
108
- `,e.length-s>t&&a>s?c+=e.slice(s,a)+`
109
- `+e.slice(a+1):c+=e.slice(s),c.slice(1)}function _U(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Vd(e,s),r=ss[n],!r&&Yf(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||wU(n);return t}function PU(e,t,n){var r="",s=e.tag,i,a,l;for(i=0,a=n.length;i<a;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),(fa(e,t,l,!1,!1)||typeof l>"u"&&fa(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function $j(e,t,n,r){var s="",i=e.tag,a,l,c;for(a=0,l=n.length;a<l;a+=1)c=n[a],e.replacer&&(c=e.replacer.call(n,String(a),c)),(fa(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&fa(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=_b(e,t)),e.dump&&Kf===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function AU(e,t,n){var r="",s=e.tag,i=Object.keys(n),a,l,c,d,f;for(a=0,l=i.length;a<l;a+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=i[a],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),fa(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),fa(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=s,e.dump="{"+r+"}"}function IU(e,t,n,r){var s="",i=e.tag,a=Object.keys(n),l,c,d,f,u,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new ps("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=_b(e,t)),d=a[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),fa(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&Kf===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,u&&(p+=_b(e,t)),fa(e,t+1,f,!0,u)&&(e.dump&&Kf===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function Dj(e,t,n){var r,s,i,a,l,c;for(s=n?e.explicitTypes:e.implicitTypes,i=0,a=s.length;i<a;i+=1)if(l=s[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,yT.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(xT.call(l.represent,c))r=l.represent[c](t,c);else throw new ps("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function fa(e,t,n,r,s,i,a){e.tag=null,e.dump=n,Dj(e,n,!1)||Dj(e,n,!0);var l=yT.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",u,p;if(f&&(u=e.duplicates.indexOf(n),p=u!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&p&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(IU(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(AU(e,t,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?$j(e,t-1,e.dump,s):$j(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(PU(e,t,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&CU(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ps("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 TU(e,t){var n=[],r=[],s,i;for(Ab(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function Ab(e,t,n){var r,s,i;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,i=e.length;s<i;s+=1)Ab(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)Ab(e[r[s]],t,n)}function RU(e,t){t=t||{};var n=new vU(t);n.noRefs||TU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),fa(n,0,r,!0,!0)?n.dump+`
110
- `:""}var LU=RU,OU={dump:LU};function P0(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 MU=zr,$U=BI,DU=KI,FU=JI,zU=QI,HU=j0,BU=gT.load,WU=gT.loadAll,VU=OU.dump,UU=ps,KU={binary:rT,float:XI,map:UI,null:qI,pairs:iT,set:oT,timestamp:tT,bool:YI,int:GI,merge:nT,omap:sT,seq:VI,str:WI},qU=P0("safeLoad","load"),YU=P0("safeLoadAll","loadAll"),GU=P0("safeDump","dump"),_T={Type:MU,Schema:$U,FAILSAFE_SCHEMA:DU,JSON_SCHEMA:FU,CORE_SCHEMA:zU,DEFAULT_SCHEMA:HU,load:BU,loadAll:WU,dump:VU,YAMLException:UU,types:KU,safeLoad:qU,safeLoadAll:YU,safeDump:GU};const ll=["requirement","planning","code","test","normal"],Ib={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},XU=["agent","control","provide","condition","jump","condition_jump","start","end"];function JU(e){return XU.includes(e)?e:"agent"}function QU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function ZU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=_T.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},i=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},c=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=a.viewport&&typeof a.viewport=="object"?a.viewport:null,f=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,u=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,p=new Set(Object.keys(s));for(const b of i)b!=null&&b.source&&p.add(String(b.source)),b!=null&&b.target&&p.add(String(b.target));const m=Array.from(p).map(b=>{const v=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},k=c[b]&&typeof c[b].width=="number"&&typeof c[b].height=="number"?{width:c[b].width,height:c[b].height}:null,w=(v==null?void 0:v.definitionId)??b,j=QU(w),_=(v==null?void 0:v.label)!=null?String(v.label):b,E=(v==null?void 0:v.role)!=null?String(v.role).trim():"",O=Ib[E]||E,H=ll.includes(O)?O:"normal",L=(v==null?void 0:v.model)!=null?String(v.model).trim():void 0,F=(v==null?void 0:v.body)!=null?String(v.body):"",D=(v==null?void 0:v.script)!=null?String(v.script):"",R=Array.isArray(v==null?void 0:v.images)?v.images:[];return{id:b,type:JU(j),position:y,...k?{width:k.width,height:k.height}:{},data:{label:_,definitionId:w,schemaType:j,role:H,model:L||void 0,body:F,images:R,...k?{displaySize:k}:{},...D.trim()!==""?{script:D}:{}}}}),g=i.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).map((b,v)=>({id:`e-${b.source}-${b.target}-${v}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:Ms.ArrowClosed}}));return{nodes:m,edges:g,instances:s,description:u,...f?{viewport:f}:{}}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const i=r.match(/\((\d+):/);s=`
111
-
112
- 💡 提示:通常由 ${i?`第 ${i[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
- YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
-
115
- ✅ 正确写法:
116
- \`\`\`yaml
117
- script: |
118
- node -e "console.log('TODO: scripts/x.mjs')"
119
- \`\`\`
120
- ❌ 错误写法(当前文件):
121
- \`\`\`yaml
122
- script: node -e "console.log('TODO: scripts/x.mjs')"
123
- \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function xp(e,t){var s,i,a,l,c,d,f,u,p,m,g,b;const n=v=>{const y={type:(v==null?void 0:v.type)??"node",name:(v==null?void 0:v.name)??"",value:(v==null?void 0:v.value)??(v==null?void 0:v.default)??""};return(v==null?void 0:v.required)===!0&&(y.required=!0),(v==null?void 0:v.showOnNode)!=null&&(y.showOnNode=!!v.showOnNode),y},r={};for(const v of e){const y=t[v.id]&&typeof t[v.id]=="object"?{...t[v.id]}:{},k=((s=v.data)==null?void 0:s.definitionId)||v.id,w=((i=v.data)==null?void 0:i.inputs)??[],j=((a=v.data)==null?void 0:a.outputs)??[],_=((l=v.data)==null?void 0:l.role)!=null?String(v.data.role).trim():"",E=y.role!=null?String(y.role).trim():"",O=Ib[_]||_,H=Ib[E]||E,L=ll.includes(O)?O:ll.includes(H)?H:"normal",F=Array.isArray(w)?w.map(n):Array.isArray(y.input)?y.input.map(V=>n(V)):[],D=Array.isArray(j)?j.map(n):Array.isArray(y.output)?y.output.map(V=>n(V)):[],R=((c=v.data)==null?void 0:c.label)!=null?String(v.data.label):y.label!=null?String(y.label):v.id,W=(d=v.data)==null?void 0:d.body,M=W!=null?String(W):y.body!=null?String(y.body):"";let $=((f=v.data)==null?void 0:f.model)!=null&&String(v.data.model).trim()!==""?String(v.data.model).trim():y.model!=null&&String(y.model).trim()!==""?String(y.model).trim():void 0;($===""||$==="default")&&($=void 0);const T={...y,definitionId:k,label:R,role:L,model:$,input:F,output:D},z=((u=v.data)==null?void 0:u.marketplaceRef)||y.marketplaceRef;z?T.marketplaceRef=String(z):delete T.marketplaceRef;const A=((p=v.data)==null?void 0:p.marketplacePackageId)||y.marketplacePackageId;A?T.marketplacePackageId=String(A):delete T.marketplacePackageId;const P=((m=v.data)==null?void 0:m.marketplaceVersion)||y.marketplaceVersion;P?T.marketplaceVersion=String(P):delete T.marketplaceVersion,k.startsWith("provide_")||M.trim()===""?delete T.body:T.body=M;const C=Array.isArray((g=v.data)==null?void 0:g.images)?v.data.images:Array.isArray(y.images)?y.images:[];C.length>0?T.images=C:delete T.images;const G=(b=v.data)==null?void 0:b.script,Z=G!=null?String(G):y.script!=null?String(y.script):"";Z.trim()===""?delete T.script:T.script=Z,delete T.temperature,delete T.maxTokens,delete T.description,r[v.id]=T}return r}function df(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function eK(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 PT(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const s=new Set(r.map(a=>a.id)),i=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>df(a)),edges:i.map(a=>df(a)),instances:xp(r,n||{})}}function AT(e,t,n,r,s={}){var u;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const i=s.offset||{x:48,y:48},a=new Set((t||[]).map(p=>p.id)),l=new Map;for(const p of e.nodes)l.set(p.id,eK(p.id,a));const c=e.nodes.map(p=>{var g,b;const m=l.get(p.id);return{...df(p),id:m,selected:!0,dragging:!1,position:{x:Number(((g=p.position)==null?void 0:g.x)||0)+i.x,y:Number(((b=p.position)==null?void 0:b.y)||0)+i.y}}}),d=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,m)=>{const g=l.get(p.source),b=l.get(p.target);return{...df(p),id:`e-${g}-${b}-${Date.now()}-${m}`,source:g,target:b,selected:!1}}),f={...r||{}};for(const[p,m]of l.entries()){const g=(u=e.instances)==null?void 0:u[p];g&&(f[m]={...df(g),label:g.label!=null?String(g.label):m})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...d],instances:f,pastedNodeIds:c.map(p=>p.id)}}function Fj(e,t,n,r){var f,u,p,m;const s=xp(e,n),i=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const b=g.position??{x:0,y:0};a[g.id]={x:b.x,y:b.y};const v=Number(((u=(f=g.data)==null?void 0:f.displaySize)==null?void 0:u.width)||g.width||0),y=Number(((m=(p=g.data)==null?void 0:p.displaySize)==null?void 0:m.height)||g.height||0);v>0&&y>0&&(l[g.id]={width:Math.round(v),height:Math.round(y)})}const c={nodePositions:a};Object.keys(l).length>0&&(c.nodeSizes=l),r!=null&&r.viewport&&Number.isFinite(Number(r.viewport.x))&&Number.isFinite(Number(r.viewport.y))&&Number.isFinite(Number(r.viewport.zoom))&&(c.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()!==""&&(c.description=String(r.description).trim());const d={instances:s,edges:i,ui:c};return _T.dump(d,{lineWidth:-1})}function tK(e){var s,i;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((i=e.data)==null?void 0:i.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],c=(l&&l.name!=null?String(l.name).trim():"")||`input-${a}`;t.inputNames.push(c)}for(let a=0;a<r.length;a++){const l=r[a],c=(l&&l.name!=null?String(l.name).trim():"")||`output-${a}`;t.outputNames.push(c)}return t}function nK(e,t,n){var c,d,f;const r=new Set(e.map(u=>u.id)),s={};for(const u of e)s[u.id]=tK(u);const i=new Map,a=new Map;for(const u of t)u.target&&r.has(u.target)&&(i.has(u.target)||i.set(u.target,new Set),u.targetHandle&&i.get(u.target).add(u.targetHandle)),u.source&&r.has(u.source)&&(a.has(u.source)||a.set(u.source,new Set),u.sourceHandle&&a.get(u.source).add(u.sourceHandle));const l=[];for(const u of e){const p=((c=u.data)==null?void 0:c.definitionId)!=null?String(u.data.definitionId):"",m=s[u.id]||{inputNames:[],outputNames:[]},g=m.inputNames.length,b=m.outputNames.length;if(!(p==="control_start"||p.startsWith("provide_"))&&g>0)for(let k=0;k<g;k++){const w=`input-${k}`;if(!((d=i.get(u.id))==null?void 0:d.has(w))){const _=m.inputNames[k]||w;l.push({nodeId:u.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:_,handle:w}),key:`${u.id}-${w}-in`})}}if(!(p==="control_end")&&b>0)for(let k=0;k<b;k++){const w=`output-${k}`;if(!((f=a.get(u.id))==null?void 0:f.has(w))){const _=m.outputNames[k]||w;l.push({nodeId:u.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:_,handle:w}),key:`${u.id}-${w}-out`})}}}return l}const lg=/\[image\s+(\d+)\]/gi;function Is(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map((t,n)=>({id:String(t.id||`image-${n+1}`),label:String(t.label||`image ${n+1}`),name:String(t.name||`image-${n+1}`),mimeType:String(t.mimeType||t.type||"image/png"),dataUrl:String(t.dataUrl||t.data||"")})).filter(t=>t.dataUrl.startsWith("data:image/")):[]}function rK(e){return`image ${Is(e).length+1}`}function sK(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function iK(e,t){const n=Is(e),r=String(t||""),s=new Set;lg.lastIndex=0;let i;for(;i=lg.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function oK(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 IT(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 cg(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 TT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=Is(n);for(const a of r){const l=await oK(a),c=rK(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=sK(s,c)}return{body:s,images:i}}function Tb(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const aK={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function lK(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(aK[e]||[]).includes(s)?r:s}const cK={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"])},uK={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"])},dK=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function fK(e,t){if(!dK.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function pK(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function hK(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 zj(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,f;const i=n[s],l=n.find(u=>(u==null?void 0:u.name)&&u.name===r.name)||i;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((d=cK[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...!r._showOnNodeExplicit&&fK(e,r)?{showOnNode:!0}:{},...(f=uK[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function RT(e){var s,i;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=Tb(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function Gf(e,t,n,r,s){var z,A,P,C,G,Z,V,ne,ce,fe,he,oe,we,_e,xe,Te,Ae,et,ct,Xe,mt;const i=((z=e.data)==null?void 0:z.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(He=>He.id===i),l=t[e.id];let c=[],d=[],f=((A=e.data)==null?void 0:A.label)??e.id,u,p,m,g,b;const v=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(Tb)),Array.isArray(l.output)&&(d=l.output.map(Tb)),l.label&&(f=String(l.label)),l.role&&typeof l.role=="string"&&(u=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(m=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(b=String(l.script)));const y=u??(typeof((P=e.data)==null?void 0:P.role)=="string"?e.data.role:"普通"),k=p??((C=e.data)==null?void 0:C.model)??void 0,w=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=w!==""?w:void 0,_=m??((G=e.data)==null?void 0:G.body)??"",E=Array.isArray(g)?g:Array.isArray((Z=e.data)==null?void 0:Z.images)?e.data.images:[],O=b!==void 0?b:((V=e.data)==null?void 0:V.script)!=null?String(e.data.script):"",H=String(e.id),L=(ne=r==null?void 0:r[s])==null?void 0:ne[H],F=(ce=L==null?void 0:L.label)==null?void 0:ce.label,D=L==null?void 0:L.body,R=L==null?void 0:L.description;v||(c.length===0&&((fe=a==null?void 0:a.inputs)!=null&&fe.length)&&(c=a.inputs.map(He=>({...He}))),d.length===0&&((he=a==null?void 0:a.outputs)!=null&&he.length)&&(d=a.outputs.map(He=>({...He}))));const W=hK(a,(a==null?void 0:a.id)??i),M=(l==null?void 0:l.marketplaceRef)||((oe=e.data)==null?void 0:oe.marketplaceRef)||pK(a);if(W==="agent_subAgent"&&!d.some(He=>(He==null?void 0:He.name)==="result")){const He=(we=a==null?void 0:a.outputs)==null?void 0:we.find(dt=>(dt==null?void 0:dt.name)==="result");d=[...d,He?{...He}:{type:"text",name:"result",default:""}]}if((W==="display_markdown"||W==="display_mermaid"||W==="display_ascii"||W==="display_chart"||W==="display_table")&&!d.some(He=>(He==null?void 0:He.name)==="next")){const He=(_e=a==null?void 0:a.outputs)==null?void 0:_e.find(dt=>(dt==null?void 0:dt.name)==="next");d=[...d,He?{...He}:{type:"node",name:"next",default:""}]}if(W==="workspace_run"){if(!c.some(He=>(He==null?void 0:He.name)==="prev")){const He=(xe=a==null?void 0:a.inputs)==null?void 0:xe.find(dt=>(dt==null?void 0:dt.name)==="prev");c=[He?{...He}:{type:"node",name:"prev",default:""},...c]}if(!d.some(He=>(He==null?void 0:He.name)==="next")){const He=(Te=a==null?void 0:a.outputs)==null?void 0:Te.find(dt=>(dt==null?void 0:dt.name)==="next");d=[...d,He?{...He}:{type:"node",name:"next",default:""}]}}c=zj(W,c,a==null?void 0:a.inputs),d=zj(W,d,a==null?void 0:a.outputs),W.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(_).trim()!==""&&(d=d.map((He,dt)=>dt===0?{...He,default:_,value:_}:He));const $=lK(W,F||f,a),T=W==="tool_nodejs"||String(O).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:F||f,displayLabel:$,definitionDisplayName:a==null?void 0:a.displayName,definitionId:W,...M?{marketplaceRef:M}:{},...l!=null&&l.marketplacePackageId||(Ae=e.data)!=null&&Ae.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((et=e.data)==null?void 0:et.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ct=e.data)!=null&&ct.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((Xe=e.data)==null?void 0:Xe.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((mt=e.data)==null?void 0:mt.schemaType)??e.type??"agent",role:y,model:k,body:D||_,images:E,script:O,inputs:c,outputs:d,description:R||j,originalLabel:f,originalBody:_,...T?{script:O}:{}}}}function LT(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var f,u,p,m;const s=n.get(r.source),i=n.get(r.target),a=((u=(f=s==null?void 0:s.data)==null?void 0:f.outputs)==null?void 0:u.length)??0,l=((m=(p=i==null?void 0:i.data)==null?void 0:p.inputs)==null?void 0:m.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,d=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&c>=0&&c<a&&d>=0&&d<l})}function Hj(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 Bj(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function ug(e,t){const n=String((t==null?void 0:t.source)||""),r=String((t==null?void 0:t.target)||"");if(!n||!r)return e;const s=Hj(t==null?void 0:t.sourceHandle,"output"),i=Hj(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var d,f,u,p;if(c.id===n){const m=Bj((d=c.data)==null?void 0:d.outputs,s);if(m!==((f=c.data)==null?void 0:f.outputs))return a=!0,{...c,data:{...c.data,outputs:m}}}if(c.id===r){const m=Bj((u=c.data)==null?void 0:u.inputs,i);if(m!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:m}}}return c});return a?l:e}const Wj=80,mK=220;function gK(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function yK(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Rh(e,t,n){const r={nodes:Array.isArray(e)?e.map(gK):[],edges:Array.isArray(t)?t.map(yK):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function Ix(e,t){const n=[...e,t];return n.length>Wj?n.slice(n.length-Wj):n}function OT({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),d=h.useRef(null),f=h.useRef(null),u=h.useRef(null),p=h.useRef(null),m=h.useRef(!1),g=h.useCallback(()=>a(_=>_+1),[]),b=h.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),v=h.useCallback(()=>{b();const _=f.current,E=u.current;return f.current=null,u.current=null,!_||!E||_.signature===E.signature?(E&&(d.current=E),!1):(l.current=Ix(l.current,_),c.current=[],d.current=E,g(),!0)},[g,b]),y=h.useCallback((_=[],E=[],O={})=>{b(),l.current=[],c.current=[],f.current=null,u.current=null,d.current=Rh(_,E,O),m.current=!1,g()},[g,b]),k=h.useCallback(_=>{m.current=!0,d.current=_,f.current=null,u.current=null,b(),s==null||s(_.value),g()},[g,b,s]),w=h.useCallback(()=>{v();const _=d.current||Rh(e,t,n),E=l.current.pop();return E?(c.current=Ix(c.current,_),k(E),!0):(g(),!1)},[g,t,n,v,e,k]),j=h.useCallback(()=>{v();const _=d.current||Rh(e,t,n),E=c.current.pop();return E?(l.current=Ix(l.current,_),k(E),!0):(g(),!1)},[g,t,n,v,e,k]);return h.useEffect(()=>()=>b(),[b]),h.useEffect(()=>{if(!r)return;const _=Rh(e,t,n);if(!d.current){d.current=_;return}if(m.current){m.current=!1,d.current=_;return}_.signature!==d.current.signature&&(f.current||(f.current=d.current),u.current=_,b(),p.current=window.setTimeout(()=>{v()},mK))},[b,t,r,n,v,e]),{canUndo:l.current.length>0||!!f.current,canRedo:c.current.length>0,resetHistory:y,undo:w,redo:j,version:i}}function or(e){switch(dg(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function dg(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 xK(e,t){const n=dg(e),r=dg(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const wK=new Set(["workspaceContext","skillsContext","mcpContext"]);function Rb(e){const t=dg(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&wK.has(n)?`${t}+${n}`:t}function MT(e){return Rb(e)}function Mu(e,t){if(!e||!t||!xK(e.type,t.type))return!1;const n=Rb(e),r=Rb(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function bK(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 $u(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=bK(t,n==="source"?"output":"input");return i<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[i]||null}function Xo(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function vK(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 kK(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function SK(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Mr(e){e.stopPropagation()}function NK(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jK(e,t){const n=`\\[${NK(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
- `).replace(/\n{3,}/g,`
125
-
126
- `).trimEnd()}function Tx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function CK(e){const t=String(e||"");let n="",r=0;lg.lastIndex=0;let s;for(;s=lg.exec(t);)n+=Tx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Tx(s[0])}</span>`,r=s.index+s[0].length;return n+=Tx(t.slice(r)),n||" "}function EK(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+i+a+l)}function $T({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var xn,lr;const{t:f}=Ln(),u=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=vK(e),b=kK(g),v=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,_=(e==null?void 0:e.nodeElapsed)??null,E=(e==null?void 0:e.definitionId)||"",O=E.startsWith("provide_"),H=E==="provide_bool",L=E==="provide_str",F=E==="provide_file",D=E==="agent_subAgent",R=D&&!v,W=H?SK(p[0]):!1,M=O?String(((xn=p[0])==null?void 0:xn.value)??((lr=p[0])==null?void 0:lr.default)??(e==null?void 0:e.body)??""):"",$=String((e==null?void 0:e.body)||""),T=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),z=!O&&!R&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",A=Is(e==null?void 0:e.images),P=h.useRef(!1),C=h.useRef(!1),G=h.useRef(null),Z=h.useRef(null),V=h.useRef(null),[ne,ce]=h.useState(M),[fe,he]=h.useState($);h.useEffect(()=>{P.current||ce(M)},[n,M]),h.useEffect(()=>{C.current||he($)},[n,$]),h.useEffect(()=>{const be=Z.current;if(!be)return;const Me=EK(be,fe);be.style.minHeight=`${Me}px`,be.style.height="",V.current&&(V.current.style.minHeight=`${Me}px`,V.current.style.height="")},[fe]),h.useEffect(()=>{const be=G.current,Me=e==null?void 0:e.onNodeContentResize;if(!R||!be||!Me||typeof ResizeObserver>"u")return;let tt=0;const zt=()=>{window.cancelAnimationFrame(tt),tt=window.requestAnimationFrame(()=>Me(n))},ie=new ResizeObserver(zt);return ie.observe(be),zt(),()=>{window.cancelAnimationFrame(tt),ie.disconnect()}},[e==null?void 0:e.onNodeContentResize,R,n]);const oe=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],we=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],_e=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],xe=((e==null?void 0:e.model)??"").trim(),Te=m==="agent"&&!E.startsWith("tool_nodejs"),Ae=new Set(oe.map(Xo)),et=new Set(we.map(Xo)),ct=new Set(_e.map(Xo)),Xe=xe?xe.startsWith("cursor:")||xe.startsWith("opencode:")||xe.startsWith("claude-code:")?xe:ct.has(xe)?`claude-code:${xe}`:et.has(xe)?`opencode:${xe}`:Ae.has(xe)?`cursor:${xe}`:xe:"",mt=xe&&!Xe.startsWith("cursor:")&&!Xe.startsWith("opencode:")&&!Xe.startsWith("claude-code:")&&!Ae.has(xe)&&!et.has(xe)&&!ct.has(xe),He=xe.startsWith("cursor:")?xe.slice(7):xe.startsWith("opencode:")?xe.slice(9):xe.startsWith("claude-code:")?xe.slice(12):xe,dt=be=>{if(y)return;const Me=be.target.value;d&&d(n,Me)},gn=be=>{be.stopPropagation(),!y&&r&&r(n)},yn=be=>{be.stopPropagation(),s&&s()},On=be=>{be.stopPropagation(),!y&&(i==null||i(n,be.target.value==="true"?"true":"false"))},rn=be=>{if(be.stopPropagation(),y)return;const Me=be.target.value;ce(Me),P.current||i==null||i(n,Me)},Yn=be=>{be.stopPropagation(),P.current=!0},Mn=be=>{if(be.stopPropagation(),y)return;P.current=!1;const Me=be.currentTarget.value;ce(Me),i==null||i(n,Me)},ue=()=>{y||i==null||i(n,ne)},ve=be=>{if(be.stopPropagation(),y)return;const Me=window.prompt("文件路径",ne);Me!=null&&(ce(Me),i==null||i(n,Me))},Be=be=>{if(he(be),a==null||a(n,be),l){const Me=iK(A,be);(Me.length!==A.length||Me.some((tt,zt)=>{var ie;return tt.id!==((ie=A[zt])==null?void 0:ie.id)}))&&l(n,Me)}},ot=be=>{if(be.stopPropagation(),y)return;const Me=be.target.value;C.current?he(Me):Be(Me)},at=be=>{be.stopPropagation(),!y&&(C.current=!0)},Lt=be=>{if(be.stopPropagation(),y)return;C.current=!1;const Me=be.currentTarget.value;Be(Me)},nt=()=>{y||Be(fe)},dn=async be=>{if(y)return;const Me=await TT({files:be,body:fe,images:A});Me&&(he(Me.body),a==null||a(n,Me.body),l==null||l(n,Me.images))},Qt=(be,Me)=>{if(be.stopPropagation(),y)return;const tt=A.filter(ie=>ie.id!==Me.id),zt=jK(fe,Me.label);he(zt),a==null||a(n,zt),l==null||l(n,tt)},ar=be=>{if(y)return;const Me=IT(be);Me.length!==0&&(be.preventDefault(),be.stopPropagation(),dn(Me).catch(()=>{}))},Cn=be=>{if(y)return;const Me=cg(be);Me.length!==0&&(be.preventDefault(),be.stopPropagation(),dn(Me).catch(()=>{}))},fn=()=>{const be=Z.current,Me=V.current;!be||!Me||(Me.scrollTop=be.scrollTop,Me.scrollLeft=be.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!k?" af-flow-node--running-disk":"")+(w?" af-flow-node--dim":"")+(R?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!v&&Te&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Mr,onMouseDown:Mr,onClick:Mr,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:Xe,onChange:dt,onPointerDown:Mr,onMouseDown:Mr,onClick:Mr,"aria-label":f("flow:node.model"),title:He||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),mt&&o.jsx("option",{value:xe,children:xe}),oe.length>0&&o.jsx("optgroup",{label:"Cursor",children:oe.map(be=>o.jsx("option",{value:`cursor:${Xo(be)}`,children:Xo(be)},`c-${be}`))}),we.length>0&&o.jsx("optgroup",{label:"OpenCode",children:we.map(be=>o.jsx("option",{value:`opencode:${Xo(be)}`,children:Xo(be)},`o-${be}`))}),_e.length>0&&o.jsx("optgroup",{label:"Claude Code",children:_e.map(be=>o.jsx("option",{value:`claude-code:${Xo(be)}`,children:Xo(be)},`cc-${be}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:_!=null&&String(_).trim()!==""?_:"--"}),j==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!v&&O&&!H&&!L&&!F&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:yn,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!v&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:gn,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((be,Me)=>{if(be.showOnNode===!1)return null;const tt=f("flow:node.inputTooltip",{name:be.name||`#${Me}`,type:be.type})+(be.default!=null&&be.default!==""?f("flow:node.defaultSuffix",{value:be.default}):""),zt=be.name||`#${Me+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[zt,be.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ds,{type:"target",position:Je.Left,id:`input-${Me}`,className:"af-flow-node__handle",style:{background:or(be.type)},title:tt})]},`in-${Me}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:T}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,H?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(W?" af-flow-node__bool-select--true":""),value:W?"true":"false",onChange:On,onPointerDown:Mr,onMouseDown:Mr,onClick:Mr,"aria-label":"Boolean value",title:W?"true":"false",disabled:y,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):L?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ne,onChange:rn,onCompositionStart:Yn,onCompositionEnd:Mn,onBlur:ue,onPointerDown:Mr,onMouseDown:Mr,onClick:Mr,placeholder:"输入文本",rows:2,readOnly:y}):F?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Mr,onMouseDown:Mr,onClick:Mr,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:rn,onCompositionStart:Yn,onCompositionEnd:Mn,onBlur:ue,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",readOnly:y}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:ve,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):D&&!v?o.jsxs("div",{ref:G,className:"af-flow-node__prompt-stack nodrag",children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:CK(fe)+`
127
- `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:fe,onChange:ot,onCompositionStart:at,onCompositionEnd:Lt,onBlur:nt,onPaste:ar,onDrop:Cn,onScroll:fn,onDragOver:be=>{cg(be).length>0&&be.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,D&&A.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:A.map((be,Me)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:be.name,children:[o.jsx("img",{src:be.dataUrl,alt:""}),o.jsxs("span",{children:["[",be.label||`image ${Me+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:tt=>Qt(tt,be),onPointerDown:Mr,onMouseDown:Mr,"aria-label":`删除 ${be.label||`image ${Me+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},be.id||Me))}):null,z?o.jsx("span",{className:"af-flow-node__prompt-preview",title:z,children:z}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((be,Me)=>{if(be.showOnNode===!1)return null;const tt=f("flow:node.outputTooltip",{name:be.name||`#${Me}`,type:be.type})+(be.default!=null&&be.default!==""?f("flow:node.defaultSuffix",{value:be.default}):""),zt=be.name||`#${Me+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[zt,be.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ds,{type:"source",position:Je.Right,id:`output-${Me}`,className:"af-flow-node__handle",style:{background:or(be.type)},title:tt})]},`out-${Me}`)})})]})]})}const wp="flowNode";function DT(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 fg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function _K(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function FT({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Ln(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[f,u]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const y=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),b=g===n;async function v(y){if(y.preventDefault(),!(!b||f)){u(!0),m("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await k.json().catch(()=>({}));if(!k.ok){m(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(k){m(String((k==null?void 0:k.message)||k))}finally{u(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:v,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function Vj({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:f}){const{t:u}=Ln(),p=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=m.current)==null?void 0:w.focus()});function k(w){w.key==="Escape"&&f(),w.key==="Enter"&&d()}return window.addEventListener("keydown",k),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",k)}},[e,f,d]),!e)return null;const g=r??u("common:common.confirm","确定"),b=s??u("common:common.cancel","取消"),v=t??u("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&f()},children:o.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:v}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:b}),a&&c?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function zT({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Ln(),l=h.useId(),c=h.useRef(null),[d,f]=h.useState(""),[u,p]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;f(""),g(""),p(!1);const k=requestAnimationFrame(()=>{var w;return(w=c.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(k)},[e,n]),!e)return null;const b=d.trim(),v=b===n;async function y(k){if(k.preventDefault(),!v||u)return;p(!0),g("");let w=null;try{const j=new AbortController;w=setTimeout(()=>j.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:j.signal}),E=await _.json().catch(()=>({}));if(!_.ok){g(typeof E.error=="string"?E.error:a("project:deleteModal.deleteFailed"));return}try{for(let O=localStorage.length-1;O>=0;O--){const H=localStorage.key(O);H&&(H.startsWith(`af:composer-sessions:${n}:${r}`)||H.startsWith(`af:composer-active-session:${n}:${r}`)||H.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(H)}}catch{}await i()}catch(j){if((j==null?void 0:j.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((j==null?void 0:j.message)||j))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:k=>f(k.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!v})]}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!v||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function PK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function zi({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(PK,{children:t})]},n))})}function HT({open:e,onClose:t}){const{t:n}=Ln(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=_K()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(zi,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(zi,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(zi,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(zi,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(zi,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(zi,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(zi,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(zi,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(zi,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(zi,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(zi,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function AK(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function BT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Ln(),[i,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const u=h.useMemo(()=>{const g=(r||[]).map(y=>{var k,w,j;return{id:y.id,label:((k=y.data)==null?void 0:k.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),b=i.trim(),v=g.map(y=>({e:y,s:AK(y,b)})).filter(y=>y.s>0);return v.sort((y,k)=>k.s-y.s||y.e.id.localeCompare(k.e.id)),v.slice(0,50).map(y=>y.e)},[r,i]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var b;const g=(b=f.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const b=u[g];b&&(n(b.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(b=>Math.min(u.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:u.map((g,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(b),onMouseDown:v=>{v.preventDefault(),p(b)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function IK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=Ln(),f=h.useId(),u=h.useRef(null),p=h.useRef(null),[m,g]=h.useState(""),[b,v]=h.useState(""),[y,k]=h.useState(!1),[w,j]=h.useState(!1),[_,E]=h.useState(!1),[O,H]=h.useState(""),[L,F]=h.useState("");if(h.useEffect(()=>{if(!e||!i)return;g(""),v(""),H(""),F(""),k(!0),j(!1),E(!1);const T=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const A=await fetch(`/api/pipeline-file-content?${T}`),P=await A.json();if(!A.ok)throw new Error(P.error||"HTTP "+A.status);g(P.content||""),v(P.content||"")}catch(A){H(A.message||String(A))}finally{k(!1)}})();const z=requestAnimationFrame(()=>{var A;return(A=u.current)==null?void 0:A.focus()});return()=>cancelAnimationFrame(z)},[e,i,n,r,s]),!e)return null;const D=m!==b;async function R(T){if(T.preventDefault(),!w){j(!0),H(""),F("");try{const z=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),A=await fetch(`/api/pipeline-file-save?${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),P=await A.json();if(!A.ok)throw new Error(P.error||"HTTP "+A.status);v(m),F(d("flow:fileEdit.saved")),l&&l()}catch(z){H(z.message||String(z))}finally{j(!1)}}}async function W(){if(!(!c||_||!m)){E(!0),H("");try{const T=await c(m);typeof T=="string"&&T&&g(T)}catch(T){H(T.message||String(T))}finally{E(!1)}}}function M(){g(b),H(""),F("")}const $=m.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:T=>{T.target===T.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:T=>T.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):O&&!m?o.jsx("div",{className:"af-file-edit-error",children:O}):o.jsxs(o.Fragment,{children:[$&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:m,onChange:T=>g(T.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(O||L)&&!y&&o.jsx("div",{className:`af-file-edit-status${L?" af-file-edit-status--success":""}`,children:L||O}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:M,disabled:!D||w||_,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:_||w||!m,children:d(_?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:R,disabled:!D||w||_,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const WT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),TK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function RK(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 LK(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 Uj(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 VT(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(WT.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 UT(e){return{inputNames:Uj(e==null?void 0:e.inputs),outputNames:Uj(e==null?void 0:e.outputs)}}function OK(e,t,n){const r=UT(t),s=LK(e),i=[];for(const a of s)if(!VT(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function MK(e,t){const n=UT(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=VT(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function $K(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function DK(e){return e.map(t=>{const n=$K(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 FK(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of TK)WT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function zK(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function HK(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function Lh({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:f}=Ln(),u=h.useId(),p=h.useRef(null),m=h.useRef(null),[g,b]=h.useState(0),[v,y]=h.useState(0),[k,w]=h.useState(null),j=h.useMemo(()=>Is(c),[c]),_=h.useMemo(()=>OK(e,a,f),[e,a,f]),E=_.length>0,O=h.useMemo(()=>MK(e,a),[e,a]),H=h.useMemo(()=>DK(O),[O]),L=h.useMemo(()=>n?null:RK(e,g),[e,g,n]),F=h.useMemo(()=>{if(!L)return[];const T=FK(a,f);return zK(T,L.query)},[L,a,f]);h.useEffect(()=>{y(T=>{const z=Math.max(0,F.length-1);return Math.min(Math.max(0,T),z)})},[F.length]);const D=h.useCallback(()=>{const T=p.current;if(!T||!L||F.length===0){w(null);return}const z=HK(T,g);if(!z){w(null);return}const A=4,P=44,C=13.5*16,G=Math.min(F.length*P+8,C);let Z=z.bottom+A;Z+G>window.innerHeight-8&&(Z=Math.max(8,z.top-G-A));const V=288;let ne=z.left;ne=Math.max(8,Math.min(ne,window.innerWidth-V-8)),w({top:Z,left:ne})},[L,F.length,g]);h.useLayoutEffect(()=>{if(!L||F.length===0){w(null);return}const T=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(T)},[L,F.length,g,e,D]),h.useEffect(()=>{if(!L||F.length===0)return;const T=()=>D();return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[L,F.length,D]);const R=h.useCallback(T=>{if(!L)return;const{atIndex:z}=L,A=e.slice(0,z)+"${"+T+"}"+e.slice(g);t(A);const P=z+T.length+3;queueMicrotask(()=>{const C=p.current;C&&(C.focus(),C.setSelectionRange(P,P)),b(P)})},[L,e,g,t]),W=h.useCallback(()=>{const T=p.current,z=m.current;!T||!z||(z.scrollTop=T.scrollTop,z.scrollLeft=T.scrollLeft,L&&F.length>0&&queueMicrotask(()=>D()))},[L,F.length,D]),M=h.useCallback(T=>{if(!n&&L&&F.length>0&&(T.key==="ArrowDown"||T.key==="ArrowUp"||T.key==="Enter")){if(T.key==="ArrowDown")T.preventDefault(),y(z=>(z+1)%F.length);else if(T.key==="ArrowUp")T.preventDefault(),y(z=>(z-1+F.length)%F.length);else if(T.key==="Enter"&&!T.shiftKey){T.preventDefault();const z=F[v];z&&R(z.insert)}}},[n,L,F,v,R]),$=h.useCallback(async T=>{if(n||typeof d!="function")return!1;const z=await TT({files:T,body:e,images:j});return z?(t(z.body),d(z.images),queueMicrotask(()=>{const A=p.current;if(!A)return;A.focus();const P=z.body.length;A.setSelectionRange(P,P),b(P)}),!0):!1},[n,j,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((T,z)=>o.jsxs("span",{className:"af-body-image-chip",title:T.name,children:[o.jsx("img",{src:T.dataUrl,alt:""}),o.jsxs("span",{children:["[",T.label||`image ${z+1}`,"]"]})]},T.id||z))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:H+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":E,"aria-describedby":E?u:void 0,onChange:T=>{t(T.target.value),b(T.target.selectionStart??T.target.value.length)},onSelect:T=>{const z=T.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:T=>{const z=T.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:T=>{const z=T.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:M,onPaste:T=>{const z=IT(T);z.length!==0&&(T.preventDefault(),$(z).catch(()=>{}))},onDragOver:T=>{cg(T).length>0&&T.preventDefault()},onDrop:T=>{const z=cg(T);z.length!==0&&(T.preventDefault(),$(z).catch(()=>{}))},onScroll:W})]}),L&&F.length>0&&k?Dr.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:F.map((T,z)=>o.jsx("li",{role:"option","aria-selected":z===v,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===v?" af-composer-mention-item--active":""),onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>y(z),onClick:()=>R(T.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${T.insert}}`}),T.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:T.subtitle}):null]})},`${T.section}-${T.insert}`))}),document.body):null,E?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:_.map(T=>T.message).join(" · ")}):null]})}const KT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Oh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Kj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Ln(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const g=n.map((b,v)=>{if(v!==u)return b;const y={...b,[p]:m};return p==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function qT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=Ln(),[m,g]=h.useState(!1),[b,v]=h.useState(!1),[y,k]=h.useState({status:"idle",message:""}),w=h.useCallback(R=>{t(W=>W&&{...W,...R})},[t]),{cursorList:j,opencodeList:_,claudeCodeList:E,currentNotInLists:O}=h.useMemo(()=>{const R=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],M=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],$=new Set([...R,...W,...M].map(Oh)),T=((e==null?void 0:e.model)??"").trim(),z=T.startsWith("cursor:")?T.slice(7):T.startsWith("opencode:")?T.slice(9):T.startsWith("claude-code:")?T.slice(12):T,A=T&&!$.has(z)?T:"";return{cursorList:R,opencodeList:W,claudeCodeList:M,currentNotInLists:A}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),L=n==="tool_nodejs"||H.trim()!=="",F=typeof c=="function"&&!i&&(e==null?void 0:e.newId),D=async()=>{if(F){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const R=await c(e,n);k({status:"success",message:R!=null&&R.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:R.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(R){k({status:"error",message:String((R==null?void 0:R.message)||R)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!F||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:R=>w({newId:R.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:R=>w({label:R.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:ll.includes(e.role)?e.role:p("flow:roles.normal"),onChange:R=>w({role:R.target.value}),disabled:i,children:ll.map(R=>o.jsx("option",{value:R,children:R},R))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const R=(e.model||"").trim();return R?O||R:""})(),onChange:R=>w({model:R.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),O?o.jsxs("option",{value:O,children:[O,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(R=>o.jsx("option",{value:Oh(R),children:R},`c-${R}`))}):null,_.length>0?o.jsx("optgroup",{label:"OpenCode",children:_.map(R=>o.jsx("option",{value:Oh(R),children:R},`o-${R}`))}):null,E.length>0?o.jsx("optgroup",{label:"Claude Code",children:E.map(R=>o.jsx("option",{value:`claude-code:${Oh(R)}`,children:R},`cc-${R}`))}):null]})]}),o.jsx(Kj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:R=>w({inputs:R}),disabled:i,requiredReadonly:!d}),o.jsx(Kj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:R=>w({outputs:R}),disabled:i,requiredReadonly:!d}),L?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>v(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lh,{value:H,onChange:R=>w({script:R}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lh,{value:e.body,onChange:R=>w({body:R}),images:e.images,onImagesChange:R=>w({images:R}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:R=>{R.target===R.currentTarget&&v(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>v(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Lh,{value:H,onChange:R=>w({script:R}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:R=>{R.target===R.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Lh,{value:e.body,onChange:R=>w({body:R}),images:e.images,onImagesChange:R=>w({images:R}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function A0(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 BK(e){const t=A0(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 YT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function qj({text:e}){const{t}=Ln(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(yp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Yj({o:e}){var r;const{t}=Ln(),n=A0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:YT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(yp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Gj(e){return BK(e)}function Xj(e){var r;if(!e)return null;const t=A0(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"?YT(String(n)):String(n)}function Jj({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Qj=2e4,GT="af:run-node-ctx-width";function fm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Va(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):Va(fm())}function WK(){try{const e=localStorage.getItem(GT);if(e==null)return Va(fm());const t=parseInt(e,10);return Number.isFinite(t)?Va(t):Va(fm())}catch{return Va(fm())}}async function Zj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function VK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function UK({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Ln(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(WK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,g]=h.useState(""),[b,v]=h.useState([]),[y,k]=h.useState(null),[w,j]=h.useState(null),_=h.useRef(null),E=h.useRef(null),O=h.useRef(0),H=h.useRef(0);h.useLayoutEffect(()=>{const A=window.matchMedia("(max-width: 960px)"),P=()=>l(A.matches);return A.addEventListener("change",P),()=>A.removeEventListener("change",P)},[]),h.useEffect(()=>{function A(){d(P=>Va(P))}return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const L=h.useCallback(()=>{d(A=>{const P=Va(A);try{localStorage.setItem(GT,String(P))}catch{}return P})},[]),F=h.useCallback(A=>{if(a||A.button!==0)return;A.preventDefault();const P=A.currentTarget;f.current={active:!0,pointerId:A.pointerId,startX:A.clientX,startW:c},P.setPointerCapture(A.pointerId)},[a,c]),D=h.useCallback(A=>{const P=f.current;if(!P.active||A.pointerId!==P.pointerId)return;const C=P.startX-A.clientX;d(Va(P.startW+C))},[]),R=h.useCallback(A=>{const P=f.current;if(!(!P.active||A.pointerId!==P.pointerId)){P.active=!1;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}L()}},[L]),W=h.useCallback(()=>{const A=f.current;A.active&&(A.active=!1,L())},[L]),M=h.useCallback(A=>{const P=Array.isArray(A)?A:[];v(P),k(C=>C&&P.some(G=>G.execId===C)?C:P.length>0?P[P.length-1].execId:null)},[]),$=h.useCallback(()=>{if(!e||!t)return;const A=++O.current,P=new AbortController,C=window.setTimeout(()=>P.abort(),Qj);(async()=>{try{const G=await Zj(t,e,n,P.signal);if(A!==O.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(C)}})()},[e,t,n,M]);h.useEffect(()=>{if(!e||!t){p(!1),g(""),v([]);return}const A=++H.current;p(!0),g(""),v([]),k(null);const P=new AbortController,C=window.setTimeout(()=>P.abort(),Qj);return(async()=>{try{const G=await Zj(t,e,n,P.signal);if(A!==H.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(A!==H.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(C),A===H.current&&p(!1)}})(),()=>{P.abort(),H.current++,O.current++}},[e,t,n,M]),h.useEffect(()=>{r&&$()},[r,$]),h.useEffect(()=>{clearInterval(E.current);const A=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(A&&A.status==="running"))&&e&&t&&(E.current=setInterval(()=>$(),2e3)),()=>clearInterval(E.current)},[b,e,t,n,r,$]),h.useEffect(()=>{_.current&&(_.current.scrollTop=0)},[y]);const T=b.find(A=>A.execId===y),z=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:z,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:F,onPointerMove:D,onPointerUp:R,onPointerCancel:R,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:VK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+qK((T==null?void 0:T.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:A=>{const P=A.target.value;k(P==="latest"?"latest":Number(P))},children:[...b].reverse().map(A=>{const P=A.execId==="latest"?i("flow:runContext.latest"):`#${A.execId}`,C=YK(i,A.status),G=A.finishedAt?` · ${KK(A.finishedAt)}`:"";return o.jsx("option",{value:String(A.execId),children:`${P} · ${C}${G}`},A.execId)})})]}),T&&o.jsxs("div",{className:"af-run-ctx-body",ref:_,children:[T.inputs&&T.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),T.inputs.map((A,P)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:A.value})]},`${A.slot}-${P}`))]}),T.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(qj,{text:T.prompt})]}),T.outputs&&T.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),T.outputs.map((A,P)=>{const C=Gj(A),G=Xj(A);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot}),C?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:C}):null,o.jsx(Jj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Yj,{o:A})]},`${A.slot}-${P}`)})]}),!T.prompt&&(!T.outputs||T.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&T&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:A=>{A.target===A.currentTarget&&j(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&T.prompt!=null&&o.jsx(qj,{text:T.prompt}),w==="output"&&T.outputs&&T.outputs.map((A,P)=>{const C=Gj(A),G=Xj(A);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:A.slot}),C?o.jsx("span",{className:"af-run-ctx-format-badge",children:C}):null,o.jsx(Jj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Yj,{o:A})]},`${A.slot}-${P}`)})]})]})})]})}function KK(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 qK(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 YK(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 GK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Ln(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,g]=h.useState({}),[b,v]=h.useState(!0),[y,k]=h.useState(!1),[w,j]=h.useState(""),[_,E]=h.useState(!1),[O,H]=h.useState(null),L=h.useRef(null),F=h.useRef(!0),D=h.useRef({});h.useMemo(()=>{var C,G,Z;const P={};for(const V of r){const ne=(Z=(G=(C=V.data)==null?void 0:C.outputs)==null?void 0:G[0])==null?void 0:Z.default;ne!=null&&ne!==""&&(P[V.id]=String(ne))}return D.current=P,P},[r]);const R=h.useMemo(()=>{var C;const P={};for(const G of i){if(!((C=G.data)!=null&&C.inputs))continue;const Z=G.data.inputs;for(let V=0;V<Z.length;V++){const ne=Z[V];if(!(ne!=null&&ne.name))continue;const ce=s.find(he=>he.target===G.id&&he.targetHandle===`input-${V}`);if(!(ce!=null&&ce.source))continue;r.find(he=>he.id===ce.source)&&(P[ce.source]=ne.name)}}return P},[i,s,r]);h.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),h.useEffect(()=>{if(!e){v(!1);return}v(!0);const P=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&P.set("archived","1"),fetch(`/api/flow/run-config?${P.toString()}`).then(C=>{if(!C.ok)throw new Error(`HTTP ${C.status}`);return C.json()}).then(C=>{var Z;if(!F.current)return;f(C.presets||{}),p(C.activePreset||null);const G=C.activePreset&&((Z=C.presets)!=null&&Z[C.activePreset])?C.presets[C.activePreset]:{};g({...D.current,...G}),v(!1)}).catch(()=>{F.current&&(g(D.current),v(!1))})},[e,t,n]),h.useEffect(()=>{var C;if(!a)return;const P={};for(const[G,Z]of Object.entries(m)){const V=R[G];if(!V)continue;const ne=r.find(fe=>fe.id===G);if(!ne)continue;(((C=ne.data)==null?void 0:C.definitionId)||"").startsWith("provide_file")?P[V]={type:"file",path:Z}:P[V]={type:"str",value:Z}}a(P)},[m,R,r,a]);const W=h.useCallback((P,C)=>{g(G=>({...G,[P]:C}))},[]),M=h.useCallback(P=>{P!==u&&(p(P),P&&d[P]?g({...D.current,...d[P]}):g(D.current))},[u,d]),$=h.useCallback(async()=>{if(w.trim()){k(!0);try{const P={...d,[w.trim()]:m},C={flowId:e,flowSource:t,archived:n,presets:P,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)})).ok&&(f(P),p(w.trim()),j(""),E(!1))}finally{k(!1)}}},[e,t,n,d,m,w]),T=h.useCallback(async()=>{if(u){k(!0);try{const P={...d};delete P[u];const C=Object.keys(P)[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:P,activePreset:C})})).ok&&(f(P),p(C),C&&P[C]?g({...D.current,...P[C]}):g(D.current))}finally{k(!1)}}},[e,t,n,d,u]),z=h.useCallback(async()=>{if(u){k(!0);try{const P={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:P,activePreset:u})})).ok&&f(P)}finally{k(!1)}}},[e,t,n,d,u,m]),A=Object.keys(d);return A.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:P=>M(P.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),A.map(P=>o.jsx("option",{value:P,children:P},P))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>E(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:T,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),_&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:w,onChange:P=>j(P.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{E(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(P=>{var he,oe;const C=((he=P.data)==null?void 0:he.definitionId)||"",G=C.startsWith("provide_file"),Z=C==="provide_bool",V=((oe=P.data)==null?void 0:oe.label)||P.id,ne=P.id,ce=m[ne]||"",fe=["true","1","yes","on"].includes(String(ce).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>H({instanceId:ne,label:V,content:ce}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:ne}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(fe?" af-run-config-bool-toggle--true":""),onClick:()=>W(ne,fe?"false":"true"),"aria-pressed":fe,children:fe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ce,onChange:we=>W(ne,we.target.value),placeholder:c(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ne)})})]}),O&&Dr.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:O.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>H(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:L,className:"af-provide-edit-modal__textarea",defaultValue:O.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!O||!L.current||(W(O.instanceId,L.current.value),H(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>H(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const XT={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"]},XK={"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 JK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function QK(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 ZK(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 e1(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(XT))if(r.includes(e))return n;return"other"}function e7({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=XK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=i[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:QK(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function t7({open:e,onClose:t,flowId:n}){var H;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,g]=h.useState(!0),[b,v]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,k]=h.useState(""),w=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const L=m&&n?`?flowId=${encodeURIComponent(n)}`:"",D=await(await fetch(`/api/composer-logs${L}`)).json();s(Array.isArray(D.sessions)?D.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),_=h.useCallback(async L=>{if(!L){f(null);return}p(!0);try{const D=await(await fetch(`/api/composer-logs/${encodeURIComponent(L)}`)).json();f(D)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return _(l),w.current=setInterval(()=>_(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,_]);const E=h.useMemo(()=>{const L=(d==null?void 0:d.events)||[],F=y.trim().toLowerCase();return L.filter(D=>{const R=e1(D.tag,D.payload);return!b[R]&&R!=="other"?!1:F?[D.tag,JSON.stringify(D.payload||"")].join(" ").toLowerCase().includes(F):!0})},[d,b,y]),O=h.useMemo(()=>{const L=(d==null?void 0:d.events)||[],F={};for(const D of L){const R=e1(D.tag,D.payload);F[R]=(F[R]||0)+1}return F},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:L=>g(L.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(L=>{const F=l===L.sessionId;return o.jsxs("div",{onClick:()=>c(L.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:F?"rgba(124,77,255,0.18)":"transparent",borderLeft:F?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:ZK(L.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:L.flowId||"(no flow)"}),L.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:L.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[JK(L.size)," · ",L.model||"default"]})]},L.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(XT).map(L=>o.jsxs("button",{type:"button",onClick:()=>v(F=>({...F,[L]:!F[L]})),style:{background:b[L]?"rgba(124,77,255,0.25)":"transparent",color:b[L]?"#e8deff":"#6a6a6a",border:`1px solid ${b[L]?"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:[L," ",O[L]!=null?`(${O[L]})`:""]},L)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:L=>k(L.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&E.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((H=d.events)==null?void 0:H.length)||0," total)"]}),E.map((L,F)=>o.jsx(e7,{event:L,defaultExpanded:L.tag==="error"},`${L.ts}_${F}`))]})]})]})]}):null}const n7="0.1.62";function t1(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 Rx(e,t){return t==="running"?t1(e):e==null||!Number.isFinite(e)||e<=0?"--":t1(e)}const JT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function r7(e){var k,w,j,_,E,O,H,L,F,D,R;const{setNodes:t}=mc(),n=a0(),{modelLists:r,onModelChange:s}=h.useContext(JT),i=h.useRef(null),a=!!((k=e.data)!=null&&k.readOnly),l=(w=e.data)!=null&&w.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,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((_=e.data)!=null&&_.isRunMode)&&!a,d=h.useCallback(W=>{const M=()=>n(W);window.requestAnimationFrame(M),window.setTimeout(M,80)},[n]),f=h.useCallback((W,M)=>{const $=c1(M);$&&(t(T=>T.map(z=>{var C,G,Z,V,ne,ce;if(z.id!==W)return z;const A=Number(((G=(C=z.data)==null?void 0:C.displaySize)==null?void 0:G.width)||z.width||((Z=z.measured)==null?void 0:Z.width)||0),P=Number(((ne=(V=z.data)==null?void 0:V.displaySize)==null?void 0:ne.height)||z.height||((ce=z.measured)==null?void 0:ce.height)||0);return Math.abs(A-$.width)<2&&Math.abs(P-$.height)<2?z:{...z,width:$.width,height:$.height,data:{...z.data,displaySize:$}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const M=i.current;if(!M)return;const $=M.getBoundingClientRect();f(W,{width:Math.max($.width,M.scrollWidth),height:Math.max($.height,M.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var ne,ce,fe,he,oe,we;if(!c)return;W.preventDefault(),W.stopPropagation();const M=i.current,$=M==null?void 0:M.getBoundingClientRect(),T=Number(((ce=(ne=e.data)==null?void 0:ne.displaySize)==null?void 0:ce.width)||e.width||((fe=e.measured)==null?void 0:fe.width)||($==null?void 0:$.width)||tR),z=Number(((oe=(he=e.data)==null?void 0:he.displaySize)==null?void 0:oe.height)||e.height||((we=e.measured)==null?void 0:we.height)||($==null?void 0:$.height)||Lb),A=W.clientX,P=W.clientY,C=e.id;let G=0;const Z=_e=>{const xe=c1({width:T+_e.clientX-A,height:z+_e.clientY-P});xe&&(window.cancelAnimationFrame(G),G=window.requestAnimationFrame(()=>f(C,xe)))},V=()=>{window.cancelAnimationFrame(G),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(C)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,(O=(E=e.data)==null?void 0:E.displaySize)==null?void 0:O.height,(L=(H=e.data)==null?void 0:H.displaySize)==null?void 0:L.width,e.height,e.id,(F=e.measured)==null?void 0:F.height,(D=e.measured)==null?void 0:D.width,e.width,d,c]),m=h.useCallback(W=>{t(M=>M.filter($=>$.id!==W))},[t]),g=h.useCallback(()=>{var T,z,A,P,C,G,Z,V;const W=((T=e.data)==null?void 0:T.definitionId)||"",M=((z=e.data)==null?void 0:z.label)||e.id,$=((C=(P=(A=e.data)==null?void 0:A.outputs)==null?void 0:P[0])==null?void 0:C.value)||((V=(Z=(G=e.data)==null?void 0:G.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:M,definitionId:W,content:$},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,M)=>{t($=>$.map(T=>{var A;if(T.id!==W)return T;const z=Array.isArray((A=T.data)==null?void 0:A.outputs)&&T.data.outputs.length?T.data.outputs.map((P,C)=>C===0?{...P,default:M,value:M}:P):[{type:"bool",name:"value",default:M,value:M}];return{...T,data:{...T.data,body:"",outputs:z}}}))},[t]),v=h.useCallback((W,M)=>{t($=>$.map(T=>T.id===W?{...T,data:{...T.data,body:M}}:T))},[t]),y=h.useCallback((W,M)=>{t($=>$.map(T=>T.id===W?{...T,data:{...T.data,images:Is(M)}}:T))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx($T,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:v,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((R=e.data)==null?void 0:R.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const s7={[wp]:r7},Ud=["CONTROL","TOOL","PROVIDE","AGENT"],i7=1200,n1="af-flow-node--sync-flash",r1="af-flow-edge--sync-flash";function s1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function i1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function I0(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 o7(e){const t=I0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Mh(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 QT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function ZT(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Lx(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 o1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function a1(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 a7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function l7(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 eR(e,t,n,r,s){const i=o7(e),a={id:t,type:wp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return Gf(a,r,s)}const tR=320,c7=220,u7=1600,Lb=104,d7=900;function l1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function c1(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:l1(t,c7,u7)||tR,height:l1(n,Lb,d7)||Lb}}function f7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function u1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=$u(i,e.sourceHandle||"output-0","source"),c=$u(a,e.targetHandle||"input-0","target");return!l||!c?!1:Mu(l,c)}function p7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=$u(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:MT(a)}:null}function h7(e,t,n){var a;const r=eR(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Mu(n.slot,c):Mu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function m7(e,t){return t?e.map((n,r)=>{const s=h7(n,e,t);if(!s)return null;const i=I0(n);return{def:n,order:r,category:i,categoryRank:Ud.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:QT(s.hydrated.data||n),description:ZT(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const g7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function y7(e){const t=new Set,n=[];let r;const s=new RegExp(g7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function d1(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 Zo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function $h(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Zo),d=a.map(Zo);return l.map(Zo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function x7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Ox(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 w7({steps:e}){const{t}=Ln();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
- `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:x7(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 v7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
- ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function k7(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 S7(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 f1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=Ln(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(p1,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(p1,{segments:t,running:n})})]})}function p1({segments:e,running:t=!1}){const{t:n}=Ln(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),i=b7(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
131
- `),l=e.filter(u=>u.kind!=="error"),c=i?l.filter(u=>u.kind!=="result"):l,d=v7(c),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((u,p)=>o.jsxs("section",{className:S7(u.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:k7(u.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function N7({fitViewEpoch:e}){const{fitView:t}=mc(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function j7({onReady:e}){const t=a0();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function h1(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function m1(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 pm=1500,g1=500,C7=262144,E7=2e3;function Mx(e){return typeof e!="string"?"":e.length<=E7?e:`[log line truncated, ${e.length} chars]`}const _7=pm;function P7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Mx(s)}}catch{return{ts:n,type:"info",text:Mx(s)}}return{ts:n,type:"log",text:Mx(`[${r}] ${s}`)}}function y1(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<_7;r--){const s=n[r];if(!s)continue;const i=P7(s);i&&t.push(i)}return t.reverse(),t}function A7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function I7(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 T7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:f,onNodeClick:u,onNodeDoubleClick:p,onEdgeClick:m,onFlowInit:g,onDrop:b,onDragOver:v,hideMinimapAndControls:y,bottomSlot:k}){const{t:w}=Ln(),j=!s,_=j||t==="pan"?!0:[1,2],E=j?!1:t==="select",O="af-flow-canvas"+(j?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),H=h.useCallback(()=>{},[]),L=h.useMemo(()=>{const F=new Map(n.map($=>[$.id,$])),D=new Set(n.filter($=>$.selected).map($=>$.id)),R=D.size>0,W=($,T)=>{const z=/^#([0-9a-f]{6})$/i.exec($);if(!z)return $;const A=parseInt(z[1],16);return`rgba(${A>>16&255}, ${A>>8&255}, ${A&255}, ${T})`},M="#ff5169";return r.map($=>{var xe,Te,Ae,et;const T=F.get($.source),z=F.get($.target),A=/^output-(\d+)$/.exec($.sourceHandle||""),P=/^input-(\d+)$/.exec($.targetHandle||""),C=T&&A?(Te=(xe=T.data)==null?void 0:xe.outputs)==null?void 0:Te[parseInt(A[1],10)]:null,G=z&&P?(et=(Ae=z.data)==null?void 0:Ae.inputs)==null?void 0:et[parseInt(P[1],10)]:null,Z=C!=null&&C.type?or(C.type):null,V=G!=null&&G.type?or(G.type):null,ne=Z&&V&&Z!==V,ce=R&&(D.has($.source)||D.has($.target)),fe=$.style||{};if(ne){const ct=$.selected?.95:ce?.85:.78,Xe=W(M,ct);return{...$,className:(($.className||"")+" af-flow-edge--type-mismatch"+(ce?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:Xe,strokeWidth:ce?2.75:2.5,strokeDasharray:"6 4"},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:Xe}:{type:Ms.ArrowClosed,color:Xe}}}const he=Z||V;if(!he)return ce?{...$,className:(($.className||"")+" af-flow-edge--adjacent").trim(),style:{...fe,strokeWidth:2.5}}:$;const oe=ce||$.selected?.7:.38,we=W(he,oe),_e=ce?2.5:fe.strokeWidth??2;return{...$,className:(($.className||"")+(ce?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:we,strokeWidth:_e},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:we}:{type:Ms.ArrowClosed,color:we}}})},[n,r]);return o.jsxs(o0,{className:O,nodes:n,edges:L,onNodesChange:s||H,onEdgesChange:i||H,onConnect:j?void 0:a,onConnectStart:j?void 0:l,onConnectEnd:j?void 0:c,isValidConnection:j?void 0:d,onNodesDelete:j?void 0:f,onNodeClick:u,onNodeDoubleClick:j?void 0:p,onEdgeClick:j?void 0:m,onInit:g,onDrop:j?void 0:b,onDragOver:j?void 0:v,nodeTypes:s7,selectionOnDrag:E,panOnDrag:_,nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j,edgesFocusable:!j,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(l0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(Lu,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(F4,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:F=>{var R;const D=(((R=F.data)==null?void 0:R.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)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:k}),y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(C4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(Lu,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:F,color:D})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:D}}),o.jsx("span",{className:"af-pin-legend__label",children:F})]},F))}),o.jsx(N7,{fitViewEpoch:e}),!j&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:w("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:w("flow:emptyCanvas.composerSub")}})]}):null]})}function x1(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 R7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function xi(e){return e==="builtin"||e==="admin"}function Mc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function L7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const nR="af:run-console-height",ff=230,Rd={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Dh={};function hm(e){if(!Number.isFinite(e))return ff;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function O7(){try{const e=localStorage.getItem(nR);if(e==null)return ff;const t=parseInt(e,10);return Number.isFinite(t)?hm(t):ff}catch{return ff}}function M7(){var ak,lk;const{t:e,i18n:t}=Ln(),{navigate:n,path:r}=Ro(),s=h.useRef(null),i=h.useRef(new Map),a=h.useCallback(x=>{s.current=typeof x=="function"?x:null},[]),[l,c]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState(null),[m,g]=h.useState(0),[b,v]=h.useState(""),[y,k]=h.useState(""),[w,j]=h.useState(""),[_,E]=h.useState(""),[O,H]=h.useState(!1),[L,F]=h.useState(""),[D,R]=h.useState(!1),[W,M]=h.useState(""),[$,T]=h.useState(!1),[z,A]=h.useState(!1),[P,C]=h.useState(!1),[G,Z]=h.useState(null),[V,ne]=h.useState(!1),[ce,fe]=h.useState(!1),he=h.useRef(!1),[oe,we]=h.useState([]),[_e,xe]=h.useState(""),[Te,Ae]=h.useState("nodes"),et=h.useRef(null),[ct,Xe]=h.useState([]),[mt,He]=h.useState(!1),[dt,gn]=h.useState(""),[yn,On]=h.useState(!1),[rn,Yn]=h.useState({name:"",id:"",description:""}),[Mn,ue]=h.useState(!1),[ve,Be]=h.useState(""),[ot,at]=h.useState(""),Lt=h.useRef(null),[nt,dn]=h.useState([]),[Qt,ar]=h.useState(!1),[Cn,fn]=h.useState(""),[xn,lr]=h.useState(""),[be,Me]=h.useState(null),[tt,zt]=h.useState(null),[ie,Ie]=h.useState([]),[We,Ht]=h.useState(""),[pn,cr]=h.useState(!1),zs=h.useCallback(x=>{Lt.current&&window.clearTimeout(Lt.current),at(x),Lt.current=window.setTimeout(()=>{at(""),Lt.current=null},3800)},[]),is=h.useCallback(x=>{const N=String(x||"").trim();if(!N)return;const B=()=>{var q;return(q=s.current)==null?void 0:q.call(s,N)};window.requestAnimationFrame(B),window.setTimeout(B,80)},[]);h.useEffect(()=>()=>{Lt.current&&window.clearTimeout(Lt.current)},[]);const[hr,Zn]=h.useState(!1),[Wr,it]=h.useState({files:[]}),[Vr,_i]=h.useState(!1),[ya,ys]=h.useState(!0);h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{x||ys(q.ok)}).catch(()=>{x||ys(!1)})};N();const B=window.setInterval(N,5e3);return()=>{x=!0,window.clearInterval(B)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/dev-info").then(N=>N.json()).then(N=>{x||xa(!!(N!=null&&N.isDev))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&nP(u.id,u.source??"user","pipeline",!!u.archived)},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[Pe,sn]=h.useState("edit"),[mr,ht]=h.useState([]),Oe=h.useRef(0),[Ur,Gn]=h.useState(new Set),[Kr,Cr]=h.useState({}),[ut,Ut]=h.useState(null),[on,Er]=h.useState(0),[Ze,gr]=h.useState(!1),[Hs,xa]=h.useState(!1),[xs,Mo]=h.useState(!1),[vr,$o]=h.useState(O7),Pi=h.useRef({active:!1,pointerId:-1,startY:0,startH:ff}),[hn,er]=h.useState(null),[ws,qr]=h.useState(null),[oi,Bs]=h.useState({}),K=h.useRef(oi);h.useEffect(()=>{K.current=oi},[oi]);const[ge,Re]=h.useState(!1),[Le,Ve]=h.useState(!1),[Zt,Ot]=h.useState({}),[mn,Yr]=h.useState({}),[os,Ws]=h.useState(null),[ur,wa]=h.useState(Rd),[Ju,jp]=h.useState(!1),[Ai,ba]=h.useState(!1),[gl,_r]=h.useState(""),[yl,xl]=h.useState(""),[Kt,yc]=h.useState(Dh),[Bt,wl]=h.useState(null),ro=h.useRef(0),ai=h.useRef(null),Do=h.useRef(null),Qu=h.useRef(!0),Fo=h.useRef(!1),[kr,bl]=h.useState(null),[li,Ii]=h.useState(null),[xc,zo]=h.useState(!1),[va,Ho]=h.useState(""),[vl,kl]=h.useState(!1),Zu=h.useRef(null),[ci,Lr]=h.useState(null),[ed,ui]=h.useState(!1),[ka,Bo]=h.useState(null),[bs,td]=h.useState(!1),[Gr,Sa]=h.useState(null),di=h.useRef(null),[vs,Ce]=h.useState(""),[ks,Na]=h.useState(0),[ja,fi]=h.useState(0),[Cp,nd]=h.useState("pan"),[Bn,so]=h.useState(!1),[$n,Ep]=h.useState(!1),rd=h.useRef(null),sd=h.useRef(null),Ca=h.useRef(null),[_p,Pp]=h.useState(0),[wt,id]=h.useState(null),[Ap,Sl]=h.useState(""),[vt,Ip]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[pi,Nl]=h.useState(""),[wc,hy]=h.useState(""),[hi,Tp]=h.useState([]),[dr,io]=h.useState([]),[od,Rp]=h.useState(!1),[jl,Lp]=h.useState([]),[ad,Vs]=h.useState(!1),[Op,Cl]=h.useState(()=>new Set),[Ti,ft]=h.useState(!1),Gt=h.useRef(null),bc=h.useRef(null),[my,ld]=h.useState({}),vc=h.useCallback(x=>{if(!x)return null;const N=x.id,B=x.source??"user",q=x.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${N}:${B}${q?":"+q:""}`,activeKey:`af:composer-active-session:${N}:${B}${q?":"+q:""}`}},[]),Mp=h.useCallback(x=>{if(!x)return"";const N=x.id,B=x.source??"user",q=x.archived?"archived":"";return`af:composer-skills:pipeline:${N}:${B}${q?":"+q:""}`},[]),$p=h.useCallback(x=>{const N=vc(x);if(!N)return{sessions:[],activeSessionId:null};try{const B=localStorage.getItem(N.sessionsKey);if(!B)return{sessions:[],activeSessionId:null};const q=JSON.parse(B);if(!Array.isArray(q))return{sessions:[],activeSessionId:null};const Y=q.filter(ee=>ee&&typeof ee.id=="string").map(ee=>({...ee,running:!1,statusLine:ee.running?e("flow:composer.pageRefreshReset"):ee.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(N.activeKey),J&&!Y.some(ee=>ee.id===J)&&(J=null)}catch{J=null}return{sessions:Y,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[vc]),kc=h.useCallback((x,N,B)=>{const q=vc(x);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(N)),B?localStorage.setItem(q.activeKey,B):localStorage.removeItem(q.activeKey)}catch{}},[vc]),Wo=h.useRef(0),El=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[as,Xr]=h.useState([]),[tr,oo]=h.useState(null),ao=h.useMemo(()=>Mp(u),[Mp,u]),[Sc,Vo]=h.useState(""),Wn=h.useMemo(()=>{if(!u)return null;const x=u.id,N=u.source??"user",B=u.archived?"archived":"";return`${x}:${N}${B?":"+B:""}`},[u]),Ea=h.useRef(!1);h.useEffect(()=>{if(!Wn){Xr([]),oo(null),El.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=El.current;if(x.flowKey===Wn)return;x.flowKey=Wn,Ea.current&&x.sessions.length>0&&kc(u,x.sessions,x.activeSessionId);const{sessions:N,activeSessionId:B}=$p(u);if(N.length===0){const q=`session-1-${Date.now()}`,Y={id:q,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};x.sessions=[Y],x.activeSessionId=q,Xr([Y]),oo(q)}else{const q=N[N.length-1];if(q&&(!q.thread||q.thread.length===0))Wo.current=Ox(N),x.sessions=N,x.activeSessionId=q.id,Xr(N),oo(q.id);else{const J=Ox(N)+1;Wo.current=J;const ee=`session-${J}-${Date.now()}`,te={id:ee,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},me=[...N,te];x.sessions=me,x.activeSessionId=ee,Xr(me),oo(ee)}}Ea.current=!0},[Wn,u,$p,kc]);const En=h.useMemo(()=>as.find(x=>x.id===tr)||null,[as,tr]),_n=(En==null?void 0:En.running)??!1,_l=(En==null?void 0:En.statusLine)??"",Uo=(En==null?void 0:En.segments)??[],lo=(En==null?void 0:En.thread)??[],cd=(En==null?void 0:En.steps)??[];En==null||En.outputDismissed;const jt=(En==null?void 0:En.phaseContext)??null,ud=h.useRef([]),[Nc,Ko]=h.useState(!1),Pl=h.useRef(null),Dp=h.useRef(null);h.useEffect(()=>{const x=Dp.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[lo,Uo]);const jc=h.useRef(null),Cc=h.useRef(!1),Al=h.useRef(null),Fp=h.useCallback(x=>{const N=++Wo.current,B=`session-${N}-${Date.now()}`,q={id:B,label:x||e("flow:composer.conversationLabel",{n:N}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Xr(Y=>[...Y,q]),oo(B),B},[]);h.useEffect(()=>{!u||!Ea.current||(El.current.sessions=as,El.current.activeSessionId=tr,kc(u,as,tr))},[as,tr,u,kc]),h.useEffect(()=>{Wo.current=Math.max(Wo.current,Ox(as))},[as]);const zp=h.useCallback(x=>{var N;jc.current===x&&((N=Pl.current)==null||N.abort()),Xr(B=>{const q=B.filter(J=>J.id!==x);if(B.some((J,ee)=>J.id===x&&B.findIndex(te=>te.id===tr)===ee)||tr===x){const J=q;J.length>0?oo(J[J.length-1].id):setTimeout(()=>{Wo.current=0;const ee=++Wo.current,te=`session-${ee}-${Date.now()}`,me={id:te,label:e("flow:composer.conversationLabel",{n:ee}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Xr(ye=>[...ye,me]),oo(te)},0)}return q})},[tr]),Jr=h.useCallback(x=>{Xr(N=>{const B=N.findIndex(J=>J.id===tr);if(B<0)return N;const q={...N[B]};x(q);const Y=[...N];return Y[B]=q,Y})},[tr]),Hp=h.useCallback(x=>{Jr(N=>{N.running=x})},[Jr]),Us=h.useCallback(x=>{Jr(N=>{N.statusLine=x})},[Jr]),Ks=h.useCallback(x=>{Jr(N=>{typeof x=="function"?N.segments=x(N.segments):N.segments=x})},[Jr]),Bp=h.useCallback(x=>{Jr(N=>{typeof x=="function"?N.thread=x(N.thread):N.thread=x})},[Jr]),mi=h.useCallback(x=>{Jr(N=>{typeof x=="function"?N.steps=x(N.steps):N.steps=x})},[Jr]),Wp=h.useCallback(x=>{Jr(N=>{N.outputDismissed=x})},[Jr]),Il=h.useCallback(x=>{Jr(N=>{N.phaseContext=typeof x=="function"?x(N.phaseContext):x})},[Jr]),qo=h.useCallback(x=>{oo(x),Xr(N=>{const B=N.findIndex(Y=>Y.id===x);if(B<0||!N[B].outputDismissed)return N;const q=[...N];return q[B]={...N[B],outputDismissed:!1},q})},[]);h.useEffect(()=>{ud.current=Uo},[Uo]);const nr=h.useRef({}),gi=h.useRef(!1),Ri=h.useRef(null),Ec=h.useRef(null),co=h.useRef(null),_a=h.useRef(!1),dd=h.useRef(0),Tl=h.useRef(""),[Et,kt,gy]=QA([]),[wn,Xt,yy]=ZA([]),qs=h.useRef(Et),Yo=h.useRef(wn),fd=h.useRef(null),_c=h.useRef(null),Vp=h.useRef(null),Rl=h.useRef(null),[an,Li]=h.useState(null),Up=h.useCallback(x=>{var N;nr.current=(N=x==null?void 0:x.extra)!=null&&N.instances&&typeof x.extra.instances=="object"?x.extra.instances:{},kt(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),Xt(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),Li(null)},[Xt,kt]),xy=h.useMemo(()=>({instances:nr.current}),[wn,Et]),{resetHistory:pd,undo:hd,redo:S}=OT({nodes:Et,edges:wn,extra:xy,enabled:!!u&&_a.current&&Pe==="edit",onRestore:Up}),I=h.useMemo(()=>Et.filter(x=>{var N;return(((N=x.data)==null?void 0:N.definitionId)||"").startsWith("provide_")}),[Et]),U=h.useMemo(()=>{var N;const x={};for(const B of Et){if(!((N=B.data)!=null&&N.inputs))continue;const q=B.data.inputs;for(let Y=0;Y<q.length;Y++){const J=q[Y];if(!(J!=null&&J.name))continue;const ee=wn.find(me=>me.target===B.id&&me.targetHandle===`input-${Y}`);if(!(ee!=null&&ee.source))continue;I.find(me=>me.id===ee.source)&&(x[ee.source]=J.name)}}return x},[Et,wn,I]),X=h.useMemo(()=>{if(Pe==="edit"||Ur.size===0)return null;const x=new Set(Ur);for(const N of wn)Ur.has(N.source)&&x.add(N.target),Ur.has(N.target)&&x.add(N.source);return x},[Pe,Ur,wn]),Q=h.useMemo(()=>Pe==="edit"?Et:Et.map(x=>{var N,B;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:Ur.has(x.id),nodeStatus:((N=Kr[x.id])==null?void 0:N.status)??null,nodeElapsed:((B=Kr[x.id])==null?void 0:B.elapsed)??null,isDim:X?!X.has(x.id):!1}}}),[Pe,Et,Ur,Kr,X]),se=h.useMemo(()=>X?wn.map(x=>{const N=Ur.has(x.source)||Ur.has(x.target),B=x.className?x.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",q=N?"af-flow-edge--focus":"af-flow-edge--dim";return{...x,className:(B?B+" ":"")+q}}):wn,[wn,Ur,X]);h.useEffect(()=>{if(!u){Yr({}),Ws(null),wa(Rd),yc(Dh),wl(null),_r(""),xl("");return}const x=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&x.set("archived","1"),fetch(`/api/flow/run-config?${x.toString()}`).then(N=>N.json()).then(N=>{Yr(N.presets||{}),Ws(N.activePreset||null)}).catch(()=>{Yr({}),Ws(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const re=h.useCallback(x=>{ro.current+=1,wa(x)},[]),ae=h.useCallback(async(x,N={})=>{if(!x)return;const B=!!N.quiet,q=!!N.force,Y=ro.current;B||(jp(!0),_r(""),xl(""));const J=new URLSearchParams({flowId:x.id,flowSource:x.source||"user"});x.archived&&J.set("archived","1");try{const ee=await fetch(`/api/flow/schedule?${J.toString()}`),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||`HTTP ${ee.status}`);if(!q&&ro.current!==Y)return;wa({...Rd,...te.schedule||{}}),yc(te.state&&typeof te.state=="object"?te.state:Dh),wl(te.status||null)}catch(ee){if(!q&&ro.current!==Y)return;wa(Rd),yc(Dh),wl(null),_r(String(ee.message||ee))}finally{jp(!1)}},[]);h.useEffect(()=>{if(!u)return;let x=!1;return(async()=>{await ae(u)})(),()=>{x=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,ae]),h.useEffect(()=>{var B,q,Y,J;if(!os||!mn[os]||I.length===0)return;const x=mn[os],N={};for(const ee of I){const te=U[ee.id];if(!te)continue;const me=((B=ee.data)==null?void 0:B.definitionId)||"",ye=x[ee.id]??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";me.startsWith("provide_file")?N[te]={type:"file",path:ye}:N[te]={type:"str",value:ye}}Object.keys(N).length>0&&Bs(N)},[os,mn,I,U]);const pe=h.useCallback(()=>{if(!Gr||!di.current)return;const x=di.current.value;kt(N=>N.map(B=>{var q,Y;return B.id!==Gr.instanceId?B:{...B,data:{...B.data,outputs:((Y=(q=B.data)==null?void 0:q.outputs)==null?void 0:Y.map((J,ee)=>ee===0?{...J,default:x}:J))||[{type:"text",name:"value",default:x}]}}})),Sa(null)},[Gr,kt]),le=h.useMemo(()=>{const x=Et.filter(N=>N.selected);return x.length===1?x[0]:null},[Et]),Ne=h.useMemo(()=>u?nK(Et,wn,e):[],[u,Et,wn,e]),ze=h.useMemo(()=>Ne.map(x=>x.key).join("|"),[Ne]),gt=h.useMemo(()=>Ne.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[Ne]);h.useLayoutEffect(()=>{ne(Ne.length>0&&!gt)},[ze,u==null?void 0:u.id,u==null?void 0:u.source,Ne.length,gt]),Ca.current=le,h.useEffect(()=>{qs.current=Et},[Et]),h.useEffect(()=>{const x=i.current,N=new Map,B=[];for(const ee of Et){const te=f7(ee);N.set(ee.id,te),x.get(ee.id)!==te&&B.push(ee.id)}if(i.current=N,B.length===0)return;const q=()=>B.forEach(ee=>{var te;return(te=s.current)==null?void 0:te.call(s,ee)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[Et]),h.useEffect(()=>{Yo.current=wn},[wn]),h.useEffect(()=>{Vp.current=an},[an]),h.useEffect(()=>{if(!an)return;const x=B=>{B.key==="Escape"&&Li(null)},N=B=>{var q,Y;(Y=(q=B.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Li(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",N)}},[an]),h.useEffect(()=>()=>{co.current!=null&&(clearTimeout(co.current),co.current=null)},[]);const qe=h.useMemo(()=>{var N;if(!le)return null;const x=(N=le.data)==null?void 0:N.definitionId;return oe.find(B=>B.id===x)??null},[le,oe]),At=h.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const N of oe){const B=I0(N);x[B].push(N)}for(const N of Ud)x[N].sort((B,q)=>B.id.localeCompare(q.id));return x},[oe]),bn=h.useMemo(()=>{const x=_e.trim().toLowerCase();if(!x)return At;const N={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const B of Ud)N[B]=At[B].filter(q=>l7(q,x));return N},[At,_e]),ls=h.useMemo(()=>Ud.reduce((x,N)=>x+bn[N].length,0),[bn]),nn=h.useMemo(()=>oe.filter(x=>{const N=String(x.id??""),B=String(x.source??"");return N.startsWith("marketplace:")||B==="marketplace"||B==="collection"}),[oe]),ln=h.useMemo(()=>{const x=new Set;for(const N of nn){const B=String(N.id??"");if(B&&(x.add(B),B.startsWith("marketplace:"))){const q=B.slice(12),[Y]=q.split("@");Y&&x.add(`marketplace:${Y}`)}}return x},[nn]),rr=h.useCallback(async()=>{f("");try{const x=await fetch("/api/flows");if(!x.ok)throw new Error("HTTP "+x.status);c(await x.json())}catch(x){f(String(x.message||x))}},[]);h.useEffect(()=>{rr()},[rr]),h.useEffect(()=>{if(r!=="/flow")return;const x=new URLSearchParams(window.location.search);x.get("new")==="1"&&!x.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{if(r!=="/flow"||!u)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&zt("settings")},[r,u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/model-lists").then(q=>q.json()).then(q=>{x||Ip({cursor:Array.isArray(q.cursor)?q.cursor.map(String):[],opencode:Array.isArray(q.opencode)?q.opencode.map(String):[],claudeCode:Array.isArray(q.claudeCode)?q.claudeCode.map(String):[]})}).catch(()=>{})};N();const B=setTimeout(N,4e3);return()=>{x=!0,clearTimeout(B)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skills").then(N=>N.json()).then(N=>{if(x)return;const B=Array.isArray(N.skills)?N.skills.filter(q=>q&&typeof q.key=="string"&&q.key.trim()).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):""})):[];Tp(B),Rp(!0)}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(N=>N.json()).then(N=>{x||(Lp(el(N)),Vs(!0))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{if(Vo(""),!(!od||!ad)){if(!ao){io([]);return}io(oP(ao,"pipeline",hi,jl)),Vo(ao)}},[jl,ad,hi,od,ao]),h.useEffect(()=>{if(!(Sc!==ao||!ao))try{localStorage.setItem(ao,JSON.stringify(dr))}catch{}},[dr,ao,Sc]);const It=h.useCallback(async x=>{const N=x.source??"user",B=!!x.archived,q=new URLSearchParams({flowId:x.id,flowSource:N});B&&q.set("archived","1");const Y=new URLSearchParams({flowId:x.id,flowSource:N});B&&Y.set("archived","1"),Y.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,ee]=await Promise.all([fetch("/api/flow?"+q.toString()),fetch("/api/nodes?"+Y.toString())]),te=await J.json();if(!J.ok||te.error)throw new Error(te.error||e("flow:nodePropsError.loadFlowFailed"));const me=await ee.json();if(!ee.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const ye=Array.isArray(me)?me:Array.isArray(me==null?void 0:me.nodes)?me.nodes:[],Fe=!Array.isArray(me)&&(me==null?void 0:me.pipelineTranslations)||{},de=ZU(te.flowYaml||"");if(de.error)throw new Error(de.error);const $e={...de.instances||{}},Se=de.nodes.map(kn=>Gf(kn,$e,ye,Fe,x.id)),xt=LT(de.edges,Se);return{flowSource:N,paletteList:ye,instances:$e,flowDescriptionText:de.description??"",viewport:m1(de.viewport),nodes:Se,edges:xt}},[t.language,e]),Dt=h.useCallback(async(x,N={})=>{const B=!!N.preserveComposer,q=B&&!!N.incrementalSync;_a.current=!1,dd.current+=1,p(x),k(""),B||(j(""),xe(""),zt(null),v(""),F(""),M(""),Ce(""),Bp([]),Ks([]),mi([]),Wp(!1),Il(null),nd("pan")),q||(nr.current={},kt([]),Xt([])),x1(x);try{const Y=await It(x);if(we(Y.paletteList),nr.current=Y.instances,v(Y.flowDescriptionText),F(x.id||""),q){const J=qs.current,ee=Yo.current;try{const te=A9(J,ee,Y.nodes,Y.edges),me=new Set([...te.changes.addedNodeIds,...te.changes.updatedNodeIds]),ye=new Set([...te.changes.addedEdgeKeys,...te.changes.updatedEdgeKeys]),Fe=me.size>0?te.nodes.map($e=>me.has($e.id)?{...$e,className:s1($e.className,n1)}:$e):te.nodes,de=ye.size>0?te.edges.map($e=>ye.has(Vf($e))?{...$e,className:s1($e.className,r1)}:$e):te.edges;kt(Fe),Xt(de),co.current!=null&&(clearTimeout(co.current),co.current=null),(me.size>0||ye.size>0)&&(co.current=window.setTimeout(()=>{co.current=null,me.size>0&&kt($e=>$e.map(Se=>{if(!me.has(Se.id))return Se;const xt=i1(Se.className,n1);return xt===String(Se.className||"")?Se:{...Se,className:xt}})),ye.size>0&&Xt($e=>$e.map(Se=>{if(!ye.has(Vf(Se)))return Se;const xt=i1(Se.className,r1);return xt===String(Se.className||"")?Se:{...Se,className:xt}}))},i7))}catch{kt(Y.nodes),Xt(Y.edges)}}else if(kt(Y.nodes),Xt(Y.edges),Ec.current=Y.viewport||null,Y.viewport){const J=()=>{var ee;try{(ee=Ri.current)==null||ee.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else g(J=>J+1);xh(x.id,Y.flowSource),Pp(J=>J+1),pd(Y.nodes,Y.edges,{instances:Y.instances});try{Tl.current=Fj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:Ec.current})}catch{Tl.current=""}_a.current=!0}catch(Y){k(String(Y.message||Y))}},[It,pd,kt,Xt]),Qe=h.useCallback(async()=>{if(!(u!=null&&u.id))return;const x=u.source??"user",N=new URLSearchParams({flowId:u.id,flowSource:x});u.archived&&N.set("archived","1"),N.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const B=await fetch("/api/nodes?"+N.toString()),q=await B.json();if(!B.ok)throw new Error((q==null?void 0:q.error)||e("flow:nodePropsError.loadNodesFailed"));const Y=Array.isArray(q)?q:Array.isArray(q==null?void 0:q.nodes)?q.nodes:[];we(Y)},[u,e,t.language]),Ct=h.useCallback(async()=>{ar(!0),fn("");try{const x=await fetch("/api/marketplace/nodes"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load marketplace nodes");dn(Array.isArray(N==null?void 0:N.nodes)?N.nodes:[])}catch(x){fn(String(x.message||x)),dn([])}finally{ar(!1)}},[]),Pr=h.useCallback(async()=>{He(!0),gn("");try{const x=await fetch("/api/marketplace/flow-snippets"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load flow snippets");Xe(Array.isArray(N==null?void 0:N.snippets)?N.snippets:[])}catch(x){gn(String(x.message||x)),Xe([])}finally{He(!1)}},[]);h.useEffect(()=>{u&&(Ct(),Pr())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Ct,Pr]);const Pa=h.useCallback(async x=>{if(!u||!x)return;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(N){lr(N),fn("");try{const B=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,nodeSpec:N})}),q=await B.json().catch(()=>({}));if(!B.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Failed to install marketplace node");await Qe()}catch(B){fn(String(B.message||B))}finally{lr("")}}},[u,Qe]),Ll=h.useCallback(async(x,N)=>{const B={packageId:(x==null?void 0:x.newId)||(x==null?void 0:x.id)||(x==null?void 0:x.label),label:(x==null?void 0:x.label)||(x==null?void 0:x.newId)||(x==null?void 0:x.id),version:"1.0.0",definitionId:N,body:(x==null?void 0:x.body)||"",script:(x==null?void 0:x.script)||"",inputs:Array.isArray(x==null?void 0:x.inputs)?x.inputs:[],outputs:Array.isArray(x==null?void 0:x.outputs)?x.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),Y=await q.json();if(!q.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Publish failed");return await Qe(),Y},[Qe,u]),ke=h.useCallback(async()=>{var q;if(!u||he.current)return;const x=u.id,N=u.source??"user",B=((q=Ca.current)==null?void 0:q.id)??null;he.current=!0,fe(!0);try{await Dt({id:x,source:N,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),B&&kt(Y=>Y.map(J=>({...J,selected:J.id===B})))}finally{he.current=!1,fe(!1)}},[u,u==null?void 0:u.archived,Dt,kt]);h.useEffect(()=>{if(gi.current||l.length===0)return;const x=new URLSearchParams(window.location.search),N=x.get("flowId");if(!N)return;const B=x.get("flowSource")??"user",q=x.get("flowArchived")==="1",Y=l.find(J=>J.id===N&&(J.source??"user")===B&&!!J.archived===q);Y&&(gi.current=!0,Dt(Y))},[l,Dt]);const pt=h.useRef(0);h.useEffect(()=>{if(!u)return;const x=u.id,N=u.source??"user",B=!!u.archived;pt.current=0;let q=!1;const Y=async()=>{var te;if(q)return;const ee=new URLSearchParams({flowId:x,flowSource:N,v:String(pt.current)});B&&ee.set("archived","1");try{const me=await fetch("/api/flow-editor-sync-poll?"+ee.toString());if(!me.ok||q)return;const ye=await me.json();if(q)return;if(ye.changed){pt.current=ye.version;const Fe=((te=Ca.current)==null?void 0:te.id)??null;await Dt({id:x,source:N,archived:B},{preserveComposer:!0,incrementalSync:!0}),await ae({id:x,source:N,archived:B},{quiet:!0,force:!0}),Fe&&kt(de=>de.map($e=>({...$e,selected:$e.id===Fe})))}else pt.current=ye.version}catch{}},J=window.setInterval(Y,2e3);return Y(),()=>{q=!0,window.clearInterval(J)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Dt,ae,kt]);const yt=h.useMemo(()=>w?w.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":w===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[w]);h.useEffect(()=>{if(!w)return;w===e("flow:status.saved")||w.startsWith(e("flow:status.runInTerminal"));const x=w.startsWith(e("flow:status.runInTerminal"))?5200:2800,N=window.setTimeout(()=>j(""),x);return()=>clearTimeout(N)},[w,e]),h.useEffect(()=>{E("")},[u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{const x=()=>{window.__provideEditContent&&(Sa(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),h.useEffect(()=>{var te,me,ye,Fe,de,$e,Se;if(!le){id(null);return}const x=nr.current[le.id]||{},{inputs:N,outputs:B}=RT(le),q=String(((te=le.data)==null?void 0:te.definitionId)??le.id??""),Y=((me=le.data)==null?void 0:me.script)!=null?String(le.data.script):void 0,J=x.script!=null?String(x.script):void 0,ee=q==="tool_nodejs"||Y&&Y.trim()!==""||J&&J.trim()!==""?String(Y??J??""):"";id({id:le.id,newId:le.id,label:String(((ye=le.data)==null?void 0:ye.label)??le.id),role:((Fe=le.data)==null?void 0:Fe.role)??"普通",model:String(((de=le.data)==null?void 0:de.model)??x.model??""),body:String((($e=le.data)==null?void 0:$e.body)??x.body??""),images:Is(((Se=le.data)==null?void 0:Se.images)??x.images),script:ee,inputs:N,outputs:B})},[le==null?void 0:le.id,_p]),h.useEffect(()=>{u&&(le||(sd.current=null,zt(x=>x==="node"?null:x)))},[u,le==null?void 0:le.id]);const rt=h.useCallback(()=>{sd.current=null,zt(x=>x==="settings"||x==="history"?x:"node")},[]),De=h.useCallback((x,N)=>{x.metaKey||x.ctrlKey||x.shiftKey||Pe!=="edit"&&qr((N==null?void 0:N.id)??null)},[Pe]),Mt=h.useCallback((x,N)=>{Pe==="edit"&&(x.preventDefault(),kt(B=>B.map(q=>({...q,selected:q.id===N.id}))),Xt(B=>B.map(q=>({...q,selected:!1}))),rt())},[rt,Pe,Xt,kt]),en=h.useCallback((x,N)=>{if(Pe!=="edit")return;const B=x.metaKey||x.ctrlKey||x.shiftKey;Xt(q=>q.map(Y=>Y.id===N.id?{...Y,selected:!Y.selected||!B}:B?Y:{...Y,selected:!1})),B||kt(q=>q.map(Y=>({...Y,selected:!1})))},[Pe,Xt,kt]),qt=h.useCallback(x=>u1(x,qs.current),[]),Pn=h.useCallback(x=>{if(!u1(x,qs.current)){j("端口类型不匹配,已取消连线");return}Li(null),kt(N=>ug(N,x)),Xt(N=>{const B=N.filter(q=>!(q.target===x.target&&q.targetHandle===x.targetHandle));return Hf({...x,markerEnd:{type:Ms.ArrowClosed}},B)})},[Xt,kt]),vn=h.useCallback((x,N)=>{_c.current=p7(N,qs.current),Li(null)},[]),Tt=h.useCallback((x,N)=>{var Se,xt,kn,Sn;const B=_c.current;if(_c.current=null,!u||!B||N!=null&&N.toNode)return;const q=m7(oe,B);if(q.length===0){j(`没有匹配 ${B.slotType} 端口的节点`);return}const Y=((xt=(Se=x==null?void 0:x.changedTouches)==null?void 0:Se[0])==null?void 0:xt.clientX)??(x==null?void 0:x.clientX),J=((Sn=(kn=x==null?void 0:x.changedTouches)==null?void 0:kn[0])==null?void 0:Sn.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const ee=Ri.current,te=document.querySelector(".af-pipeline-flow .react-flow");if(!ee||!te)return;const me=te.getBoundingClientRect(),ye=320,Fe=Math.min(440,104+q.length*58),de=Math.max(12,Math.min(Y-me.left,me.width-ye-12)),$e=Math.max(12,Math.min(J-me.top,me.height-Fe-12));Li({left:de,top:$e,flowPosition:ee.screenToFlowPosition({x:Y,y:J}),draft:B,candidates:q,query:""})},[oe,u]),cn=h.useCallback(x=>{for(const N of x)delete nr.current[N.id]},[]),cs=h.useCallback(x=>{Ri.current=x},[]),Oi=h.useCallback(x=>{kt(B=>B.map(q=>({...q,selected:q.id===x}))),Xt(B=>B.map(q=>({...q,selected:!1}))),rt();const N=()=>{var me,ye,Fe;const B=Ri.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(x);if(!q)return;const Y=(me=B.getInternalNode)==null?void 0:me.call(B,x),J=((ye=Y==null?void 0:Y.measured)==null?void 0:ye.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((Fe=Y==null?void 0:Y.measured)==null?void 0:Fe.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:te}=B.getViewport();B.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:h1(te),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(N))},[kt,Xt,rt]),uo=h.useCallback(x=>{kt(B=>B.map(q=>({...q,selected:q.id===x}))),Xt(B=>B.map(q=>({...q,selected:!1})));const N=()=>{var ye,Fe,de;const B=Ri.current;if(!(B!=null&&B.getNode))return;const q=B.getNode(x);if(!q)return;const Y=(ye=B.getInternalNode)==null?void 0:ye.call(B,x),J=((Fe=Y==null?void 0:Y.measured)==null?void 0:Fe.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((de=Y==null?void 0:Y.measured)==null?void 0:de.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:te}=B.getViewport(),me=h1(te);B.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:me,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(N))},[kt,Xt]),Ss=h.useCallback((x,N)=>{const B=`node-${Date.now()}`;return eR(x,B,N,nr.current,oe)},[oe]),Kp=h.useCallback(x=>{if(!u||!x)return;let N={x:180,y:160};const B=Ri.current,q=document.querySelector(".af-pipeline-flow .react-flow");if(B&&q){const Y=q.getBoundingClientRect();N=B.screenToFlowPosition({x:Y.left+Y.width*.45,y:Y.top+Y.height*.38})}kt(Y=>[...Y,Ss(x,N)])},[u,kt,Ss]),wy=h.useCallback(x=>{const N=Vp.current;if(!u||!N||!(x!=null&&x.def))return;const B=Ss(x.def,N.flowPosition),q=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:B.id,targetHandle:`input-${x.slotIndex}`}:{source:B.id,sourceHandle:`output-${x.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};kt(Y=>ug([...Y,B],q)),Xt(Y=>{const J=Y.filter(ee=>!(ee.target===q.target&&ee.targetHandle===q.targetHandle));return Hf({...q,markerEnd:{type:Ms.ArrowClosed}},J)}),Li(null)},[u,Ss,kt,Xt]),l2=h.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),c2=h.useCallback(x=>{var ee;if(x.preventDefault(),!u)return;const N=Ri.current;if(!N)return;const B=N.screenToFlowPosition({x:x.clientX,y:x.clientY}),q=x.dataTransfer.getData("application/agentflow-snippet");if(q){const te=ct.find(me=>`${me.id}@${me.version}`===q);te&&((ee=Rl.current)==null||ee.call(Rl,te,B));return}const Y=x.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=oe.find(te=>te.id===Y);J&&kt(te=>[...te,Ss(J,B)])},[u,oe,ct,kt,Ss]),yi=h.useCallback(async(x,N)=>{if(!u)return;const B=Fj(x,N,nr.current,{description:b,viewport:Ec.current});if(B!==Tl.current){j(e("flow:status.saving"));try{const q=R7(u.source),Y=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:q,flowYaml:B,...u.archived?{flowArchived:!0}:{}})}),J=await Y.json();if(!Y.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(Tl.current=B,j(e("flow:status.saved")),xi(u.source)&&q==="workspace"){const ee={id:u.id,source:"workspace",path:void 0};p(ee),x1(ee),xh(u.id,"workspace")}}catch(q){j(e("flow:status.saveFailed")+": "+(q.message||q))}}},[u,b]);h.useEffect(()=>{if(!u||!_a.current||Pe!=="edit"||u.archived)return;const x=dd.current,N=setTimeout(()=>{x===dd.current&&_a.current&&yi(qs.current,Yo.current)},400);return()=>clearTimeout(N)},[Et,wn,b,Pe,u,yi]);const qp=h.useCallback(async x=>{if(!u||u.archived)return;const N=u.source??"user";if(!(N!=="user"&&N!=="workspace")&&N!==x){H(!0),E("");try{const B=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:N,toSource:x})}),q=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof q.error=="string"?q.error:e("flow:composer.requestFailed"));const Y=q.flowSource==="workspace"||q.flowSource==="user"?q.flowSource:x;let J={id:u.id,source:Y,archived:u.archived};try{const ee=await fetch("/api/flows");if(ee.ok){const te=await ee.json(),me=Array.isArray(te)?te.find(ye=>ye.id===u.id&&(ye.source??"user")===Y&&!!ye.archived==!!u.archived):null;me&&(J=me)}}catch{}await Dt(J,{preserveComposer:!0}),xh(u.id,Y)}catch(B){E(String(B.message||B))}finally{H(!1)}}},[u,Dt]),by=h.useCallback(async()=>{if(u){ba(!0),_r(""),xl("");try{const x=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,schedule:ur})}),N=await x.json().catch(()=>({}));if(!x.ok||!N.success)throw new Error(N.error||"Failed to save schedule");wa({...Rd,...N.schedule||{}}),xl(e("flow:schedule.saved")),await ae(u,{quiet:!0,force:!0})}catch(x){_r(String(x.message||x))}finally{ba(!1)}}},[u,ur,ae,e]),u2=h.useCallback(async()=>{u&&(await yi(qs.current,Yo.current),!u.archived&&u.source!=="builtin"&&await by())},[u,yi,by]),Yp=h.useCallback(async()=>{if(!u||!L.trim())return;const x=L.trim();if(x===u.id){M("");return}R(!0),M("");try{const N=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:x})}),B=await N.json().catch(()=>({}));if(!N.ok)throw new Error(typeof B.error=="string"?B.error:e("flow:composer.requestFailed"));let q={id:B.flowId,source:B.flowSource??u.source,archived:u.archived};try{const Y=await fetch("/api/flows");if(Y.ok){const J=await Y.json(),ee=Array.isArray(J)?J.find(te=>te.id===B.flowId&&(te.source??"user")===(B.flowSource??u.source)):null;ee&&(q=ee)}}catch{}await Dt(q,{preserveComposer:!0}),xh(B.flowId,B.flowSource??u.source)}catch(N){M(String(N.message||N))}finally{R(!1)}},[u,L,Dt]),G0=h.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{T(!0),setTimeout(()=>T(!1),2e3)}).catch(()=>{})},[]),vy=h.useCallback(()=>{yi(Et,wn)},[yi,Et,wn]),X0=h.useCallback(()=>{var N,B;if(!u)return;const x=m1((B=(N=Ri.current)==null?void 0:N.getViewport)==null?void 0:B.call(N));x&&(Ec.current=x,j("已固定 Pipeline 进入视角"),yi(qs.current,Yo.current))},[yi,u]),d2=h.useCallback((x,N)=>{const B=N.trim()===""||N==="default"?void 0:N.trim(),q=Et.map(Y=>Y.id===x?{...Y,data:{...Y.data,model:B}}:Y);kt(q),yi(q,wn)},[Et,wn,kt,yi]),Gp=h.useCallback(()=>{var xt,kn;if(!wt||!u||!le)return!1;const x=le.id,N=wt.newId.trim();if(Sl(""),!KT.test(N))return Sl(e("flow:nodePropsError.invalidInstanceId")),!1;if(Et.some(Sn=>Sn.id===N&&Sn.id!==x))return Sl(e("flow:nodePropsError.duplicateInstanceId")),!1;const B=wt.role.trim(),q=ll.includes(B)?B:"普通",Y=wt.model.trim(),J=Sn=>(Array.isArray(Sn)?Sn:[]).map(Wt=>({type:String((Wt==null?void 0:Wt.type)??"节点").trim()||"节点",name:String((Wt==null?void 0:Wt.name)??""),default:String((Wt==null?void 0:Wt.default)??""),required:!!(Wt!=null&&Wt.required),showOnNode:(Wt==null?void 0:Wt.showOnNode)!=null?Wt.showOnNode!==!1:!!(Wt!=null&&Wt.required)||String((Wt==null?void 0:Wt.type)??"节点").trim().toLowerCase()==="node"})),ee=J(wt.inputs),te=J(wt.outputs),me=String(((xt=le.data)==null?void 0:xt.definitionId)??N),ye=me.startsWith("provide_"),Fe={...le.data,label:wt.label.trim()||N,role:q,model:Y===""||Y==="default"?void 0:Y,body:ye?"":wt.body,images:ye?[]:Is(wt.images),inputs:ee,outputs:ye&&Array.isArray((kn=le.data)==null?void 0:kn.outputs)?le.data.outputs:te},de=String(wt.script??"").trim();me==="tool_nodejs"||de!==""?Fe.script=String(wt.script??""):delete Fe.script;let $e,Se=wn;if(N!==x){const Sn={...nr.current},Wt={...Sn[x]||{}};delete Sn[x],Sn[N]=Wt,nr.current=Sn,$e=Et.map(St=>St.id!==x?St:{...St,id:N,selected:!0,data:Fe}),Se=wn.map((St,Jt)=>({...St,source:St.source===x?N:St.source,target:St.target===x?N:St.target,id:`e-${St.source===x?N:St.source}-${St.target===x?N:St.target}-${Jt}`}))}else $e=Et.map(Sn=>Sn.id===x?{...Sn,data:Fe}:Sn);return kt($e),Xt(Se),is(N),yi($e,Se),!0},[wt,u,le,Et,wn,kt,Xt,is,yi]),ky=h.useCallback(()=>{var kn,Sn;if(!wt||!u||!le)return!1;const x=le.id,N=wt.role.trim(),B=ll.includes(N)?N:"普通",q=wt.model.trim(),Y=Wt=>(Array.isArray(Wt)?Wt:[]).map(St=>({type:String((St==null?void 0:St.type)??"节点").trim()||"节点",name:String((St==null?void 0:St.name)??""),default:String((St==null?void 0:St.default)??""),required:!!(St!=null&&St.required),showOnNode:(St==null?void 0:St.showOnNode)!=null?St.showOnNode!==!1:!!(St!=null&&St.required)||String((St==null?void 0:St.type)??"节点").trim().toLowerCase()==="node"})),J=Y(wt.inputs),ee=Y(wt.outputs),te=String(((kn=le.data)==null?void 0:kn.definitionId)??x),me=te.startsWith("provide_"),ye=wt.label.trim()||x,Fe=q===""||q==="default"?void 0:q,de={...le.data,label:ye,role:B,model:Fe,body:me?"":wt.body,images:me?[]:Is(wt.images),inputs:J,outputs:me&&Array.isArray((Sn=le.data)==null?void 0:Sn.outputs)?le.data.outputs:ee},$e=String(wt.script??"").trim();te==="tool_nodejs"||$e!==""?de.script=String(wt.script??""):delete de.script;const Se=le.data||{};return(Se.label!==de.label||Se.role!==de.role||Se.model!==de.model||Se.body!==de.body||JSON.stringify(Is(Se.images))!==JSON.stringify(de.images)||(Se.script??void 0)!==(de.script??void 0)||JSON.stringify(Se.inputs||[])!==JSON.stringify(J)||JSON.stringify(Se.outputs||[])!==JSON.stringify(ee))&&(kt(Wt=>Wt.map(St=>St.id===x?{...St,data:de}:St)),is(x)),!0},[wt,u,le,kt,is]),J0=h.useRef(ky);h.useEffect(()=>{J0.current=ky},[ky]),h.useEffect(()=>{if(!wt||!u||!_a.current||Pe!=="edit")return;const x=setTimeout(()=>{J0.current()},400);return()=>clearTimeout(x)},[wt,u,Pe]);const f2=h.useCallback(()=>{if(!(!wt||!le)){if(wt.newId.trim()===le.id){Sl("");return}Gp()}},[wt,le,Gp]);h.useEffect(()=>{const x=N=>{var ee,te,me;if(Pe!=="edit")return;const B=DT(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){if(tt==="node"&&le&&wt){N.preventDefault(),N.stopPropagation(),Gp()||vy();return}if(B)return;N.preventDefault(),N.stopPropagation(),vy();return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),Ep(ye=>!ye);return}if($n)return;if(Bn){if(N.key==="Escape"){N.preventDefault(),so(!1);return}if(fg(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),so(!1);return}(N.key==="v"||N.key==="V"||N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&N.preventDefault();return}if(B)return;const q=N.key.toLowerCase(),Y=(N.metaKey||N.ctrlKey)&&!N.shiftKey&&q==="z",J=(N.metaKey||N.ctrlKey)&&(N.shiftKey&&q==="z"||q==="y");if(Y||J){N.preventDefault(),N.stopPropagation();const ye=Y?hd():S();j(ye?Y?"Undo canvas change":"Redo canvas change":Y?"Nothing to undo":"Nothing to redo");return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="c"){const ye=PT(qs.current,Yo.current,nr.current);ye&&(N.preventDefault(),N.stopPropagation(),fd.current=ye,j(`Copied ${ye.nodes.length} node${ye.nodes.length>1?"s":""}`));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="v"){const ye=AT(fd.current,qs.current,Yo.current,nr.current);ye&&(N.preventDefault(),N.stopPropagation(),nr.current=ye.instances,kt(ye.nodes),Xt(ye.edges),j(`Pasted ${ye.pastedNodeIds.length} node${ye.pastedNodeIds.length>1?"s":""}`));return}if((N.key==="a"||N.key==="A")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),(ee=et.current)==null||ee.focus(),(me=(te=et.current)==null?void 0:te.select)==null||me.call(te);return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="a"){N.preventDefault(),N.stopPropagation(),kt(ye=>ye.map(Fe=>({...Fe,selected:!0}))),Xt(ye=>ye.map(Fe=>({...Fe,selected:!1})));return}if(fg(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),so(ye=>!ye);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),nd("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),nd("pan");return}if((N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),X0();return}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[vy,X0,Bn,$n,tt,le,wt,Gp,Pe,hd,S]),h.useEffect(()=>{if(Pe!=="running"||ut==null)return;let x=Math.floor((Date.now()-ut)/1e3);const N=setInterval(()=>{const B=Date.now()-ut,q=Math.floor(B/1e3);q!==x&&(x=q,Er(B))},500);return()=>clearInterval(N)},[Pe,ut]),h.useEffect(()=>{const x=Do.current;!x||!x.parentElement||Qu.current&&(Fo.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[mr]),h.useEffect(()=>{const x=Do.current;if(!x)return;const N=x.parentElement;if(!N)return;const B=()=>{if(Fo.current)return;const q=N.scrollHeight-N.scrollTop-N.clientHeight;Qu.current=q<40};return N.addEventListener("scroll",B,{passive:!0}),()=>N.removeEventListener("scroll",B)},[Ze,Pe]),h.useEffect(()=>{if(Pe==="edit"||!Ze)return;Qu.current=!0;const x=Do.current;x&&(Fo.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Fo.current=!1}))},[Pe,Ze]),h.useEffect(()=>{mr.length>pm+g1&&ht(x=>x.length>pm+g1?x.slice(-pm):x)},[mr]);const p2=h.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const N=x.currentTarget;Pi.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:vr},N.setPointerCapture(x.pointerId)},[vr]),h2=h.useCallback(x=>{const N=Pi.current;if(!N.active||x.pointerId!==N.pointerId)return;const B=N.startY-x.clientY;$o(hm(N.startH+B))},[]),Xp=h.useCallback(()=>{$o(x=>{const N=hm(x);try{localStorage.setItem(nR,String(N))}catch{}return N})},[]),Q0=h.useCallback(x=>{const N=Pi.current;if(!(!N.active||x.pointerId!==N.pointerId)){N.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}Xp()}},[Xp]),m2=h.useCallback(()=>{const x=Pi.current;x.active&&(x.active=!1,Xp())},[Xp]);h.useEffect(()=>{function x(){$o(N=>hm(N))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const fo=h.useCallback(async(x={})=>{if(!u)return;const N=x.runUuid!=null&&String(x.runUuid).trim()?String(x.runUuid).trim():null,B=x.cliInputsOverride??K.current,q=!!x.prepareOnly;if(sn(q?"ready":"running"),ht(q?[]:[{ts:new Date().toISOString(),type:"info",text:N?e("flow:run.connectingApiResume",{uuid:N}):e("flow:run.connectingApi")}]),Gn(new Set),Cr({}),gr(!q),zt(null),N||er(null),q)return;if(!N){const J=Date.now();Ut(J),Er(0)}const Y=new AbortController;ai.current=Y;try{const J=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",...N?{uuid:N}:{},cliInputs:B}),signal:Y.signal});if(!J.ok){const de=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));ht($e=>[...$e,{ts:new Date().toISOString(),type:"error",text:de.error||e("flow:composer.requestFailed")}]),sn("error");return}if(ht(de=>[...de,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){ht(de=>[...de,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),sn("error");return}const ee=J.body.getReader(),te=new TextDecoder;let me="";const ye=de=>{const $e=de.ts||new Date().toISOString();if(de.type==="event")if(de.event==="node-start")Gn(Se=>new Set(Se).add(de.instanceId)),Cr(Se=>({...Se,[de.instanceId]:{status:"running",startMs:Date.now()}})),ht(Se=>[...Se,{ts:$e,type:"node-start",text:de.label?e("flow:run.nodeStartWithLabel",{instanceId:de.instanceId,label:de.label}):e("flow:run.nodeStart",{instanceId:de.instanceId})}]);else if(de.event==="node-done"){Gn(xt=>{const kn=new Set(xt);return kn.delete(de.instanceId),kn});const Se=de.elapsed??null;Cr(xt=>({...xt,[de.instanceId]:{status:"success",elapsed:Se}})),ht(xt=>[...xt,{ts:$e,type:"node-done",text:Se?e("flow:run.nodeDoneWithElapsed",{instanceId:de.instanceId,elapsed:Se}):e("flow:run.nodeDone",{instanceId:de.instanceId})}])}else if(de.event==="node-failed")Gn(Se=>{const xt=new Set(Se);return xt.delete(de.instanceId),xt}),Cr(Se=>({...Se,[de.instanceId]:{status:"failed",elapsed:de.elapsed??null}})),ht(Se=>[...Se,{ts:$e,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:de.instanceId})}]);else if(de.event==="apply-start"){if(de.uuid&&er(String(de.uuid)),typeof de.runStartTime=="number"&&de.runStartTime>0)Ut(de.runStartTime),Er(Math.max(0,Date.now()-de.runStartTime));else if(typeof de.totalExecutedMs=="number"&&de.totalExecutedMs>0){const Se=Date.now()-de.totalExecutedMs;Ut(Se),Er(de.totalExecutedMs)}ht(Se=>[...Se,{ts:$e,type:"info",text:e("flow:run.pipelineStart",{uuid:de.uuid||"?"})}])}else de.event==="apply-done"?ht(Se=>[...Se,{ts:$e,type:"info",text:de.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:de.totalElapsed}):e("flow:run.pipelineDone")}]):de.event==="apply-paused"?ht(Se=>[...Se,{ts:$e,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(de.pendingNodes||[]).join(", ")})}]):ht(Se=>[...Se,{ts:$e,type:"event",text:`[${de.event}] ${JSON.stringify(de)}`}]);else de.type==="user-check-content"?(bl({instanceId:de.instanceId,execId:de.execId??1,inputPath:de.inputPath,outputPath:de.outputPath,content:de.content||""}),Ii(de.content||""),zo(!1),Ho(""),kl(!1),ht(Se=>[...Se,{ts:$e,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:de.instanceId})}])):de.type==="user-ask-prompt"?(Lr({instanceId:de.instanceId,execId:de.execId??1,question:de.question||"",options:Array.isArray(de.options)?de.options:[]}),ui(!1),ht(Se=>[...Se,{ts:$e,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:de.instanceId,defaultValue:`等待用户选择 (${de.instanceId})`})}])):de.type==="tool-print-content"?(Bo({instanceId:de.instanceId,execId:de.execId??1,content:de.content||"",createdAt:Date.now()}),td(!1)):de.type==="log"?ht(Se=>[...Se,{ts:$e,type:"log",text:de.text!=null?String(de.text):""}]):de.type==="error"?ht(Se=>[...Se,{ts:$e,type:"error",text:de.message||e("flow:run.unknownError")}]):de.type==="done"?ht(Se=>[...Se,{ts:$e,type:"done",text:e("flow:run.executionEnd",{exitCode:de.exitCode??"?"})}]):ht(Se=>[...Se,{ts:$e,type:"log",text:JSON.stringify(de)}])},Fe=de=>{if(de.trim())try{ye(JSON.parse(de))}catch{ht($e=>[...$e,{ts:new Date().toISOString(),type:"log",text:de}])}};for(;;){const{done:de,value:$e}=await ee.read();me+=te.decode($e??new Uint8Array,{stream:!de});const Se=me.split(`
133
- `);me=Se.pop()??"";for(const xt of Se)Fe(xt);if(de)break}me.trim()&&Fe(me),sn("done")}catch(J){J.name==="AbortError"?(ht(ee=>[...ee,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),sn("stopped")):(ht(ee=>[...ee,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),sn("error"))}finally{ai.current=null,Gn(new Set)}},[u]),[g2,Sy]=h.useState(!1),y2=h.useCallback(()=>{Sy(!0)},[]),x2=h.useCallback(async()=>{if(Sy(!1),ai.current&&(ai.current.abort(),ai.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}sn("stopped"),Gn(new Set)},[u]),Ol=h.useCallback(()=>{sn("edit"),Gn(new Set),Cr({}),qr(null),er(null)},[]),[w2,Jp]=h.useState(!1),b2=h.useCallback(async()=>{if(Jp(!1),ai.current&&(ai.current.abort(),ai.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Ol()},[u,Ol]),v2=h.useCallback(()=>{Jp(!1),n("/projects")},[n]),k2=h.useCallback(x=>{const N=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,B=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;er(N);const q=x.status||"unknown";let Y="stopped";q==="success"?Y="done":q==="failed"?Y="error":q==="running"?Y="running":Y="stopped",sn(Y);const J=typeof x.at=="number"?x.at:null;if(Y==="running"&&J!=null?(Ut(J),Er(Math.max(0,Date.now()-J))):J!=null&&typeof x.endedAt=="number"&&x.endedAt>J?(Ut(null),Er(x.endedAt-J)):(Ut(null),Er(Math.max(0,x.durationMs??0))),ht([]),Gn(new Set),Cr({}),qr(null),zt(null),gr(!1),N&&B){const ee=new URLSearchParams({flowId:B,runId:N});fetch(`/api/run-node-statuses?${ee}`).then(te=>te.json()).then(te=>{const me=te.statuses&&typeof te.statuses=="object"?te.statuses:{},ye={};for(const[Fe,de]of Object.entries(me))de&&typeof de=="object"&&typeof de.status=="string"&&(ye[Fe]={status:de.status,...de.elapsed!=null&&String(de.elapsed).trim()!==""?{elapsed:String(de.elapsed)}:{}});Cr(ye)}).catch(()=>{})}},[u==null?void 0:u.id]);h.useEffect(()=>{if(!(u!=null&&u.id)||Pe!=="edit")return;let x=!1;return(async()=>{try{const N=await fetch("/api/pipeline-recent-runs"),B=await N.json();if(x||!N.ok)return;const Y=(Array.isArray(B.runs)?B.runs:[]).find(te=>te.flowId===u.id&&te.status==="running");if(!Y||x)return;const J=Y.runId||null;er(J),sn("running"),gr(!0),Ut(Y.at||Date.now()),Oe.current=0;const ee=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const te=new URLSearchParams({flowId:u.id,runId:J}),ye=await(await fetch(`/api/run-node-statuses?${te}`)).json();if(x)return;const Fe=ye.statuses&&typeof ye.statuses=="object"?ye.statuses:{},de={},$e=new Set;for(const[Se,xt]of Object.entries(Fe))xt&&typeof xt=="object"&&typeof xt.status=="string"&&(de[Se]={status:xt.status,...xt.elapsed!=null&&String(xt.elapsed).trim()!==""?{elapsed:String(xt.elapsed)}:{}},xt.status==="running"&&$e.add(Se));Cr(de),Gn($e);try{const Se=new URLSearchParams({flowId:u.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),xt=await fetch(`/api/run-log?${Se}`);if(xt.ok){const kn=await xt.json();if(!x){Oe.current=Number(kn.bytes||0);const Sn=y1(typeof kn.text=="string"?kn.text:"");ht([...Sn,...ee]);return}}}catch{}}ht(ee)}catch{}})(),()=>{x=!0}},[u==null?void 0:u.id]),h.useEffect(()=>{if(Pe==="edit"||!(u!=null&&u.id)||!hn)return;let x=!1,N=null;const B=async()=>{try{const q=new URLSearchParams({flowId:u.id,runId:hn}),Y=await fetch(`/api/run-node-statuses?${q}`);if(!Y.ok)return;const J=await Y.json();if(x)return;const ee=J.statuses&&typeof J.statuses=="object"?J.statuses:{},te={},me=new Set;for(const[ye,Fe]of Object.entries(ee))Fe&&typeof Fe=="object"&&typeof Fe.status=="string"&&(te[ye]={status:Fe.status,...Fe.elapsed!=null&&String(Fe.elapsed).trim()!==""?{elapsed:String(Fe.elapsed)}:{}},Fe.status==="running"&&me.add(ye));Cr(ye=>A7(ye,te)?ye:te),Gn(ye=>I7(ye,me)?ye:me);try{const ye=new URLSearchParams({flowId:u.id,runId:hn,sinceBytes:String(Oe.current||0),tailBytes:String(C7)}),Fe=await fetch(`/api/run-log?${ye}`);if(Fe.ok){const de=await Fe.json();if(x)return;const $e=Number(de.bytes||0),Se=typeof de.text=="string"?de.text:"";if(Se){const xt=y1(Se);xt.length>0&&ht(kn=>[...kn,...xt])}Oe.current=$e}}catch{}try{const ye=await fetch("/api/pipeline-recent-runs");if(!ye.ok)return;const Fe=await ye.json();if(x)return;const $e=(Array.isArray(Fe.runs)?Fe.runs:[]).find(Se=>Se.flowId===u.id&&Se.runId===hn);if($e&&$e.status){const Se=$e.status;Se==="running"?sn(xt=>xt==="running"?xt:"running"):Se==="success"?sn("done"):Se==="failed"?sn("error"):(Se==="stopped"||Se==="interrupted")&&sn("stopped")}}catch{}}catch{}};return B(),N=window.setInterval(B,2500),()=>{x=!0,N&&window.clearInterval(N)}},[Pe,u==null?void 0:u.id,hn]),h.useEffect(()=>{if(tt!=="history"||!u)return;let x=!1;return(async()=>{cr(!0),Ht("");try{const N=await fetch("/api/pipeline-recent-runs"),B=await N.json();if(!N.ok)throw new Error(B.error||"HTTP "+N.status);x||Ie(Array.isArray(B.runs)?B.runs:[])}catch(N){x||(Ht(String(N.message||N)),Ie([]))}finally{x||cr(!1)}})(),()=>{x=!0}},[tt,u]),h.useEffect(()=>{if(!u){it({files:[]});return}let x=!1;return(async()=>{_i(!0);try{const N=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),B=await fetch(`/api/pipeline-files?${N}`),q=await B.json();if(!B.ok)throw new Error(q.error||"HTTP "+B.status);x||it({files:Array.isArray(q.files)?q.files:[],path:q.path,error:q.error})}catch(N){x||it({files:[],error:N.message||String(N)})}finally{x||_i(!1)}})(),()=>{x=!0}},[u]);const md=h.useMemo(()=>u?ie.filter(x=>x&&x.flowId===u.id).sort((x,N)=>N.at-x.at):[],[ie,u]),us=h.useMemo(()=>{let x=0,N=0,B=0,q=0,Y=0;for(const J of md){const ee=J.status||"unknown";ee==="success"?x+=1:ee==="failed"?N+=1:ee==="running"?B+=1:ee==="stopped"?q+=1:ee==="interrupted"&&(Y+=1)}return{success:x,failed:N,running:B,stopped:q,interrupted:Y}},[md]),gd=h.useMemo(()=>u?d1(vs,ks):null,[u,vs,ks]),Mi=h.useMemo(()=>{if(!gd||!u)return[];const x=gd.query.toLowerCase(),N=Y=>x?Y.some(J=>J&&String(J).toLowerCase().includes(x)):!0,B=Et.map(Y=>{var ye,Fe;const J=Y.id,ee=String(((ye=Y.data)==null?void 0:ye.label)??J),te=(Fe=Y.data)!=null&&Fe.definitionId?String(Y.data.definitionId):"",me=[ee!==J?ee:"",te&&te!==J?te:""].filter(Boolean);return{id:J,label:ee,defId:te,subs:me}}).filter(({id:Y,label:J,defId:ee})=>N([Y,J,ee])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,18).map(({id:Y,label:J,defId:ee})=>{const te=[J!==Y?J:null,ee||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:Y,title:Y,subtitle:te}}),q=oe.filter(Y=>Y&&Y.id&&N([Y.id,Y.label,Y.description])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,22).map(Y=>({kind:"definition",id:Y.id,title:Y.id,subtitle:Y.label&&Y.label!==Y.id?String(Y.label):String(Y.type||"")}));return[...B,...q]},[gd,Et,oe,u]),yd=h.useMemo(()=>{const x=Mi.filter(B=>B.kind==="instance"),N=Mi.filter(B=>B.kind==="definition");return{instances:x,definitions:N}},[Mi]);h.useEffect(()=>{fi(x=>{const N=Math.max(0,Mi.length-1);return Math.min(Math.max(0,x),N)})},[Mi]);const Z0=h.useMemo(()=>y7(vs),[vs]),Or=h.useMemo(()=>Et.filter(x=>x.selected),[Et]),Ny=h.useMemo(()=>new Set(Or.map(x=>x.id)),[Or]),Qp=h.useMemo(()=>wn.filter(x=>Ny.has(x.source)&&Ny.has(x.target)),[wn,Ny]),ek=h.useMemo(()=>{const x=_e.trim().toLowerCase();return x?ct.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(B=>String(B).toLowerCase().includes(x))):ct},[ct,_e]),tk=h.useCallback((x,N)=>{const B=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",q=Date.now().toString(36);let Y=`${B}-${q}`,J=2;for(;N.has(Y);)Y=`${B}-${q}-${J}`,J+=1;return N.add(Y),Y},[]),nk=h.useCallback((x,N)=>{var Jt,ds;if(!u||!x)return;const B=x.snippet&&typeof x.snippet=="object"?x.snippet:{},q=B.instances&&typeof B.instances=="object"?B.instances:{},Y=Object.keys(q);if(Y.length===0)return;const J=new Set(qs.current.map(Ye=>Ye.id)),ee={};for(const Ye of Y)ee[Ye]=tk(Ye,J);const te=(Jt=B.ui)!=null&&Jt.nodePositions&&typeof B.ui.nodePositions=="object"?B.ui.nodePositions:{},me=(ds=B.ui)!=null&&ds.nodeSizes&&typeof B.ui.nodeSizes=="object"?B.ui.nodeSizes:{},ye=Y.map(Ye=>{const Nn=te[Ye];return{id:Ye,x:typeof(Nn==null?void 0:Nn.x)=="number"?Nn.x:0,y:typeof(Nn==null?void 0:Nn.y)=="number"?Nn.y:0}}),Fe=Math.min(...ye.map(Ye=>Ye.x)),de=Math.min(...ye.map(Ye=>Ye.y));let $e=N||{x:180,y:160};const Se=Ri.current,xt=document.querySelector(".af-pipeline-flow .react-flow");if(!N&&Se&&xt){const Ye=xt.getBoundingClientRect();$e=Se.screenToFlowPosition({x:Ye.left+Ye.width*.48,y:Ye.top+Ye.height*.32})}const kn={};for(const Ye of Y)kn[ee[Ye]]={...q[Ye]||{}};nr.current={...nr.current,...kn};const Sn=Y.map(Ye=>{const Nn=q[Ye]||{},po=ye.find(wd=>wd.id===Ye)||{x:0,y:0},$i=me[Ye]&&typeof me[Ye].width=="number"&&typeof me[Ye].height=="number"?{width:me[Ye].width,height:me[Ye].height}:null,$l={id:ee[Ye],type:"flowNode",selected:!0,position:{x:$e.x+(po.x-Fe),y:$e.y+(po.y-de)},...$i?{width:$i.width,height:$i.height}:{},data:{label:Nn.label||ee[Ye],definitionId:Nn.definitionId||Ye,role:Nn.role||"normal",body:Nn.body||"",script:Nn.script||"",...$i?{displaySize:$i}:{}}};return Gf($l,nr.current,oe,{},u.id)}),Wt=new Set(Y),St=(Array.isArray(B.edges)?B.edges:[]).filter(Ye=>Wt.has(Ye==null?void 0:Ye.source)&&Wt.has(Ye==null?void 0:Ye.target)).map((Ye,Nn)=>({id:`e-${ee[Ye.source]}-${ee[Ye.target]}-${Date.now()}-${Nn}`,source:ee[Ye.source],target:ee[Ye.target],sourceHandle:Ye.sourceHandle??void 0,targetHandle:Ye.targetHandle??void 0,markerEnd:{type:Ms.ArrowClosed}}));kt(Ye=>[...Ye.map(Nn=>({...Nn,selected:!1})),...Sn]),Xt(Ye=>[...Ye.map(Nn=>({...Nn,selected:!1})),...St]),j(`已添加流程片段:${x.displayName||x.id}`)},[tk,oe,u,Xt,kt]);Rl.current=nk;const S2=h.useCallback(()=>{var B,q;if(Or.length<2){gn("请先在画布上选择至少两个节点。"),Ae("flows");return}const x=Or[0],N=Or.length===2?`${((B=x.data)==null?void 0:B.label)||x.id} 片段`:`${((q=x.data)==null?void 0:q.label)||x.id} 等 ${Or.length} 个节点`;Yn({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Be(""),On(!0),Ae("flows")},[Or]),N2=h.useCallback(async()=>{var J,ee;if(!u||Or.length<2)return;const x=rn.name.trim();if(!x){Be("请填写片段名称。");return}const N=xp(Or,nr.current),B={},q={};for(const te of Or){B[te.id]={x:((J=te.position)==null?void 0:J.x)||0,y:((ee=te.position)==null?void 0:ee.y)||0};const me=L7(te);me&&(q[te.id]=me)}const Y=Qp.map(te=>({source:te.source,target:te.target,sourceHandle:te.sourceHandle??null,targetHandle:te.targetHandle??null}));ue(!0),Be("");try{const te=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:rn.id,name:x,displayName:x,version:"1.0.0",description:rn.description,snippet:{instances:N,edges:Y,ui:{nodePositions:B,nodeSizes:q}}})}),me=await te.json().catch(()=>({}));if(!te.ok||(me==null?void 0:me.ok)===!1)throw new Error((me==null?void 0:me.error)||"Publish failed");On(!1),j(`流程片段已发布:${me.id||x}`),zs(`流程片段已发布:${me.id||x}`),await Pr(),Ae("flows")}catch(te){Be(String(te.message||te))}finally{ue(!1)}},[u,Or,Qp,rn,Pr,zs]),Zp=h.useMemo(()=>{const x=[],N=new Set;for(const Y of Or)N.add(Y.id),x.push({node:Y,kind:"canvas"});const B=new Map(Et.map(Y=>[Y.id,Y])),q=new Map(oe.map(Y=>[Y.id,Y]));for(const Y of Z0){if(N.has(Y))continue;const J=B.get(Y);if(J){N.add(Y),x.push({node:J,kind:"mention"});continue}const ee=q.get(Y);ee&&(N.add(Y),x.push({definition:ee,kind:"definition"}))}return x},[Or,Z0,Et,oe]),Ns=h.useMemo(()=>{const x=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],N=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],B=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[],q=N.map(ye=>`opencode:${Zo(ye)}`),Y=B.map(ye=>`claude-code:${Zo(ye)}`),J=new Set([...x,...N,...B].map(Zo).concat(q).concat(Y)),ee=(pi||"").trim(),te=$h(pi,x,N,B),me=te&&!J.has(te)&&!J.has(ee)?ee:"";return{cursorList:x,opencodeList:N,claudeCodeList:B,currentNotInLists:me}},[vt,pi]),jy=h.useMemo(()=>new Set(dr),[dr]),Cy=dr.length,eh=h.useMemo(()=>{const x=new Map(hi.map(J=>[J.key,J])),N=new Set,B=new Set,q=jl.map(J=>{const ee=ol(J,hi).map(te=>x.get(te)).filter(Boolean);for(const te of ee)N.add(te.key),B.add(String(te.name||te.id||te.key||"").trim());return{...J,skills:ee}}).filter(J=>J.skills.length>0),Y=hi.filter(J=>{const ee=String(J.name||J.id||J.key||"").trim();return!N.has(J.key)&&!B.has(ee)});return{groups:q,ungrouped:Y}},[jl,hi]),Pc=h.useCallback(()=>{const x=Gt.current;if(!x)return;const N=x.getBoundingClientRect(),B=Math.min(400,Math.max(300,window.innerWidth-24)),q=Math.min(Math.max(12,N.right-B),window.innerWidth-B-12),Y=Math.max(140,N.top-22),J=Math.min(360,Y);ld({position:"fixed",left:`${q}px`,top:`${Math.max(12,N.top-J-10)}px`,width:`${B}px`,maxHeight:`${J}px`})},[]);h.useEffect(()=>{const x=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],N=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],B=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[];Nl(q=>{const Y=$h(q,x,N,B);return Y===q?q:Y})},[vt.cursor,vt.opencode,vt.claudeCode]),h.useEffect(()=>{if(!Ti)return;Pc();const x=B=>{var Y,J;const q=B.target;(Y=Gt.current)!=null&&Y.contains(q)||(J=bc.current)!=null&&J.contains(q)||ft(!1)},N=B=>{B.key==="Escape"&&ft(!1)};return window.addEventListener("resize",Pc),window.addEventListener("scroll",Pc,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",N),()=>{window.removeEventListener("resize",Pc),window.removeEventListener("scroll",Pc,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",N)}},[Ti,Pc]);const Ml=h.useCallback(async(x,N={})=>{var St;if(!u||Cc.current)return;const B=N.phaseContextSnapshot,q=(typeof x=="string"?x:vs).trim();if(!q)return;const Y=ud.current;Cc.current=!0,Hp(!0),Us(e("flow:composer.connecting")),zt(Jt=>Jt!=="composer"?"composer":Jt);const J=[...lo];if(Y.length>0&&J.push({type:"assistant",segments:[...Y]}),Bp([...J,{type:"user",text:q}]),J.filter(Jt=>Jt.type==="user").length===0){const Jt=q.replace(/\s+/g," ").slice(0,30)+(q.length>30?"…":"");Xr(ds=>ds.map(Ye=>Ye.id===tr?{...Ye,label:Jt}:Ye))}const ee=J.map(Jt=>Jt.type==="user"?{role:"user",text:Jt.text}:{role:"assistant",text:(Jt.segments||[]).filter(Ye=>Ye.kind==="assistant"||Ye.kind==="result").map(Ye=>Ye.text).join(`
134
- `)}).filter(Jt=>Jt.text),te=B??jt;Ce(""),Ks([]),mi([]),Wp(!1);const me=new AbortController;Pl.current=me,jc.current=tr;let ye=null;const Fe=Array.isArray(vt==null?void 0:vt.cursor)?vt.cursor:[],de=Array.isArray(vt==null?void 0:vt.opencode)?vt.opencode:[],$e=Array.isArray(vt==null?void 0:vt.claudeCode)?vt.claudeCode:[],Se=$h(pi,Fe,de,$e),xt=Zp.filter(Jt=>Jt.kind!=="definition"&&Jt.node).map(Jt=>Jt.node.id),kn=u;let Sn=!1,Wt=!1;try{ye=setTimeout(()=>me.abort(),12e4);const Jt={prompt:q,model:Se,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:xt,thread:ee,selectedSkills:dr};te&&te.nextPhase&&!te.isLastPhase&&(Jt.phaseContext={phaseIndex:te.nextPhase.index,phases:te.phases,userPromptOriginal:te.userPromptOriginal||q}),wc&&(Jt.phaseRole=wc);const ds=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Jt),signal:me.signal});if(ye&&(clearTimeout(ye),ye=null),!ds.ok){let $i=ds.statusText||e("flow:composer.requestFailed");try{const $l=await ds.json();$l&&$l.error&&($i=String($l.error))}catch{}Us($i),Ks([{kind:"error",text:$i}]);return}const Ye=(St=ds.body)==null?void 0:St.getReader();if(!Ye){Us(e("flow:composer.cannotReadStream"));return}const Nn=new TextDecoder;let po="";for(;;){const{done:$i,value:$l}=await Ye.read();if($i)break;for(po+=Nn.decode($l,{stream:!0});;){const wd=po.indexOf(`
135
- `);if(wd<0)break;const ck=po.slice(0,wd).trim();if(po=po.slice(wd+1),!ck)continue;let Ge;try{Ge=JSON.parse(ck)}catch{continue}if(Ge.type==="status"&&typeof Ge.line=="string"&&Us(Ge.line),Ge.type==="natural"&&typeof Ge.text=="string"&&Ge.text){const An=typeof Ge.kind=="string"&&Ge.kind?Ge.kind:"assistant";Ks(jn=>[...jn,{kind:An,text:Ge.text}])}if(Ge.type==="error"&&Ge.message){Wt=!0;const An=Ge.code?` [${Ge.code}]`:"",jn=String(Ge.message)+An;Us(jn),Ks(js=>[...js,{kind:"error",text:jn}])}if(Ge.type==="plan"&&Array.isArray(Ge.steps)){mi(Ge.steps.map(jn=>({...jn,status:"pending"})));const An=Ge.steps.map((jn,js)=>`${js+1}. ${jn.description||jn.type}`).join(`
136
- `);Ks(jn=>[...jn,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ge.steps.length,summary:An})}])}if(Ge.type==="step-start"){const An=Ge.index??0,jn=Ge.total??0,js=Ge.tier?` [${Ge.tier}]`:"",A2=Ge.model?` (${Ge.model})`:"";Us(e("flow:composer.step",{current:An+1,total:jn,description:(Ge.description||"")+js+A2})),mi(I2=>I2.map(Ac=>Ac.index===An?{...Ac,status:"running",model:Ge.model,tier:Ge.tier,nodeRole:Ge.nodeRole??Ac.nodeRole,instanceId:Ge.instanceId??Ac.instanceId,instanceLabel:Ge.instanceLabel??Ac.instanceLabel}:Ac))}if(Ge.type==="step-progress"){const An=Ge.index??0,jn=Ge.total??0;Us(e("flow:composer.step",{current:An+1,total:jn,description:Ge.description||""}))}if(Ge.type==="step-done"){const An=Ge.index??0;mi(jn=>jn.map(js=>js.index===An?{...js,status:Ge.success?"done":"error"}:js))}if(Ge.type==="phase-plan"&&Array.isArray(Ge.phases)){Il(jn=>({...jn||{},phases:Ge.phases,currentPhase:Ge.currentPhase??0,phaseTotal:Ge.phaseTotal??Ge.phases.length,phaseName:Ge.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(jn==null?void 0:jn.userPromptOriginal)||q}));const An=Ge.phases.map((jn,js)=>`${js+1}. ${jn.label}`).join(" → ");Ks(jn=>[...jn,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ge.phases.length,labels:An,current:Ge.phaseName||""})}])}Ge.type==="phase-complete"&&(Il(An=>{var js;return{...An||{},phases:Ge.phases||(An==null?void 0:An.phases)||[],currentPhase:Ge.phaseIndex??0,phaseTotal:Ge.phaseTotal??((js=Ge.phases)==null?void 0:js.length)??0,phaseName:Ge.phaseName||"",isLastPhase:!!Ge.isLastPhase,nextPhase:Ge.nextPhase||null,userPromptOriginal:Ge.userPromptOriginal||(An==null?void 0:An.userPromptOriginal)||q}}),!Ge.isLastPhase&&Ge.nextPhase&&Ks(An=>[...An,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ge.phaseName||e("flow:composer.nextPhase"),nextPhase:Ge.nextPhase.label})}])),Ge.type==="done"&&(Sn=!0,Us(An=>An||e("flow:composer.done")))}}}catch(Jt){const ds=Jt;if(ds.name==="AbortError"){const Ye=e(ye?"flow:composer.connectTimeout":"flow:composer.aborted");Us(Ye),Ks(Nn=>[...Nn,{kind:"error",text:Ye}])}else{const Ye=ds.code||ds.name||"UNKNOWN",Nn=`${ds.message||String(Jt)} [${Ye}]`;Us(Nn),Ks(po=>[...po,{kind:"error",text:Nn}])}}finally{if(Cc.current=!1,Hp(!1),Pl.current=null,jc.current=null,ye&&clearTimeout(ye),Sn&&kn){const Jt={id:kn.id,source:kn.source??"user",archived:kn.archived};(async()=>(await Dt(Jt,{preserveComposer:!0,incrementalSync:!0}),await ae(Jt,{quiet:!0,force:!0})))()}}},[u,vs,pi,vt,Zp,Dt,ae,lo,tr,jt,wc,dr]);Al.current=Ml;const rk=h.useCallback(()=>{!jt||jt.isLastPhase||(Il(null),Ml(e("flow:composer.skipRemainingPhases")))},[jt,Ml]),sk=h.useCallback(()=>{if(!jt||jt.isLastPhase||!jt.nextPhase)return;const x=String(jt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Ml(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:jt})},[jt,Ml]);h.useEffect(()=>{if(!Nc)return;const x=N=>{N.key==="Escape"&&Ko(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[Nc]),h.useEffect(()=>{Pe!=="edit"&&Ko(!1)},[Pe]),h.useLayoutEffect(()=>{const x=rd.current;if(!x)return;if(!u){x.style.height="";return}x.style.height="0px";const N=getComputedStyle(x),B=parseFloat(N.lineHeight),q=(parseFloat(N.paddingTop)||0)+(parseFloat(N.paddingBottom)||0),Y=Number.isFinite(B)&&B>0?B:13*1.45,J=q+Y*2,ee=q+Y*10,te=Math.min(Math.max(x.scrollHeight,J),ee);x.style.height=`${te}px`},[vs,u]);const Ey=h.useCallback(x=>{const N=vs,B=ks,q=d1(N,B);if(!q)return;const Y=N.slice(0,q.atIndex)+`@${x} `+N.slice(B);Ce(Y);const J=q.atIndex+x.length+2;queueMicrotask(()=>{const ee=rd.current;ee&&(ee.focus(),ee.setSelectionRange(J,J)),Na(J)})},[vs,ks]),_y=h.useCallback(x=>{Ce(N=>{const B=`@${x}`,q=N.indexOf(B);return q<0?N:N.slice(0,q)+N.slice(q+B.length)})},[]),ik=h.useCallback(x=>{x.kind==="canvas"?kt(N=>N.map(B=>B.id===x.node.id?{...B,selected:!1}:B)):x.kind==="mention"?_y(x.node.id):_y(x.definition.id)},[kt,_y]),j2=h.useCallback(()=>{zt(x=>x==="history"?null:"history")},[]),C2=h.useCallback(()=>{zt(x=>x==="settings"?null:"settings")},[]),E2=h.useCallback(()=>{zt(x=>x==="composer"?null:"composer")},[]),xd=h.useCallback(()=>{zt(x=>(x==="node"&&Ca.current&&(sd.current=Ca.current.id),null))},[]),ok=h.useCallback(()=>{so(x=>!x)},[]),_2=()=>{if(!u)return null;const x=Ai||u.archived||xi(u.source),N=Bt!=null&&Bt.running?e("flow:schedule.running"):ur.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),B=Bt!=null&&Bt.running?"running":ur.enabled?"waiting":"disabled",q=nt.slice(0,12),Y=u.archived||xi(u.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:xd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:L,onChange:J=>{F(J.target.value),M("")},onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),Yp())},onBlur:()=>{L.trim()&&L.trim()!==u.id&&Yp()},placeholder:u.id,disabled:D,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Mc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Mc(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),u.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:b,onChange:J=>v(J.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>G0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:$?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:O,onClick:()=>qp("workspace"),children:e(O?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:O,onClick:()=>qp("user"),children:e(O?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),_?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:_}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[nt.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Ct,disabled:Qt,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(Qt?"common:common.loading":"common:common.refresh")]})]}),Cn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Cn}):null,Qt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):q.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:q.map(J=>{const ee=J.definitionId||`marketplace:${J.id}${J.version?`@${J.version}`:""}`,te=ln.has(ee)||ln.has(`marketplace:${J.id}`),me=nn.find($e=>String($e.id)===ee||String($e.id)===`marketplace:${J.id}`),ye=xn===ee,Fe=Mh(J.inputs||J.input),de=Mh(J.outputs||J.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:te?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:J.displayName||J.label||J.id}),o.jsx("span",{children:J.version?`v${J.version}`:ee})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:J.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:Fe.length>0?Fe.map($e=>o.jsx("span",{className:"af-pipeline-market-chip",children:$e},`in-${ee}-${$e}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:de.length>0?de.map($e=>o.jsx("span",{className:"af-pipeline-market-chip",children:$e},`out-${ee}-${$e}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>Me(J),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:te?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:Y||ye,onClick:()=>{te&&me?(Kp(me),zt(null)):Pa(J)},children:e(ye?"flow:settings.installingNode":te?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},ee)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),Ju?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!ur.enabled,disabled:x,onChange:J=>re(ee=>({...ee,enabled:J.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:ur.cron||"",disabled:x,onChange:J=>re(ee=>({...ee,cron:J.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:ur.timezone||"",disabled:x,onChange:J=>re(ee=>({...ee,timezone:J.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:ur.preset||"",disabled:x,onChange:J=>re(ee=>({...ee,preset:J.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(mn).map(J=>o.jsx("option",{value:J,children:J},J))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${B}`}),o.jsx("span",{children:ur.nextRunAt?e("flow:schedule.nextRun",{time:new Date(ur.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",N]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Kt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Kt.lastTriggeredAt).toLocaleString()})]}):null,Kt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Kt.lastSkippedAt).toLocaleString(),Kt.lastSkipReason?` · ${Kt.lastSkipReason}`:""]})]}):null,Kt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Kt.lastRunUuid})]}):null,Kt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Kt.lastExitCode)})]}):null,Kt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Kt.lastFinishedAt).toLocaleString()})]}):null]}),Bt!=null&&Bt.lastError||Kt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Bt==null?void 0:Bt.lastError)||Kt.lastError}):null,u.archived||xi(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,gl?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:gl}):null,yl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:yl}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Et.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:nn.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Mc(u.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:u.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${B}`,children:N})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:Et.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:u.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Mc(u.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void u2(),disabled:Ai,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(Ai?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:xd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},P2=()=>{const x=be;if(!x)return null;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,B=x.displayName||x.label||x.id,q=Mh(x.inputs||x.input),Y=Mh(x.outputs||x.output);return Dr.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:J=>{J.target===J.currentTarget&&Me(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:B})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Me(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(q.length>0?q:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-in-${ee}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:B}),o.jsx("span",{children:N})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(Y.length>0?Y:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-out-${ee}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-input-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:Y.length>0?Y.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-output-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:N})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(J=>J.to||J).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(ty,{children:[o.jsx(j7,{onReady:a}),o.jsxs(JT.Provider,{value:{modelLists:vt,onModelChange:d2},children:[o.jsxs("div",{className:"af-pipeline-page"+(Pe!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Pe==="running"?Jp(!0):Pe!=="edit"?Ol():n("/projects")},"aria-label":e(Pe!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Pe!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",n7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Tf(u,"workspace")),children:"Workspace"}),o.jsx("button",{type:"button",onClick:()=>n(Tf(u,"display")),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[Hs&&o.jsx("button",{type:"button",className:"af-icon-btn"+(xs?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Mo(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Pe==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:Rx(on,"running")})]}),Pe==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:Rx(on,"stopped")})]}),(Pe==="done"||Pe==="error")&&o.jsxs("div",{className:"af-run-timer"+(Pe==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Pe==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:Rx(on,Pe)})]}),Pe!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Ze?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>gr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Pe==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(tt==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!u,onClick:j2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(tt==="settings"?" af-icon-btn--active":""),onClick:C2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!u,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(tt==="composer"?" af-composer-topbar-btn--active":"")+(_n?" af-composer-topbar-btn--running":""),onClick:E2,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(Bn?" af-icon-btn--active":""),onClick:ok,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!u,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!u||xi(u.source)||u.source!=="user"&&u.source!=="workspace",onClick:()=>C(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!u||xi(u.source)||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>A(!0),children:"Archive"})]}),Pe==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:y2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Pe==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void fo(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ol,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Pe==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void fo({runUuid:hn}),title:hn?e("flow:topbar.resumeTitle",{uuid:hn}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ol,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Pe==="done"||Pe==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void fo(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ol,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!u,onClick:()=>void fo(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>Re(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":ge,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),ge&&u&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var N,B,q,Y,J;Re(!1);const x={};for(const ee of I){const te=U[ee.id];te&&(x[te]=((N=oi[te])==null?void 0:N.value)??((B=oi[te])==null?void 0:B.path)??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"")}Ot(x),Ve(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Re(!1),fo({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Re(!1),fo()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(mn).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var q;Re(!1);const N=mn[x]||{},B={};for(const Y of I){const J=U[Y.id];if(!J)continue;const ee=((q=Y.data)==null?void 0:q.definitionId)||"",te=N[Y.id]??"";ee.startsWith("provide_file")?B[J]={type:"file",path:te}:B[J]={type:"str",value:te}}fo({cliInputsOverride:B})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),ot?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:ot}),o.jsx("button",{type:"button",onClick:()=>at(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(Pe!=="edit"?" af-pipeline-body--run-mode":""),children:[Pe==="edit"&&tt!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${hr?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Zn(x=>!x),"aria-expanded":hr,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:hr?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||Wr.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),hr&&o.jsx("div",{className:"af-palette-workspace-tree",children:Vr?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Wr.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Wr.error}):u?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:u.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",Wr.files.length,")"]})]}),Wr.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Wr.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Z({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):Wr.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Wr.files.filter(x=>{var N;return x.type==="directory"&&((N=x.children)==null?void 0:N.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(N=>o.jsxs("li",{className:`af-palette-workspace-item${N.type==="file"?" af-palette-workspace-item--clickable":""}`,title:N.path,onClick:N.type==="file"?()=>Z({filePath:N.path,fileName:N.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:N.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:N.name}),N.type==="file"&&N.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:N.size<1024?`${N.size}B`:N.size<1024*1024?`${(N.size/1024).toFixed(1)}KB`:`${(N.size/1024/1024).toFixed(1)}MB`})]},N.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Te==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:et,type:"search",className:"af-palette-search-input",value:_e,onChange:x=>xe(x.target.value),placeholder:(Te==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Te==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Te==="nodes",className:"af-palette-tab"+(Te==="nodes"?" af-palette-tab--active":""),onClick:()=>Ae("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Te==="flows",className:"af-palette-tab"+(Te==="flows"?" af-palette-tab--active":""),onClick:()=>Ae("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?o.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Te==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:S2,disabled:!u||Or.length<2,title:Or.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Or.length," 节点 / ",Qp.length," 连线"]})]})}),dt?o.jsx("p",{className:"af-err af-palette-list-err",children:dt}):null,mt?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):ek.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:ek.map(x=>{const N=`${x.id}@${x.version}`,B=x.displayName||x.name||x.id,q=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>nk(x),draggable:!!u,onDragStart:Y=>{Y.dataTransfer.setData("application/agentflow-snippet",N),Y.dataTransfer.effectAllowed="move"},disabled:!u,title:q,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:B}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),q?o.jsx("span",{className:"af-palette-card-desc",children:q}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},N)})})]}):o.jsx("p",{className:"af-palette-empty",children:_e.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Ud.filter(x=>bn[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:bn[x].map(N=>{const B=a1(N.inputs,"input"),q=a1(N.outputs,"output"),J=N.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":ZT(N),ee=QT(N);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>Kp(N),draggable:!!u,onDragStart:te=>{te.dataTransfer.setData("application/agentflow-node",N.id),te.dataTransfer.effectAllowed="move"},disabled:!u,title:J||N.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:a7(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:ee}),ee!==N.id?o.jsx("span",{className:"af-palette-card-id",children:N.id}):null]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[B.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[B.shown.map((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:o1("input",te,me),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:or(te==null?void 0:te.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Lx(te,me)})]},`in-${me}`)),B.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",B.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[q.shown.map((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:o1("output",te,me),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Lx(te,me)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:or(te==null?void 0:te.type)}})]},`out-${me}`)),q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",q.hidden]}):null]})]})]})]},N.id)})})]},x)),u&&oe.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,u&&oe.length>0&&_e.trim()&&ls===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,u?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(ya?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(ya?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+yt,role:"status","aria-live":"polite",children:w}):null]})]}):Pe!=="edit"&&u?o.jsx(GK,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:I,edges:wn,nodes:Et,onCliInputsChange:Bs,onBackToEdit:Ol}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,u&&Ne.length>0&&!V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:ce,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void ke(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>ne(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:Ne.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:N=>{N.preventDefault(),Oi(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,u&&Ne.length>0&&V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Ne.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:ok,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>ne(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:ce,onClick:()=>void ke(),children:e("common:common.refresh")})]})]}):null,tt==="settings"&&u&&Pe==="edit"?_2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?o.jsxs(o.Fragment,{children:[o.jsx(T7,{fitViewEpoch:m,canvasTool:Cp,nodes:Q,edges:se,onNodesChange:Pe!=="edit"?void 0:gy,onEdgesChange:Pe!=="edit"?void 0:yy,onConnect:Pe!=="edit"?void 0:Pn,onConnectStart:Pe!=="edit"?void 0:vn,onConnectEnd:Pe!=="edit"?void 0:Tt,isValidConnection:Pe!=="edit"?void 0:qt,onNodesDelete:Pe!=="edit"?void 0:cn,onNodeClick:De,onNodeDoubleClick:Mt,onEdgeClick:en,onFlowInit:cs,onDrop:c2,onDragOver:l2,hideMinimapAndControls:!!(u&&tt),bottomSlot:Pe==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Zp.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Zp.map((x,N)=>{var me,ye;if(x.kind==="definition"){const Fe=x.definition,de=String(Fe.label??Fe.id),$e=[Fe.id,Fe.description?String(Fe.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:$e,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:de}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>ik(x),"aria-label":e("flow:composer.removeFromInput",{id:Fe.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Fe.id}`)}const B=x.node,q=x.kind,Y=String(((me=B.data)==null?void 0:me.label)??B.id),J=(ye=B.data)!=null&&ye.definitionId?String(B.data.definitionId):"",ee=J&&J!==Y?`${Y} · ${B.id} · ${J}`:`${Y} · ${B.id}`,te=q==="canvas"?e("flow:composer.deselectNode",{id:B.id}):e("flow:composer.removeFromInput",{id:B.id});return o.jsxs("div",{className:"af-composer-node-chip"+(q==="mention"?" af-composer-node-chip--mention":""),title:ee,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:Y}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>ik(x),"aria-label":te,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},B.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:rd,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:vs,rows:2,onChange:x=>{Ce(x.target.value),Na(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Na(N.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Ml();return}if(gd&&Mi.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),fi(N=>(N+1)%Mi.length);else if(x.key==="ArrowUp")x.preventDefault(),fi(N=>(N-1+Mi.length)%Mi.length);else if(x.key==="Enter"){x.preventDefault();const N=Mi[ja];N&&Ey(N.id)}}},onKeyUp:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Na(N.selectionStart??N.value.length)},onClick:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Na(N.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),gd&&u&&Mi.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[yd.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,yd.instances.map((x,N)=>{const B=N;return o.jsx("li",{role:"option","aria-selected":B===ja,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(B===ja?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>fi(B),onClick:()=>Ey(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),yd.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,yd.definitions.map((x,N)=>{const B=yd.instances.length+N;return o.jsx("li",{role:"option","aria-selected":B===ja,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(B===ja?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>fi(B),onClick:()=>Ey(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[as.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:tr||"",onChange:x=>{x.target.value==="__new__"?Fp():qo(x.target.value)},disabled:_n,"aria-label":e("flow:composer.switchConversation"),children:[as.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Gt,type:"button",className:"af-composer-skills-button"+(Cy>0?" af-composer-skills-button--active":""),disabled:!u||_n,"aria-haspopup":"listbox","aria-expanded":Ti,onClick:()=>ft(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Cy>0?`Skills ${Cy}`:"Skills"})]}),Ti&&!_n?Dr.createPortal(o.jsx("div",{ref:bc,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:my,children:hi.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[eh.groups.map(x=>{const N=ol(x,hi),B=iP(x,jy,hi),q=Op.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(q?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:B==="all",disabled:N.length===0,onChange:Y=>{const J=Y.target.checked;io(ee=>J?rP(ee,N):sP(ee,N))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,B==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":q?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{Cl(Y=>{const J=new Set(Y);return J.has(x.id)?J.delete(x.id):J.add(x.id),J})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:q?"expand_more":"expand_less"})]})]}),q?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(Y=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:jy.has(Y.key),onChange:J=>{const ee=J.target.checked;io(te=>ee?te.includes(Y.key)?te:[...te,Y.key]:te.filter(me=>me!==Y.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Y.name}),Y.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Y.description}):null]})]},`${x.id}:${Y.key}`))})]},x.id)}),eh.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:eh.ungrouped.length})]}),eh.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:jy.has(x.key),onChange:N=>{const B=N.target.checked;io(q=>B?q.includes(x.key)?q:[...q,x.key]:q.filter(Y=>Y!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(pi||"").trim()?Ns.currentNotInLists?Ns.currentNotInLists:$h(pi,Ns.cursorList,Ns.opencodeList,Ns.claudeCodeList):"",onChange:x=>Nl(x.target.value),disabled:!u||_n,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Ns.currentNotInLists?o.jsxs("option",{value:Ns.currentNotInLists,children:[Ns.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Ns.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:Ns.cursorList.map(x=>o.jsx("option",{value:Zo(x),children:x},`composer-c-${x}`))}):null,Ns.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:Ns.opencodeList.map(x=>o.jsx("option",{value:`opencode:${Zo(x)}`,children:x},`composer-o-${x}`))}):null,Ns.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:Ns.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${Zo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(u&&vs.trim()&&!_n?" af-composer-send--active":"")+(_n?" af-composer-send--stop":""),disabled:!u||!_n&&!vs.trim(),"aria-label":e(_n?"flow:composer.stopGeneration":"flow:composer.send"),title:_n?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(_n){(x=Pl.current)==null||x.abort();return}Ml()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_n?"stop":"arrow_upward"})})]})]}),Nc?Dr.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&Ko(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(_n?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:_l||void 0,children:_n&&!_l?e("flow:composer.executing"):_l||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ko(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),cd.length>1&&!(jt&&Array.isArray(jt.phases)&&jt.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(w7,{steps:cd})}):null,jt&&Array.isArray(jt.phases)&&jt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:jt.phases.map((x,N)=>{const B=x.status||(N<(jt.currentPhase??0)?"done":N===(jt.currentPhase??0)?_n?"running":jt.nextPhase||jt.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(B==="done"?" af-composer-phase-item--done":"")+(B==="running"?" af-composer-phase-item--running":"")+(B==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:B==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(f1,{thread:lo,liveSegments:Uo,running:_n})}),jt&&!jt.isLastPhase&&jt.nextPhase&&!_n?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:jt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:sk,children:e("flow:composer.phaseReviewContinue",{label:jt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:rk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),an&&Pe==="edit"?(()=>{var q;const x=String(an.query||"").trim().toLowerCase(),N=x?an.candidates.filter(Y=>{var J,ee,te;return[(J=Y.def)==null?void 0:J.id,Y.displayLabel,Y.description,(ee=Y.slot)==null?void 0:ee.name,(te=Y.slot)==null?void 0:te.type].filter(Boolean).some(me=>String(me).toLowerCase().includes(x))}):an.candidates,B=an.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:an.left,top:an.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:or((q=an.draft.slot)==null?void 0:q.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",an.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Li(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:an.query,onChange:Y=>Li(J=>J&&{...J,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N.map(Y=>{var te,me;const J=Y.displayLabel||((te=Y.def)==null?void 0:te.id),ee=Lx(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>wy(Y),title:Y.description||Y.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:J}),J!==Y.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:B}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:or((me=Y.slot)==null?void 0:me.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:ee})]})]},`${Y.def.id}-${Y.slotIndex}`)}),N.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Pe!=="edit"&&Ze&&o.jsxs("div",{className:"af-run-console",style:{height:vr},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:p2,onPointerMove:h2,onPointerUp:Q0,onPointerCancel:Q0,onLostPointerCapture:m2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[Pe==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>gr(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[mr.map((x,N)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},N)),o.jsx("div",{ref:Do})]})]})]}),Pe!=="edit"&&ws&&u?o.jsx(UK,{instanceId:ws,flowId:u.id,runId:hn,nodeStatus:((ak=Kr[ws])==null?void 0:ak.status)??null,onClose:()=>qr(null)}):null,tt&&tt!=="settings"&&u&&Pe==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(tt==="node"?" af-pipeline-drawer--wide":"")+(tt==="composer"?" af-pipeline-drawer--wide":""),"aria-label":tt==="settings"?e("flow:settings.title"):tt==="history"?e("flow:history.title"):tt==="composer"?"AI Composer":e("flow:nodeProps.title"),children:tt==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:xd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),as.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[as.map(x=>o.jsxs("button",{type:"button",ref:N=>{N&&x.id===tr&&N.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===tr?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>qo(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:N=>{N.stopPropagation(),zp(x.id)},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),zp(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>Fp(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(_n?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:_n&&!_l?e("flow:composer.executing"):_l||e("flow:composer.ready")}),jt&&Array.isArray(jt.phases)&&jt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:jt.phases.map((x,N)=>{const B=x.status||(N<(jt.currentPhase??0)?"done":N===(jt.currentPhase??0)?_n?"running":jt.isLastPhase&&N===jt.phases.length-1||jt.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(B==="done"?" af-composer-phase-item--done":"")+(B==="running"?" af-composer-phase-item--running":"")+(B==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:B==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:Dp,children:o.jsx(f1,{thread:lo,liveSegments:Uo,running:_n})}),jt&&!jt.isLastPhase&&jt.nextPhase&&!_n?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:jt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:sk,children:e("flow:composer.phaseReviewContinue",{label:jt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:rk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):tt==="node"&&le?wt?o.jsx(qT,{draft:wt,setDraft:id,definitionId:String(((lk=le.data)==null?void 0:lk.definitionId)??le.id),systemPromptReadonly:String((qe==null?void 0:qe.description)??""),modelLists:vt,disabled:!u,onIdBlur:f2,onClose:xd,onPublishToMarketplace:Ll,error:Ap,ioSlots:{inputs:Array.isArray(wt==null?void 0:wt.inputs)?wt.inputs:[],outputs:Array.isArray(wt==null?void 0:wt.outputs)?wt.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(tt==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:xd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:tt==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:L,onChange:x=>{F(x.target.value),M("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Yp())},onBlur:()=>{L.trim()&&L.trim()!==u.id&&Yp()},placeholder:u.id,disabled:D,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Mc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Mc(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>G0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:$?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:O,onClick:()=>qp("workspace"),children:e(O?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:O,onClick:()=>qp("user"),children:e(O?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),_?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:_}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:b,onChange:x=>v(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),Ju?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!ur.enabled,disabled:Ai||u.archived||xi(u.source),onChange:x=>re(N=>({...N,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:ur.cron||"",disabled:Ai||u.archived||xi(u.source),onChange:x=>re(N=>({...N,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:ur.timezone||"",disabled:Ai||u.archived||xi(u.source),onChange:x=>re(N=>({...N,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:ur.preset||"",disabled:Ai||u.archived||xi(u.source),onChange:x=>re(N=>({...N,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(mn).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),ur.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(ur.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:Bt!=null&&Bt.running?e("flow:schedule.running"):ur.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Kt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Kt.lastTriggeredAt).toLocaleString()})]}):null,Kt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Kt.lastSkippedAt).toLocaleString(),Kt.lastSkipReason?` · ${Kt.lastSkipReason}`:""]})]}):null,Kt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Kt.lastRunUuid})]}):null,Kt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Kt.lastExitCode)})]}):null,Kt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Kt.lastFinishedAt).toLocaleString()})]}):null]}),Bt!=null&&Bt.lastError||Kt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Bt==null?void 0:Bt.lastError)||Kt.lastError}):null,u.archived||xi(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,gl?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:gl}):null,yl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:yl}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:Ai||u.archived||xi(u.source),onClick:by,children:e(Ai?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Et.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:u.id})]}),pn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):We?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:We}):md.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[us.success+us.failed+us.running+us.stopped+us.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[us.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:us.success})}):null,us.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:us.failed})}):null,us.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:us.stopped})}):null,us.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:us.interrupted})}):null,us.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:us.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:md.map((x,N)=>{const B=x.status||"unknown",q=B==="success"?"af-exec-history-card--success":B==="failed"?"af-exec-history-card--failed":B==="stopped"?"af-exec-history-card--stopped":B==="interrupted"?"af-exec-history-card--interrupted":B==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",Y=e(B==="success"?"flow:history.success":B==="failed"?"flow:history.failed":B==="stopped"?"flow:history.stopped":B==="interrupted"?"flow:history.interrupted":B==="running"?"flow:history.running":"flow:history.unknown"),J=B==="success"?"check_circle":B==="failed"?"error":B==="stopped"?"stop_circle":B==="interrupted"?"sync_disabled":B==="running"?"progress_activity":"help",ee=x.runId||`${x.at}-${N}`,te=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:md.length-N});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${q}`,onClick:()=>k2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:te}),o.jsx("span",{className:"af-exec-history-card-time",children:qw(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J}),Y]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),AM(x.durationMs,e)]})]})]})},`${u.id}-${ee}`)})})]})]})})]})}):null]}),o.jsx(Vj,{open:g2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:x2,onCancel:()=>Sy(!1)}),o.jsx(Vj,{open:w2,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:v2,onSecondary:b2,onCancel:()=>Jp(!1)}),o.jsx(HT,{open:Bn,onClose:()=>so(!1)}),P2(),o.jsx(BT,{open:$n,onClose:()=>Ep(!1),onJump:uo,nodes:Et}),o.jsx(t7,{open:xs,onClose:()=>Mo(!1),flowId:(u==null?void 0:u.id)??""}),o.jsx(FT,{open:z,onClose:()=>A(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{A(!1),await rr(),n("/projects?tab=archived")}}),o.jsx(zT,{open:P&&!!(u!=null&&u.id),onClose:()=>C(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),onDeleted:async()=>{C(!1),p(null),kt([]),Xt([]),Il(null),await rr(),n("/projects")}}),yn&&Dr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>On(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:rn.name,onChange:x=>{const N=x.target.value;Yn(B=>({...B,name:N,id:B.id?B.id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:rn.id,onChange:x=>Yn(N=>({...N,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:rn.description,onChange:x=>Yn(N=>({...N,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Or.length," 个节点和 ",Qp.length," 条内部连线。"]}),ve?o.jsx("div",{className:"af-flow-snippet-error",children:ve}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>On(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Mn||!rn.name.trim(),onClick:()=>void N2(),children:Mn?"发布中…":"发布"})]})]})}),document.body),o.jsx(IK,{open:!!G,onClose:()=>Z(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(G==null?void 0:G.filePath)??"",fileName:(G==null?void 0:G.fileName)??"",onSaved:()=>{it(x=>({...x}))}})]}),kr&&Pe!=="edit"&&Dr.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:kr.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:xc?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!kr||!u||!hn)return;const x=li||kr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:hn,instanceId:kr.instanceId,content:x})})).ok?(bl(B=>B&&{...B,content:x}),zo(!1),ht(B=>[...B,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):ht(B=>[...B,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{ht(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Ii(kr.content),zo(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>zo(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>bl(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:xc?o.jsx("textarea",{ref:Zu,className:"af-user-check-modal__textarea",value:li||kr.content,onChange:x=>Ii(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:li||kr.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:va,onChange:x=>Ho(x.target.value),disabled:vl}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:vl||!va.trim(),onClick:()=>{!kr||!u||!hn||!va.trim()||(kl(!0),ht(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"ai-edit-user-check-content",runUuid:hn,instanceId:kr.instanceId,content:li||kr.content,prompt:va})}).then(x=>x.json()).then(x=>{kl(!1),x.ok&&x.content?(Ii(x.content),zo(!0),Ho(""),ht(N=>[...N,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):ht(N=>[...N,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{kl(!1),ht(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[vl?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!kr||!u||!hn)return;const x=li||kr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:hn,instanceId:kr.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-check",runUuid:hn,instanceId:kr.instanceId,execId:kr.execId})}),bl(null),Ho(""),fo({runUuid:hn})):ht(B=>[...B,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{ht(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),ci&&Pe!=="edit"&&Dr.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:ci.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Lr(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[ci.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:ci.question})}):null,ci.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:ci.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:ed,onClick:async()=>{if(!(!ci||!u||!hn)){ui(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-ask",runUuid:hn,instanceId:ci.instanceId,execId:ci.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Lr(null),ui(!1),fo({runUuid:hn})):(ui(!1),ht(B=>[...B,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{ui(!1),ht(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(ed?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),ka&&Pe!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(bs?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:ka.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>td(x=>!x),"aria-label":e(bs?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(bs?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:bs?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Bo(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(yp,{children:ka.content})})})]}),Gr&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:Gr.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Sa(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:di,className:"af-provide-edit-modal__textarea",defaultValue:Gr.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:pe,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Sa(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Le&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Ve(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:I.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:I.map(x=>{var me,ye;const N=U[x.id];if(!N)return null;const B=((me=x.data)==null?void 0:me.definitionId)||"",q=B.startsWith("provide_file"),Y=B==="provide_bool",J=((ye=x.data)==null?void 0:ye.label)||x.id,ee=Zt[N]??"",te=["true","1","yes","on"].includes(String(ee).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(q?" af-run-params-item__icon--file":""),children:q?"description":Y?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:J}),o.jsx("span",{className:"af-run-params-item__slot",children:N})]}),Y?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(te?" af-run-config-bool-toggle--true":""),onClick:()=>Ot(Fe=>({...Fe,[N]:te?"false":"true"})),"aria-pressed":te,children:te?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:ee,onChange:Fe=>Ot(de=>({...de,[N]:Fe.target.value})),placeholder:e(q?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var N;const x={};for(const B of I){const q=U[B.id];if(!q)continue;const Y=((N=B.data)==null?void 0:N.definitionId)||"",J=Zt[q]??"";Y.startsWith("provide_file")?x[q]={type:"file",path:J}:x[q]={type:"str",value:J}}Ve(!1),Re(!1),fo({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Ve(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const $7="modulepreload",D7=function(e){return"/"+e},w1={},F7=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=D7(c),c in w1)return;w1[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const u=document.createElement("link");if(u.rel=d?"stylesheet":$7,d||(u.as="script"),u.crossOrigin="",u.href=c,l&&u.setAttribute("nonce",l),document.head.appendChild(u),d)return new Promise((p,m)=>{u.addEventListener("load",p),u.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},z7=new Set(["echarts"]),H7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),B7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),W7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function rl(e){return e&&typeof e=="object"&&!Array.isArray(e)}function dc(e,t){if(!rl(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:rl(n[r])&&rl(s)&&(n[r]=dc(n[r],s));return n}function ay(e,t){return e==null?e:Array.isArray(e)?e.map(n=>rl(n)?dc(n,t):n):rl(e)?dc(e,t):e}function V7(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 Ob(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)=>Ob(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||B7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Ob(r,`${t}.${n}`)}}}function U7(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!H7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function K7(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:dc(e,t)}function q7(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(!rl(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return dc(i,n)}):rl(e)?dc(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function Y7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:ay(e,n)}function b1(e,t="rgba(255, 255, 255, 0.62)"){return ay(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 G7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:ay(e,n)}function X7(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:ay(e,t)}function J7(e,t,n){const r=q7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>rl(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??W7,textStyle:dc(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:K7(e.tooltip),legend:Y7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?G7(e.grid,s||i):e.grid,xAxis:b1(e.xAxis),yAxis:b1(e.yAxis),radar:X7(e.radar),series:t}}function Q7(e){const t=V7(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(!z7.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");Ob(n);const r=U7(n.option.series),s=n.title==null?"":String(n.title),i=J7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function sa(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 rR(e){const t=sa(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function sR(e){return sa(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function Z7(e){const t=String(e||"").replace(/\r\n/g,`
137
- `).split(`
138
- `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"";if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&sa(l).length>1&&rR(t[a+1])){i();const c=sa(l),d=sR(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&sa(t[a]).length>1;)f.push(sa(t[a])),a++;n.push({type:"table",headers:c,align:d,rows:f});continue}r.push(l),a++}return i(),n}function iR(e,t=!1){return{...t?{p:({children:n})=>o.jsx(o.Fragment,{children:n})}:{},img:({src:n,alt:r})=>o.jsx("img",{src:e?e(n):n||"",alt:r||"",loading:"lazy"}),a:({href:n,children:r})=>o.jsx("a",{href:n||"",target:"_blank",rel:"noopener noreferrer",children:r})}}function v1({children:e,resolveSrc:t}){return o.jsx(yp,{components:iR(t,!0),children:String(e||"")})}function T0({content:e,resolveSrc:t}){const n=h.useMemo(()=>Z7(e),[e]),r=h.useMemo(()=>iR(t),[t]);return o.jsx(o.Fragment,{children:n.map((s,i)=>s.type!=="table"?o.jsx(yp,{components:r,children:s.text},`md-${i}`):o.jsx("div",{className:"af-work-display-table-wrap",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:s.headers.map((a,l)=>o.jsx("th",{style:{textAlign:s.align[l]||"left"},children:o.jsx(v1,{resolveSrc:t,children:a})},l))})}),o.jsx("tbody",{children:s.rows.map((a,l)=>o.jsx("tr",{children:s.headers.map((c,d)=>o.jsx("td",{style:{textAlign:s.align[d]||"left"},children:o.jsx(v1,{resolveSrc:t,children:a[d]||""})},d))},l))})]})},`table-${i}`))})}function eq(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
140
- `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(i){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
141
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function mo(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 tq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>mo(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>mo(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>mo(i[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:mo(s)||`Column ${i+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,i)=>({key:String(i),label:mo(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>mo(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>mo(s[a])):s&&typeof s=="object"?r.map(i=>mo(s[i.key])):r.map((i,a)=>a===0?mo(s):""))}}function nq(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=tq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
142
- `).split(`
143
- `).filter(l=>l.trim());if(s.length>=2&&sa(s[0]).length>1&&rR(s[1])){const l=sa(s[0]),c=sR(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>sa(d)),error:""}}const i=r.includes(" ")?" ":",",a=eq(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function R0({content:e}){const t=h.useMemo(()=>nq(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:mo(n[i])},`${s.key}-${i}`))},r))})]})})}function L0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>Q7(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),F7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const rq="af:workspace-graph:v2",zc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],sq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),iq={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:""}]},oq={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}]},aq={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}]},lq=new Set(["png","jpg","jpeg","gif","webp","svg"]),cq=320,oR=180,aR=960,Mb=96,lR=900,$b="display-ref:",uq="0.1.62";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 xo(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 pg(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 lq.has(n)}function hg(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=xo(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function fq(e,t){const n=String(e||"").trim();if(!n)return"";const r=xo(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function pq(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 mq(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 gq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!mq(e)}function yq(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function k1(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 cR(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 uR(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function O0(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 Kd(e){const t=String(O0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function S1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function mg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function qd(e){return mg(e)}function Db(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function $x(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 N1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function j1(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 C1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=$u(s.get(n),e.sourceHandle||"output-0","source"),a=$u(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Mu(i,a))}function xq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=$u(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:MT(a)}:null}function wq(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Mu(t.slot,a):Mu(a,t.slot)))continue;const c=Kd(n);return{def:n,order:r,category:c,categoryRank:zc.indexOf(c),slot:a,slotIndex:i,displayLabel:qd(n),description:Db(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Yd(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 bq(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function vq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Fh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:vq(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function dR(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function kq(e){var s,i;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[dR(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(((i=e==null?void 0:e.measured)==null?void 0:i.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 Dx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=pR(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const g=r[m]||{},b=g.definitionId||m,v=t.find(H=>H.id===b),y=O0(v)||b,k=t.find(H=>H.id===y)||v,w=g.marketplaceRef||uR(v),j=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},_=!!Un(y),E=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,O=gu(E,{display:_});return{id:m,type:wp,position:j,...O?{width:O.width,height:O.height}:{},data:{label:g.label||mg(v)||mg(k)||m,definitionId:y,...w?{marketplaceRef:w}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:cR(y,k||v),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...O?{nodeSize:O}:{},..._&&O?{displaySize:O}:{}}}}).map(m=>Gf(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,g)=>({id:m.id||`we-${m.source}-${m.target}-${g}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:Ms.ArrowClosed}}));return{nodes:d,edges:LT(f,d),instances:r}}function E1(e){return`${$b}${e}`}function Fx(e){const t=String(e||"");return t.startsWith($b)?t.slice($b.length):t}function fR(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 Fb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Un((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=gu(d[u],{display:!0});p&&(c[u]=p)});const f=fR(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function Sq(e,t=[]){return Fb(e,t)}function Nq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function jq(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 _1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function gu(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:_1(n,oR,aR)||cq,height:_1(r,Mb,lR)||Mb}}function Hc(e){var s,i,a,l,c,d,f,u,p,m,g;const t=!!Un((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return gu({width:n,height:r},{display:t})}function zh(e,t,n){var l,c;const r=pR(xp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=Hc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function pR(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Un(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 Un(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 ec(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Un(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Xf(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 yu(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/(?:^|\n)---agentflow\s*\n([\s\S]*?)\n---end(?:\n|$)/i);if(n!=null&&n[1]){const a=n[1],l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
144
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
145
- `).replace(/\s+$/g,""):f.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("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function Jf(e,t){const n=xo(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 P1(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 Cq(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(i=>[i.id,i]));return(Array.isArray(n)?n:[]).filter(i=>String((i==null?void 0:i.target)||"")===r).slice(0,4).map(i=>{const a=s.get(String((i==null?void 0:i.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),d=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&d.push(` task: ${c.slice(0,4e3)}`),d.join(`
146
- `)}).filter(Boolean).join(`
147
-
148
- `)}function Uu(e){let t=yu(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function Eq(e){const t=Uu(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Yl(e,t){return e==="html"?Eq(t):""}function hR(e){const t=Uu(e);if(!t.trim())return"";const n=`<base target="_self"><script>
149
- (() => {
150
- document.addEventListener("click", (event) => {
151
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
152
- if (!link) return;
153
- const rawHref = String(link.getAttribute("href") || "").trim();
154
- if (!rawHref || rawHref.startsWith("#")) return;
155
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
156
- event.preventDefault();
157
- window.location.href = link.href;
158
- }, true);
159
- })();
160
- <\/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 _q(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 Pq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function Aq(e,t){const n=URL.createObjectURL(e);try{Pq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function mR(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 Iq(e){const t=mR(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>"}
161
- ${t.documentElement.outerHTML}`:""}function zx(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 Tq(e,t,n,r={}){var v;const s=(v=e==null?void 0:e.getBoundingClientRect)==null?void 0:v.call(e),i=mR(e),a=i==null?void 0:i.documentElement,l=i==null?void 0:i.body,c=(r==null?void 0:r.card)||null,d=(r==null?void 0:r.displayBody)||null,f=(r==null?void 0:r.scroller)||null,u=(r==null?void 0:r.displaySize)||null,p={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((u==null?void 0:u.width)||0)||null,displaySizeHeight:Number((u==null?void 0:u.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:zx(c),displayBody:zx(d),scroller:zx(f)},m=[Number(t)||0,Number((u==null?void 0:u.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.scrollWidth)||0),Number((f==null?void 0:f.clientWidth)||0),Number((f==null?void 0:f.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,...m.length?m:[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:p}}async function Rq({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:i,filename:a,snapshotElements:l,displaySize:c}){const d=Tq(r,s,i,{...l||{},displaySize:c}),f=Iq(r),u=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:f||t,sourceFilePath:n||"",width:d.width,height:d.height,filename:a})});if(!u.ok){const m=await u.json().catch(()=>({}));throw new Error(m.error||"截图失败")}const p=await u.blob();Aq(p,a)}function Lq(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 Oq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Mq(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const i=(l,c="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?c&&(n.get(d).label=c):n.set(d,{id:d,label:c||d}),d},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),d=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?i(d[1],d[2]||d[3]||d[4]||d[1]):i(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){s=c[2].toUpperCase();continue}const d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function gR({code:e}){const t=h.useMemo(()=>Mq(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,i=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((f,u)=>{l.set(f.id,{x:24+(n?u*(r+i):u%3*(r+i)),y:24+(n?u%3*(s+a):u*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(f=>f.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(f=>f.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((f,u)=>{const p=l.get(f.from),m=l.get(f.to);if(!p||!m)return null;const g=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+m.x+r)/2} ${p.y+s/2}, ${(p.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return o.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${f.from}-${f.to}-${u}`)}),t.nodes.map(f=>{const u=l.get(f.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-work-node__mermaid-box",x:u.x,y:u.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-work-node__mermaid-text",x:u.x+r/2,y:u.y+s/2+5,textAnchor:"middle",children:f.label.slice(0,22)})]},f.id)})]})})}function Hi({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const u=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=u>p+1,g=m?Math.max(12,p/u*100):100,b=Math.max(0,100-g),v=m?Math.min(b,f.scrollTop/Math.max(1,u-p)*b):0;i({visible:m,top:v,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(u);for(const m of Array.from(u.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const u=n.current;if(!u)return;const p=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),c=h.useCallback((f,u=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-u)/b},[s.height]),d=h.useCallback(f=>{var j,_;if(!s.visible)return;f.preventDefault(),f.stopPropagation();const u=r.current;if(!u)return;const p=u.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,v=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(c(f.clientY,v));const y=f.pointerId;(_=(j=f.currentTarget).setPointerCapture)==null||_.call(j,y);const k=E=>{E.preventDefault(),l(c(E.clientY,v))},w=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[o.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function $q({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Un(e==null?void 0:e.definitionId),i=ec(e),a=s==="image"?"":Xf(i,s),[l,c]=h.useState(""),[d,f]=h.useState(""),[u,p]=h.useState(!1);if(h.useEffect(()=>{let v=!1;return a?(p(!0),f(""),c(""),Jf(t,a).then(y=>{v||c(y)}).catch(y=>{v||f(String(y.message||y))}).finally(()=>{v||p(!1)}),()=>{v=!0}):(c(""),f(""),p(!1),()=>{v=!0})},[a,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]),!s)return null;const m=a?l:i,g=s==="html"?Uu(m):yu(m),b=Yl(s,g);if(u)return o.jsxs(Hi,{className:"af-work-display-empty",children:["Loading ",a,"..."]});if(d)return o.jsx(Hi,{className:"af-work-display-empty",children:d});if(b)return o.jsx(Hi,{className:"af-work-display-empty",children:b});if(!g.trim())return o.jsx(Hi,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return o.jsx(Hi,{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals",srcDoc:hR(g)},r)});if(s==="image"){const v=hg(g,t);return o.jsx(Hi,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:v,alt:Lq(e),loading:"lazy"})})}return s==="markdown"?o.jsx(Hi,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(T0,{content:g,resolveSrc:v=>hg(v,t)})}):s==="chart"?o.jsx(Hi,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(L0,{content:g})}):s==="table"?o.jsx(Hi,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(R0,{content:g})}):s==="mermaid"?o.jsxs(Hi,{className:"af-work-display-body",children:[o.jsx(gR,{code:g}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:g})]}):o.jsx(Hi,{className:"af-work-display-body af-work-display-body--ascii",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:g})})}function Dq({node:e}){var u,p,m,g,b,v,y,k,w,j,_;const t=Un((u=e==null?void 0:e.data)==null?void 0:u.definitionId),n=ec(e==null?void 0:e.data),r=t==="image"?"":Xf(n,t),[s,i]=h.useState(""),[a,l]=h.useState(!1);h.useEffect(()=>{var O;let E=!1;return r?(l(!0),i(""),Jf(((O=e==null?void 0:e.data)==null?void 0:O.flowParams)||{},r).then(H=>{E||i(H)}).catch(()=>{E||i("")}).finally(()=>{E||l(!1)}),()=>{E=!0}):(i(""),l(!1),()=>{E=!0})},[r,(m=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:m.flowId,(b=(g=e==null?void 0:e.data)==null?void 0:g.flowParams)==null?void 0:b.flowSource,(y=(v=e==null?void 0:e.data)==null?void 0:v.flowParams)==null?void 0:y.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const c=r?s:n,d=t==="html"?Uu(c):yu(c),f=Yl(t,d);return a?o.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?o.jsx("div",{className:"af-display-picker-preview__empty",children:f}):d.trim()?t==="html"?o.jsx("iframe",{title:((w=e==null?void 0:e.data)==null?void 0:w.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals",srcDoc:hR(d)}):t==="image"?o.jsx("img",{src:hg(d,(j=e==null?void 0:e.data)==null?void 0:j.flowParams),alt:((_=e==null?void 0:e.data)==null?void 0:_.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?o.jsx("div",{className:"af-display-picker-preview__markdown",children:o.jsx(T0,{content:d,resolveSrc:E=>{var O;return hg(E,(O=e==null?void 0:e.data)==null?void 0:O.flowParams)}})}):t==="chart"?o.jsx(L0,{content:d}):t==="table"?o.jsx(R0,{content:d}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(gR,{code:d}),o.jsx("pre",{children:d})]}):o.jsx("pre",{className:"af-display-picker-preview__pre",children:d}):o.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function Fq({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=h.useRef(null),i=h.useRef(null),[a,l]=h.useState(!1),c=h.useCallback(f=>{const u=String(e||""),p=s.current,m=Number((p==null?void 0:p.selectionStart)??u.length),g=Number((p==null?void 0:p.selectionEnd)??m),b=u.slice(0,m),v=u.slice(g),y=b&&!b.endsWith(`
162
- `)?`
163
- `:"",k=v&&!v.startsWith(`
164
- `)?`
165
- `:"",w=`${b}${y}${f}${k}${v}`;t==null||t(w),window.requestAnimationFrame(()=>{var _,E;const j=b.length+y.length+f.length;(_=s.current)==null||_.focus(),(E=s.current)==null||E.setSelectionRange(j,j)})},[t,e]),d=h.useCallback(async f=>{if(!r&&!(!f||a)){l(!0);try{const u=await(n==null?void 0:n(f)),p=String(u||"").trim();if(p){const m=String(f.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";c(`![${m}](${p})`)}}finally{l(!1)}}},[c,n,r,a]);return o.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:f=>f.stopPropagation(),onDragOver:f=>{var p;Array.from(((p=f.dataTransfer)==null?void 0:p.items)||[]).some(m=>String((m==null?void 0:m.type)||"").startsWith("image/"))&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},onDrop:f=>{var p;const u=Array.from(((p=f.dataTransfer)==null?void 0:p.files)||[]).find(pg);u&&(f.preventDefault(),d(u))},children:[o.jsxs("div",{className:"af-work-display-editor__toolbar",children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:a||r,onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:a?"hourglass_top":"add_photo_alternate"})}),o.jsx("input",{ref:i,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:f=>{var p;const u=(p=f.target.files)==null?void 0:p[0];f.target.value="",u&&d(u)}})]}),o.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:f=>t==null?void 0:t(f.target.value),onKeyDown:f=>{f.key==="Escape"&&f.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r})]})}function zq({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},i=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=h.useState(a),d=h.useRef(!1),f=String(s.candidateContent||""),u=!!s.running,p=!!(t!=null&&t.readOnly),m=String(s.error||"");return h.useEffect(()=>{d.current||c(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-work-node-chat__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"继续微调"}),o.jsx("span",{children:(t==null?void 0:t.label)||e})]}),o.jsx("button",{type:"button",onClick:()=>{var g;return(g=t==null?void 0:t.onCloseNodeChat)==null?void 0:g.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||u||m||f.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[i.slice(-4).map((g,b)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${g.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:g.role==="assistant"?"AI":"你"}),o.jsx("p",{children:g.text})]},`${g.at||b}-${b}`)),u?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,m?o.jsx("div",{className:"af-work-node-chat__error",children:m}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:u||p,"aria-label":"添加上下文",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),o.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:u||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:g=>{var v;d.current=!1;const b=g.currentTarget.value;c(b),(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,b)},onChange:g=>{var v;const b=g.target.value;c(b),d.current||(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,b)},onKeyDown:g=>{var b,v;g.isComposing||(b=g.nativeEvent)!=null&&b.isComposing||g.keyCode===229||(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),(v=t==null?void 0:t.onSendNodeChat)==null||v.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:u||p||!l.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onSendNodeChat)==null?void 0:g.call(t,e,l)},"aria-label":"发送",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),o.jsxs("div",{className:"af-work-node-chat__actions",children:[o.jsx("button",{type:"button",disabled:u||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:u||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"append")},children:"追加"})]})]}):o.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:[o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function Hq(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function Bq(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function A1(e,t){const n=Un(t==null?void 0:t.definitionId)||"markdown";return`outputs/${Bq((t==null?void 0:t.label)||e||n)}.${Hq(n)}`}function Wq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((P,C)=>({slot:P,idx:C})).sort((P,C)=>{var ce,fe,he,oe;const G=String(((ce=P.slot)==null?void 0:ce.name)||"").trim(),Z=String(((fe=C.slot)==null?void 0:fe.name)||"").trim();if(G==="next"&&Z!=="next")return-1;if(Z==="next"&&G!=="next")return 1;const V=String(((he=P.slot)==null?void 0:he.type)||"").trim(),ne=String(((oe=C.slot)==null?void 0:oe.type)||"").trim();return V==="node"&&ne!=="node"?-1:ne==="node"&&V!=="node"?1:P.idx-C.idx}),l=Un(t==null?void 0:t.definitionId),c=h.useRef(null),d=h.useRef(null),[f,u]=h.useState(0),[p,m]=h.useState(!1),[g,b]=h.useState(!1),[v,y]=h.useState(!1),[k,w]=h.useState(""),[j,_]=h.useState(!1),E=h.useRef(null),O=ec(t),H=l==="markdown"?O:"",L=!!(t!=null&&t.readOnly),F=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{if(!g)return;const P=()=>b(!1);return window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",P,!0),window.addEventListener("mouseup",P,!0),window.addEventListener("blur",P),()=>{window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",P,!0),window.removeEventListener("mouseup",P,!0),window.removeEventListener("blur",P)}},[g]),h.useEffect(()=>{v||w(String(H||""))},[H,v]);const D=(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"),R=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,W=h.useCallback(async()=>{var we,_e,xe,Te,Ae,et,ct,Xe,mt,He;if(l!=="html"||p)return;const P=ec(t),C=Xf(P,l);let G=P;if(C)try{G=await Jf((t==null?void 0:t.flowParams)||{},C)}catch(dt){m(!1),console.warn("Failed to read HTML display file before saving image.",dt);return}const Z=Uu(G);if(!Z.trim())return;const V=Yl(l,Z);if(V){console.warn(V);return}const ne=(_e=(we=d.current)==null?void 0:we.getBoundingClientRect)==null?void 0:_e.call(we),ce=(Te=(xe=c.current)==null?void 0:xe.querySelector)==null?void 0:Te.call(xe,".af-work-display-body"),fe=(et=(Ae=c.current)==null?void 0:Ae.querySelector)==null?void 0:et.call(Ae,".af-visible-scroll-frame__scroller"),he=Math.round(Math.max(Number((ne==null?void 0:ne.width)||0),Number((R==null?void 0:R.width)||0),Number(((ct=c.current)==null?void 0:ct.clientWidth)||0),Number((ce==null?void 0:ce.clientWidth)||0),Number((fe==null?void 0:fe.clientWidth)||0),Math.max(320,Number((R==null?void 0:R.width)||960)-2))),oe=Math.round(Math.max(Number((ne==null?void 0:ne.height)||0),Number((R==null?void 0:R.height)||0),Number(((Xe=c.current)==null?void 0:Xe.clientHeight)||0),Number((ce==null?void 0:ce.clientHeight)||0),Number((fe==null?void 0:fe.clientHeight)||0),Math.max(180,Number((R==null?void 0:R.height)||640)-46)));m(!0);try{await Rq({flowParams:(t==null?void 0:t.flowParams)||{},content:Z,sourceFilePath:C,iframe:d.current,width:he,height:oe,filename:_q((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:ce,scroller:fe},displaySize:R}),(mt=t==null?void 0:t.onStatus)==null||mt.call(t,"已导出 HTML 展示截图")}catch(dt){const gn=String((dt==null?void 0:dt.message)||dt||"截图失败");(He=t==null?void 0:t.onStatus)==null||He.call(t,`HTML 截图失败:${gn}`),console.warn("Failed to save HTML display as PNG.",dt)}finally{m(!1)}},[t,R==null?void 0:R.height,R==null?void 0:R.width,e,l,p]),M=h.useCallback(P=>{var C;L||!P||l!=="image"||(C=t==null?void 0:t.onUploadImageToDisplayNode)==null||C.call(t,e,P)},[t,e,l,L]),$=h.useCallback(P=>{var C,G;(C=P==null?void 0:P.stopPropagation)==null||C.call(P),!L&&((G=t==null?void 0:t.onSetDisplayNodeContent)==null||G.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(w(""),y(!1)))},[t,e,l,L]),T=h.useCallback(P=>{var Z,V;L||l!=="image"||!(Array.from(((Z=P.dataTransfer)==null?void 0:Z.files)||[]).some(pg)||Array.from(((V=P.dataTransfer)==null?void 0:V.items)||[]).some(ne=>String((ne==null?void 0:ne.type)||"").startsWith("image/")))||(P.preventDefault(),P.stopPropagation(),P.dataTransfer.dropEffect="copy",_(!0))},[l,L]),z=h.useCallback(P=>{l==="image"&&(P.currentTarget.contains(P.relatedTarget)||_(!1))},[l]),A=h.useCallback(P=>{var G;if(l!=="image")return;const C=Array.from(((G=P.dataTransfer)==null?void 0:G.files)||[]).find(pg);C&&(P.preventDefault(),P.stopPropagation(),_(!1),M(C))},[l,M]);return o.jsxs("div",{className:"af-work-display-card"+(R?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(g?" af-work-display-card--resizing":"")+(j?" af-work-display-card--image-drop":"")+(F?" 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:R?{width:R.width,height:R.height}:void 0,ref:c,onDragOver:T,onDragLeave:z,onDrop:A,children:[o.jsx(rI,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>b(!0),onResizeEnd:()=>b(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((P,C)=>{if(P.showOnNode===!1)return null;const G=`${4.15+C*1.75}rem`,Z=P.name||`#${C+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:G},children:Z}),o.jsx(Ds,{type:"target",position:Je.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:G,background:or(P.type)},title:`${Z} · ${P.type}`})]},`in-${C}`)}),a.map(({slot:P,idx:C},G)=>{if(P.showOnNode===!1)return null;const Z=`${4.15+G*1.75}rem`,V=P.name||`#${C+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Z},children:V}),o.jsx(Ds,{type:"source",position:Je.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Z,background:or(P.type)},title:`${V} · ${P.type}`})]},`out-${C}`)}),o.jsxs("div",{className:"af-work-display-card__head",children:[o.jsxs("div",{className:"af-work-display-card__title",children:[o.jsx("span",{className:"material-symbols-outlined",children:Oq(l)}),o.jsx("strong",{children:D}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:P=>P.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var P,C,G,Z;try{(Z=(G=(C=(P=d.current)==null?void 0:P.contentWindow)==null?void 0:C.history)==null?void 0:G.back)==null||Z.call(G)}catch{}},"aria-label":"后退",title:"后退",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var P,C,G,Z;try{(Z=(G=(C=(P=d.current)==null?void 0:P.contentWindow)==null?void 0:C.history)==null?void 0:G.forward)==null||Z.call(G)}catch{}},"aria-label":"前进",title:"前进",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>u(P=>P+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:p,onClick:W,"aria-label":"截图另存为图片",title:"截图另存为图片",children:o.jsx("span",{className:"material-symbols-outlined",children:p?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?v?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:P=>P.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:L,onClick:()=>{var P;(P=t==null?void 0:t.onSetDisplayNodeContent)==null||P.call(t,e,k,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),y(!1)},"aria-label":"保存并预览",title:"保存并预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"done"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{w(String(H||"")),y(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:P=>{P.stopPropagation(),w(String(H||"")),y(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:E,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:P=>{var G;const C=(G=P.target.files)==null?void 0:G[0];P.target.value="",C&&M(C)}}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:P=>{var C;P.stopPropagation(),(C=E.current)==null||C.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:$,"aria-label":"清空内容",title:"清空内容",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:()=>{var P;return(P=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:P.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"save"})}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:L,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&v?o.jsx(Fq,{value:k,onChange:w,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:L}):o.jsx($q,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:d,htmlFrameVersion:f}),o.jsx(zq,{nodeId:e,data:t})]})}function Vq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=(t==null?void 0:t.runningRunNodeId)===e,l=(t==null?void 0:t.nodeStatus)==="stopped",c=!!(t!=null&&t.readOnly);return o.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(l?" af-work-run-card--stopped":""),children:[s.map((d,f)=>{if(d.showOnNode===!1)return null;const u=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:u},children:p}),o.jsx(Ds,{type:"target",position:Je.Left,id:`input-${f}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:u,background:or(d.type)},title:`${p} · ${d.type}`})]},`in-${f}`)}),i.map((d,f)=>{if(d.showOnNode===!1)return null;const u=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:u},children:p}),o.jsx(Ds,{type:"source",position:Je.Right,id:`output-${f}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:u,background:or(d.type)},title:`${p} · ${d.type}`})]},`out-${f}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:c,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:c,onClick:d=>{var f,u;d.stopPropagation(),a?(f=t==null?void 0:t.onStopWorkspaceNode)==null||f.call(t,e):(u=t==null?void 0:t.onRunWorkspaceNode)==null||u.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),o.jsx("span",{children:a?"Stop":"Run line"})]})]})}function Uq(e){var m,g,b,v,y,k,w,j,_,E,O,H,L;const{setEdges:t,setNodes:n}=mc(),r=(m=e.data)==null?void 0:m.onSyncNodePropDraft,s=!!((g=e.data)!=null&&g.readOnly),[i,a]=h.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=h.useCallback(F=>{s||(n(D=>D.filter(R=>R.id!==F)),t(D=>D.filter(R=>R.source!==F&&R.target!==F)))},[s,t,n]),d=h.useCallback((F,D)=>{s||(n(R=>R.map(W=>W.id===F?{...W,data:{...W.data,model:D}}:W)),r==null||r(F,{model:D}))},[s,n,r]),f=h.useCallback((F,D)=>{s||(n(R=>R.map(W=>{var $;if(W.id!==F)return W;const M=Array.isArray(($=W.data)==null?void 0:$.outputs)&&W.data.outputs.length?W.data.outputs.map((T,z)=>z===0?{...T,default:D,value:D}:T):[{type:"bool",name:"value",default:D,value:D}];return{...W,data:{...W.data,body:"",outputs:M}}})),r==null||r(F,R=>({body:"",outputs:Array.isArray(R==null?void 0:R.outputs)&&R.outputs.length?R.outputs.map((M,$)=>$===0?{...M,default:D,value:D}:M):[{type:"bool",name:"value",default:D,value:D}]})))},[s,n,r]),u=h.useCallback((F,D)=>{s||(n(R=>R.map(W=>W.id===F?{...W,data:{...W.data,body:D}}:W)),r==null||r(F,{body:D}))},[s,n,r]),p=h.useCallback((F,D)=>{if(s)return;const R=Is(D);n(W=>W.map(M=>M.id===F?{...M,data:{...M.data,images:R}}:M)),r==null||r(F,{images:R})},[s,n,r]);return Un((v=e.data)==null?void 0:v.definitionId)?o.jsx(Wq,{...e,deleteNode:c}):((y=e.data)==null?void 0:y.definitionId)==="workspace_run"?o.jsx(Vq,{...e,deleteNode:c}):((k=e.data)==null?void 0:k.definitionId)==="control_load_skills"?o.jsx(rY,{...e,deleteNode:c,skills:(w=e.data)==null?void 0:w.skills,skillCollections:(j=e.data)==null?void 0:j.skillCollections,onChangeSkillKeys:(_=e.data)==null?void 0:_.onChangeLoadSkillKeys}):((E=e.data)==null?void 0:E.definitionId)==="control_load_mcp"?o.jsx(sY,{...e,deleteNode:c,servers:(O=e.data)==null?void 0:O.mcpServers,onChangeMcpNames:(H=e.data)==null?void 0:H.onChangeLoadMcpNames}):o.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(i?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,children:[s?null:o.jsx(rI,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:oR,minHeight:Mb,maxWidth:aR,maxHeight:lR,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx($T,{...e,deleteNode:c,modelLists:(L=e.data)==null?void 0:L.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:u,onNodeImagesChange:p})]})}const Kq={[wp]:Uq};function yR(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&yR(n.children,t);return t}function xR(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&xR(n.children,t));return t}function Hh(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 qq(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function Yq(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(i,a,l)=>{const c=r[a],d=l?`${l}/${c}`:c,f=a===r.length-1;let u=!1;const p=(Array.isArray(i)?i:[]).map(m=>m.name!==c?m:(u=!0,f?{...m,type:"file",name:c,path:d,icon:Yd(c),size:n}:{...m,type:"directory",name:c,path:d,icon:Yd(c,!0),children:s(m.children||[],a+1,d)}));return u||p.push(f?{type:"file",name:c,path:d,icon:Yd(c),size:n}:{type:"directory",name:c,path:d,icon:Yd(c,!0),children:s([],a+1,d)}),qq(p)};return s(e||[],0,"")}function wR({items:e,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:c}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(d=>{var p;const f=d.type==="directory",u=f&&(r==null?void 0:r.has(d.path));return o.jsxs("li",{children:[o.jsxs("div",{className:"af-work-file-row",children:[o.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+d.type,draggable:!f,onDragStart:m=>{f||c==null||c(m,d)},onClick:()=>f?s==null?void 0:s(d.path):n(d),title:d.path,children:[f?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:u?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:d.icon||Yd(d.name,f)}),o.jsx("span",{children:d.name})]}),f?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>i==null?void 0:i(d.path),title:"新增文件","aria-label":`在 ${d.name} 新增文件`,children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>a==null?void 0:a(d.path),title:"新增文件夹","aria-label":`在 ${d.name} 新增文件夹`,children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,f?null:o.jsx("a",{className:"af-work-file-action",href:fq(d.path,t),download:d.name,onClick:m=>m.stopPropagation(),title:"下载","aria-label":`下载 ${d.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"download"})}),o.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:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),f&&!u&&((p=d.children)!=null&&p.length)?o.jsx(wR,{items:d.children,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:c}):null]},d.path)})})}function Gq({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return o.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,i)=>{const a=s.kind==="run-log"||s.kind==="run-summary"||s.kind==="activity"||s.kind==="prompt"||s.kind==="raw"||s.kind==="thinking"||s.kind==="result"||s.kind==="assistant"?"reply":s.role==="user"?"user-msg":s.error?"error":"reply",l=s.kind==="run-summary"?"Steps":s.kind==="run-log"?"Run":s.kind==="activity"?"Activity":s.kind==="prompt"?"Prompt":s.kind==="raw"?"Raw Trace":s.kind==="thinking"?"Thinking":s.kind==="result"?"Result":s.kind==="assistant"?"Response":s.role==="user"?"You":s.error?"Error":"Reply";return o.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[o.jsx("div",{className:"af-composer-ai-block-label",children:l}),o.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${i}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function gg(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 Xq(e){const t=gg((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 gg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Jq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function Qq(e){const t=gg((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 gg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Zq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function I1(e){var r,s,i,a,l,c;if(!e)return null;const{inputs:t,outputs:n}=RT(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((s=e.data)==null?void 0:s.role)??"normal"),model:String(((i=e.data)==null?void 0:i.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:Is((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),inputs:t,outputs:n}}function T1(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 eY(e,t,n){var f,u;const r=String(((f=e==null?void 0:e.data)==null?void 0:f.definitionId)??n),s=r.startsWith("provide_"),i=String((t==null?void 0:t.role)||"").trim(),a=ll.includes(i)?i:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:s?"":String((t==null?void 0:t.body)??""),images:s?[]:Is(t==null?void 0:t.images),inputs:T1(t==null?void 0:t.inputs),outputs:s&&Array.isArray((u=e.data)==null?void 0:u.outputs)?e.data.outputs:T1(t==null?void 0:t.outputs)},d=String((t==null?void 0:t.script)??"").trim();return r==="tool_nodejs"||d!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script,c}function R1({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:i=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=i?l:a;if(i){if(!KT.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(b=>b.id===c&&b.id!==a))return{ok:!1,error:"Duplicate instance id"}}const d=eY(r,s,c),f=r.data||{};if(!(c!==a||f.label!==d.label||f.role!==d.role||f.model!==d.model||f.body!==d.body||JSON.stringify(Is(f.images))!==JSON.stringify(d.images)||(f.script??void 0)!==(d.script??void 0)||JSON.stringify(f.inputs||[])!==JSON.stringify(d.inputs||[])||JSON.stringify(f.outputs||[])!==JSON.stringify(d.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(b=>b.id===a?{...b,id:c,selected:!0,data:d}:b);let m=t,g=n;if(c!==a){g={...n||{}};const b={...g[a]||{}};delete g[a],g[c]=b,m=t.map((v,y)=>({...v,source:v.source===a?c:v.source,target:v.target===a?c:v.target,id:`we-${v.source===a?c:v.source}-${v.target===a?c:v.target}-${y}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:m,instances:g}}function tY(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function nY(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","inputs","outputs"])tY(e[s],t[s])&&(r[s]=n[s]);return r}function rY({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],d=Array.isArray(s)?s:[],f=Array.isArray(i)?i:[],[u,p]=h.useState(!1),[m,g]=h.useState(""),[b,v]=h.useState(()=>new Set),y=h.useRef(null),k=h.useRef(null),[w,j]=h.useState({visible:!1,top:0,height:100}),_=h.useMemo(()=>new Set(Xq(t)),[t]),E=h.useMemo(()=>new Map(d.map($=>[$.key,$])),[d]),O=h.useMemo(()=>{const $=new Set,T=f.map(A=>{const P=ol(A,d).map(C=>E.get(C)).filter(Boolean);for(const C of P)$.add(C.key);return{...A,skills:P}}).filter(A=>A.skills.length>0),z=d.filter(A=>!$.has(A.key));return{collectionGroups:T,ungrouped:z}},[E,f,d]);h.useEffect(()=>{v($=>{let T=!1;const z=new Set($);for(const A of O.collectionGroups)z.has(A.id)||(z.add(A.id),T=!0);return T?z:$})},[O.collectionGroups]);const H=h.useMemo(()=>{const $=m.trim().toLowerCase();if(!$)return O;const T=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(C=>String(C||"").toLowerCase()).join(" ").includes($);return{collectionGroups:O.collectionGroups.map(A=>{const C=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(G=>String(G||"").toLowerCase()).join(" ").includes($)?A.skills:A.skills.filter(T);return{...A,skills:C}}).filter(A=>A.skills.length>0),ungrouped:O.ungrouped.filter(T)}},[O,m]),L=h.useCallback(($,T)=>{const z=new Set(_);for(const A of $)T?z.add(A):z.delete(A);a==null||a(e,Array.from(z))},[e,_,a]),F=h.useCallback($=>{v(T=>{const z=new Set(T);return z.has($)?z.delete($):z.add($),z})},[]),D=h.useCallback(()=>{const $=y.current;if(!$)return;const T=Math.max(1,$.scrollHeight),z=Math.max(1,$.clientHeight),A=T>z+1,P=A?Math.max(12,z/T*100):100,C=Math.max(0,100-P),G=A?Math.min(C,$.scrollTop/Math.max(1,T-z)*C):0;j({visible:A,top:G,height:P})},[]);h.useEffect(()=>{if(!u)return;const $=requestAnimationFrame(D);return()=>cancelAnimationFrame($)},[b,H,_.size,u,D]);const R=h.useCallback($=>{const T=y.current;if(!T)return;const z=Math.max(0,T.scrollHeight-T.clientHeight);T.scrollTop=Math.min(1,Math.max(0,$))*z,D()},[D]),W=h.useCallback(($,T=0)=>{const z=k.current;if(!z)return 0;const A=z.getBoundingClientRect(),P=w.height/100*A.height,C=Math.max(1,A.height-P);return($-A.top-T)/C},[w.height]),M=h.useCallback($=>{var ce,fe;if(!w.visible)return;$.preventDefault(),$.stopPropagation();const T=k.current;if(!T)return;const z=T.getBoundingClientRect(),A=w.top/100*z.height,P=w.height/100*z.height,G=$.clientY>=z.top+A&&$.clientY<=z.top+A+P?$.clientY-z.top-A:P/2;R(W($.clientY,G));const Z=$.pointerId;(fe=(ce=$.currentTarget).setPointerCapture)==null||fe.call(ce,Z);const V=he=>{he.preventDefault(),R(W(he.clientY,G))},ne=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",ne),window.removeEventListener("pointercancel",ne)};window.addEventListener("pointermove",V),window.addEventListener("pointerup",ne),window.addEventListener("pointercancel",ne)},[W,R,w.height,w.top,w.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[l.map(($,T)=>{if($.showOnNode===!1)return null;const z=`${2.6+T*1.7}rem`,A=$.name||`#${T+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:z},children:A}),o.jsx(Ds,{type:"target",position:Je.Left,id:`input-${T}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:z,background:or($.type)},title:`${A} · ${$.type}`})]},`in-${T}`)}),c.map(($,T)=>{if($.showOnNode===!1)return null;const z=`${2.6+T*1.7}rem`,A=$.name||`#${T+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:z},children:A}),o.jsx(Ds,{type:"source",position:Je.Right,id:`output-${T}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:z,background:or($.type)},title:`${A} · ${$.type}`})]},`out-${T}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:$=>{var T;$.stopPropagation(),u||(T=t==null?void 0:t.onRefreshSkills)==null||T.call(t),p(z=>!z)},children:[o.jsx("span",{children:_.size>0?`${_.size} skills selected`:"选择 Skills"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:m,onChange:$=>g($.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?o.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:D,children:[H.collectionGroups.map($=>{const T=$.skills.map(C=>C.key),z=T.filter(C=>_.has(C)).length,A=T.length>0&&z===T.length,P=b.has($.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(P?" af-work-load-skills-menu__group--collapsed":""),children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:C=>L(T,C.target.checked),"aria-label":`选择 ${$.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>F($.id),"aria-expanded":!P,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:$.name}),$.description?o.jsx("em",{children:$.description}):null]})}),o.jsxs("small",{children:[z,"/",T.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>F($.id),"aria-label":P?`展开 ${$.name}`:`收起 ${$.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:P?"chevron_right":"expand_more"})})]}),P?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:$.skills.map(C=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:_.has(C.key),onChange:G=>L([C.key],G.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:C.name}),C.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:C.description}):null]})]},`${$.id}:${C.key}`))})]},$.id)}),H.ungrouped.length>0?o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("small",{children:H.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:H.ungrouped.map($=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:_.has($.key),onChange:T=>L([$.key],T.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:$.name}),$.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:$.description}):null]})]},`ungrouped:${$.key}`))})]}):null,H.collectionGroups.length===0&&H.ungrouped.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),o.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(w.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:M,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${w.height}%`,top:`${w.top}%`}})})]}):null]})]})}function sY({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:i}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,d]=h.useState(!1),[f,u]=h.useState(""),p=h.useMemo(()=>new Set(Qq(t)),[t]),m=h.useMemo(()=>(Array.isArray(s)?s:[]).map(v=>({name:String((v==null?void 0:v.name)||""),description:String((v==null?void 0:v.description)||""),detail:String((v==null?void 0:v.url)||[v==null?void 0:v.command,...Array.isArray(v==null?void 0:v.args)?v.args:[]].filter(Boolean).join(" ")||""),type:String((v==null?void 0:v.type)||"")})).filter(v=>v.name),[s]),g=h.useMemo(()=>{const v=f.trim().toLowerCase();return v?m.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(v)):m},[f,m]),b=h.useCallback((v,y)=>{const k=new Set(p);for(const w of v)y?k.add(w):k.delete(w);i==null||i(e,Array.from(k))},[e,p,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[a.map((v,y)=>{if(v.showOnNode===!1)return null;const k=`${2.6+y*1.7}rem`,w=v.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:w}),o.jsx(Ds,{type:"target",position:Je.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:or(v.type)},title:`${w} · ${v.type}`})]},`in-${y}`)}),l.map((v,y)=>{if(v.showOnNode===!1)return null;const k=`${2.6+y*1.7}rem`,w=v.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:w}),o.jsx(Ds,{type:"source",position:Je.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:or(v.type)},title:`${w} · ${v.type}`})]},`out-${y}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"hub"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:v=>{var y;v.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(k=>!k)},children:[o.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:f,onChange:v=>u(v.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),f?o.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{className:"af-work-load-skills-menu",children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"MCP Servers"}),o.jsx("small",{children:g.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(v=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:p.has(v.name),onChange:y=>b([v.name],y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:v.name}),v.description||v.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:v.description||v.detail}):null]})]},v.name))})]}),g.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空"})]})]}):null]})]})}function iY(){var pd,hd;const{t:e,i18n:t}=Ln(),{navigate:n}=Ro(),r=mc(),s=a0(),i=h.useMemo(dq,[]),[a,l]=h.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[c,d]=h.useState(!1),[f,u]=h.useState(!1),[p,m]=QA([]),[g,b,v]=ZA([]),y=h.useRef([]),k=h.useRef([]),[w,j]=h.useState(()=>Fb(null,[])),_=h.useRef(w),[E,O]=h.useState(null),H=h.useRef(null),[L,F]=h.useState([]),D=h.useRef(new Map),R=h.useRef(new Map),W=h.useRef(null),M=h.useRef(null),$=h.useRef(null),[T,z]=h.useState(null),[A,P]=h.useState({}),C=h.useRef({}),G=h.useRef(!1),Z=h.useRef(null),[V,ne]=h.useState([]),[ce,fe]=h.useState(""),[he,oe]=h.useState("nodes"),[we,_e]=h.useState([]),[xe,Te]=h.useState(!1),[Ae,et]=h.useState(""),[ct,Xe]=h.useState(!1),[mt,He]=h.useState({name:"",id:"",description:""}),[dt,gn]=h.useState(!1),[yn,On]=h.useState(""),[rn,Yn]=h.useState(""),Mn=h.useRef(null),[ue,ve]=h.useState(!1),[Be,ot]=h.useState(!1),[at,Lt]=h.useState(""),[nt,dn]=h.useState(null),[Qt,ar]=h.useState({title:"",layout:"gallery",nodeIds:[]}),[Cn,fn]=h.useState(!1),[xn,lr]=h.useState(""),[be,Me]=h.useState(!1),[tt,zt]=h.useState(""),[ie,Ie]=h.useState(!1),[We,Ht]=h.useState("nodes"),[pn,cr]=h.useState(""),[zs,is]=h.useState(0),[hr,Zn]=h.useState(""),Wr=h.useRef(""),[it,Vr]=h.useState(null),_i=h.useRef(null),[ya,ys]=h.useState(""),[Pe,sn]=h.useState([]),[mr,ht]=h.useState(""),[Oe,Ur]=h.useState(!0),[Gn,Kr]=h.useState(""),[Cr,ut]=h.useState(()=>new Set),Ut=h.useRef(null),[on,Er]=h.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[Ze,gr]=h.useState(!1),[Hs,xa]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[xs,Mo]=h.useState(""),[vr,$o]=h.useState([]),[Pi,hn]=h.useState(!1),[er,ws]=h.useState([]),[qr,oi]=h.useState([]),[Bs,K]=h.useState(!1),[ge,Re]=h.useState([]),Le=h.useCallback(S=>{Mn.current&&window.clearTimeout(Mn.current),Yn(S),Mn.current=window.setTimeout(()=>{Yn(""),Mn.current=null},3800)},[]),Ve=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const U=()=>s(I);window.requestAnimationFrame(U),window.setTimeout(U,80)},[s]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(on)))}catch{}},[on]);const Zt=h.useCallback(S=>{const I=Ut.current;if(!I)return;const U=I.getBoundingClientRect(),X=16,Q=150,se=230,re=U.top+X,ae=U.bottom-X,pe=Math.max(Q,ae-re-se),le=Math.min(Math.max(S-re,Q),pe);Er(le)},[]),Ot=h.useCallback(S=>{S.preventDefault(),S.stopPropagation(),gr(!0),Zt(S.clientY);const I=X=>{X.preventDefault(),Zt(X.clientY)},U=()=>{gr(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",U,!0),window.removeEventListener("pointercancel",U,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",U,!0),window.addEventListener("pointercancel",U,!0)},[Zt]);h.useEffect(()=>()=>{Mn.current&&window.clearTimeout(Mn.current)},[]);const[mn,Yr]=h.useState(()=>new Set),[os,Ws]=h.useState(!1),ur=h.useRef(null),wa=h.useRef(null),Ju=h.useRef(null),[jp,Ai]=h.useState({}),[ba,gl]=h.useState(""),[_r,yl]=h.useState(!1),[xl,Kt]=h.useState([]),[yc,Bt]=h.useState([]),[wl,ro]=h.useState("workspace"),[ai,Do]=h.useState(!1),[Qu,Fo]=h.useState(!0),[kr,bl]=h.useState(""),[li,Ii]=h.useState({}),[xc,zo]=h.useState(!1),[va,Ho]=h.useState(!1),[vl,kl]=h.useState(!1),[Zu,ci]=h.useState("pan"),[Lr,ed]=h.useState(null),[ui,ka]=h.useState(""),Bo=h.useRef(null),bs=h.useRef(!1),[td,Gr]=h.useState(()=>new Set),[Sa,di]=h.useState({}),[vs,Ce]=h.useState(""),ks=h.useMemo(()=>pq(i),[i]),[Na,ja]=h.useState(""),fi=i.flowSource||"user",Cp=!!(i.flowId&&!i.archived&&(fi==="user"||fi==="workspace")),nd=h.useMemo(()=>{if(!i.flowId)return"/flow?panel=settings";const S=Tf({id:i.flowId,source:fi,archived:!!i.archived},"pipeline"),[I,U=""]=S.split("?"),X=new URLSearchParams(U);return X.set("panel","settings"),`${I}?${X.toString()}`},[i.archived,i.flowId,fi]);h.useEffect(()=>{i.flowId&&nP(i.flowId,i.flowSource||"user","workspace",!!i.archived)},[i]),h.useEffect(()=>{const S=()=>{l(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[]),h.useEffect(()=>{Kt([]),Bt([]),ro("workspace"),Fo(!0)},[i]);const Bn=h.useCallback(async()=>{const S=xo(i),I=await fetch(`/api/workspace/files?${S.toString()}`),U=await I.json();if(!I.ok)throw new Error(U.error||"读取 workspace 失败");const X=U.files||[];sn(X),ut(new Set(xR(X))),ht(U.root||"")},[i]),so=h.useCallback(async()=>{Te(!0),et("");try{const S=await fetch("/api/marketplace/flow-snippets"),I=await S.json().catch(()=>({}));if(!S.ok)throw new Error(I.error||"读取流程片段失败");_e(Array.isArray(I.snippets)?I.snippets:[])}catch(S){et(String(S.message||S)),_e([])}finally{Te(!1)}},[]),$n=h.useCallback(async(S=p,I=g)=>{var se;if(!G.current)return;if(!Oe)throw Ce("Readonly workspace"),new Error("Readonly workspace");const U=zh(S,I,C.current);U.ui={...U.ui||{},...H.current?{viewport:H.current}:{},displayPage:Sq(_.current,S)};const X=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:U})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"保存 workspace graph 失败");C.current=((se=Q.graph)==null?void 0:se.instances)||U.instances,P(C.current),Ce("Workspace graph saved")},[g,i,p,Oe]),Ep=h.useCallback(S=>{var U;const I=(U=S==null?void 0:S.extra)!=null&&U.instances&&typeof S.extra.instances=="object"?S.extra.instances:{};C.current=I,P(I),m(Array.isArray(S==null?void 0:S.nodes)?S.nodes:[]),b(Array.isArray(S==null?void 0:S.edges)?S.edges:[]),Zn(""),z(null)},[b,m]),rd=h.useMemo(()=>({instances:A}),[A]),sd=OT({nodes:p,edges:g,extra:rd,enabled:G.current,onRestore:Ep}),{resetHistory:Ca,undo:_p,redo:Pp}=sd,wt=h.useCallback(async()=>{var gt,qe;G.current=!1;const S=xo(i),I=xo(i);I.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[U,X]=await Promise.all([fetch(`/api/nodes?${I.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),Bn()]),Q=await U.json(),se=await X.json();if(!U.ok)throw new Error(Q.error||"读取节点定义失败");if(!X.ok)throw new Error(se.error||"读取 workspace graph 失败");const re=[...(Array.isArray(Q)?Q:Q.nodes||[]).filter(At=>!sq.has(At.id)),oq,aq,iq];ne(re);const ae=se.graph||JSON.parse(localStorage.getItem(rq)||"null")||{},pe=Dx(ae,re),le=Fb((gt=ae==null?void 0:ae.ui)==null?void 0:gt.displayPage,pe.nodes),Ne=fR((qe=ae==null?void 0:ae.ui)==null?void 0:qe.viewport);C.current=pe.instances,P(pe.instances),m(pe.nodes),b(pe.edges),j(le),_.current=le,O(Ne),H.current=Ne,F([]),Ca(pe.nodes,pe.edges,{instances:pe.instances});const ze=se.writable!==!1;Ur(ze),Ce(ze?"Workspace ready":"Readonly workspace"),G.current=!0},[i,t.language,Bn,Ca,b,m]),id=h.useCallback(async(S,I)=>{const U={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:I,body:(S==null?void 0:S.body)||"",script:(S==null?void 0:S.script)||"",inputs:Array.isArray(S==null?void 0:S.inputs)?S.inputs:[],outputs:Array.isArray(S==null?void 0:S.outputs)?S.outputs:[],flowId:i.flowId,flowSource:i.flowSource||"user",archived:!!i.archived},X=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)}),Q=await X.json().catch(()=>({}));if(!X.ok||(Q==null?void 0:Q.ok)===!1)throw new Error((Q==null?void 0:Q.error)||"Publish failed");return await wt(),Ce(`Published node ${Q.definitionId||Q.id||U.packageId}`),Q},[i,wt]),Ap=h.useCallback((S="workspace")=>{Do(!0),Vr(null),ro(S||"workspace")},[]),Sl=h.useCallback(async(S="")=>{const I=String(S||ui||"").trim();bs.current=!0,Bo.current&&(Bo.current.abort(),Bo.current=null),ka(""),Gr(new Set),di(U=>{const X={...U};for(const[Q,se]of Object.entries(X))(se==null?void 0:se.status)==="running"&&(X[Q]={status:"stopped"});return I&&(X[I]={status:"stopped"}),X}),Ce(I?`Workspace run stopped: ${I}`:"Workspace run stopped"),Bt(U=>U.map(X=>(!I||X.runNodeId===I)&&X.status==="running"?{...X,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(X.messages)?X.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:X));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runNodeId:I})})}catch{}},[i,ui]),vt=h.useCallback(async()=>{if(i.flowId)try{const S=xo(i),I=await fetch(`/api/workspace/run/status?${S.toString()}`),U=await I.json().catch(()=>({}));if(!I.ok||!U.running)return;const X=String(U.runNodeId||"").trim();X?(ka(X),Gr(new Set([X])),di(Q=>({...Q,[X]:{status:"running"}})),Ce(`Workspace run still running: ${X}`)):Ce("Workspace run still running"),Bt(Q=>{if(Q.some(re=>re.status==="running"&&(!X||re.runNodeId===X)))return Q;const se=`run-restored-${U.startedAt||Date.now()}`;return[...Q.slice(-7),{id:se,label:X?`Run ${X}`:"Workspace Run",runNodeId:X,status:"running",startedAt:U.startedAt||Date.now(),steps:X?[{id:X,label:X,status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:"Workspace run is still running in the background.",at:Date.now()}]}]})}catch{}},[i]),Ip=h.useCallback(async S=>{if(!Oe){Ce("Readonly workspace");return}if(!S||ui)return;let I=p,U=g,X=C.current;const Q=_i.current;if(Q!=null&&Q.id){const le=I.find(ze=>ze.id===Q.id),Ne=R1({nodes:I,edges:U,instances:X,selectedNode:le,draft:Q,allowRename:!1});if(Ne!=null&&Ne.error){ys(Ne.error),Ce(Ne.error);return}Ne!=null&&Ne.ok&&Ne.changed&&(I=Ne.nodes,U=Ne.edges,X=Ne.instances,C.current=X,P(X),m(I),b(U),Ve(Ne.nextId||Q.id))}const se=zh(I,U,X),re=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,ae=`Run ${S}`,pe=new AbortController;Bo.current=pe,bs.current=!1,ka(S),Gr(new Set([S])),di({[S]:{status:"running"}}),Ce(`Running ${S}...`),ro(re),Bt(le=>[...le.slice(-7),{id:re,label:ae,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await $n(I,U);const le=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:pe.signal,body:JSON.stringify({...i,graph:se,runNodeId:S,model:xs,selectedSkills:er,stream:!0})});if(!le.ok){const ke=await le.json().catch(()=>({}));throw new Error(ke.error||"Workspace run failed")}if(!le.body)throw new Error("Workspace run stream unavailable");const Ne=le.body.getReader(),ze=new TextDecoder;let gt="",qe=[],At=[],bn=S;const ls=(ke,pt)=>{var Mt,en;const yt=p.find(qt=>qt.id===ke),rt=String(((Mt=yt==null?void 0:yt.data)==null?void 0:Mt.label)||ke||"").trim(),De=String(pt||((en=yt==null?void 0:yt.data)==null?void 0:en.definitionId)||"").trim();return De&&De!==rt?`${rt} (${De})`:rt},nn=(ke,pt,yt)=>{const rt=String(ke||"").trim();rt&&Bt(De=>De.map(Mt=>{if(Mt.id!==re)return Mt;const qt=[...Array.isArray(Mt.steps)?Mt.steps:[]],Pn=qt.findIndex(Ss=>Ss.id===rt),vn={id:rt,label:ls(rt,pt),status:yt};Pn>=0?qt[Pn]={...qt[Pn],...vn}:qt.push(vn);const Tt=qt.map((Ss,Kp)=>{const wy=Ss.status==="done"?"[done]":Ss.status==="failed"?"[failed]":"[running]";return`${Kp+1}. ${wy} ${Ss.label}`}).join(`
166
- `),cn=Array.isArray(Mt.messages)?Mt.messages:[],cs=cn.findIndex(Ss=>Ss.kind==="run-summary"),Oi={role:"assistant",kind:"run-summary",text:Tt||"准备运行...",at:Date.now()},uo=[...cn];return cs>=0?uo[cs]=Oi:uo.unshift(Oi),{...Mt,steps:qt,messages:uo.slice(-160)}}))},ln=ke=>{const pt=String(ke||"").trim();if(!pt)return;const yt=bn;bn=pt,Gr(new Set([pt])),di(rt=>{var De;return{...rt,...yt&&yt!==pt&&((De=rt[yt])==null?void 0:De.status)==="running"?{[yt]:{status:"success"}}:{},[pt]:{status:"running"}}})},rr=ke=>{const pt=String(ke||"").trim();pt&&(Gr(yt=>{const rt=new Set(yt);return rt.delete(pt),rt}),di(yt=>({...yt,[pt]:{status:"success"}})))},It=(ke,pt)=>{const yt=String(pt||"");if(!yt.trim())return;const rt=["assistant","thinking","result","error","prompt"].includes(ke)?ke:"assistant";Bt(De=>De.map(Mt=>{if(Mt.id!==re)return Mt;let en=Array.isArray(Mt.messages)?Mt.messages:[];if(rt==="result"){const vn=[...en].reverse().find(Tt=>Tt.kind==="assistant");if(String((vn==null?void 0:vn.text)||"").trim()===yt.trim())return Mt}if(rt==="assistant"){const vn=en.findIndex(Tt=>Tt.kind==="result"&&String(Tt.text||"").trim()===yt.trim());vn>=0&&(en=en.filter((Tt,cn)=>cn!==vn))}const qt=[...en],Pn=qt[qt.length-1];return Pn&&Pn.kind===rt&&!Pn.error?qt[qt.length-1]={...Pn,text:`${Pn.text||""}${Pn.text?`
167
- `:""}${yt}`}:qt.push({role:"assistant",kind:rt,text:yt,...rt==="error"?{error:!0}:{},at:Date.now()}),{...Mt,messages:qt.slice(-160)}}))},Dt=ke=>{const pt=String(ke||"");pt.trim()&&Bt(yt=>yt.map(rt=>{var qt;if(rt.id!==re)return rt;const De=Array.isArray(rt.messages)?rt.messages:[],Mt=De.findIndex(Pn=>Pn.kind==="thinking"),en=[...De];if(Mt>=0){const Pn=String(((qt=en[Mt])==null?void 0:qt.text)||"");en[Mt]={...en[Mt],text:`${Pn}${Pn&&!Pn.endsWith(`
168
- `),""}${pt}`,at:Date.now()}}else{const Pn=en.findIndex(vn=>vn.kind==="activity");en.splice(Pn>=0?Pn+1:en.length,0,{role:"assistant",kind:"thinking",text:pt,at:Date.now()})}return{...rt,messages:en.slice(-160)}}))},Qe=ke=>{const pt=yq(ke);pt&&Bt(yt=>yt.map(rt=>{if(rt.id!==re)return rt;const De=Array.isArray(rt.activities)?rt.activities:[],Mt=De[De.length-1]===pt?De:[...De,pt].slice(-8),en=Array.isArray(rt.messages)?rt.messages:[],qt=en.findIndex(Tt=>Tt.kind==="activity"),Pn={role:"assistant",kind:"activity",text:Mt.map((Tt,cn)=>`${cn+1}. ${Tt}`).join(`
169
- `),at:Date.now()},vn=[...en];if(qt>=0)vn[qt]=Pn;else{const Tt=vn.findIndex(cn=>cn.kind==="run-summary");vn.splice(Tt>=0?Tt+1:0,0,Pn)}return{...rt,activities:Mt,messages:vn.slice(-160)}}))},Ct=ke=>{const pt=String((ke==null?void 0:ke.source)||"runner"),yt=String((ke==null?void 0:ke.stream)||""),rt=String((ke==null?void 0:ke.eventType)||"event"),De=String((ke==null?void 0:ke.text)||"").trim();if(!De)return;const Mt=`[${pt}${yt?`:${yt}`:""}] ${rt}
170
- ${De}`;Bt(en=>en.map(qt=>{if(qt.id!==re)return qt;const vn=[...Array.isArray(qt.rawTrace)?qt.rawTrace:[],Mt].slice(-80),Tt=Array.isArray(qt.messages)?qt.messages:[],cn=Tt.findIndex(uo=>uo.kind==="raw"),cs={role:"assistant",kind:"raw",text:vn.join(`
171
-
172
- ---
173
-
174
- `),at:Date.now()},Oi=[...Tt];return cn>=0?Oi[cn]=cs:Oi.push(cs),{...qt,rawTrace:vn,messages:Oi.slice(-160)}}))},Pr=ke=>{Bt(pt=>pt.map(yt=>yt.id===re?{...yt,status:ke,endedAt:Date.now()}:yt))},Pa=ke=>{const pt=new Set,yt=String((ke==null?void 0:ke.nodeId)||"").trim();yt&&pt.add(yt);for(const rt of Array.isArray(ke==null?void 0:ke.displayNodeIds)?ke.displayNodeIds:[]){const De=String(rt||"").trim();De&&pt.add(De)}for(const rt of Array.isArray(ke==null?void 0:ke.touchedNodeIds)?ke.touchedNodeIds:[]){const De=String(rt||"").trim();De&&pt.add(De)}if(pt.size===0)for(const rt of Array.isArray(ke==null?void 0:ke.order)?ke.order:[]){const De=String(rt||"").trim();De&&pt.add(De)}return pt},Ll=(ke,pt=null)=>{const yt=Dx(ke||se,V),rt=new Map(yt.nodes.map(en=>[en.id,en])),De=yt.instances||{},Mt=pt instanceof Set?pt:null;m(en=>{const qt=new Set(en.map(Tt=>Tt.id)),vn={...zh(en,k.current,C.current).instances||{}};for(const[Tt,cn]of Object.entries(De)){if(Mt&&!Mt.has(Tt)||!qt.has(Tt))continue;const cs=vn[Tt];Un((cn==null?void 0:cn.definitionId)||(cs==null?void 0:cs.definitionId))?vn[Tt]=cn:Array.isArray(cn==null?void 0:cn.output)&&(vn[Tt]={...cs||cn,output:cn.output})}return C.current=vn,P(vn),en.map(Tt=>{var cs,Oi,uo;if(Mt&&!Mt.has(Tt.id))return Tt;const cn=rt.get(Tt.id);return cn?Un(((cs=cn.data)==null?void 0:cs.definitionId)||((Oi=Tt.data)==null?void 0:Oi.definitionId))?{...Tt,data:{...Tt.data,...cn.data}}:Array.isArray((uo=cn.data)==null?void 0:uo.outputs)?{...Tt,data:{...Tt.data,outputs:cn.data.outputs}}:Tt:Tt})})};for(;;){const{value:ke,done:pt}=await Ne.read();if(pt)break;gt+=ze.decode(ke,{stream:!0});const yt=gt.split(`
175
- `);gt=yt.pop()||"";for(const rt of yt){if(!rt.trim())continue;const De=JSON.parse(rt);if(De.type==="error")throw new Error(De.error||"Workspace run failed");if(De.type==="stopped"){bs.current=!0,qe=Array.isArray(De.order)?De.order:qe;continue}if(De.type==="node-start"&&(Ce(`Running ${De.nodeId}...`),ln(De.nodeId),nn(De.nodeId,De.definitionId,"running")),De.type==="node-done"&&(rr(De.nodeId),nn(De.nodeId,De.definitionId,"done")),De.type==="status"&&Qe(De.line||De.message||""),De.type==="paused"&&(At=Array.isArray(De.nodeIds)?De.nodeIds:[]),De.type==="natural"&&(De.kind==="thinking"?Dt(De.text||""):It(De.kind,De.text||"")),De.type==="raw"){const Mt=k1(De);Mt&&Dt(Mt),Ct(De)}De.type==="graph"&&De.graph&&Ll(De.graph,Pa(De)),De.type==="done"&&(De.graph&&Ll(De.graph,Pa(De)),qe=Array.isArray(De.order)?De.order:[],At=Array.isArray(De.pauseNodeIds)?De.pauseNodeIds:At)}}if(gt.trim()){const ke=JSON.parse(gt);if(ke.type==="error")throw new Error(ke.error||"Workspace run failed");if(ke.type==="stopped"&&(bs.current=!0),ke.type==="node-start"&&(Ce(`Running ${ke.nodeId}...`),ln(ke.nodeId),nn(ke.nodeId,ke.definitionId,"running")),ke.type==="node-done"&&(rr(ke.nodeId),nn(ke.nodeId,ke.definitionId,"done")),ke.type==="status"&&Qe(ke.line||ke.message||""),ke.type==="paused"&&(At=Array.isArray(ke.nodeIds)?ke.nodeIds:[]),ke.type==="natural"&&(ke.kind==="thinking"?Dt(ke.text||""):It(ke.kind,ke.text||"")),ke.type==="raw"){const pt=k1(ke);pt&&Dt(pt),Ct(ke)}ke.type==="graph"&&ke.graph&&Ll(ke.graph,Pa(ke)),ke.type==="done"&&(ke.graph&&Ll(ke.graph,Pa(ke)),qe=Array.isArray(ke.order)?ke.order:[],At=Array.isArray(ke.pauseNodeIds)?ke.pauseNodeIds:At)}bs.current&&(Gr(new Set),di(ke=>{var yt;const pt=((yt=Object.entries(ke).find(([,rt])=>(rt==null?void 0:rt.status)==="running"))==null?void 0:yt[0])||S;return pt?{...ke,[pt]:{status:"stopped"}}:ke})),Ce(bs.current?`Workspace run stopped: ${S}`:At.length?`Workspace run paused at ${At.join(", ")}`:`Workspace run done: ${qe.length?qe.join(" -> "):S}`),Pr(bs.current?"stopped":At.length?"paused":"done"),bs.current||await Bn()}catch(le){if(bs.current||(le==null?void 0:le.name)==="AbortError"){Gr(new Set),di(Ne=>{var gt;const ze=((gt=Object.entries(Ne).find(([,qe])=>(qe==null?void 0:qe.status)==="running"))==null?void 0:gt[0])||S;return ze?{...Ne,[ze]:{status:"stopped"}}:Ne}),Ce(`Workspace run stopped: ${S}`),Bt(Ne=>Ne.map(ze=>ze.id===re?{...ze,status:"stopped",endedAt:Date.now()}:ze));return}Gr(new Set),di(Ne=>{var gt;const ze=(gt=Object.entries(Ne).find(([,qe])=>(qe==null?void 0:qe.status)==="running"))==null?void 0:gt[0];return ze?{...Ne,[ze]:{status:"failed"}}:Ne}),Ce(String(le.message||le)),Bt(Ne=>Ne.map(ze=>ze.id===re?{...ze,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(ze.messages)?ze.messages:[],{role:"assistant",error:!0,text:String(le.message||le),at:Date.now()}].slice(-160)}:ze))}finally{Bo.current===pe&&(Bo.current=null),ka(""),Gr(new Set)}},[xs,g,i,Bn,p,V,Ve,ui,$n,er,b,m,Oe]),pi=h.useCallback(async()=>{try{const I=await(await fetch("/api/skills")).json().catch(()=>({})),U=Array.isArray(I.skills)?I.skills.map(X=>({key:String(X.key),name:String(X.name||X.id||X.key),description:X.description?String(X.description):"",sourceLabel:X.sourceLabel?String(X.sourceLabel):""})):[];$o(U),hn(!0)}catch{hn(!0)}},[]),Nl=h.useCallback(async()=>{try{const I=await(await fetch("/api/mcps")).json().catch(()=>({})),U=Array.isArray(I.servers)?I.servers.map(X=>({name:String((X==null?void 0:X.name)||""),type:String((X==null?void 0:X.type)||""),url:String((X==null?void 0:X.url)||""),command:String((X==null?void 0:X.command)||""),args:Array.isArray(X==null?void 0:X.args)?X.args.map(String):[],description:String((X==null?void 0:X.description)||"")})).filter(X=>X.name):[];Re(U)}catch{Re([])}},[]);h.useEffect(()=>{wt().catch(S=>Ce(String(S.message||S))),so(),fetch("/api/model-lists").then(S=>S.json()).then(S=>xa({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(()=>{}),pi(),Nl(),vt(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{oi(el(S)),K(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>ed(S.user||null)).catch(()=>ed(null))},[wt,so,Nl,pi,vt,ks]),h.useEffect(()=>{if(ja(""),!(!Pi||!Bs)){if(!ks){ws([]);return}ws(oP(ks,"workspace",vr,qr)),ja(ks)}},[qr,Bs,vr,Pi,ks]),h.useEffect(()=>{if(!(Na!==ks||!ks))try{localStorage.setItem(ks,JSON.stringify(er))}catch{}},[er,ks,Na]),h.useEffect(()=>{C.current=A},[A]),h.useEffect(()=>{y.current=p},[p]),h.useEffect(()=>{const S=D.current,I=new Map,U=[];for(const re of p){const ae=dR(re);I.set(re.id,ae),S.get(re.id)!==ae&&U.push(re.id)}if(D.current=I,U.length===0)return;const X=()=>U.forEach(re=>s(re)),Q=window.requestAnimationFrame(X),se=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(se)}},[p,s]),h.useEffect(()=>{k.current=g},[g]),h.useEffect(()=>{_.current=w},[w]),h.useEffect(()=>{H.current=E},[E]),h.useEffect(()=>{_i.current=it},[it]),h.useEffect(()=>{Wr.current=hr},[hr]),h.useEffect(()=>{$.current=T},[T]),h.useEffect(()=>{if(!T)return;const S=U=>{U.key==="Escape"&&z(null)},I=U=>{var X,Q;(Q=(X=U.target)==null?void 0:X.closest)!=null&&Q.call(X,".af-connect-node-menu")||z(null)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",I),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",I)}},[T]),h.useEffect(()=>{if(G.current&&Oe)return Z.current&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{$n().catch(S=>Ce(String(S.message||S)))},650),()=>{Z.current&&window.clearTimeout(Z.current)}},[p,g,w,$n,Oe]);const wc=h.useCallback((S,I)=>{if(!Oe){Ce("Readonly workspace");return}const U=Jq(I),X=pe=>Array.isArray(pe)?pe.map(le=>(le==null?void 0:le.name)!=="skillKeys"&&(le==null?void 0:le.name)!=="skillsContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:U,value:U}):[],Q=p.map(pe=>{var le;return pe.id!==S?pe:{...pe,data:{...pe.data,body:U,inputs:X((le=pe.data)==null?void 0:le.inputs)}}}),se=C.current||{},re=se[S]&&typeof se[S]=="object"?se[S]:{},ae={...se,[S]:{...re,body:U,input:X(re.input)}};C.current=ae,m(Q),P(ae),Vr(pe=>!pe||pe.id!==S?pe:{...pe,body:U,inputs:X(pe.inputs)}),$n(Q,g).catch(pe=>Ce(String(pe.message||pe)))},[g,p,$n,m,Oe]),hy=h.useCallback((S,I)=>{if(!Oe){Ce("Readonly workspace");return}const U=Zq(I),X=pe=>Array.isArray(pe)?pe.map(le=>(le==null?void 0:le.name)!=="serverNames"&&(le==null?void 0:le.name)!=="mcpContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:U,value:U}):[],Q=p.map(pe=>{var le;return pe.id!==S?pe:{...pe,data:{...pe.data,body:U,inputs:X((le=pe.data)==null?void 0:le.inputs)}}}),se=C.current||{},re=se[S]&&typeof se[S]=="object"?se[S]:{},ae={...se,[S]:{...re,body:U,input:X(re.input)}};C.current=ae,m(Q),P(ae),Vr(pe=>!pe||pe.id!==S?pe:{...pe,body:U,inputs:X(pe.inputs)}),$n(Q,g).catch(pe=>Ce(String(pe.message||pe)))},[g,p,$n,m,Oe]),hi=h.useCallback(S=>{const I=String(S||"").trim();I&&(bl(U=>U===I?"":I),Ii(U=>({...U,[I]:U[I]||{sessionId:`nodechat_${Date.now()}_${I.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Tp=h.useCallback((S,I)=>{const U=String(S||"").trim();U&&Ii(X=>({...X,[U]:{...X[U]||{sessionId:`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(I||""),error:""}}))},[]),dr=h.useCallback((S,I,U="replace",X={})=>{var ln,rr;if(!Oe){Ce("Readonly workspace");return}const Q=String(S||"").trim();if(!Q)return;const se=y.current.find(It=>It.id===Q),re=Un((ln=se==null?void 0:se.data)==null?void 0:ln.definitionId),ae=yu(I),pe=re==="html"?Uu(ae):String(ae||""),le=se?ec(se.data):"",Ne=U==="append"&&String(le||"").trim()?`${String(le).replace(/\s+$/g,"")}
176
-
177
- ${pe.trim()}`:pe,ze=re==="image"?"src":"content",gt=X!=null&&X.reloadDisplay?Date.now():(rr=se==null?void 0:se.data)==null?void 0:rr.displayReloadKey,qe=It=>{let Dt=!1;return(Array.isArray(It)?It:[]).map(Ct=>{const Pr=String((Ct==null?void 0:Ct.name)||""),Pa=String((Ct==null?void 0:Ct.type)||"");return Pr===ze||Pr==="filePath"||Pa==="text"?Dt?{...Ct,default:"",value:""}:(Dt=!0,{...Ct,default:Ne,value:Ne}):Ct})},At=y.current.map(It=>{var Dt,Qe;return It.id!==Q?It:{...It,data:{...It.data,body:Ne,...gt?{displayReloadKey:gt}:{},inputs:qe((Dt=It.data)==null?void 0:Dt.inputs),outputs:qe((Qe=It.data)==null?void 0:Qe.outputs)}}}),bn=C.current||{},ls=bn[Q]&&typeof bn[Q]=="object"?bn[Q]:{},nn={...bn,[Q]:{...ls,body:Ne,input:qe(ls.input),output:qe(ls.output)}};C.current=nn,m(At),P(nn),Vr(It=>(It==null?void 0:It.id)===Q?{...It,body:Ne}:It),(X==null?void 0:X.logChat)!==!1&&Ii(It=>{var Dt;return{...It,[Q]:{...It[Q]||{},candidateContent:"",messages:[...(Dt=It[Q])!=null&&Dt.messages&&Array.isArray(It[Q].messages)?It[Q].messages:[],{role:"assistant",text:U==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),$n(At,k.current).catch(It=>Ce(String(It.message||It))),Ce(String((X==null?void 0:X.statusMessage)||"")||(U==="append"?"已追加节点内容":"已替换节点内容"))},[$n,m,Oe]),io=h.useCallback(async S=>{if(!Oe)return Ce("Readonly workspace"),"";if(!pg(S))return Ce("请选择图片文件"),"";try{const I=new FormData;I.set("file",S),I.set("dir","img"),i.flowId&&I.set("flowId",i.flowId),i.flowSource&&I.set("flowSource",i.flowSource),i.archived&&I.set("archived","1");const U=await fetch("/api/workspace/upload",{method:"POST",body:I}),X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"上传图片失败");const Q=String(X.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await Bn(),ut(se=>{const re=new Set(se);for(const ae of Hh(Q))re.delete(ae);return re}),Ce(`已上传图片 ${Q}`),Q}catch(I){return Ce(String(I.message||I)),""}},[i,Bn,Oe]),od=h.useCallback(async(S,I)=>{const U=String(S||"").trim();if(!U)return;const X=await io(I);X&&dr(U,X,"replace",{logChat:!1,statusMessage:`已上传图片 ${X}`})},[dr,io]),Rp=h.useCallback((S,I="replace")=>{var Q;const U=String(S||"").trim(),X=String(((Q=li[U])==null?void 0:Q.candidateContent)||"").trim();!U||!X||dr(U,X,I)},[li,dr]),jl=h.useCallback(async(S,I=void 0)=>{var At,bn,ls;if(!Oe){Ce("Readonly workspace");return}const U=String(S||"").trim();if(!U)return;const X=li[U]||{},Q=String(I!==void 0?I:X.draft||"").trim();if(!Q||X.running)return;const se=y.current.find(nn=>nn.id===U);if(!se)return;const re=Un((At=se.data)==null?void 0:At.definitionId)||"markdown",ae=ec(se.data);let pe=Xf(ae,re),le=yu(ae);if(pe)try{le=await Jf(i,pe)}catch(nn){Ce(String(nn.message||nn))}else if(re!=="image"&&String(le||"").trim()){const nn=Yl(re,le);if(nn){Ce(`${nn} 未进入微调。`);return}try{const ln=await P1(i,A1(U,se.data),le);await Bn(),dr(U,ln,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${ln}`}),pe=ln,le=""}catch(ln){Ce(String(ln.message||ln));return}}const Ne=Cq(U,y.current,k.current),ze={role:"user",text:Q,at:Date.now()},gt=Array.isArray(X.messages)?X.messages:[],qe=X.sessionId||`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`;Ii(nn=>({...nn,[U]:{...X,sessionId:qe,messages:[...gt,ze],draft:"",running:!0,error:""}}));try{const nn=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,sessionId:qe,node:{id:U,label:((bn=se.data)==null?void 0:bn.label)||U,definitionId:((ls=se.data)==null?void 0:ls.definitionId)||""},nodeKind:re,currentContent:pe?"":le,sourceContext:Ne,targetFilePath:pe,messages:gt,message:Q,model:xs})}),ln=await nn.json().catch(()=>({}));if(!nn.ok)throw new Error(ln.error||"节点微调失败");const rr=String(ln.candidateContent||ln.reply||"").trim(),It=!!ln.directFileEdit,Dt=String(ln.artifactPath||pe||"").trim();if(It&&Dt){const Qe=Yl(re,rr);if(Qe)throw new Error(`${Qe} 文件已由 agent 修改,请检查 ${Dt}。`);await Bn(),dr(U,Dt,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Dt}`})}else if(rr){const Qe=Yl(re,rr);if(Qe)throw new Error(`${Qe} 已取消写入,避免覆盖当前展示文件。`);if(pe){const Ct=await P1(i,pe,rr);await Bn(),dr(U,Ct,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ct}`})}else dr(U,rr,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}Ii(Qe=>{var Ct;return{...Qe,[U]:{...Qe[U]||{},sessionId:String(ln.sessionId||qe),running:!1,candidateContent:"",messages:[...(Ct=Qe[U])!=null&&Ct.messages&&Array.isArray(Qe[U].messages)?Qe[U].messages:[...gt,ze],{role:"assistant",text:rr||It?Dt?`已更新文件 ${Dt}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(nn){const ln=String(nn.message||nn);Ii(rr=>({...rr,[U]:{...rr[U]||{},running:!1,error:ln}})),Ce(ln)}},[xs,i,Bn,li,dr,Oe]),Lp=h.useCallback(async(S,I)=>{if(!Oe){Ce("Readonly workspace");return}const U=Un(I==null?void 0:I.definitionId)||"markdown",X=ec(I),Q=Xf(X,U);let se=yu(X);if(Q)try{se=await Jf(i,Q)}catch(le){Ce(String(le.message||le));return}if(!String(se||"").trim()){Ce("展示节点没有可保存内容");return}const re=Yl(U,se);if(re){Ce(`${re} 未保存文件。`);return}const ae=A1(S,I),pe=window.prompt("保存到 workspace 相对路径",ae);if(pe)try{const le=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:pe,content:se})}),Ne=await le.json().catch(()=>({}));if(!le.ok)throw new Error(Ne.error||"保存文件失败");const ze=Ne.path||pe,gt=xo(i);gt.set("path",ze);const qe=await fetch(`/api/workspace/file?${gt.toString()}`);if(!qe.ok){const At=await qe.json().catch(()=>({}));throw new Error(At.error||`保存后读取失败:${ze}`)}await Bn(),sn(At=>Yq(At,ze,String(se||"").length)),ut(At=>{const bn=new Set(At);for(const ls of Hh(ze))bn.delete(ls);return bn}),dr(S,ze,"replace",{logChat:!1,statusMessage:`已保存并引用 ${ze}`}),Ce(`已保存 ${ze}`)}catch(le){Ce(String(le.message||le))}},[i,Bn,dr,Oe]),ad=h.useCallback((S,I)=>{const U=String(S||"");U&&Vr(X=>{if(!X||X.id!==U)return X;const Q=typeof I=="function"?I(X):I;return!Q||typeof Q!="object"?X:{...X,...Q}})},[]),Vs=h.useMemo(()=>p.map(S=>{var I,U;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:Hs,showBodyPreview:!0,isExecuting:td.has(S.id),nodeStatus:((I=Sa[S.id])==null?void 0:I.status)??null,nodeElapsed:((U=Sa[S.id])==null?void 0:U.elapsed)??null,flowParams:i,readOnly:!Oe,onRunWorkspaceNode:Ip,onStopWorkspaceNode:Sl,runningRunNodeId:ui,skills:vr,skillCollections:qr,onChangeLoadSkillKeys:wc,onRefreshSkills:pi,mcpServers:ge,onChangeLoadMcpNames:hy,onRefreshMcps:Nl,onSaveDisplayNodeToFile:Lp,onUploadWorkspaceImage:io,onUploadImageToDisplayNode:od,onStatus:Ce,nodeChatActive:kr===S.id,nodeChat:li[S.id]||null,onSetDisplayNodeContent:dr,onToggleNodeChat:hi,onCloseNodeChat:()=>bl(""),onUpdateNodeChatDraft:Tp,onSendNodeChat:jl,onApplyNodeChatCandidate:Rp,onSyncNodePropDraft:ad}}}),[kr,Rp,hy,wc,i,ge,Hs,li,p,Nl,pi,Ip,ui,Lp,jl,dr,qr,vr,Sl,ad,hi,Tp,od,io,td,Sa,Oe]),Op=h.useMemo(()=>new Map(Vs.map(S=>[S.id,S])),[Vs]),Cl=h.useMemo(()=>{const S=new Set(L);return w.nodeIds.map((I,U)=>{var ae;const X=Op.get(I);if(!X||!Un((ae=X.data)==null?void 0:ae.definitionId))return null;const Q=Hc(X)||{width:520,height:320},se=gu(w.nodeSizes[I]||Q,{display:!0})||Q,re=w.nodePositions[I]||{x:180+U*36,y:120+U*28};return{...X,id:E1(I),position:re,selected:S.has(I),width:se.width,height:se.height,data:{...X.data,sourceNodeId:I,displayPageMode:!0,readOnly:!0,selected:S.has(I),displaySize:se,nodeSize:se}}}).filter(Boolean)},[w,Op,L]),Ti=h.useMemo(()=>Vs.filter(S=>{var I;return Un((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[Vs]),ft=a==="display";h.useEffect(()=>{if(!ft||!w.viewport)return;const S=w.viewport,I=()=>{try{r.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(U)},[w.viewport,ft,r]),h.useEffect(()=>{if(ft||!E)return;const S=E,I=()=>{try{r.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(U)},[ft,r,E]),h.useEffect(()=>{const S=R.current,I=new Map,U=[];for(const re of[...Vs,...Cl]){const ae=kq(re);I.set(re.id,ae),S.get(re.id)!==ae&&U.push(re.id)}if(R.current=I,U.length===0)return;const X=()=>U.forEach(re=>s(re)),Q=window.requestAnimationFrame(X),se=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(se)}},[Cl,Vs,s]);const Gt=h.useMemo(()=>p.find(S=>S.id===hr)||null,[p,hr]),bc=h.useRef({id:"",draft:null}),my=h.useMemo(()=>{const S=I1(Gt);return S?JSON.stringify(S):""},[Gt]);h.useEffect(()=>{if(!Gt){bc.current={id:"",draft:null},Vr(null),ys("");return}const S=I1(Gt),I=bc.current;bc.current={id:Gt.id,draft:S},Vr(U=>!U||U.id!==Gt.id||I.id!==Gt.id||!I.draft?S:nY(U,I.draft,S)),ys("")},[Gt==null?void 0:Gt.id,my]);const ld=h.useCallback((S=!1)=>{if(!it||!Gt)return!1;if(!Oe)return ys("Readonly workspace"),Ce("Readonly workspace"),!1;ys("");const I=R1({nodes:p,edges:g,instances:C.current,selectedNode:Gt,draft:it,allowRename:S});return I!=null&&I.error?(ys(I.error),!1):(!(I!=null&&I.ok)||!I.changed||(C.current=I.instances,P(I.instances),m(I.nodes),b(I.edges),I.nextId!==Gt.id&&Zn(I.nextId),Ve(I.nextId)),!0)},[g,it,p,Gt,b,m,Ve,Oe]);h.useEffect(()=>{if(!Oe||!it||!Gt)return;const S=window.setTimeout(()=>{ld(!1)},350);return()=>window.clearTimeout(S)},[it==null?void 0:it.label,it==null?void 0:it.role,it==null?void 0:it.model,it==null?void 0:it.body,JSON.stringify((it==null?void 0:it.images)||[]),it==null?void 0:it.script,JSON.stringify((it==null?void 0:it.inputs)||[]),JSON.stringify((it==null?void 0:it.outputs)||[]),ld,Gt==null?void 0:Gt.id,Oe]);const vc=h.useMemo(()=>{const S=new Map(Vs.map(I=>[I.id,I]));return g.map(I=>{var le,Ne,ze,gt;const U=S.get(I.source),X=S.get(I.target),Q=/^output-(\d+)$/.exec(I.sourceHandle||""),se=/^input-(\d+)$/.exec(I.targetHandle||""),re=U&&Q?(Ne=(le=U.data)==null?void 0:le.outputs)==null?void 0:Ne[parseInt(Q[1],10)]:null,ae=X&&se?(gt=(ze=X.data)==null?void 0:ze.inputs)==null?void 0:gt[parseInt(se[1],10)]:null,pe=re!=null&&re.type?or(re.type):ae!=null&&ae.type?or(ae.type):"";return pe?{...I,style:{...I.style||{},stroke:pe,strokeWidth:2},markerEnd:{type:Ms.ArrowClosed,color:pe}}:I})},[g,Vs]),Mp=ft?Cl:Vs,$p=ft?[]:vc,kc=h.useMemo(()=>ft?Cl.map(S=>({...S,id:Fx(S.id)})):Vs,[Cl,Vs,ft]),Wo=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const U=ft?E1(I):I;ft?F([I]):(m(Q=>Q.map(se=>({...se,selected:se.id===U}))),b(Q=>Q.map(se=>({...se,selected:!1}))),Zn(U));const X=()=>{var le,Ne,ze;const Q=r.getNode(U);if(!Q)return;const se=(le=r.getInternalNode)==null?void 0:le.call(r,U),re=((Ne=se==null?void 0:se.measured)==null?void 0:Ne.width)??(se==null?void 0:se.width)??Q.width??260,ae=((ze=se==null?void 0:se.measured)==null?void 0:ze.height)??(se==null?void 0:se.height)??Q.height??120,{zoom:pe}=r.getViewport();r.setCenter(Q.position.x+re/2,Q.position.y+ae/2,{zoom:Nq(pe),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(X))},[ft,r,b,m]),El=h.useCallback(()=>{const S=r.getViewport(),I={x:Number(S.x)||0,y:Number(S.y)||0,zoom:Math.min(Math.max(Number(S.zoom)||1,.1),4)};if(ft){const U={..._.current,viewport:I};_.current=U,j(U),Ce("已固定 Display 进入视角")}else H.current=I,O(I),Ce("已固定 Workspace 进入视角");$n(y.current,k.current).catch(U=>Ce(String(U.message||U)))},[ft,r,$n]),as=h.useMemo(()=>{const S=ce.trim().toLowerCase(),I={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const U of V)S&&![U.id,U.label,U.displayName,U.description].some(X=>String(X||"").toLowerCase().includes(S))||I[Kd(U)].push(U);for(const U of zc)I[U].sort((X,Q)=>X.id.localeCompare(Q.id));return I},[V,ce]),Xr=h.useMemo(()=>{const S=pn.trim().toLowerCase();return V.filter(I=>!S||[I.id,I.label,I.displayName,I.description].some(U=>String(U||"").toLowerCase().includes(S))).sort((I,U)=>{const X=zc.indexOf(Kd(I)),Q=zc.indexOf(Kd(U));return X!==Q?X-Q:qd(I).localeCompare(qd(U))}).slice(0,30)},[V,pn]),tr=h.useMemo(()=>{const S=pn.trim().toLowerCase();return we.filter(I=>!S||[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].some(U=>String(U||"").toLowerCase().includes(S))).sort((I,U)=>String(I.displayName||I.name||I.id).localeCompare(String(U.displayName||U.name||U.id))).slice(0,30)},[we,pn]);h.useEffect(()=>{is(0)},[pn,ie,We]),h.useEffect(()=>{if(!ie)return;const S=window.setTimeout(()=>{var I;return(I=Ju.current)==null?void 0:I.focus()},0);return()=>window.clearTimeout(S)},[ie]);const oo=h.useMemo(()=>{const S=Gn.trim().toLowerCase();return S?yR(Pe).filter(I=>I.path.toLowerCase().includes(S)):Pe},[Gn,Pe]),ao=[...(Hs.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(Hs.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(Hs.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],Sc=h.useMemo(()=>new Set(er),[er]),Vo=h.useMemo(()=>{const S=new Map(vr.map(se=>[se.key,se])),I=new Set,U=new Set,X=qr.map(se=>{const re=ol(se,vr).map(ae=>S.get(ae)).filter(Boolean);for(const ae of re)I.add(ae.key),U.add(String(ae.name||ae.id||ae.key||"").trim());return{...se,skills:re}}).filter(se=>se.skills.length>0),Q=vr.filter(se=>{const re=String(se.name||se.id||se.key||"").trim();return!I.has(se.key)&&!U.has(re)});return{groups:X,ungrouped:Q}},[qr,vr]);h.useEffect(()=>{Yr(S=>{let I=!1;const U=new Set(S);for(const X of Vo.groups)U.has(X.id)||(U.add(X.id),I=!0);return I?U:S})},[Vo.groups]);const Wn=h.useMemo(()=>{const S=p.filter(I=>I.selected);return S.length>0?S:hr?p.filter(I=>I.id===hr):[]},[p,hr]),Ea=h.useMemo(()=>Wn.map(S=>S.id),[Wn]),En=h.useMemo(()=>p.filter(S=>{var I;return Un((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[p]),_n=h.useMemo(()=>Wn.filter(S=>{var I;return Un((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}).map(S=>S.id),[Wn]),_l=h.useMemo(()=>{const S=String((Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[Lr]),Uo=h.useMemo(()=>new Set(Ea),[Ea]),lo=h.useMemo(()=>g.filter(S=>Uo.has(S.source)&&Uo.has(S.target)),[g,Uo]),cd=h.useCallback(S=>{const I=S==="display"?"display":"workspace";l(I),Zn(""),F([]),z(null),Ie(!1),Me(!1);const U=xo(i);I==="display"&&U.set("view","display");const X=`/workspace${U.toString()?`?${U.toString()}`:""}`;window.history.pushState({},"",X)},[i]),jt=h.useCallback(S=>{var X;const I=String(S||"").trim();if(!I)return;const U=y.current.find(Q=>Q.id===I);if(!U||!Un((X=U.data)==null?void 0:X.definitionId)){Ce("展示节点不可用");return}j(Q=>{if(Q.nodeIds.includes(I))return Q;const se=Q.nodeIds.length,re=Hc(U);return{nodeIds:[...Q.nodeIds,I],nodePositions:{...Q.nodePositions,[I]:{x:180+se*36,y:120+se*28}},nodeSizes:{...Q.nodeSizes,...re?{[I]:re}:{}}}}),F([I])},[]),ud=h.useCallback(S=>{const I=String(S||"").trim();I&&(j(U=>{const X=U.nodeIds.filter(re=>re!==I),Q={...U.nodePositions},se={...U.nodeSizes};return delete Q[I],delete se[I],{nodeIds:X,nodePositions:Q,nodeSizes:se}}),F(U=>U.filter(X=>X!==I)))},[]),Nc=h.useCallback(S=>{const I=String(S||"").trim();I&&(_.current.nodeIds.includes(I)?ud(I):jt(I))},[jt,ud]),Ko=h.useMemo(()=>{const S=tt.trim().toLowerCase();return S?Ti.filter(I=>{var U,X;return[I.id,(U=I.data)==null?void 0:U.label,(X=I.data)==null?void 0:X.definitionId].filter(Boolean).some(Q=>String(Q).toLowerCase().includes(S))}):Ti},[Ti,tt]),Pl=h.useMemo(()=>{const S=Ko.length,I=S<=1?1:S<=4?2:3,U=Array.from({length:I},()=>({height:0,nodes:[]}));for(const X of Ko){const Q=Hc(X)||{width:420,height:260},se=Math.max(1,Number(Q.width)||420),re=Math.max(1,Number(Q.height)||260),ae=Math.min(26,Math.max(5.5,re/se*16))+3.2;let pe=U[0];for(const le of U)le.height<pe.height&&(pe=le);pe.nodes.push(X),pe.height+=ae}return U.map(X=>X.nodes)},[Ko]),Dp=h.useCallback(S=>{var se,re;const I=w.nodeIds.includes(S.id),U=Hc(S)||{width:420,height:260},X=Math.max(1,Math.round(Number(U.width)||420)),Q=Math.max(1,Math.round(Number(U.height)||260));return o.jsxs("button",{type:"button",className:"af-display-picker-card"+(I?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${X} / ${Q}`},onClick:()=>Nc(S.id),children:[o.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:o.jsx("input",{type:"checkbox",checked:I,readOnly:!0,tabIndex:-1})}),o.jsx("span",{className:"af-display-picker-card__preview",children:o.jsx(Dq,{node:S})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((se=S.data)==null?void 0:se.label)||S.id}),o.jsxs("small",{children:[Un((re=S.data)==null?void 0:re.definitionId)," · ",S.id]})]})]},S.id)},[w.nodeIds,Nc]),jc=h.useMemo(()=>{const S=ce.trim().toLowerCase();return S?we.filter(I=>[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].filter(Boolean).some(U=>String(U).toLowerCase().includes(S))):we},[we,ce]),Cc=h.useCallback((S,I)=>{const U=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let X=`${U}_${Date.now().toString(36)}`,Q=2;for(;I.has(X);)X=`${U}_${Date.now().toString(36)}_${Q}`,Q+=1;return I.add(X),X},[]),Al=h.useCallback((S,I)=>{var It,Dt;if(!Oe){Ce("Readonly workspace");return}const U=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},X=U.instances&&typeof U.instances=="object"?U.instances:{},Q=Object.keys(X);if(Q.length===0)return;const se=new Set(y.current.map(Qe=>Qe.id)),re={};for(const Qe of Q)re[Qe]=Cc(Qe,se);const ae=(It=U.ui)!=null&&It.nodePositions&&typeof U.ui.nodePositions=="object"?U.ui.nodePositions:{},pe=(Dt=U.ui)!=null&&Dt.nodeSizes&&typeof U.ui.nodeSizes=="object"?U.ui.nodeSizes:{},le=Q.map(Qe=>{const Ct=ae[Qe];return{id:Qe,x:typeof(Ct==null?void 0:Ct.x)=="number"?Ct.x:0,y:typeof(Ct==null?void 0:Ct.y)=="number"?Ct.y:0}}),Ne=Math.min(...le.map(Qe=>Qe.x)),ze=Math.min(...le.map(Qe=>Qe.y));let gt=I||{x:360+y.current.length*24,y:180+y.current.length*18};if(!I){const Qe=document.querySelector(".af-workspace-canvas .react-flow");if(Qe){const Ct=Qe.getBoundingClientRect();gt=r.screenToFlowPosition({x:Ct.left+Ct.width*.48,y:Ct.top+Ct.height*.32})}}const qe={},At={},bn={};for(const Qe of le){const Ct=re[Qe.id];qe[Ct]={...X[Qe.id]||{}},At[Ct]={x:gt.x+(Qe.x-Ne),y:gt.y+(Qe.y-ze)};const Pr=pe[Qe.id];typeof(Pr==null?void 0:Pr.width)=="number"&&typeof(Pr==null?void 0:Pr.height)=="number"&&(bn[Ct]={width:Pr.width,height:Pr.height})}const ls=new Set(Q),nn=(Array.isArray(U.edges)?U.edges:[]).filter(Qe=>ls.has(Qe==null?void 0:Qe.source)&&ls.has(Qe==null?void 0:Qe.target)).map(Qe=>({source:re[Qe.source],target:re[Qe.target],sourceHandle:Qe.sourceHandle??null,targetHandle:Qe.targetHandle??null})),ln=Dx({instances:qe,edges:nn,ui:{nodePositions:At,nodeSizes:bn}},V),rr=ln.nodes.map(Qe=>({...Qe,selected:!0}));C.current={...C.current,...ln.instances},P(C.current),m(Qe=>[...Qe.map(Ct=>({...Ct,selected:!1})),...rr]),b(Qe=>[...Qe.map(Ct=>({...Ct,selected:!1})),...ln.edges]),Ce(`已添加流程片段:${S.displayName||S.id}`)},[Cc,V,r,b,m,Oe]),Fp=h.useCallback(()=>{var U,X;if(Wn.length<2){et("请先在 workspace 画布上选择至少两个节点。"),oe("flows");return}const S=Wn[0],I=Wn.length===2?`${((U=S.data)==null?void 0:U.label)||S.id} 片段`:`${((X=S.data)==null?void 0:X.label)||S.id} 等 ${Wn.length} 个节点`;He({name:I,id:I.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),On(""),Xe(!0),oe("flows")},[Wn]),zp=h.useCallback(async()=>{var Q,se;if(Wn.length<2)return;const S=mt.name.trim();if(!S){On("请填写片段名称。");return}const I={},U={};for(const re of Wn){I[re.id]={x:((Q=re.position)==null?void 0:Q.x)||0,y:((se=re.position)==null?void 0:se.y)||0};const ae=Hc(re);ae&&(U[re.id]=ae)}const X=lo.map(re=>({source:re.source,target:re.target,sourceHandle:re.sourceHandle??null,targetHandle:re.targetHandle??null}));gn(!0),On("");try{const re=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:mt.id,name:S,displayName:S,version:"1.0.0",description:mt.description,snippet:{instances:xp(Wn,C.current),edges:X,ui:{nodePositions:I,nodeSizes:U}}})}),ae=await re.json().catch(()=>({}));if(!re.ok||ae.ok===!1)throw new Error(ae.error||"发布流程片段失败");Xe(!1),Ce(`流程片段已发布:${ae.id||S}`),Le(`流程片段已发布:${ae.id||S}`),await so(),oe("flows")}catch(re){On(String(re.message||re))}finally{gn(!1)}},[so,mt,lo,Wn,Le]);h.useCallback(()=>{if(En.length===0){Ce("当前 workspace 没有 display 节点");return}const S=_n.length>0?_n:En.map(U=>U.id),I=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display";ar({title:I,layout:"gallery",nodeIds:S}),Lt(""),dn(null),ve(!0)},[i.flowId,_n,En]);const Jr=h.useCallback(S=>{ar(I=>{const U=Array.isArray(I.nodeIds)?I.nodeIds:[];return U.includes(S)?{...I,nodeIds:U.filter(X=>X!==S)}:{...I,nodeIds:[...U,S]}})},[]),Hp=h.useCallback(async()=>{var U;const S=Qt.title.trim(),I=Array.isArray(Qt.nodeIds)?Qt.nodeIds:[];if(I.length===0){Lt("请选择至少一个 display 节点。");return}ot(!0),Lt(""),dn(null);try{await $n(p,g);const X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:S,layout:Qt.layout,nodeIds:I})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"发布展示页失败");const se=new URL(Q.url||`/display/${((U=Q.share)==null?void 0:U.id)||""}`,window.location.origin).href;dn({...Q,absoluteUrl:se}),Ce("展示页已生成")}catch(X){Lt(String(X.message||X))}finally{ot(!1)}},[Qt,g,i,p,$n]),Us=h.useCallback(async()=>{var I;const S=Array.isArray(w.nodeIds)?w.nodeIds:[];if(S.length===0){Lt("请先添加至少一个展示节点。"),Ce("请先添加至少一个展示节点"),Me(!0);return}ot(!0),Lt("");try{await $n(p,g);const U=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display",X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:U,layout:"canvas",nodeIds:S})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"生成展示链接失败");const se=new URL(Q.url||`/display/${((I=Q.share)==null?void 0:I.id)||""}`,window.location.origin).href;dn({...Q,absoluteUrl:se}),fn(!0),Ce("展示链接已生成")}catch(U){const X=String(U.message||U);Lt(X),Ce(X)}finally{ot(!1)}},[w.nodeIds,g,i,p,$n]),Ks=h.useCallback(async()=>{const S=nt==null?void 0:nt.absoluteUrl;if(!S)return;const I=await jq(S);lr(I?"copied":"failed"),window.setTimeout(()=>lr(""),1600)},[nt==null?void 0:nt.absoluteUrl]),Bp=h.useCallback(S=>{m(I=>I.map(U=>U.id===S?{...U,selected:!1}:U)),Zn(I=>I===S?"":I)},[m]),mi=h.useCallback(()=>{const S=ur.current;if(!S)return;const I=S.getBoundingClientRect(),U=Math.min(420,Math.max(320,I.width+160)),X=12,Q=Math.max(180,I.top-X*2),se=Math.min(560,Q);Ai({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-U-12,I.left)),top:Math.max(X,I.top-se-X),width:U,maxHeight:se,zIndex:1e4})},[]);h.useEffect(()=>{if(!os)return;mi();const S=U=>{var Q,se;const X=U.target;(Q=ur.current)!=null&&Q.contains(X)||(se=wa.current)!=null&&se.contains(X)||Ws(!1)},I=U=>{U.key==="Escape"&&Ws(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",I),window.addEventListener("resize",mi),window.addEventListener("scroll",mi,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",I),window.removeEventListener("resize",mi),window.removeEventListener("scroll",mi,!0)}},[os,mi]);const Wp=h.useCallback(S=>{var X,Q,se;if(a==="display"){const re=[];let ae=!1;j(pe=>{var ze,gt;const le={...pe.nodePositions},Ne={...pe.nodeSizes};for(const qe of S||[]){const At=Fx(qe==null?void 0:qe.id);if(!(!At||!pe.nodeIds.includes(At))){if(qe.type==="select"){qe.selected&&re.push(At);continue}if(qe.type==="position"&&qe.position){le[At]={x:qe.position.x,y:qe.position.y},ae=!0;continue}if(qe.type==="dimensions"&&((ze=qe.dimensions)!=null&&ze.width)&&((gt=qe.dimensions)!=null&&gt.height)){const bn=gu({width:Math.round(Number(qe.dimensions.width)),height:Math.round(Number(qe.dimensions.height))},{display:!0});bn&&(Ne[At]=bn,ae=!0)}}}return ae?{...pe,nodePositions:le,nodeSizes:Ne}:pe}),(S||[]).some(pe=>(pe==null?void 0:pe.type)==="select")&&F(re);return}if(!Oe){const re=(S||[]).filter(ae=>(ae==null?void 0:ae.type)==="select");re.length>0&&m(ae=>Qm(re,ae));return}const I=new Map;for(const re of S||[])if((re==null?void 0:re.type)==="dimensions"&&((X=re.dimensions)!=null&&X.width)&&((Q=re.dimensions)!=null&&Q.height)){const ae=p.find(Ne=>Ne.id===re.id),pe=!!Un((se=ae==null?void 0:ae.data)==null?void 0:se.definitionId),le=gu({width:Math.round(Number(re.dimensions.width)),height:Math.round(Number(re.dimensions.height))},{display:pe});le&&I.set(re.id,le)}const U=Array.from(I.keys());if(m(re=>Qm(S,re).map(ae=>{var le;const pe=I.get(ae.id);return pe?Un((le=ae.data)==null?void 0:le.definitionId)?{...ae,width:pe.width,height:pe.height,data:{...ae.data,nodeSize:pe,displaySize:pe}}:{...ae,width:pe.width,height:pe.height,data:{...ae.data,nodeSize:pe}}:ae})),U.length>0){const re=()=>U.forEach(ae=>s(ae));window.requestAnimationFrame(re),window.setTimeout(re,80)}},[p,m,s,a,Oe]),Il=h.useCallback(S=>{if(a!=="display"){if(!Oe){const I=(S||[]).filter(U=>(U==null?void 0:U.type)==="select");I.length>0&&b(U=>s0(I,U));return}v(S)}},[v,b,a,Oe]),qo=h.useCallback(()=>{const S=document.querySelector(".af-workspace-canvas .react-flow");if(S){const I=S.getBoundingClientRect();return r.screenToFlowPosition({x:I.left+I.width*.48,y:I.top+I.height*.32})}return{x:360+p.length*36,y:180+p.length*28}},[p.length,r]),nr=h.useCallback(()=>{var S,I,U;if(Gt){const X=Number(((S=Gt.measured)==null?void 0:S.width)||Gt.width||260);return{x:Number(((I=Gt.position)==null?void 0:I.x)||0)+X+140,y:Number(((U=Gt.position)==null?void 0:U.y)||0)}}return qo()},[qo,Gt]),gi=h.useCallback((S,I={})=>{if(!Oe)return Ce("Readonly workspace"),null;if(!S)return null;const U=O0(S)||S.id,X=uR(S),Q=I.id||bq(U,p),se=Fh(S.inputs),re=Fh(S.outputs),ae={definitionId:U,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:I.label||mg(S),role:"normal",body:I.body||"",input:I.inputs||se,output:I.outputs||re},pe={id:Q,type:wp,position:I.position||qo(),data:{label:ae.label,definitionId:U,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:cR(U,S),role:"normal",body:ae.body,inputs:ae.input,outputs:ae.output}},le={...Gf(pe,{...C.current,[Q]:ae},V),selected:!0};return m(Ne=>[...Ne.map(ze=>({...ze,selected:!1})),le]),I.openProperties&&Zn(Q),Q},[qo,p,V,m,Oe]),Ri=h.useCallback(S=>C1(S,y.current),[]),Ec=h.useCallback(S=>{if(!Oe){Ce("Readonly workspace");return}if(!C1(S,y.current)){Ce("端口类型不匹配,已取消连线");return}z(null),m(I=>ug(I,S)),b(I=>{const U=I.filter(X=>!(X.target===S.target&&X.targetHandle===S.targetHandle));return Hf({...S,markerEnd:{type:Ms.ArrowClosed}},U)})},[b,m,Oe]),co=h.useCallback((S,I)=>{Oe&&(M.current=xq(I,y.current),z(null))},[Oe]),_a=h.useCallback((S,I)=>{var gt,qe,At,bn;if(!Oe)return;const U=M.current;if(M.current=null,!U||I!=null&&I.toNode)return;const X=wq(V,U);if(X.length===0){Ce(`没有匹配 ${U.slotType} 端口的节点`);return}const Q=((qe=(gt=S==null?void 0:S.changedTouches)==null?void 0:gt[0])==null?void 0:qe.clientX)??(S==null?void 0:S.clientX),se=((bn=(At=S==null?void 0:S.changedTouches)==null?void 0:At[0])==null?void 0:bn.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(Q)||!Number.isFinite(se))return;const re=document.querySelector(".af-workspace-canvas .react-flow");if(!re)return;const ae=re.getBoundingClientRect(),pe=320,le=Math.min(440,104+X.length*58),Ne=Math.max(12,Math.min(Q-ae.left,ae.width-pe-12)),ze=Math.max(12,Math.min(se-ae.top,ae.height-le-12));z({left:Ne,top:ze,flowPosition:r.screenToFlowPosition({x:Q,y:se}),draft:U,candidates:X,query:""})},[V,r,Oe]),dd=h.useCallback(S=>{if(!Oe){Ce("Readonly workspace"),z(null);return}const I=$.current;if(!I||!(S!=null&&S.def))return;const U=gi(S.def,{position:I.flowPosition});if(!U)return;const X=I.draft.handleType==="source"?{source:I.draft.nodeId,sourceHandle:I.draft.handleId,target:U,targetHandle:`input-${S.slotIndex}`}:{source:U,sourceHandle:`output-${S.slotIndex}`,target:I.draft.nodeId,targetHandle:I.draft.handleId};m(Q=>ug(Q,X)),b(Q=>{const se=Q.filter(re=>!(re.target===X.target&&re.targetHandle===X.targetHandle));return Hf({...X,markerEnd:{type:Ms.ArrowClosed}},se)}),z(null)},[gi,b,Oe]),Tl=h.useCallback(S=>{S&&(gi(S,{position:nr()}),Ie(!1),cr(""))},[gi,nr]),Et=h.useCallback(S=>{S&&(Al(S,nr()),Ie(!1),cr(""))},[Al,nr]);h.useEffect(()=>{const S=I=>{var le;if(I.defaultPrevented)return;const U=DT(I.target)||hq(I.target);if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"){I.preventDefault(),$n().catch(Ne=>Ce(String(Ne.message||Ne)));return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"){I.preventDefault(),I.stopPropagation(),kl(Ne=>!Ne);return}if(vl)return;if(va){(I.key==="Escape"||fg(I))&&(I.preventDefault(),Ho(!1));return}const X=I.key.toLowerCase(),Q=(I.metaKey||I.ctrlKey)&&X==="c",se=(I.metaKey||I.ctrlKey)&&X==="v",re=U&&Q&&gq(I.target);if(U&&!re)return;const ae=(I.metaKey||I.ctrlKey)&&!I.shiftKey&&X==="z",pe=(I.metaKey||I.ctrlKey)&&(I.shiftKey&&X==="z"||X==="y");if(ae||pe){if(ft){I.preventDefault(),I.stopPropagation(),Ce("展示页布局会自动保存");return}if(!Oe){I.preventDefault(),Ce("Readonly workspace");return}I.preventDefault(),I.stopPropagation();const Ne=ae?_p():Pp();Ce(Ne?ae?"Undo canvas change":"Redo canvas change":ae?"Nothing to undo":"Nothing to redo");return}if(Q){if(ft)return;const Ne=Wr.current,ze=(y.current||[]).some(qe=>qe==null?void 0:qe.selected)?y.current:(y.current||[]).map(qe=>Ne&&qe.id===Ne?{...qe,selected:!0}:qe),gt=PT(ze,k.current,C.current);gt&&(I.preventDefault(),I.stopPropagation(),W.current=gt,re&&typeof((le=I.target)==null?void 0:le.blur)=="function"&&I.target.blur(),Ce(`Copied ${gt.nodes.length} node${gt.nodes.length>1?"s":""}`));return}if(se){if(ft){I.preventDefault(),I.stopPropagation();return}if(!Oe){I.preventDefault(),Ce("Readonly workspace");return}const Ne=AT(W.current,y.current,k.current,C.current);Ne&&(I.preventDefault(),I.stopPropagation(),C.current=Ne.instances,P(Ne.instances),m(Ne.nodes),b(Ne.edges),Ce(`Pasted ${Ne.pastedNodeIds.length} node${Ne.pastedNodeIds.length>1?"s":""}`));return}if(fg(I)&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),Ho(!0);return}if(I.key==="a"||I.key==="A"){if(I.metaKey||I.ctrlKey){I.preventDefault(),ft?F(_.current.nodeIds):(m(Ne=>Ne.map(ze=>({...ze,selected:!0}))),b(Ne=>Ne.map(ze=>({...ze,selected:!1}))));return}if(I.altKey)return;if(ft){I.preventDefault(),Me(!0);return}if(!Oe){I.preventDefault(),Ce("Readonly workspace");return}I.preventDefault(),Ie(!0);return}if((I.key==="v"||I.key==="V")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),ci("select");return}if((I.key==="h"||I.key==="H")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),ci("pan");return}(I.key==="f"||I.key==="F")&&!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),El())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[ft,vl,El,Pp,$n,va,b,m,_p,Oe]);const kt=h.useCallback(S=>{ut(I=>{const U=new Set(I);return U.has(S)?U.delete(S):U.add(S),U})},[]),gy=h.useCallback((S,I)=>{S.dataTransfer.effectAllowed="copy",S.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:I.path,name:I.name,type:I.type})),S.dataTransfer.setData("text/plain",I.path)},[]),wn=h.useCallback((S,I)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",I.id),S.dataTransfer.setData("text/plain",I.id)},[]),Xt=h.useCallback(async(S,I)=>{const U=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),X=U.split(".").pop(),Q=X==="html"?"display_html":X==="csv"||X==="tsv"||X==="json"&&/\b(table|data|rows|report)\b/i.test(U)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(X)?"display_image":"display_markdown",se=V.find(ze=>ze.id===Q);if(!se){Ce("展示节点不可用");return}const re=Q==="display_image";let ae=String(S.path||"");if(!re){const ze=xo(i);ze.set("path",S.path);const gt=await fetch(`/api/workspace/file?${ze.toString()}`),qe=await gt.json();if(!gt.ok)throw new Error(qe.error||"读取文件失败");ae=String(qe.content||"")}const pe=Q==="display_image"?"src":"content",le=Fh(se.inputs).map(ze=>ze.name===pe?{...ze,default:ae,value:ae}:ze),Ne=Fh(se.outputs).map(ze=>ze.name===pe?{...ze,default:ae,value:ae}:ze);gi(se,{label:S.name||"Display",body:ae,inputs:le,outputs:Ne,position:I}),Ce(`已创建展示:${S.path}`)},[gi,i,V]),yy=h.useCallback(S=>{if(!Oe){Ce("Readonly workspace");return}Xt(S,qo()).catch(I=>Ce(String(I.message||I)))},[Xt,qo,Oe]),qs=h.useCallback(S=>{if(!Oe){S.preventDefault(),Ce("Readonly workspace");return}const I=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(I){S.preventDefault();let re;try{re=JSON.parse(I)}catch{return}if(!(re!=null&&re.path))return;const ae=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Xt(re,ae).catch(pe=>Ce(String(pe.message||pe)));return}const U=S.dataTransfer.getData("application/agentflow-snippet");if(U){const re=we.find(pe=>`${pe.id}@${pe.version}`===U);if(!re)return;S.preventDefault();const ae=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Al(re,ae);return}const X=S.dataTransfer.getData("application/agentflow-node");if(!X)return;const Q=V.find(re=>re.id===X);if(!Q)return;S.preventDefault();const se=r.screenToFlowPosition({x:S.clientX,y:S.clientY});gi(Q,{position:se})},[Xt,gi,we,Al,V,r,Oe]),Yo=h.useCallback(S=>{if(!Oe)return;const I=Array.from(S.dataTransfer.types||[]);!I.includes("application/x-agentflow-workspace-file")&&!I.includes("application/agentflow-node")&&!I.includes("application/agentflow-snippet")||(S.preventDefault(),S.dataTransfer.dropEffect=I.includes("application/agentflow-node")||I.includes("application/agentflow-snippet")?"move":"copy")},[Oe]),fd=h.useCallback(async(S="")=>{if(!Oe){Ce("Readonly workspace");return}const I=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!I)return;const U=S&&!I.includes("/")?`${S}/${I}`:I;try{const X=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:U,content:""})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件失败");await Bn(),ut(se=>{const re=new Set(se);for(const ae of Hh(Q.path||U))re.delete(ae);return re}),Ce(`已创建 ${Q.path}`)}catch(X){Ce(String(X.message||X))}},[i,Bn,Oe]),_c=h.useCallback(async(S="")=>{if(!Oe){Ce("Readonly workspace");return}const I=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!I)return;const U=S&&!I.includes("/")?`${S}/${I}`:I;try{const X=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:U})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件夹失败");await Bn(),ut(se=>{const re=new Set(se);for(const ae of Hh(Q.path||U))re.delete(ae);return Q.path&&re.delete(Q.path),re}),Ce(`已创建 ${Q.path}`)}catch(X){Ce(String(X.message||X))}},[i,Bn,Oe]),Vp=h.useCallback(async S=>{if(!Oe){Ce("Readonly workspace");return}if(!(!(S!=null&&S.path)||!window.confirm(`删除 ${S.path}?`)))try{const I=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:S.path})}),U=await I.json();if(!I.ok)throw new Error(U.error||"删除失败");Ce(`已删除 ${U.path}`),await Bn()}catch(I){Ce(String(I.message||I))}},[i,Bn,Oe]),Rl=h.useCallback(async()=>{if(!Oe){Ce("Readonly workspace");return}const S=ba.trim();if(!S||_r)return;const I=zh(p,g,C.current);gl(""),yl(!0),Ap("workspace"),Kt(U=>[...U,{role:"user",text:S,at:Date.now()}]);try{await $n(p,g);const U=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,prompt:S,outputKind:"markdown",workspaceGraph:I,allowFlowYaml:!1,model:xs,selectedSkills:er,selectedNodeIds:Ea})}),X=await U.json();if(!U.ok)throw new Error(X.error||"生成失败");const Q=String(X.content||"").trim();Kt(se=>[...se,{role:"assistant",text:Q,at:Date.now()}]),await wt(),Ce("AI 生成完成")}catch(U){const X=String(U.message||U);Kt(Q=>[...Q,{role:"assistant",text:X,error:!0,at:Date.now()}]),Ce(X)}finally{yl(!1)}},[xs,_r,ba,g,i,wt,p,Ap,$n,Ea,er,Oe]),an=yc.find(S=>S.id===wl)||null,Li=an?Array.isArray(an.messages)?an.messages:[]:xl,Up=an?an.status==="running":_r,xy=an?an.status==="running"?`${an.label} running`:an.status==="paused"?`${an.label} paused`:an.status==="failed"?`${an.label} failed`:`${an.label} done`:_r?"Workspace agent running":xl.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:i.flowId?`${i.flowId} · ${mr}`:mr||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",uq,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{n(Tf({id:i.flowId,source:i.flowSource||"user",archived:!!i.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:a==="workspace"?"af-view-switch__active":"",onClick:()=>cd("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:a==="display"?"af-view-switch__active":"",onClick:()=>cd("display"),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:vs}),ft?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Be||!(nt!=null&&nt.absoluteUrl)&&w.nodeIds.length===0,onClick:()=>{lr(""),nt!=null&&nt.absoluteUrl?fn(!0):Us()},title:nt!=null&&nt.absoluteUrl?"查看展示链接":w.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Be?"hourglass_empty":"ios_share"}),Be?"生成中":nt!=null&&nt.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ti.length===0,onClick:()=>Me(!0),title:Ti.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>n(nd),"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Cp,onClick:()=>d(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:o.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!Cp,onClick:()=>u(!0),"aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ho(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ai?" af-composer-topbar-btn--active":"")+(_r?" af-composer-topbar-btn--running":""),disabled:ft,onClick:()=>Do(S=>!S),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Oe,onClick:()=>$n().catch(S=>Ce(String(S.message||S))),children:"Save"})]})]}),rn?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:rn}),o.jsx("button",{type:"button",onClick:()=>Yn(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!ft&&(ai||it)?" af-workspace-body--drawer":"")+(!ft&&xc?" af-workspace-body--sidebar-collapsed":"")+(ft?" af-workspace-body--display-mode":""),children:[!ft&&xc?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Ie(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>zo(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>zo(!1),"aria-label":"展开侧边栏",title:(Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"展开侧边栏",children:_l})]})}):null,ft?null:o.jsxs("aside",{ref:Ut,className:"af-workspace-sidebar"+(Ze?" af-workspace-sidebar--resizing":""),"aria-hidden":xc,style:{"--af-work-files-pane-height":`${Math.round(on)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>zo(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Oe,onClick:()=>fd(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Oe,onClick:()=>_c(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Bn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:Gn,onChange:S=>Kr(S.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(wR,{items:oo,flowParams:i,onOpen:yy,collapsedDirs:Cr,onToggleDir:kt,onCreateFile:fd,onCreateFolder:_c,onDelete:Vp,onFileDragStart:gy})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Ot,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:he==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:ce,onChange:S=>fe(S.target.value),placeholder:he==="flows"?"搜索流程片段...":"搜索节点...","aria-label":he==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":he==="nodes",className:"af-palette-tab"+(he==="nodes"?" af-palette-tab--active":""),onClick:()=>oe("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":he==="flows",className:"af-palette-tab"+(he==="flows"?" af-palette-tab--active":""),onClick:()=>oe("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:he==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:Fp,disabled:Wn.length<2,title:Wn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Wn.length," 节点 / ",lo.length," 连线"]})]})}),Ae?o.jsx("p",{className:"af-err af-palette-list-err",children:Ae}):null,xe?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):jc.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:jc.map(S=>{const I=`${S.id}@${S.version}`,U=S.displayName||S.name||S.id,X=S.description||`${S.nodeCount||0} 个节点,${S.edgeCount||0} 条连线`;return o.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",I),Q.dataTransfer.setData("text/plain",I)},onClick:()=>Al(S),title:X,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:U}),o.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),X?o.jsx("span",{className:"af-palette-card-desc",children:X}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[S.nodeCount||0," nodes"]}),o.jsxs("span",{children:[S.edgeCount||0," edges"]})]})]},I)})})]}):o.jsx("p",{className:"af-palette-empty",children:ce.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[zc.map(S=>{var I;return(I=as[S])!=null&&I.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${S}`,children:[o.jsx("h3",{className:"af-palette-cat",children:S}),o.jsx("div",{className:"af-palette-cards",children:as[S].map(U=>{const X=j1(U.inputs,"input"),Q=j1(U.outputs,"output"),se=Db(U),re=qd(U);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:ae=>wn(ae,U),onClick:()=>gi(U),title:se||U.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:S1(S)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:re}),re!==U.id?o.jsx("span",{className:"af-palette-card-id",children:U.id}):null]})]}),se?o.jsx("span",{className:"af-palette-card-desc",children:se}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[X.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[X.shown.map((ae,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:N1("input",ae,pe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:or(ae==null?void 0:ae.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:$x(ae,pe)})]},`in-${pe}`)),X.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",X.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((ae,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:N1("output",ae,pe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:$x(ae,pe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:or(ae==null?void 0:ae.type)}})]},`out-${pe}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},U.id)})})]},S):null}),V.length>0&&ce.trim()&&zc.every(S=>{var I;return!((I=as[S])!=null&&I.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(o0,{className:"af-flow-canvas af-workspace-flow"+(Zu==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ft?" af-workspace-flow--display-mode":""),nodes:Mp,edges:$p,nodeTypes:Kq,onNodesChange:Wp,onEdgesChange:Il,onConnect:ft?void 0:Ec,onConnectStart:ft?void 0:co,onConnectEnd:ft?void 0:_a,isValidConnection:ft?void 0:Ri,onNodeClick:(S,I)=>{if(ft){F([Fx(I.id)]);return}hr&&Zn(I.id)},onNodeDoubleClick:(S,I)=>{S.preventDefault(),!ft&&(Do(!1),m(U=>U.map(X=>({...X,selected:X.id===I.id}))),b(U=>U.map(X=>({...X,selected:!1}))),Zn(I.id))},onPaneClick:()=>{ft?F([]):Zn("")},onDrop:ft?void 0:qs,onDragOver:ft?void 0:Yo,nodesDraggable:ft?!0:Oe,nodesConnectable:ft?!1:Oe,edgesReconnectable:ft?!1:Oe,deleteKeyCode:ft?null:Oe?["Backspace","Delete"]:null,selectionOnDrag:Zu==="select",panOnDrag:Zu==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(l0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ft&&T?(()=>{var X;const S=String(T.query||"").trim().toLowerCase(),I=S?T.candidates.filter(Q=>{var se,re,ae;return[(se=Q.def)==null?void 0:se.id,Q.displayLabel,Q.description,(re=Q.slot)==null?void 0:re.name,(ae=Q.slot)==null?void 0:ae.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(S))}):T.candidates,U=T.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:T.left,top:T.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:or((X=T.draft.slot)==null?void 0:X.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",T.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>z(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:T.query,onChange:Q=>z(se=>se&&{...se,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[I.map(Q=>{var ae,pe;const se=Q.displayLabel||((ae=Q.def)==null?void 0:ae.id),re=$x(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>dd(Q),title:Q.description||Q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:se}),se!==Q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:U}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:or((pe=Q.slot)==null?void 0:pe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:re})]})]},`${Q.def.id}-${Q.slotIndex}`)}),I.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ft&&!Qu?o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Fo(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:Wn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Wn.map(S=>{var Q,se;const I=String(((Q=S.data)==null?void 0:Q.label)??S.id),U=(se=S.data)!=null&&se.definitionId?String(S.data.definitionId):"",X=U&&U!==I?`${I} · ${S.id} · ${U}`:`${I} · ${S.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:X,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:U||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:I}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Bp(S.id),"aria-label":`取消选择 ${S.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},S.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:ba,rows:2,onChange:S=>gl(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),Rl())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Oe})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:ur,type:"button",className:"af-composer-skills-button"+(er.length>0?" af-composer-skills-button--active":""),disabled:_r||!Oe,"aria-haspopup":"listbox","aria-expanded":os,onClick:()=>Ws(S=>!S),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:er.length>0?`Skills ${er.length}`:"Skills"})]}),os&&!_r?Dr.createPortal(o.jsx("div",{ref:wa,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:jp,children:vr.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Vo.groups.map(S=>{const I=ol(S,vr),U=iP(S,Sc,vr),X=mn.has(S.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(X?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:U==="all",disabled:I.length===0,onChange:Q=>{const se=Q.target.checked;ws(re=>se?rP(re,I):sP(re,I))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:S.name}),S.builtin?o.jsx("em",{children:"built-in"}):null,U==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":X?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{Yr(Q=>{const se=new Set(Q);return se.has(S.id)?se.delete(S.id):se.add(S.id),se})},children:[o.jsx("span",{children:S.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X?"expand_more":"expand_less"})]})]}),X?null:o.jsx("div",{className:"af-composer-skill-group-items",children:S.skills.map(Q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Sc.has(Q.key),onChange:se=>{const re=se.target.checked;ws(ae=>re?ae.includes(Q.key)?ae:[...ae,Q.key]:ae.filter(pe=>pe!==Q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${S.id}:${Q.key}`))})]},S.id)}),Vo.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Vo.ungrouped.length})]}),Vo.ungrouped.map(S=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Sc.has(S.key),onChange:I=>{const U=I.target.checked;ws(X=>U?X.includes(S.key)?X:[...X,S.key]:X.filter(Q=>Q!==S.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:S.name}),S.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:S.description}):null]})]},`ungrouped:${S.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:xs,onChange:S=>Mo(S.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),ao.map(S=>o.jsx("option",{value:S.value,children:S.label},S.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(ba.trim()&&!_r?" af-composer-send--active":"")+(_r?" af-composer-send--stop":""),disabled:_r||!ba.trim()||!Oe,"aria-label":_r?"Running":"Send",onClick:()=>void Rl(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_r?"sync":"arrow_upward"})})]})]})]})}):ft?null:o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Fo(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!ft&&ai?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Do(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(wl==="workspace"?" af-composer-session-tab--active":""),onClick:()=>ro("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),yc.map(S=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(wl===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>ro(S.id),title:S.runNodeId||S.label,children:o.jsx("span",{className:"af-composer-session-label",children:S.label})},S.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Up?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:xy}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(Gq,{messages:Li,running:Up,showRunningIndicator:!an})})]})}):!ft&&it&&Gt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(qT,{draft:it,setDraft:Vr,definitionId:String(((pd=Gt.data)==null?void 0:pd.definitionId)||Gt.id),systemPromptReadonly:String(((hd=Gt.data)==null?void 0:hd.description)||""),modelLists:Hs,disabled:!Oe,onIdBlur:()=>ld(!0),onClose:()=>Zn(""),onPublishToMarketplace:id,error:ya,ioSlots:{inputs:Array.isArray(it==null?void 0:it.inputs)?it.inputs:[],outputs:Array.isArray(it==null?void 0:it.outputs)?it.outputs:[]}})}):null,o.jsx(HT,{open:va,onClose:()=>Ho(!1)}),o.jsx(BT,{open:vl,onClose:()=>kl(!1),onJump:Wo,nodes:kc}),o.jsx(FT,{open:c,onClose:()=>d(!1),flowId:i.flowId||"",flowSource:fi,onArchived:()=>{d(!1),n("/projects?tab=archived")}}),o.jsx(zT,{open:f&&!!i.flowId,onClose:()=>u(!1),flowId:i.flowId||"",flowSource:fi,flowArchived:!!i.archived,onDeleted:async()=>{u(!1),n("/projects")}}),ct?Dr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Xe(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:mt.name,onChange:S=>{const I=S.target.value;He(U=>({...U,name:I,id:U.id?U.id:I.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:mt.id,onChange:S=>He(I=>({...I,id:S.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:mt.description,onChange:S=>He(I=>({...I,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Wn.length," 个节点和 ",lo.length," 条内部连线。"]}),yn?o.jsx("div",{className:"af-flow-snippet-error",children:yn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Xe(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:dt||!mt.name.trim(),onClick:()=>void zp(),children:dt?"发布中...":"发布"})]})]})}),document.body):null,ue?Dr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"发布展示页",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),"发布展示页"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ve(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{type:"text",value:Qt.title,onChange:S=>ar(I=>({...I,title:S.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"布局"}),o.jsxs("select",{className:"af-display-share-select",value:Qt.layout,onChange:S=>ar(I=>({...I,layout:S.target.value})),children:[o.jsx("option",{value:"gallery",children:"Gallery"}),o.jsx("option",{value:"document",children:"Document"}),o.jsx("option",{value:"slides",children:"Slides"})]})]}),o.jsx("div",{className:"af-display-share-node-list",role:"group","aria-label":"选择展示节点",children:En.map(S=>{var U,X;const I=Array.isArray(Qt.nodeIds)&&Qt.nodeIds.includes(S.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:I,onChange:()=>Jr(S.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((U=S.data)==null?void 0:U.label)||S.id}),o.jsxs("small",{children:[Un((X=S.data)==null?void 0:X.definitionId)," · ",S.id]})]})]},S.id)})}),nt!=null&&nt.absoluteUrl?o.jsxs("div",{className:"af-display-share-result",children:[o.jsx("input",{type:"text",readOnly:!0,value:nt.absoluteUrl,onFocus:S=>S.target.select()}),o.jsx("button",{type:"button",onClick:()=>window.open(nt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),o.jsx("button",{type:"button",onClick:()=>void Ks(),children:xn==="copied"?"已复制":xn==="failed"?"复制失败":"复制"})]}):null,at?o.jsx("div",{className:"af-flow-snippet-error",children:at}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>ve(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Be||!Array.isArray(Qt.nodeIds)||Qt.nodeIds.length===0,onClick:()=>void Hp(),children:Be?"生成中...":"生成链接"})]})]})}),document.body):null,Cn?Dr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{lr(""),fn(!1)},"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[nt!=null&&nt.absoluteUrl?o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",readOnly:!0,value:nt.absoluteUrl,onFocus:S=>S.target.select(),autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>window.open(nt.absoluteUrl,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void Ks(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:xn==="copied"?"check":"content_copy"}),xn==="copied"?"已复制":xn==="failed"?"复制失败":"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),at?o.jsx("div",{className:"af-flow-snippet-error",children:at}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{lr(""),fn(!1)},children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Be||w.nodeIds.length===0,onClick:()=>void Us(),children:Be?"生成中...":nt!=null&&nt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,be?Dr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Me(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-display-picker-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:tt,onChange:S=>zt(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":Pl.length||1},children:Ko.length>0?Pl.map((S,I)=>o.jsx("div",{className:"af-display-picker-column",children:S.map(Dp)},`display-picker-column-${I}`)):o.jsx("div",{className:"af-display-picker-empty",children:Ti.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>Me(!1),children:"完成"})})]})}),document.body):null,!ft&&ie?Dr.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Ie(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":We==="nodes",className:"af-workspace-quick-add__tab"+(We==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ht("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":We==="flows",className:"af-workspace-quick-add__tab"+(We==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ht("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Ju,value:pn,onChange:S=>cr(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),Ie(!1);else if(S.key==="ArrowDown"){S.preventDefault();const I=We==="flows"?tr.length:Xr.length;is(U=>Math.min(Math.max(0,I-1),U+1))}else S.key==="ArrowUp"?(S.preventDefault(),is(I=>Math.max(0,I-1))):S.key==="Tab"?(S.preventDefault(),Ht(I=>I==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),We==="flows"?Et(tr[zs]||tr[0]):Tl(Xr[zs]||Xr[0]))},placeholder:We==="flows"?"搜索流程片段...":"搜索节点...","aria-label":We==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:We==="flows"?tr.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:xe?"正在加载流程片段...":Ae||"没有匹配的流程片段"}):tr.map((S,I)=>{const U=S.displayName||S.name||S.id,X=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,Q=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,se=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(X||{}).length,re=Number.isFinite(Number(S.edgeCount))?Number(S.edgeCount):Array.isArray(Q)?Q.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(I===zs?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>is(I),onClick:()=>Et(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:U}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[S.id,S.version?` · v${S.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:S.description||`${se} 节点 / ${re} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):Xr.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Xr.map((S,I)=>{const U=Kd(S),X=qd(S),Q=Db(S);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(I===zs?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>is(I),onClick:()=>Tl(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:S1(U)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:X}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:S.id}),Q?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:U})]},S.id)})})]})}),document.body):null]})]})}function oY(){return o.jsx(ty,{children:o.jsx(iY,{})})}function aY(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=(e==null?void 0:e.kind)==="image"?"src":"content",r=a=>String((a==null?void 0:a.value)??(a==null?void 0:a.default)??""),s=a=>r(a).trim(),i=t.find(a=>(a==null?void 0:a.name)===n&&s(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&s(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&s(a));return String((e==null?void 0:e.body)||(i?r(i):""))}function lY(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function bR(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/(?:^|\n)---agentflow\s*\n([\s\S]*?)\n---end(?:\n|$)/i);if(n!=null&&n[1]){const a=n[1],l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
178
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
179
- `).replace(/\s+$/g,""):f.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("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function M0(e){let t=bR(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function cY(e){const t=M0(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function uY(e){const t=M0(e);if(!t.trim())return"";const n=`<base target="_self"><script>
180
- (() => {
181
- document.addEventListener("click", (event) => {
182
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
183
- if (!link) return;
184
- const rawHref = String(link.getAttribute("href") || "").trim();
185
- if (!rawHref || rawHref.startsWith("#")) return;
186
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
187
- event.preventDefault();
188
- window.location.href = link.href;
189
- }, true);
190
- })();
191
- <\/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 vR(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=new URLSearchParams;return r.set("id",t),r.set("path",n),`/api/display/file/raw?${r.toString()}`}function dY(e,t){const n=String(e||"").trim();return n?vR(n,t):""}function fY({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const u=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=u>p+1,g=m?Math.max(12,p/u*100):100,b=Math.max(0,100-g),v=m?Math.min(b,f.scrollTop/Math.max(1,u-p)*b):0;i({visible:m,top:v,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(u);for(const m of Array.from(u.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const u=n.current;if(!u)return;const p=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),c=h.useCallback((f,u=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-u)/b},[s.height]),d=h.useCallback(f=>{if(!s.visible)return;f.preventDefault(),f.stopPropagation();const u=r.current;if(!u)return;const p=u.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,v=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(c(f.clientY,v));const y=w=>{w.preventDefault(),l(c(w.clientY,v))},k=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[o.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function pY({node:e,shareId:t,style:n}){const r=aY(e),s=e.kind==="html"?M0(r):bR(r),i=e.kind==="html"?cY(s):"",a=`af-public-display-node__body--${e.kind||"unknown"}`;return o.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}`,style:n,children:[o.jsx("div",{className:"af-public-display-node__head",children:o.jsxs("div",{className:"af-public-display-node__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:lY(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(fY,{className:a,children:i?o.jsx("div",{className:"af-public-display-empty",children:i}):s.trim()?o.jsxs(o.Fragment,{children:[e.kind==="html"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals",srcDoc:uY(s)}):null,e.kind==="image"?o.jsx("img",{src:vR(s,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(T0,{content:s,resolveSrc:l=>dY(l,t)})}):null,e.kind==="chart"?o.jsx(L0,{content:s}):null,e.kind==="table"?o.jsx(R0,{content:s}):null,e.kind==="mermaid"||e.kind==="ascii"?o.jsx("pre",{children:s}):null]}):o.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function hY({data:e}){return o.jsx(pY,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const mY={publicDisplay:hY};function gY(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 kR(){var a;const{path:e}=Ro(),t=h.useMemo(()=>gY(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let l=!1;async function c(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(d=>({...d,loading:!0,error:""}));try{const d=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),f=await d.json().catch(()=>({}));if(!d.ok)throw new Error(f.error||"展示页不存在");l||r({loading:!1,error:"",share:f.share||null,nodes:Array.isArray(f.nodes)?f.nodes:[]})}catch(d){l||r({loading:!1,error:String((d==null?void 0:d.message)||d),share:null,nodes:[]})}}return c(),()=>{l=!0}},[t]);const s=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((c,d)=>{const f=c.position&&typeof c.position.x=="number"&&typeof c.position.y=="number"?c.position:{x:120+d*40,y:100+d*32},u=c.size&&typeof c.size.width=="number"&&typeof c.size.height=="number"?c.size:{width:520,height:320};return{id:c.id,type:"publicDisplay",position:f,data:{node:c,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(u.width)||520),height:Math.max(1,Number(u.height)||320)}}}),[t,n.nodes]),i=h.useMemo(()=>{var u;const l=(u=n.share)==null?void 0:u.viewport;if(!l||typeof l!="object")return null;const c=Number(l.x),d=Number(l.y),f=Number(l.zoom);return!Number.isFinite(c)||!Number.isFinite(d)||!Number.isFinite(f)?null:{x:c,y:d,zoom:Math.min(Math.max(f,.1),4)}},[(a=n.share)==null?void 0:a.viewport]);return n.loading?o.jsx("main",{className:"af-public-display-page",children:o.jsx("div",{className:"af-public-display-status",children:"Loading..."})}):n.error?o.jsx("main",{className:"af-public-display-page",children:o.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),o.jsx("span",{children:n.error})]})}):o.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:o.jsx(ty,{children:o.jsx(o0,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:mY,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:i||void 0,fitView:!i,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:o.jsx(l0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const Nt=e=>typeof e=="string",Ld=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},L1=e=>e==null?"":""+e,yY=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},xY=/###/g,O1=e=>e&&e.indexOf("###")>-1?e.replace(xY,"."):e,M1=e=>!e||Nt(e),pf=(e,t,n)=>{const r=Nt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(M1(e))return{};const i=O1(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return M1(e)?{}:{obj:e,k:O1(r[s])}},$1=(e,t,n)=>{const{obj:r,k:s}=pf(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=pf(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=pf(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},wY=(e,t,n,r)=>{const{obj:s,k:i}=pf(e,t,Object);s[i]=s[i]||[],s[i].push(n)},yg=(e,t)=>{const{obj:n,k:r}=pf(e,t);if(n)return n[r]},bY=(e,t,n)=>{const r=yg(e,n);return r!==void 0?r:yg(t,n)},SR=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Nt(e[r])||e[r]instanceof String||Nt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):SR(e[r],t[r],n):e[r]=t[r]);return e},$c=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var vY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const kY=e=>Nt(e)?e.replace(/[&<>"'\/]/g,t=>vY[t]):e;class SY{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 NY=[" ",",","?","!",";"],jY=new SY(20),CY=(e,t,n)=>{t=t||"",n=n||"";const r=NY.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=jY.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},zb=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=i;c<r.length;++c)if(c!==i&&(l+=n),l+=r[c],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;i+=c-i+1;break}s=a}return s},xg=e=>e&&e.replace("_","-"),EY={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 wg{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||EY,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:(Nt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new wg(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new wg(this.logger,t)}}var No=new wg;class ly{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let d=0;d<c;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let d=0;d<c;d++)l.apply(l,[t,...r])})}}class D1 extends ly{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):Nt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=yg(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!Nt(r)?c:zb(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),$1(this.data,l,s),i.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const i in r)(Nt(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=yg(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?SR(c,r,i):c={...c,...r},$1(this.data,l,c),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var NR={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const F1={};class bg extends ly{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),yY(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=No.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!CY(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Nt(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:Nt(i)?[i]:i}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],d=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(f){const j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${j}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const u=this.resolve(t,n);let p=u&&u.res;const m=u&&u.usedKey||a,g=u&&u.exactUsedKey||a,b=Object.prototype.toString.apply(p),v=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!Nt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&w&&v.indexOf(b)<0&&!(Nt(y)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const j=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(u.res=j,u.usedParams=this.getUsedParamsDetails(n),u):j}if(i){const j=Array.isArray(p),_=j?[]:{},E=j?g:m;for(const O in p)if(Object.prototype.hasOwnProperty.call(p,O)){const H=`${E}${i}${O}`;_[O]=this.translate(H,{...n,joinArrays:!1,ns:l}),_[O]===H&&(_[O]=p[O])}p=_}}else if(k&&Nt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,_=!1;const E=n.count!==void 0&&!Nt(n.count),O=bg.hasDefaultValue(n),H=E?this.pluralResolver.getSuffix(d,n.count,n):"",L=n.ordinal&&E?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",F=E&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),D=F&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${H}`]||n[`defaultValue${L}`]||n.defaultValue;!this.isValidLookup(p)&&O&&(j=!0,p=D),this.isValidLookup(p)||(_=!0,p=a);const W=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:p,M=O&&D!==p&&this.options.updateMissing;if(_||j||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,a,M?D:p),i){const A=this.resolve(a,{...n,keySeparator:!1});A&&A.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let $=[];const T=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&T&&T[0])for(let A=0;A<T.length;A++)$.push(T[A]);else this.options.saveMissingTo==="all"?$=this.languageUtils.toResolveHierarchy(n.lng||this.language):$.push(n.lng||this.language);const z=(A,P,C)=>{const G=O&&C!==p?C:W;this.options.missingKeyHandler?this.options.missingKeyHandler(A,c,P,G,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(A,c,P,G,M,n),this.emit("missingKey",A,c,P,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&E?$.forEach(A=>{const P=this.pluralResolver.getSuffixes(A,n);F&&n[`defaultValue${this.options.pluralSeparator}zero`]&&P.indexOf(`${this.options.pluralSeparator}zero`)<0&&P.push(`${this.options.pluralSeparator}zero`),P.forEach(C=>{z([A],a+C,n[`defaultValue${C}`]||D)})}):z($,a,D))}p=this.extendTranslation(p,t,n,u,r),_&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(_||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(u.res=p,u.usedParams=this.getUsedParamsDetails(n),u):p}extendTranslation(t,n,r,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=Nt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(d){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let u=r.replace&&!Nt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),t=this.interpolator.interpolate(t,u,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;f<m&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return i&&i[0]===m[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):a.translate(...m,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=Nt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=NR.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,i,a,l;return Nt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=n.count!==void 0&&!Nt(n.count),m=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(Nt(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(v=>{this.isValidLookup(r)||(l=v,!F1[`${b[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(F1[`${b[0]}-${v}`]=!0,this.logger.warn(`key "${s}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;a=y;const k=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,y,v,n);else{let j;p&&(j=this.pluralResolver.getSuffix(y,n.count,n));const _=`${this.options.pluralSeparator}zero`,E=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(f+j),n.ordinal&&j.indexOf(E)===0&&k.push(f+j.replace(E,this.options.pluralSeparator)),m&&k.push(f+_)),g){const O=`${f}${this.options.contextSeparator}${n.context}`;k.push(O),p&&(k.push(O+j),n.ordinal&&j.indexOf(E)===0&&k.push(O+j.replace(E,this.options.pluralSeparator)),m&&k.push(O+_))}}let w;for(;w=k.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,v,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!Nt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const i of n)delete s[i]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Hx=e=>e.charAt(0).toUpperCase()+e.slice(1);class z1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=No.create("languageUtils")}getScriptPartFromCode(t){if(t=xg(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=xg(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Nt(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]=Hx(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]=Hx(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Hx(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Nt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return Nt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):Nt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let _Y=[{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}],PY={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 AY=["v1","v2","v3"],IY=["v4"],H1={zero:0,one:1,two:2,few:3,many:4,other:5},TY=()=>{const e={};return _Y.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:PY[t.fc]}})}),e};class RY{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=No.create("pluralResolver"),(!this.options.compatibilityJSON||IY.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=TY(),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=xg(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[i]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,i)=>H1[s]-H1[i]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const i=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!AY.includes(this.options.compatibilityJSON)}}const B1=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=bY(e,t,n);return!i&&s&&Nt(n)&&(i=zb(e,n,r),i===void 0&&(i=zb(t,n,r))),i},Bx=e=>e.replace(/\$/g,"$$$$");class LY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=No.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:i,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:v,maxReplaces:y,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:kY,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?$c(i):a||"{{",this.suffix=l?$c(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?$c(p):m||$c("$t("),this.nestingSuffix=g?$c(g):b||$c(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=y||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let i,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=B1(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:m}):y}const g=m.split(this.formatSeparator),b=g.shift().trim(),v=g.join(this.formatSeparator).trim();return this.format(B1(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,u=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>Bx(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Bx(this.escape(m)):Bx(m)}].forEach(m=>{for(l=0;i=m.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const v=f(t,i,s);a=Nt(v)?v:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!Nt(a)&&!this.useRawValueToEscape&&(a=L1(a));const b=m.safeValue(a);if(t=t.replace(i[0],b),u?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(c,d)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const u=c.split(new RegExp(`${f}[ ]*{`));let p=`{${u[1]}`;c=u[0],p=this.interpolate(p,a);const m=p.match(/'/g),g=p.match(/"/g);(m&&m.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${f}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!Nt(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 f=s[1].split(this.formatSeparator).map(u=>u.trim());s[1]=f.shift(),c=f,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!Nt(i))return i;Nt(i)||(i=L1(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=c.reduce((f,u)=>this.format(f,u,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const OY=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Dc=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(xg(r),s),t[a]=l),l(n)}};class MY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=No.create("formatter"),this.options=t,this.formats={number:Dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:Dc((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:Dc((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:Dc((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:Dc((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Dc(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(c=>c.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,c)=>{const{formatName:d,formatOptions:f}=OY(c);if(this.formats[d]){let u=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=p.locale||p.lng||s.locale||s.lng||r;u=this.formats[d](l,m,{...f,...s,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const $Y=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class DY extends ly{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=No.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const i={},a={},l={},c={};return t.forEach(d=>{let f=!0;n.forEach(u=>{const p=`${d}|${u}`;!r.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),c[u]===void 0&&(c[u]=!0)))}),f||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{wY(c.loaded,[i],a),$Y(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(u=>{l[d][u]===void 0&&(l[d][u]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:i,callback:a});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Nt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Nt(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,r,s,c):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(u=>l(null,u)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const W1=()=>({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]),Nt(e[1])&&(t.defaultValue=e[1]),Nt(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}}),V1=e=>(Nt(e.ns)&&(e.ns=[e.ns]),Nt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Nt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Bh=()=>{},FY=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Qf extends ly{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=V1(t),this.services={},this.logger=No,this.modules={external:[]},FY(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&&(Nt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=W1();this.options={...s,...this.options,...V1(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const i=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?No.init(i(this.modules.logger),this.options):No.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=MY);const u=new z1(this.options);this.store=new D1(this.options.resources,this.options);const p=this.services;p.logger=No,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new RY(u,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new LY(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new DY(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(m,...b)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new bg(this.services,this.options),this.translator.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bh),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[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(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const c=Ld(),d=()=>{const f=(u,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(u,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bh;const s=Nt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Ld();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=Bh),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&NR.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=Ld();this.emit("languageChanging",t);const i=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const d=Nt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let c;if(typeof l!="object"){for(var d=arguments.length,f=new Array(d>2?d-2:0),u=2;u<d;u++)f[u-2]=arguments[u];c=s.options.overloadTranslationOptionHandler([a,l].concat(f))}else c={...l};c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let m;return c.keyPrefix&&Array.isArray(a)?m=a.map(g=>`${c.keyPrefix}${p}${g}`):m=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(m,c)};return Nt(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Ld();return this.options.ns?(Nt(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=Ld();Nt(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new z1(W1());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 Qf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bh;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new Qf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new D1(this.store.data,s),i.services.resourceStore=i.store),i.translator=new bg(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,d=new Array(c>1?c-1:0),f=1;f<c;f++)d[f-1]=arguments[f];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Br=Qf.createInstance();Br.createInstance=Qf.createInstance;Br.createInstance;Br.dir;Br.init;Br.loadResources;Br.reloadResources;Br.use;Br.changeLanguage;Br.getFixedT;Br.t;Br.exists;Br.setDefaultNamespace;Br.hasLoadedNamespace;Br.loadNamespaces;Br.loadLanguages;function zY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Zf(e){"@babel/helpers - typeof";return Zf=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},Zf(e)}function HY(e,t){if(Zf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Zf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function BY(e){var t=HY(e,"string");return Zf(t)=="symbol"?t:t+""}function WY(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,BY(r.key),r)}}function VY(e,t,n){return t&&WY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var jR=[],UY=jR.forEach,KY=jR.slice;function qY(e){return UY.call(KY.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var U1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,YY=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!U1.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!U1.test(s.path))throw new TypeError("option path is invalid");a+="; Path=".concat(s.path)}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(s.expires.toUTCString())}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite){var c=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},K1={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=YY(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},GY={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=K1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&K1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},XY={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var c=i[a].substring(0,l);c===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Od=null,q1=function(){if(Od!==null)return Od;try{Od=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Od=!1}return Od},JY={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&q1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&q1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Md=null,Y1=function(){if(Md!==null)return Md;try{Md=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Md=!1}return Md},QY={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&Y1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&Y1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},ZY={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}},eG={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}},tG={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}},nG={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]}},CR=!1;try{document.cookie,CR=!0}catch{}var ER=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];CR||ER.splice(1,1);function rG(){return{order:ER,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var _R=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};zY(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return VY(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=qY(r,this.options||{},rG()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(GY),this.addDetector(XY),this.addDetector(JY),this.addDetector(QY),this.addDetector(ZY),this.addDetector(eG),this.addDetector(tG),this.addDetector(nG)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();_R.type="languageDetector";const sG={name:"AgentFlow",tagline:"AI Workflow Orchestration"},iG={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},oG={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"},aG={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},lG={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},cG={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},uG={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},dG={app:sG,nav:iG,common:oG,status:aG,nodeTypes:lG,engine:cG,links:uG},fG="Flow Editor",pG="Nodes",hG="Edges",mG="Properties",gG={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"},yG={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},xG={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},wG={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},bG={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"},vG={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)"},kG={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},SG={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},NG={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},jG={node:"Node",text:"Text",file:"File",bool:"Boolean"},CG={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"},EG={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"},_G={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},PG={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."},AG={mainNav:"Main Navigation"},IG={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'},TG={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):
192
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
193
- 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}}"},RG={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"},LG={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},OG={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}}"},MG={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"},$G={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"},DG={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"},FG={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"},zG={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"},HG={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},BG={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},WG={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"},VG={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."},UG={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},KG={save:"Save",cancel:"Cancel"},qG={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},YG={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},GG={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"},XG={title:fG,nodes:pG,edges:hG,properties:mG,node:gG,nodeProps:yG,actions:xG,panel:wG,palette:bG,pipeline:vG,status:kG,roles:SG,phases:NG,types:jG,runContext:CG,shortcuts:EG,jumpPalette:_G,emptyCanvas:PG,sidebar:AG,validation:IG,composer:TG,topbar:RG,palette2:LG,run:OG,fileEdit:MG,settings:$G,schedule:DG,history:FG,nodePropsError:zG,placeholder:HG,time:BG,userCheck:WG,userAsk:VG,toolPrint:UG,provideEdit:KG,runParams:qG,runPreset:YG,runConfig:GG},JG="Settings",QG={engine:"Engine Settings",preferences:"Global Preferences"},ZG={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)."},eX={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..."}},tX={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."},nX={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."},rX={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)"},sX={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"},iX={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},oX={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},aX={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},lX={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."},cX={title:JG,crumb:QG,workspace:ZG,cursor:eX,opencode:tX,claudeCode:nX,env:rX,allowlist:sX,system:iX,shortcuts:oX,language:aX,onboarding:lX},uX={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},dX={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)"},fX={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},pX={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},hX={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},mX={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},gX={aiLabels:uX,placeholders:dX,actions:fX,labels:pX,tooltips:hX,rightPanel:mX},yX="Projects",xX="All",wX="Archived",bX="Nodes",vX="My Nodes",kX="My Flows",SX="Skills",NX="Active Projects",jX="Archived Pipelines",CX="Global Nodes",EX="Manage node versions published to the current workspace marketplace, {{count}} total.",_X="Manage flow snippets published to the current workspace marketplace, {{count}} total.",PX="Global Skills",AX="Create New Project",IX="New Pipeline",TX="SEARCH PIPELINES...",RX="SEARCH NODES...",LX="SEARCH FLOW SNIPPETS...",OX="SEARCH SKILLS...",MX="Refresh Resources",$X="Loading pipelines...",DX="Loading global resources...",FX="Filter result: {{count}} items (matching title, description, path and tags)",zX="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",HX="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",BX="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",WX="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",VX="Executable building blocks for pipeline runtime",UX="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.",KX="Published local node packages",qX="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",YX="Published flow snippets",GX="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",XX="Operating guides for Composer and agents",JX="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",QX="No archived projects.",ZX="No active pipelines; archived items are in the Archived tab.",eJ="No global nodes available.",tJ="No marketplace nodes have been published.",nJ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",rJ="No skills available.",sJ="No description.",iJ='No node matches "{{query}}".',oJ='No flow snippet matches "{{query}}".',aJ='No skill matches "{{query}}".',lJ="{{inputs}} in / {{outputs}} out",cJ="Flow Snippet",uJ="{{nodes}} nodes / {{edges}} edges",dJ="Skill",fJ="Node detail",pJ="Flow snippet detail",hJ="Skill detail",mJ="Type",gJ="Source",yJ="Package",xJ="Version",wJ="Path",bJ="Editable",vJ="Read only",kJ="Editable",SJ="Schema",NJ="Inputs",jJ="Outputs",CJ="Runtime",EJ="Node Body",_J="Files",PJ="Usage",AJ="No runtime manifest.",IJ="No node body or README.",TJ="No previewable files.",RJ="Select a file to preview.",LJ="Binary file preview is not supported.",OJ="Large file; showing the first 256KB only.",MJ="No pipelines using this node were found.",$J="Node Management",DJ="Delete Node Version",FJ="Deleting...",zJ="AgentFlow checks all flow references before deleting; installed or used versions are kept.",HJ="Delete {{id}}@{{version}}? This cannot be undone.",BJ="Deleted {{id}}@{{version}}.",WJ="{{count}} flow(s) still use it.",VJ="Flow Snippet Management",UJ="Delete Flow Snippet",KJ="Deleting...",qJ="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",YJ="Delete {{id}}@{{version}}? This cannot be undone.",GJ="Deleted {{id}}@{{version}}.",XJ="No slots",JJ="Purpose",QJ="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",ZJ="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.",eQ="Scale",tQ="Flow Preview",nQ="Edges",rQ="Snippet JSON",sQ="{{count}} more edge(s)",iQ="No previewable nodes.",oQ="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",aQ="SKILL.md Preview",lQ="No preview content available.",cQ="Select a resource to inspect details.",uQ="Failed to load pipeline list.",dQ="No pipelines in current workspace.",fQ="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.",pQ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',hQ="Recent Activity",mQ="No recent activity",gQ="No recent activity matching the keyword",yQ="Recent Run",xQ="Recent Open",wQ={builtin:"Built-in",workspace:"Workspace",user:"User"},bQ={flow:"Flow",global:"Global",marketplace:"Marketplace"},vQ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},kQ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},SQ="Open to edit this pipeline in the node canvas.",NQ={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>"},jQ={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"},CQ={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"},EQ={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"},_Q={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"},PQ={title:yX,all:xX,archived:wX,nodes:bX,myNodes:vX,myFlows:kX,skills:SX,activeProjects:NX,archivedPipelines:jX,globalNodes:CX,myNodesHint:EX,myFlowsHint:_X,globalSkills:PX,createNew:AX,newPipeline:IX,searchPipelines:TX,searchNodes:RX,searchFlows:LX,searchSkills:OX,refreshResources:MX,loadingPipelines:$X,loadingResources:DX,filterResult:FX,archivedHint:zX,activeHint:HX,nodesHint:BX,skillsHint:WX,nodesPurposeTitle:VX,nodesPurposeDesc:UX,myNodesPurposeTitle:KX,myNodesPurposeDesc:qX,myFlowsPurposeTitle:YX,myFlowsPurposeDesc:GX,skillsPurposeTitle:XX,skillsPurposeDesc:JX,noArchived:QX,noActive:ZX,noNodes:eJ,noMyNodes:tJ,noMyFlows:nJ,noSkills:rJ,noDescription:sJ,noNodeMatch:iJ,noFlowSnippetMatch:oJ,noSkillMatch:aJ,nodeSlots:lJ,flowSnippet:cJ,flowSnippetNodes:uJ,skill:dJ,nodeDetail:fJ,flowDetail:pJ,skillDetail:hJ,detailType:mJ,detailSource:gJ,detailPackage:yJ,detailVersion:xJ,detailPath:wJ,detailEditable:bJ,readOnly:vJ,editable:kJ,nodeSchema:SJ,nodeInputs:NJ,nodeOutputs:jJ,nodeRuntime:CJ,nodeBody:EJ,nodeFiles:_J,nodeUsage:PJ,noRuntimeManifest:AJ,noNodeBody:IJ,noNodeFiles:TJ,selectNodeFile:RJ,binaryFile:LJ,fileTruncated:OJ,noNodeUsage:MJ,myNodeManagement:$J,deleteMyNode:DJ,deletingMyNode:FJ,deleteMyNodeHint:zJ,deleteMyNodeConfirm:HJ,deleteMyNodeSuccess:BJ,deleteMyNodeUsedBy:WJ,myFlowManagement:VJ,deleteMyFlow:UJ,deletingMyFlow:KJ,deleteMyFlowHint:qJ,deleteMyFlowConfirm:YJ,deleteMyFlowSuccess:GJ,noSlots:XJ,resourceMeaning:JJ,nodesMeaning:QJ,myFlowsMeaning:ZJ,flowSnippetScale:eQ,flowSnippetPreview:tQ,flowSnippetEdges:nQ,flowSnippetJson:rQ,flowSnippetMoreEdges:sQ,noFlowSnippetPreview:iQ,skillsMeaning:oQ,skillPreview:aQ,skillPreviewEmpty:lQ,selectResource:cQ,loadFailed:uQ,noPipelines:dQ,emptyHint:fQ,noMatch:pQ,recentActivity:hQ,noRecentActivity:mQ,noMatchRecent:gQ,recentRun:yQ,recentOpen:xQ,sourceBadge:wQ,resourceSource:bQ,resourceFilter:vQ,nodeDetailTabs:kQ,defaultCardDesc:SQ,hubCard:NQ,newPipelineModal:jQ,importModal:CQ,deleteModal:EQ,archiveModal:_Q},AQ="Back",IQ="Next",TQ="Skip",RQ="Done",LQ="Start Creating",OQ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
194
-
195
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
196
-
197
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},MQ={intro:`Now you're in the flow editor.
198
-
199
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
200
-
201
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
202
-
203
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
204
-
205
- The left node panel allows you to freely drag, delete, and adjust connections.`},$Q={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"},DQ={back:AQ,next:IQ,skip:TQ,done:RQ,startCreate:LQ,projects:OQ,flow:MQ,newPipeline:$Q},FQ={name:"AgentFlow",tagline:"AI 工作流编排"},zQ={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},HQ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},BQ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},WQ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},VQ={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},UQ={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},KQ={app:FQ,nav:zQ,common:HQ,status:BQ,nodeTypes:WQ,engine:VQ,links:UQ},qQ="流程编辑器",YQ="节点",GQ="连线",XQ="属性",JQ={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:"编辑内容"},QQ={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},ZQ={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},eZ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},tZ={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},nZ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},rZ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},sZ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},iZ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},oZ={node:"节点",text:"文本",file:"文件",bool:"布尔"},aZ={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:"等待"},lZ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},cZ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},uZ={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},dZ={mainNav:"主导航"},fZ={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},pZ={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}} 步):
206
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
207
- 当前:{{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}}"},hZ={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},mZ={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},gZ={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}} 的分支"},yZ={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},xZ={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:"已复制"},wZ={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:"定时配置已保存"},bZ={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},vZ={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},kZ={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},SZ={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},NZ={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},jZ={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},CZ={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},EZ={save:"保存",cancel:"取消"},_Z={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},PZ={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},AZ={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},IZ={title:qQ,nodes:YQ,edges:GQ,properties:XQ,node:JQ,nodeProps:QQ,actions:ZQ,panel:eZ,palette:tZ,pipeline:nZ,status:rZ,roles:sZ,phases:iZ,types:oZ,runContext:aZ,shortcuts:lZ,jumpPalette:cZ,emptyCanvas:uZ,sidebar:dZ,validation:fZ,composer:pZ,topbar:hZ,palette2:mZ,run:gZ,fileEdit:yZ,settings:xZ,schedule:wZ,history:bZ,nodePropsError:vZ,placeholder:kZ,time:SZ,userCheck:NZ,userAsk:jZ,toolPrint:CZ,provideEdit:EZ,runParams:_Z,runPreset:PZ,runConfig:AZ},TZ="设置",RZ={engine:"引擎设置",preferences:"全局首选项"},LZ={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},OZ={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},MZ={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},$Z={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},DZ={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},FZ={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:"添加"},zZ={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},HZ={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},BZ={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},WZ={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},VZ={title:TZ,crumb:RZ,workspace:LZ,cursor:OZ,opencode:MZ,claudeCode:$Z,env:DZ,allowlist:FZ,system:zZ,shortcuts:HZ,language:BZ,onboarding:WZ},UZ={thinking:"思考",result:"结果",reply:"回复",error:"错误"},KZ={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},qZ={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},YZ={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},GZ={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},XZ={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},JZ={aiLabels:UZ,placeholders:KZ,actions:qZ,labels:YZ,tooltips:GZ,rightPanel:XZ},QZ="项目",ZZ="全部",eee="已归档",tee="Nodes",nee="我的 Nodes",ree="我的流程",see="Skills",iee="活跃项目",oee="已归档流水线",aee="全局 Nodes",lee="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",cee="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",uee="全局 Skills",dee="创建新项目",fee="新建流水线",pee="搜索流水线…",hee="搜索 nodes…",mee="搜索流程片段…",gee="搜索 skills…",yee="刷新资源",xee="加载流水线列表…",wee="加载全局资源…",bee="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",vee="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",kee="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",See="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Nee="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",jee="流程运行时的可执行积木",Cee="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",Eee="已发布的本地节点包",_ee="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Pee="已发布的流程片段",Aee="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Iee="Composer/Agent 的操作指南",Tee="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",Ree="暂无归档项目。",Lee="暂无未归档流水线;已归档项在 Archived 标签中查看。",Oee="暂无可用全局 nodes。",Mee="暂无已发布的 marketplace nodes。",$ee="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Dee="暂无可用 skills。",Fee="暂无描述。",zee="未找到与「{{query}}」匹配的 node。",Hee="未找到与「{{query}}」匹配的流程片段。",Bee="未找到与「{{query}}」匹配的 skill。",Wee="{{inputs}} in / {{outputs}} out",Vee="流程片段",Uee="{{nodes}} 节点 / {{edges}} 连线",Kee="Skill",qee="Node 详情",Yee="流程片段详情",Gee="Skill 详情",Xee="类型",Jee="来源",Qee="包",Zee="版本",ete="路径",tte="可编辑",nte="只读",rte="可编辑",ste="Schema",ite="输入",ote="输出",ate="Runtime",lte="节点内容",cte="Files",ute="Usage",dte="暂无 runtime manifest。",fte="暂无节点正文或 README。",pte="暂无可预览文件。",hte="请选择文件查看内容。",mte="二进制文件暂不支持预览。",gte="文件较大,仅显示前 256KB。",yte="暂未发现使用此 node 的流水线。",xte="节点管理",wte="删除节点版本",bte="删除中…",vte="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",kte="确定删除 {{id}}@{{version}}?此操作不可撤销。",Ste="已删除 {{id}}@{{version}}。",Nte="仍有 {{count}} 个 Flow 使用它。",jte="流程片段管理",Cte="删除流程片段",Ete="删除中…",_te="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Pte="确定删除 {{id}}@{{version}}?此操作不可撤销。",Ate="已删除 {{id}}@{{version}}。",Ite="无槽位",Tte="作用",Rte="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Lte="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Ote="规模",Mte="流程预览",$te="连线",Dte="片段 JSON",Fte="还有 {{count}} 条连线",zte="暂无可预览节点。",Hte="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Bte="SKILL.md 预览",Wte="暂无可预览内容。",Vte="请选择一个资源查看详情。",Ute="未能加载流水线列表。",Kte="当前工作区暂无流水线。",qte="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Yte="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Gte="最近打开或最近运行",Xte="暂无打开或运行记录",Jte="暂无与关键词匹配的最近记录",Qte="最近运行",Zte="最近打开",ene={builtin:"内置",workspace:"工作区",user:"用户"},tne={flow:"Flow",global:"Global",marketplace:"Marketplace"},nne={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},rne={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},sne="打开以在节点画布中编辑此流水线。",ine={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},one={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:"关闭"},ane={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},lne={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},cne={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},une={title:QZ,all:ZZ,archived:eee,nodes:tee,myNodes:nee,myFlows:ree,skills:see,activeProjects:iee,archivedPipelines:oee,globalNodes:aee,myNodesHint:lee,myFlowsHint:cee,globalSkills:uee,createNew:dee,newPipeline:fee,searchPipelines:pee,searchNodes:hee,searchFlows:mee,searchSkills:gee,refreshResources:yee,loadingPipelines:xee,loadingResources:wee,filterResult:bee,archivedHint:vee,activeHint:kee,nodesHint:See,skillsHint:Nee,nodesPurposeTitle:jee,nodesPurposeDesc:Cee,myNodesPurposeTitle:Eee,myNodesPurposeDesc:_ee,myFlowsPurposeTitle:Pee,myFlowsPurposeDesc:Aee,skillsPurposeTitle:Iee,skillsPurposeDesc:Tee,noArchived:Ree,noActive:Lee,noNodes:Oee,noMyNodes:Mee,noMyFlows:$ee,noSkills:Dee,noDescription:Fee,noNodeMatch:zee,noFlowSnippetMatch:Hee,noSkillMatch:Bee,nodeSlots:Wee,flowSnippet:Vee,flowSnippetNodes:Uee,skill:Kee,nodeDetail:qee,flowDetail:Yee,skillDetail:Gee,detailType:Xee,detailSource:Jee,detailPackage:Qee,detailVersion:Zee,detailPath:ete,detailEditable:tte,readOnly:nte,editable:rte,nodeSchema:ste,nodeInputs:ite,nodeOutputs:ote,nodeRuntime:ate,nodeBody:lte,nodeFiles:cte,nodeUsage:ute,noRuntimeManifest:dte,noNodeBody:fte,noNodeFiles:pte,selectNodeFile:hte,binaryFile:mte,fileTruncated:gte,noNodeUsage:yte,myNodeManagement:xte,deleteMyNode:wte,deletingMyNode:bte,deleteMyNodeHint:vte,deleteMyNodeConfirm:kte,deleteMyNodeSuccess:Ste,deleteMyNodeUsedBy:Nte,myFlowManagement:jte,deleteMyFlow:Cte,deletingMyFlow:Ete,deleteMyFlowHint:_te,deleteMyFlowConfirm:Pte,deleteMyFlowSuccess:Ate,noSlots:Ite,resourceMeaning:Tte,nodesMeaning:Rte,myFlowsMeaning:Lte,flowSnippetScale:Ote,flowSnippetPreview:Mte,flowSnippetEdges:$te,flowSnippetJson:Dte,flowSnippetMoreEdges:Fte,noFlowSnippetPreview:zte,skillsMeaning:Hte,skillPreview:Bte,skillPreviewEmpty:Wte,selectResource:Vte,loadFailed:Ute,noPipelines:Kte,emptyHint:qte,noMatch:Yte,recentActivity:Gte,noRecentActivity:Xte,noMatchRecent:Jte,recentRun:Qte,recentOpen:Zte,sourceBadge:ene,resourceSource:tne,resourceFilter:nne,nodeDetailTabs:rne,defaultCardDesc:sne,hubCard:ine,newPipelineModal:one,importModal:ane,deleteModal:lne,archiveModal:cne},dne="返回",fne="下一步",pne="跳过",hne="完成",mne="开始创建",gne={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
208
-
209
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
210
-
211
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},yne={intro:`现在进入流程编辑器。
212
-
213
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
214
-
215
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
216
-
217
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
218
-
219
- 左侧节点面板可以自由拖拽、删除和调整连接。`},xne={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},wne={back:dne,next:fne,skip:pne,done:hne,startCreate:mne,projects:gne,flow:yne,newPipeline:xne},bne={en:{common:dG,flow:XG,settings:cX,composer:gX,project:PQ,onboarding:DQ},zh:{common:KQ,flow:IZ,settings:VZ,composer:JZ,project:une,onboarding:wne}};Br.use(_R).use(xM).init({resources:bne,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 vne=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function kne(e){return Br.changeLanguage(e)}const Hb="agentflow-settings-opencode-plan-v1";function Wx(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 PR(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Sne(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Bl(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const s=String(r.key??"").trim(),i=String(r.value??""),a=String(r.id??"").trim()||PR(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:c})}return n}function G1(e){return Bl(e).map(({key:t,value:n})=>({key:t,value:n}))}function X1(){try{return localStorage.getItem(Hb)??""}catch{return""}}function Nne(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function J1(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 jne({authUser:e}){const{t,i18n:n}=Ln(["common","settings"]),r=n.language||"zh",[s,i]=h.useState(""),[a,l]=h.useState(""),[c,d]=h.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[f,u]=h.useState(""),[p,m]=h.useState(!1),[g,b]=h.useState(!1),[v,y]=h.useState(""),[k,w]=h.useState([]),[j,_]=h.useState(""),[E,O]=h.useState(!1),[H,L]=h.useState(""),[F,D]=h.useState(""),[R,W]=h.useState(!1),[M,$]=h.useState(()=>new Set),[T,z]=h.useState(""),[A,P]=h.useState([]),[C,G]=h.useState(!1),[Z,V]=h.useState(""),[ne,ce]=h.useState([]),[fe,he]=h.useState([]),[oe,we]=h.useState(""),[_e,xe]=h.useState(""),[Te,Ae]=h.useState(!1),[et,ct]=h.useState(!1),[Xe,mt]=h.useState(""),He=h.useRef(null),dt=h.useRef(!1),gn=h.useRef(!1),yn=h.useRef(""),On=h.useCallback(async()=>{l("");try{const ie=await fetch("/api/ui-context");if(!ie.ok)throw new Error("HTTP "+ie.status);const Ie=await ie.json();i(typeof Ie.workspaceRoot=="string"?Ie.workspaceRoot:"")}catch(ie){l(String(ie.message||ie)),i("")}},[]),rn=h.useCallback(async()=>{u(""),m(!0);try{const ie=await fetch("/api/model-lists");if(!ie.ok)throw new Error("HTTP "+ie.status);const Ie=await ie.json();d(Wx(Ie))}catch(ie){u(String(ie.message||ie))}finally{m(!1)}},[]),Yn=h.useCallback(async()=>{_("");try{const ie=await fetch("/api/user-env"),Ie=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Ie.error=="string"?Ie.error:"HTTP "+ie.status);const We=Bl(Array.isArray(Ie.env)?Ie.env:[],"user").map(cr=>({...cr,scope:"user"})),pn=[...e!=null&&e.isAdmin?Bl(Array.isArray(Ie.globalEnv)?Ie.globalEnv:[],"global").map(cr=>({...cr,scope:"global"})):[],...We];yn.current=JSON.stringify(pn),w(pn)}catch(ie){w([]),_(String(ie.message||ie))}finally{gn.current=!0}},[e==null?void 0:e.isAdmin]),Mn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){G(!0),V("");try{const ie=await fetch("/api/feedback"),Ie=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Ie.error=="string"?Ie.error:"HTTP "+ie.status);P(Array.isArray(Ie.feedback)?Ie.feedback:[])}catch(ie){V(String(ie.message||ie))}finally{G(!1)}}},[e==null?void 0:e.isAdmin]),ue=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Ae(!0),mt("");try{const ie=await fetch("/api/admin/user-allowlist"),Ie=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Ie.error=="string"?Ie.error:"HTTP "+ie.status);const We=Ie.allowlist&&typeof Ie.allowlist=="object"?Ie.allowlist:{};ce(Array.isArray(We.fileUsers)?We.fileUsers.map(String):[]),he(Array.isArray(We.envUsers)?We.envUsers.map(String):[]),we(typeof We.path=="string"?We.path:"")}catch(ie){mt(String(ie.message||ie))}finally{Ae(!1)}}},[e==null?void 0:e.isAdmin]),ve=h.useCallback(async ie=>{if(e!=null&&e.isAdmin){ct(!0),mt("");try{const Ie=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ie})}),We=await Ie.json().catch(()=>({}));if(!Ie.ok)throw new Error(typeof We.error=="string"?We.error:"HTTP "+Ie.status);const Ht=We.allowlist&&typeof We.allowlist=="object"?We.allowlist:{};ce(Array.isArray(Ht.fileUsers)?Ht.fileUsers.map(String):[]),he(Array.isArray(Ht.envUsers)?Ht.envUsers.map(String):[]),we(typeof Ht.path=="string"?Ht.path:"")}catch(Ie){mt(String(Ie.message||Ie))}finally{ct(!1)}}},[e==null?void 0:e.isAdmin]),Be=h.useCallback(async ie=>{const Ie=Bl(ie),We=Ie.filter(pn=>pn.scope!=="global"),Ht=Ie.filter(pn=>pn.scope==="global");O(!0),_("");try{const pn=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G1(We),...e!=null&&e.isAdmin?{globalEnv:G1(Ht)}:{}})}),cr=await pn.json().catch(()=>({}));if(!pn.ok)throw new Error(typeof cr.error=="string"?cr.error:"HTTP "+pn.status);const zs=Bl(Array.isArray(cr.env)?cr.env:[],"user").map(Zn=>({...Zn,scope:"user"})),hr=[...e!=null&&e.isAdmin?Bl(Array.isArray(cr.globalEnv)?cr.globalEnv:[],"global").map(Zn=>({...Zn,scope:"global"})):[],...zs];yn.current=JSON.stringify(hr),w(hr)}catch(pn){_(String(pn.message||pn))}finally{O(!1)}},[e==null?void 0:e.isAdmin]),ot=h.useCallback(async()=>{u(""),m(!0);try{const ie=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:T.trim()})}),Ie=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Ie.error=="string"?Ie.error:"HTTP "+ie.status);d(Wx(Ie.modelLists))}catch(ie){u(String(ie.message||ie))}finally{m(!1)}},[T]);h.useEffect(()=>{On(),rn(),Yn(),e!=null&&e.isAdmin&&(Mn(),ue()),(async()=>{try{const ie=await fetch("/api/agentflow-config");if(ie.ok){const Ie=await ie.json(),We=typeof Ie.opencodeProvider=="string"?Ie.opencodeProvider:"";z(We),He.current=We;try{localStorage.setItem(Hb,We)}catch{}}else{const Ie=X1();z(Ie),He.current=Ie}}catch{const ie=X1();z(ie),He.current=ie}finally{dt.current=!0}})()},[e==null?void 0:e.isAdmin,On,Mn,rn,ue,Yn]),h.useEffect(()=>{if(!gn.current||JSON.stringify(Bl(k))===yn.current)return;const Ie=setTimeout(()=>{Be(k)},350);return()=>clearTimeout(Ie)},[k,Be]),h.useEffect(()=>{if(!dt.current)return;const ie=T.trim();if(ie===He.current)return;const Ie=setTimeout(()=>{(async()=>{b(!0),y("");try{const We=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ie})}),Ht=await We.json().catch(()=>({}));if(!We.ok)throw new Error(typeof Ht.error=="string"?Ht.error:"HTTP "+We.status);He.current=ie;try{localStorage.setItem(Hb,ie)}catch{}Ht.modelLists&&d(Wx(Ht.modelLists))}catch(We){y(String(We.message||We))}finally{b(!1)}})()},450);return()=>clearTimeout(Ie)},[T]);const at=c.cursor.length>0,Lt=c.opencode.length>0,nt=c.claudeCode.length>0,dn=ne.length>0||fe.length>0,Qt=h.useCallback(()=>{var ie;s&&((ie=navigator.clipboard)==null||ie.writeText(s))},[s]),ar=h.useCallback(()=>{const ie=H.trim(),Ie=F;if(ie){if(!Sne(ie)){_(t("settings:env.invalidKey"));return}w(We=>[...We,{id:PR(),key:ie,value:Ie,scope:e!=null&&e.isAdmin&&R?"global":"user"}]),L(""),D("")}},[e==null?void 0:e.isAdmin,R,H,F,t]),Cn=h.useCallback(ie=>{w(Ie=>Ie.filter(We=>We.id!==ie))},[]),fn=h.useCallback((ie,Ie)=>{w(We=>We.map(Ht=>Ht.id===ie?{...Ht,...Ie}:Ht))},[]),xn=h.useCallback(ie=>{$(Ie=>{const We=new Set(Ie);return We.has(ie)?We.delete(ie):We.add(ie),We})},[]),lr=h.useCallback(()=>{const ie=_e.trim();if(!ie)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ie)){mt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(ne.map(We=>String(We||"").trim().toLowerCase())).has(ie.toLowerCase())){xe("");return}xe(""),ve([...ne,ie])},[_e,ne,ve]),be=h.useCallback(ie=>{const Ie=String(ie||"").trim().toLowerCase();Ie&&ve(ne.filter(We=>String(We||"").trim().toLowerCase()!==Ie))},[ne,ve]),Me=h.useCallback(ie=>{const Ie=ie.target.value;kne(Ie)},[]),tt=ie=>{const Ie=J1(ie,r);return Ie?t("settings:cursor.modelList.fetchedAt",{time:Ie}):t("settings:cursor.modelList.never")},zt=ie=>J1(ie,r)||String(ie||"");return o.jsxs("div",{className:"af-settings-page",children:[o.jsx("header",{className:"af-settings-top",children:o.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,f?o.jsx("p",{className:"af-err af-settings-api-hint",children:f}):null,j?o.jsx("p",{className:"af-err af-settings-api-hint",children:j}):null]}),o.jsxs("div",{className:"af-settings-layout",children:[o.jsxs("div",{className:"af-settings-bento",children:[o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[o.jsxs("div",{className:"af-set-card-inner",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),o.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Qt,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),o.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),o.jsx("span",{className:"af-set-badge"+(at?" af-set-badge--ok":" af-set-badge--muted"),children:t(at?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:at?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(at?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:at?t("settings:cursor.modelList.count",{count:c.cursor.length})+" · "+tt(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),at?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:c.cursor.join(`
220
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>ot(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),o.jsx("span",{className:"af-set-badge"+(Lt?" af-set-badge--ok":" af-set-badge--err"),children:t(Lt?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),o.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:T,onChange:ie=>z(ie.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,v?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:v}):null]}),Lt?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+" · "+tt(c.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:c.opencode.join(`
221
- `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>ot(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(nt?" af-set-badge--ok":" af-set-badge--err"),children:t(nt?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:nt?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(nt?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:nt?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+" · "+tt(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),nt?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:c.claudeCode.join(`
222
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>ot(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),o.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:E?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[o.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[o.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?o.jsx("span",{children:t("settings:env.scope")}):null,o.jsx("span",{children:t("settings:env.value")}),o.jsx("span",{})]}),k.map(ie=>o.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ie.key,onChange:Ie=>fn(ie.id,{key:Ie.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:ie.scope!=="global"?"is-active":"",onClick:()=>fn(ie.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:ie.scope==="global"?"is-active":"",onClick:()=>fn(ie.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:M.has(ie.id)?"text":"password",value:ie.value,onChange:Ie=>fn(ie.id,{value:Ie.target.value}),placeholder:Nne(ie.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>xn(ie.id),"aria-label":M.has(ie.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:M.has(ie.id)?"visibility_off":"visibility"})})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ie.key}),onClick:()=>Cn(ie.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ie.id)),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:H,onChange:ie=>L(ie.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:R?"":"is-active",onClick:()=>W(!1),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:R?"is-active":"",onClick:()=>W(!0),children:t("settings:env.global")})]})}):null,o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:F,onChange:ie=>D(ie.target.value),"aria-label":t("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:ar,disabled:!H.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]})]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),o.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),o.jsx("span",{className:"af-set-badge"+(dn?" af-set-badge--ok":" af-set-badge--muted"),children:t(dn?"settings:allowlist.enabled":"settings:allowlist.open")}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void ue(),disabled:Te,children:t(Te?"settings:allowlist.refreshing":"common:common.refresh")})]}),Xe?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Xe}):null,oe?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",o.jsx("code",{children:oe})]}):null,o.jsxs("div",{className:"af-allowlist-grid",children:[o.jsxs("div",{className:"af-allowlist-main",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.fileList")}),o.jsx("span",{children:et?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:ne.length})})]}),o.jsx("div",{className:"af-allowlist-list",children:ne.length>0?ne.map(ie=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:ie}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>be(ie),"aria-label":t("settings:allowlist.remove",{username:ie}),disabled:et,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie)):o.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:_e,onChange:ie=>xe(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&lr()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:lr,disabled:et||!_e.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.envList")}),o.jsx("span",{children:t("settings:allowlist.readonly")})]}),o.jsx("div",{className:"af-allowlist-env-list",children:fe.length>0?fe.map(ie=>o.jsx("code",{children:ie},ie)):o.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),o.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Mn(),disabled:C,children:C?"刷新中...":"刷新"})]}),Z?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Z}):null,o.jsx("div",{className:"af-feedback-list",children:A.length>0?A.map(ie=>o.jsxs("article",{className:"af-feedback-item",children:[o.jsxs("header",{className:"af-feedback-item__head",children:[o.jsxs("div",{children:[o.jsx("h3",{children:ie.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:ie.username||ie.userId||"unknown"}),o.jsx("span",{children:zt(ie.createdAt)})]})]}),ie.contact?o.jsx("span",{className:"af-feedback-item__contact",children:ie.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:ie.content}),ie.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:ie.pageUrl}):null]},ie.id)):o.jsx("div",{className:"af-feedback-empty",children:C?"正在加载反馈...":"暂无反馈"})})]}):null]}),o.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[o.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[o.jsxs("div",{className:"af-set-rail-inner",children:[o.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),o.jsxs("div",{className:"af-set-health-line",children:[o.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),o.jsx("span",{className:"af-set-health-label",children:t(!a&&!f?"settings:system.normal":"settings:system.abnormal")})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.cursorModels")}),o.jsx("span",{children:c.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.opencodeModels")}),o.jsx("span",{children:c.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.claudeCodeModels")}),o.jsx("span",{children:c.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]})]}),o.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),o.jsxs("div",{className:"af-set-rail-card",children:[o.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Me,"aria-label":t("settings:language.description"),children:vne.map(ie=>o.jsxs("option",{value:ie.code,children:[ie.flag," ",ie.name]},ie.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function Cne(){const{navigate:e}=Ro(),[t,n]=h.useState(""),[r,s]=h.useState(""),[i,a]=h.useState(!1),[l,c]=h.useState(""),[d,f]=h.useState(!1),u=async p=>{if(p.preventDefault(),!i){a(!0),c("");try{const m=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,content:r,pageUrl:window.location.href})}),g=await m.json().catch(()=>({}));if(!m.ok)throw new Error(g.error||"提交失败");f(!0),n(""),s("")}catch(m){c(String(m.message||m))}finally{a(!1)}}};return o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?o.jsxs("div",{className:"af-feedback-success",role:"status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsxs("div",{children:[o.jsx("strong",{children:"已提交"}),o.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,o.jsxs("form",{className:"af-feedback-form",onSubmit:u,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:t,onChange:p=>n(p.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:r,onChange:p=>s(p.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),l?o.jsx("p",{className:"af-err af-feedback-error",children:l}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:i||!t.trim()||!r.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"hourglass_empty":"send"}),i?"提交中...":"提交反馈"]})})]})]})})}function AR(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Q1(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:AR(),key:r,value:String(s??""),private:n.has(r)}))}function Z1(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 mm(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(`
223
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:Q1(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:Q1(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 Vx(){return mm({name:"",raw:{command:""}})}function Ene(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const i=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);i.length&&(n.args=i)}const r=Z1(e.envRows),s=Z1(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(s).length&&(n.headers=s),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean)}}function eC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function tC(e){return e?e.ok?"ok":"error":"unknown"}function nC({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,c)=>n(t.map(d=>d.id===a?{...d,[l]:c}:d));return o.jsxs("div",{className:"af-mcp-field",children:[o.jsxs("div",{className:"af-mcp-field-head",children:[o.jsx("span",{children:e}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:AR(),key:"",value:"",private:!0}]),children:"添加"})]}),o.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?o.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>o.jsxs("div",{className:"af-mcp-kv-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>i(a.id,"key",l.target.value)}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>i(a.id,"value",l.target.value)}),o.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[o.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>i(a.id,"private",l.target.checked)}),o.jsx("span",{children:"个人"})]}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function _ne(){var R;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,i]=h.useState(Vx),[a,l]=h.useState(""),[c,d]=h.useState(!1),[f,u]=h.useState(!1),[p,m]=h.useState(!1),[g,b]=h.useState({}),[v,y]=h.useState(""),[k,w]=h.useState(""),j=h.useMemo(()=>n.find(W=>W.name===a)||null,[a,n]),_=j&&g[j.name]||null,E=h.useCallback(async()=>{d(!0),y("");try{const W=await fetch("/api/mcps"),M=await W.json().catch(()=>({}));if(!W.ok)throw new Error(M.error||"MCP HTTP "+W.status);const $=Array.isArray(M.servers)?M.servers:[];t(String(M.path||"")),r($),a&&$.some(T=>T.name===a)&&i(mm($.find(T=>T.name===a)))}catch(W){y(String(W.message||W))}finally{d(!1)}},[a]);h.useEffect(()=>{E()},[E]);const O=()=>{l(""),i(Vx()),w(""),y("")},H=W=>{l(W.name),i(mm(W)),w(""),y("")},L=async(W="")=>{m(!0),y(""),w("");try{const M=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W?{name:W}:{})}),$=await M.json().catch(()=>({}));if(!M.ok)throw new Error($.error||"检测 MCP 失败");const T=Array.isArray($.results)?$.results:[];b(z=>{const A={...z};for(const P of T)P!=null&&P.name&&(A[P.name]=P);return A}),w(W?`已检测 ${W}。`:"已检测所有 MCP。")}catch(M){y(String(M.message||M))}finally{m(!1)}},F=async()=>{u(!0),y(""),w("");try{const W=Ene(s);if(!W.nextName)throw new Error("请填写 MCP 名称");const M=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await M.json().catch(()=>({}));if(!M.ok)throw new Error($.error||"保存 MCP 失败");const T=Array.isArray($.servers)?$.servers:[];r(T),t(String($.path||e)),l(W.nextName),i(mm(T.find(z=>z.name===W.nextName)||null)),b(z=>{const A={...z};return s.originalName&&s.originalName!==W.nextName&&delete A[s.originalName],delete A[W.nextName],A}),w("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(W){y(String(W.message||W))}finally{u(!1)}},D=async W=>{if(W!=null&&W.name&&window.confirm(`删除 MCP "${W.name}"?`)){u(!0),y(""),w("");try{const M=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W.name})}),$=await M.json().catch(()=>({}));if(!M.ok)throw new Error($.error||"删除 MCP 失败");r(Array.isArray($.servers)?$.servers:[]),l(""),i(Vx()),b(T=>{const z={...T};return delete z[W.name],z}),w("已删除。")}catch(M){y(String(M.message||M))}finally{u(!1)}}};return o.jsxs("main",{className:"af-settings-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),o.jsxs("div",{className:"af-settings-top-right",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:E,disabled:c||f,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>L(),disabled:p||c||f||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:f,children:"新增 MCP"})]})]}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("section",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),o.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",o.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),o.jsxs("div",{className:"af-mcp-layout",children:[o.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2",children:"Servers"}),o.jsxs("div",{className:"af-mcp-list-head-actions",children:[o.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),o.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:f,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?o.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?o.jsxs("div",{className:"af-mcp-empty",children:[o.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:O,disabled:f,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(W=>o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===W.name?" af-mcp-server-item--active":""),onClick:()=>H(W),children:[o.jsx("span",{className:"material-symbols-outlined",children:W.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:W.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${tC(g[W.name])}`,children:eC(g[W.name])})]}),o.jsx("em",{children:W.url||[W.command,...W.args||[]].filter(Boolean).join(" ")})]})]},W.name))})]}),o.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:j?"编辑 MCP":"新增 MCP"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),j?o.jsxs("div",{className:"af-mcp-editor-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>L(j.name),disabled:p||f,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>D(j),disabled:f,children:"删除"})]}):null]}),v?o.jsx("p",{className:"af-mcp-error",children:v}):null,k?o.jsx("p",{className:"af-mcp-status",children:k}):null,_?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${tC(_)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:eC(_)}),o.jsxs("span",{children:[_.elapsedMs||0,"ms"]})]}),_.error?o.jsx("p",{children:_.error}):null,(R=_.tools)!=null&&R.length?o.jsx("div",{className:"af-mcp-tools-list",children:_.tools.map(W=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:W.name}),W.description?o.jsx("span",{children:W.description}):null]},W.name))}):null]}):null,o.jsxs("div",{className:"af-mcp-form",children:[o.jsxs("label",{className:"af-set-label",children:["MCP 名称",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:W=>i(M=>({...M,name:W.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:W=>i(M=>({...M,type:W.target.value})),children:[o.jsx("option",{value:"url",children:"URL / HTTP"}),o.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:W=>i(M=>({...M,url:W.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-set-label",children:["Command",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:W=>i(M=>({...M,command:W.target.value})),placeholder:"uvx"})]}),o.jsxs("label",{className:"af-set-label",children:["Args,每行一个",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:W=>i(M=>({...M,argsText:W.target.value})),placeholder:`mcp-server-example
224
- --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:W=>i(M=>({...M,description:W.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(nC,{title:"Headers",rows:s.headerRows,onChange:W=>i(M=>({...M,headerRows:W})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(nC,{title:"Env",rows:s.envRows,onChange:W=>i(M=>({...M,envRows:W})),placeholderKey:"TOKEN",placeholderValue:"..."}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:W=>i(M=>({...M,extraJson:W.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:O,disabled:f,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:F,disabled:f,children:f?"保存中...":"保存 MCP"})]})]})]})]})})]})}const Pne=[{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"}],Ane=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Ine=[{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"}],Tne=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Wh({icon:e,title:t,label:n,tone:r="violet"}){return o.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[o.jsx("span",{className:"material-symbols-outlined",children:e}),o.jsxs("div",{children:[o.jsx("strong",{children:t}),o.jsx("small",{children:n})]})]})}function Rne(){return o.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[o.jsx("div",{className:"likee-scene-grid"}),o.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[o.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),o.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),o.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),o.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),o.jsx("div",{className:"likee-node-pos likee-node-a",children:o.jsx(Wh,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),o.jsx("div",{className:"likee-node-pos likee-node-b",children:o.jsx(Wh,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),o.jsx("div",{className:"likee-node-pos likee-node-c",children:o.jsx(Wh,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),o.jsx("div",{className:"likee-node-pos likee-node-d",children:o.jsx(Wh,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),o.jsxs("div",{className:"likee-phone-preview",children:[o.jsxs("div",{className:"likee-phone-top",children:[o.jsx("span",{children:"关注"}),o.jsx("strong",{children:"推荐"}),o.jsx("span",{children:"直播"})]}),o.jsxs("div",{className:"likee-phone-card",children:[o.jsx("div",{className:"likee-gift",children:"AD"}),o.jsx("h4",{children:"广告个性化引导弹框"}),o.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),o.jsx("button",{children:"继续"}),o.jsx("button",{className:"secondary",children:"稍后"})]})]}),o.jsxs("div",{className:"likee-display-panel",children:[o.jsxs("div",{className:"likee-panel-header",children:[o.jsx("span",{children:"DISPLAY"}),o.jsx("strong",{children:"需求资产面板"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"需求"}),o.jsx("strong",{children:"首页广告个性化引导"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"数据"}),o.jsx("strong",{children:"m09 PV Top 1"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"同步"}),o.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function gm({kicker:e,title:t,children:n}){return o.jsxs("div",{className:"likee-section-copy",children:[o.jsx("p",{className:"likee-section-kicker",children:e}),o.jsx("h2",{children:t}),o.jsx("p",{children:n})]})}function Lne(){return o.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[o.jsx(gm,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),o.jsx("div",{className:"likee-skill-grid",children:Ine.map(e=>o.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[o.jsxs("div",{className:"likee-skill-head",children:[o.jsx("div",{className:"likee-skill-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.name}),o.jsx("span",{children:e.namespace})]})]}),o.jsx("div",{className:"likee-skill-mode",children:e.mode}),o.jsx("p",{children:e.usage}),o.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>o.jsx("strong",{children:t},t))})]},e.name))})]})})}function IR(){return o.jsxs("div",{className:"likee-page",children:[o.jsx("div",{className:"likee-top-actions",children:o.jsxs("a",{href:"/projects",className:"likee-home-link",children:[o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),o.jsxs("section",{className:"likee-hero",children:[o.jsx(Rne,{}),o.jsxs("div",{className:"likee-hero-content",children:[o.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),o.jsx("h1",{children:"Likee Agent 工作台"}),o.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),o.jsxs("div",{className:"likee-signal-row",children:[o.jsx("span",{children:"查业务逻辑"}),o.jsx("span",{children:"查 CK / Hive"}),o.jsx("span",{children:"生成原型"}),o.jsx("span",{children:"生成 PRD"}),o.jsx("span",{children:"同步 TAPD / Git"})]}),o.jsxs("div",{className:"likee-hero-actions",children:[o.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),o.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),o.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),o.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),o.jsx("section",{id:"likee-scenarios",className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner",children:[o.jsx(gm,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),o.jsx("div",{className:"likee-scenario-grid",children:Pne.map(e=>o.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[o.jsx("div",{className:"likee-scenario-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.question})]}),o.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>o.jsx("span",{children:t},t))}),o.jsxs("div",{className:"likee-scenario-result",children:[o.jsx("span",{children:"产出"}),o.jsx("strong",{children:e.result})]})]},e.title))})]})}),o.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[o.jsx(gm,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),o.jsx("div",{className:"likee-usecase-stack",children:Ane.map(e=>o.jsxs("article",{className:"likee-usecase-card",children:[o.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>o.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),o.jsxs("div",{className:"likee-usecase-body",children:[o.jsx("div",{className:"likee-usecase-label",children:e.label}),o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.trigger}),o.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>o.jsx("li",{children:t},t))}),o.jsxs("div",{className:"likee-usecase-output",children:[o.jsx("span",{children:"实际产物"}),o.jsx("div",{children:e.outputs.map(t=>o.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),o.jsx(Lne,{}),o.jsx("section",{className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[o.jsx(gm,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),o.jsx("div",{className:"likee-capability-table",children:Tne.map(([e,t,n])=>o.jsxs("div",{className:"likee-capability-row",children:[o.jsx("span",{children:e}),o.jsx("strong",{children:t}),o.jsx("p",{children:n})]},e))})]})})]})}function TR(e){return t=>typeof t===e}var One=TR("function"),Mne=e=>e===null,rC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",sC=e=>!$ne(e)&&!Mne(e)&&(One(e)||typeof e=="object"),$ne=TR("undefined");function Dne(e,t,n){return Une(n,e,t)?!0:(Kne(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Fne(e,t,n):e instanceof Map&&t instanceof Map?Bne(e,t,n):e instanceof Set&&t instanceof Set?Vne(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?zne(e,t):rC(e)&&rC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Hne(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Wne(e,t,n))}function bp(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!sC(e)||!t||!sC(t)?!1:Dne(e,t,n)}function Fne(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!bp(e[s],t[s],n))return!1;return!0}function zne(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 Hne(e,t,n){return e.message===t.message&&e.name===t.name&&bp(e.cause,t.cause,n)}function Bne(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(!bp(r[1],t.get(r[0]),n))return!1;return!0}function Wne(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=r.length;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[s]))return!1;for(let s=r.length;s--!==0;){const i=r[s];if(!(i==="_owner"&&e.$$typeof)&&!bp(e[i],t[i],n))return!1}return!0}function Vne(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 Une(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Kne(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function $0(e,t){return bp(e,t,new WeakMap)}function Ux(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function qne(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Yne(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Gne(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Xne(e,t){const n=Gne();h.useEffect(()=>{if(!n)return e()},t)}function RR(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function Jne(e,t){const n=h.useRef(t);return $0(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function Qne(e){h.useEffect(()=>{e()},[])}function Zne(e=0){const[t,n]=h.useState({height:Ux()?window.innerHeight:0,width:Ux()?window.innerWidth:0}),r=h.useRef(0),s=h.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return h.useEffect(()=>{if(!Ux())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Yne(window,"resize",i),()=>{qne(window,"resize",i)}},[]),t}var ere=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],tre=["bigint","boolean","null","number","string","symbol","undefined"];function vp(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(nre(t))return t}function no(e){return t=>vp(t)===e}function nre(e){return ere.includes(e)}function Ku(e){return t=>typeof t===e}function rre(e){return tre.includes(e)}var sre=["innerHTML","ownerDocument","style","attributes","nodeValue"],kp=e=>Array.isArray(e),ire=e=>vp(e)==="AsyncGeneratorFunction",ore=no("AsyncFunction"),are=Ku("bigint"),lre=e=>e===!0||e===!1,cre=no("Date"),ure=no("Error"),cl=Ku("function"),dre=no("GeneratorFunction"),fre=e=>typeof e=="number"&&Number.isInteger(e),Bb=no("Map"),LR=e=>Number.isNaN(e),D0=e=>e===null,OR=no("Function"),pre=no("Promise"),hre=no("RegExp"),Wb=no("Set"),Sp=Ku("string"),mre=Ku("symbol"),F0=Ku("undefined"),gre=no("WeakMap"),yre=no("WeakSet"),z0=e=>D0(e)||F0(e),MR=e=>!F0(e),xre=e=>Ku("number")(e)&&!LR(e),wre=e=>Sp(e)&&e.trim().length>0,bre=e=>{if(!Sp(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},cy=e=>!z0(e)&&(cl(e)||typeof e=="object"),$R=e=>{if(vp(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},vre=e=>D0(e)||rre(typeof e),kre=e=>vp(e)==="URL",DR=e=>!z0(e)&&cl(e[Symbol.iterator]),Sre=e=>DR(e)&&cl(e.next)&&cl(e.throw),Nre=e=>cl(e)&&/^class\s/.test(e.toString()),jre=(e,t)=>!kp(e)||!cl(t)?!1:e.every(n=>t(n)),Cre=e=>cy(e)&&!$R(e)&&e.nodeType===1&&Sp(e.nodeName)&&sre.every(t=>t in e),Ere=e=>Sp(e)&&e.length===0||kp(e)&&e.length===0||cy(e)&&!Bb(e)&&!Wb(e)&&Object.keys(e).length===0||Wb(e)&&e.size===0||Bb(e)&&e.size===0,_re=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Pre=(e,t)=>kp(e)?e.indexOf(t)>-1:!1,Are=(e,t,n)=>{if(!cy(e)||!t)return!1;const r=e[t];return cl(n)?n(r):MR(r)};function Pt(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(kp(e))return"Array";if(OR(e))return"Function";const t=vp(e);return t||"Object"}Pt.array=kp;Pt.arrayOf=jre;Pt.asyncGeneratorFunction=ire;Pt.asyncFunction=ore;Pt.bigint=are;Pt.boolean=lre;Pt.class=Nre;Pt.date=cre;Pt.defined=MR;Pt.domElement=Cre;Pt.empty=Ere;Pt.error=ure;Pt.function=cl;Pt.generator=Sre;Pt.generatorFunction=dre;Pt.instanceOf=_re;Pt.integer=fre;Pt.iterable=DR;Pt.map=Bb;Pt.nan=LR;Pt.null=D0;Pt.nullOrUndefined=z0;Pt.nonEmptyString=wre;Pt.number=xre;Pt.numericString=bre;Pt.object=cy;Pt.oneOf=Pre;Pt.plainFunction=OR;Pt.plainObject=$R;Pt.primitive=vre;Pt.promise=pre;Pt.propertyOf=Are;Pt.regexp=hre;Pt.set=Wb;Pt.string=Sp;Pt.symbol=mre;Pt.undefined=F0;Pt.url=kre;Pt.weakMap=gre;Pt.weakSet=yre;var ts=Pt;/* v8 ignore next -- @preserve */var Ire=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Tre=function(e,t){return e+ep(t)},ep=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(Tre,""):Ire(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?ep(e.props.children):""};ep.default=ep;var Rre=ep;const Kx=dl(Rre);var FR={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(i){return typeof i=="object"&&i!==null&&!(i instanceof RegExp)&&!(i instanceof Date)}}function r(s){function i(_){return _!=="constructor"&&_!=="prototype"&&_!=="__proto__"}function a(_){let E=0;const O=_.length,H=new Array(O);for(E;E<O;++E)H[E]=y(_[E]);return H}function l(_){const E={};if(p&&Object.getPrototypeOf(_)!==t)return p(_);const O=u(_);let H,L,F;for(H=0,L=O.length;H<L;++H)i(F=O[H])&&(E[F]=y(_[F]));return E}function c(_,E){const O=_.length,H=E.length;let L=0;const F=new Array(O+H);for(L;L<O;++L)F[L]=y(_[L]);for(L=0;L<H;++L)F[L+O]=y(E[L]);return F}const d=Object.prototype.propertyIsEnumerable;function f(_){const E=Object.keys(_),O=Object.getOwnPropertySymbols(_);for(let H=0,L=O.length;H<L;++H)d.call(_,O[H])&&E.push(O[H]);return E}const u=s!=null&&s.symbols?f:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,m=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 v=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:w,getKeys:u,isMergeableObject:m}):c;function y(_){return m(_)?Array.isArray(_)?a(_):l(_):_}function k(_,E){const O={},H=u(_),L=u(E);let F,D,R;for(F=0,D=H.length;F<D;++F)i(R=H[F])&&L.indexOf(R)===-1&&(O[R]=y(_[R]));for(F=0,D=L.length;F<D;++F)if(i(R=L[F]))if(R in _)H.indexOf(R)!==-1&&(p&&m(E[R])&&Object.getPrototypeOf(E[R])!==t?O[R]=p(E[R]):O[R]=w(_[R],E[R]));else{if(g&&typeof E[R]>"u")continue;O[R]=y(E[R])}return O}function w(_,E){if(g&&typeof E>"u")return y(_);const O=Array.isArray(E),H=Array.isArray(_);return b(E)?E:m(_)?O&&H?v(_,E):O!==H?y(E):k(_,E):y(E)}function j(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return w(arguments[0],arguments[1])}let _;for(let E=0,O=arguments.length;E<O;++E)_=w(_,arguments[E]);return _}return s!=null&&s.all?j:w}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(FR);var Lre=FR.exports;const Ore=dl(Lre);var Mre=new Error("Element already at target scroll position"),$re=new Error("Scroll cancelled"),Dre=Math.min,iC=Date.now,Fre={left:oC("scrollLeft"),top:oC("scrollTop")};function oC(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=Hre);var a=iC(),l=n[e],c=s.ease||zre,d=isNaN(s.duration)?350:+s.duration,f=!1;return l===r?i(Mre,n[e]):requestAnimationFrame(p),u;function u(){f=!0}function p(m){if(f)return i($re,n[e]);var g=iC(),b=Dre(1,(g-a)/d),v=c(b);n[e]=v*(r-l)+l,b<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function zre(e){return .5*(1-Math.cos(Math.PI*e))}function Hre(){}const Bre=dl(Fre);var zR={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(hf,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})})(zR);var Wre=zR.exports;const HR=dl(Wre),Vre=["top","right","bottom","left"],aC=["start","end"],lC=Vre.reduce((e,t)=>e.concat(t,t+"-"+aC[0],t+"-"+aC[1]),[]),Du=Math.min,tc=Math.max,vg=Math.round,Vh=Math.floor,Po=e=>({x:e,y:e}),Ure={left:"right",right:"left",bottom:"top",top:"bottom"};function Vb(e,t,n){return tc(e,Du(t,n))}function qu(e,t){return typeof e=="function"?e(t):e}function pa(e){return e.split("-")[0]}function Ao(e){return e.split("-")[1]}function BR(e){return e==="x"?"y":"x"}function H0(e){return e==="y"?"height":"width"}function Ua(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function B0(e){return BR(Ua(e))}function WR(e,t,n){n===void 0&&(n=!1);const r=Ao(e),s=B0(e),i=H0(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Sg(a)),[a,Sg(a)]}function Kre(e){const t=Sg(e);return[kg(e),t,kg(t)]}function kg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const cC=["left","right"],uC=["right","left"],qre=["top","bottom"],Yre=["bottom","top"];function Gre(e,t,n){switch(e){case"top":case"bottom":return n?t?uC:cC:t?cC:uC;case"left":case"right":return t?qre:Yre;default:return[]}}function Xre(e,t,n,r){const s=Ao(e);let i=Gre(pa(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(kg)))),i}function Sg(e){const t=pa(e);return Ure[t]+e.slice(t.length)}function Jre(e){return{top:0,right:0,bottom:0,left:0,...e}}function VR(e){return typeof e!="number"?Jre(e):{top:e,right:e,bottom:e,left:e}}function Ng(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 dC(e,t,n){let{reference:r,floating:s}=e;const i=Ua(t),a=B0(t),l=H0(a),c=pa(t),d=i==="y",f=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-s.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-s.width,y:u};break;default:m={x:r.x,y:r.y}}switch(Ao(t)){case"start":m[a]-=p*(n&&d?-1:1);break;case"end":m[a]+=p*(n&&d?-1:1);break}return m}async function Qre(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:p=!1,padding:m=0}=qu(t,e),g=VR(m),v=l[p?u==="floating"?"reference":"floating":u],y=Ng(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),k=u==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},_=Ng(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:w,strategy:c}):k);return{top:(y.top-_.top+g.top)/j.y,bottom:(_.bottom-y.bottom+g.bottom)/j.y,left:(y.left-_.left+g.left)/j.x,right:(_.right-y.right+g.right)/j.x}}const Zre=50,ese=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Qre},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:u}=dC(d,r,c),p=r,m=0;const g={};for(let b=0;b<i.length;b++){const v=i[b];if(!v)continue;const{name:y,fn:k}=v,{x:w,y:j,data:_,reset:E}=await k({x:f,y:u,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});f=w??f,u=j??u,g[y]={...g[y],..._},E&&m<Zre&&(m++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(d=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):E.rects),{x:f,y:u}=dC(d,p,c)),b=-1)}return{x:f,y:u,placement:p,strategy:s,middlewareData:g}},tse=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=qu(e,t)||{};if(d==null)return{};const u=VR(f),p={x:n,y:r},m=B0(s),g=H0(m),b=await a.getDimensions(d),v=m==="y",y=v?"top":"left",k=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=i.reference[g]+i.reference[m]-p[m]-i.floating[g],_=p[m]-i.reference[m],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let O=E?E[w]:0;(!O||!await(a.isElement==null?void 0:a.isElement(E)))&&(O=l.floating[w]||i.floating[g]);const H=j/2-_/2,L=O/2-b[g]/2-1,F=Du(u[y],L),D=Du(u[k],L),R=F,W=O-b[g]-D,M=O/2-b[g]/2+H,$=Vb(R,M,W),T=!c.arrow&&Ao(s)!=null&&M!==$&&i.reference[g]/2-(M<R?F:D)-b[g]/2<0,z=T?M<R?M-R:M-W:0;return{[m]:p[m]+z,data:{[m]:$,centerOffset:M-$-z,...T&&{alignmentOffset:z}},reset:T}}});function nse(e,t,n){return(e?[...n.filter(s=>Ao(s)===e),...n.filter(s=>Ao(s)!==e)]:n.filter(s=>pa(s)===s)).filter(s=>e?Ao(s)===e||(t?kg(s)!==s:!1):!0)}const rse=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:i,middlewareData:a,placement:l,platform:c,elements:d}=t,{crossAxis:f=!1,alignment:u,allowedPlacements:p=lC,autoAlignment:m=!0,...g}=qu(e,t),b=u!==void 0||p===lC?nse(u||null,m,p):p,v=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,k=b[y];if(k==null)return{};const w=WR(k,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==k)return{reset:{placement:b[0]}};const j=[v[pa(k)],v[w[0]],v[w[1]]],_=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:j}],E=b[y+1];if(E)return{data:{index:y+1,overflows:_},reset:{placement:E}};const O=_.map(F=>{const D=Ao(F.placement);return[F.placement,D&&f?F.overflows.slice(0,2).reduce((R,W)=>R+W,0):F.overflows[0],F.overflows]}).sort((F,D)=>F[1]-D[1]),L=((s=O.filter(F=>F[2].slice(0,Ao(F[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||O[0][0];return L!==l?{data:{index:y+1,overflows:_},reset:{placement:L}}:{}}}},sse=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=qu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=pa(s),k=Ua(l),w=pa(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),_=p||(w||!b?[Sg(l)]:Kre(l)),E=g!=="none";!p&&E&&_.push(...Xre(l,b,g,j));const O=[l,..._],H=await c.detectOverflow(t,v),L=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&L.push(H[y]),u){const M=WR(s,a,j);L.push(H[M[0]],H[M[1]])}if(F=[...F,{placement:s,overflows:L}],!L.every(M=>M<=0)){var D,R;const M=(((D=i.flip)==null?void 0:D.index)||0)+1,$=O[M];if($&&(!(u==="alignment"?k!==Ua($):!1)||F.every(A=>Ua(A.placement)===k?A.overflows[0]>0:!0)))return{data:{index:M,overflows:F},reset:{placement:$}};let T=(R=F.filter(z=>z.overflows[0]<=0).sort((z,A)=>z.overflows[1]-A.overflows[1])[0])==null?void 0:R.placement;if(!T)switch(m){case"bestFit":{var W;const z=(W=F.filter(A=>{if(E){const P=Ua(A.placement);return P===k||P==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(P=>P>0).reduce((P,C)=>P+C,0)]).sort((A,P)=>A[1]-P[1])[0])==null?void 0:W[0];z&&(T=z);break}case"initialPlacement":T=l;break}if(s!==T)return{reset:{placement:T}}}return{}}}},ise=new Set(["left","top"]);async function ose(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=pa(n),l=Ao(n),c=Ua(n)==="y",d=ise.has(a)?-1:1,f=i&&c?-1:1,u=qu(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*f,y:p*d}:{x:p*d,y:m*f}}const ase=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=t,c=await ose(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},lse=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:k,y:w}=y;return{x:k,y:w}}},...d}=qu(e,t),f={x:n,y:r},u=await i.detectOverflow(t,d),p=Ua(pa(s)),m=BR(p);let g=f[m],b=f[p];if(a){const y=m==="y"?"top":"left",k=m==="y"?"bottom":"right",w=g+u[y],j=g-u[k];g=Vb(w,g,j)}if(l){const y=p==="y"?"top":"left",k=p==="y"?"bottom":"right",w=b+u[y],j=b-u[k];b=Vb(w,b,j)}const v=c.fn({...t,[m]:g,[p]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[m]:a,[p]:l}}}}}};function uy(){return typeof window<"u"}function Yu(e){return UR(e)?(e.nodeName||"").toLowerCase():"#document"}function ti(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Oo(e){var t;return(t=(UR(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function UR(e){return uy()?e instanceof Node||e instanceof ti(e).Node:!1}function Zi(e){return uy()?e instanceof Element||e instanceof ti(e).Element:!1}function ga(e){return uy()?e instanceof HTMLElement||e instanceof ti(e).HTMLElement:!1}function fC(e){return!uy()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ti(e).ShadowRoot}function Np(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=eo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function cse(e){return/^(table|td|th)$/.test(Yu(e))}function dy(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const use=/transform|translate|scale|rotate|perspective|filter/,dse=/paint|layout|strict|content/,Dl=e=>!!e&&e!=="none";let qx;function W0(e){const t=Zi(e)?eo(e):e;return Dl(t.transform)||Dl(t.translate)||Dl(t.scale)||Dl(t.rotate)||Dl(t.perspective)||!V0()&&(Dl(t.backdropFilter)||Dl(t.filter))||use.test(t.willChange||"")||dse.test(t.contain||"")}function fse(e){let t=ul(e);for(;ga(t)&&!Fu(t);){if(W0(t))return t;if(dy(t))return null;t=ul(t)}return null}function V0(){return qx==null&&(qx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qx}function Fu(e){return/^(html|body|#document)$/.test(Yu(e))}function eo(e){return ti(e).getComputedStyle(e)}function fy(e){return Zi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ul(e){if(Yu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fC(e)&&e.host||Oo(e);return fC(t)?t.host:t}function KR(e){const t=ul(e);return Fu(t)?e.ownerDocument?e.ownerDocument.body:e.body:ga(t)&&Np(t)?t:KR(t)}function tp(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=KR(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=ti(s);if(i){const l=Ub(a);return t.concat(a,a.visualViewport||[],Np(s)?s:[],l&&n?tp(l):[])}else return t.concat(s,tp(s,[],n))}function Ub(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qR(e){const t=eo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ga(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=vg(n)!==i||vg(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function U0(e){return Zi(e)?e:e.contextElement}function xu(e){const t=U0(e);if(!ga(t))return Po(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=qR(t);let a=(i?vg(n.width):n.width)/r,l=(i?vg(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const pse=Po(0);function YR(e){const t=ti(e);return!V0()||!t.visualViewport?pse:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hse(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ti(e)?!1:t}function fc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=U0(e);let a=Po(1);t&&(r?Zi(r)&&(a=xu(r)):a=xu(e));const l=hse(i,n,r)?YR(i):Po(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,f=s.width/a.x,u=s.height/a.y;if(i){const p=ti(i),m=r&&Zi(r)?ti(r):r;let g=p,b=Ub(g);for(;b&&r&&m!==g;){const v=xu(b),y=b.getBoundingClientRect(),k=eo(b),w=y.left+(b.clientLeft+parseFloat(k.paddingLeft))*v.x,j=y.top+(b.clientTop+parseFloat(k.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,u*=v.y,c+=w,d+=j,g=ti(b),b=Ub(g)}}return Ng({width:f,height:u,x:c,y:d})}function py(e,t){const n=fy(e).scrollLeft;return t?t.left+n:fc(Oo(e)).left+n}function GR(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-py(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function mse(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=Oo(r),l=t?dy(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=Po(1);const f=Po(0),u=ga(r);if((u||!u&&!i)&&((Yu(r)!=="body"||Np(a))&&(c=fy(r)),u)){const m=fc(r);d=xu(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const p=a&&!u&&!i?GR(a,c):Po(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+p.x,y:n.y*d.y-c.scrollTop*d.y+f.y+p.y}}function gse(e){return Array.from(e.getClientRects())}function yse(e){const t=Oo(e),n=fy(e),r=e.ownerDocument.body,s=tc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=tc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+py(e);const l=-n.scrollTop;return eo(r).direction==="rtl"&&(a+=tc(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const pC=25;function xse(e,t){const n=ti(e),r=Oo(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const f=V0();(!f||f&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=py(r);if(d<=0){const f=r.ownerDocument,u=f.body,p=getComputedStyle(u),m=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-m);g<=pC&&(i-=g)}else d<=pC&&(i+=d);return{width:i,height:a,x:l,y:c}}function wse(e,t){const n=fc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=ga(e)?xu(e):Po(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,d=r*i.y;return{width:a,height:l,x:c,y:d}}function hC(e,t,n){let r;if(t==="viewport")r=xse(e,n);else if(t==="document")r=yse(Oo(e));else if(Zi(t))r=wse(t,n);else{const s=YR(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Ng(r)}function XR(e,t){const n=ul(e);return n===t||!Zi(n)||Fu(n)?!1:eo(n).position==="fixed"||XR(n,t)}function bse(e,t){const n=t.get(e);if(n)return n;let r=tp(e,[],!1).filter(l=>Zi(l)&&Yu(l)!=="body"),s=null;const i=eo(e).position==="fixed";let a=i?ul(e):e;for(;Zi(a)&&!Fu(a);){const l=eo(a),c=W0(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Np(a)&&!c&&XR(e,a))?r=r.filter(f=>f!==a):s=l,a=ul(a)}return t.set(e,r),r}function vse(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?dy(t)?[]:bse(t,this._c):[].concat(n),r],l=hC(t,a[0],s);let c=l.top,d=l.right,f=l.bottom,u=l.left;for(let p=1;p<a.length;p++){const m=hC(t,a[p],s);c=tc(m.top,c),d=Du(m.right,d),f=Du(m.bottom,f),u=tc(m.left,u)}return{width:d-u,height:f-c,x:u,y:c}}function kse(e){const{width:t,height:n}=qR(e);return{width:t,height:n}}function Sse(e,t,n){const r=ga(t),s=Oo(t),i=n==="fixed",a=fc(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Po(0);function d(){c.x=py(s)}if(r||!r&&!i)if((Yu(t)!=="body"||Np(s))&&(l=fy(t)),r){const m=fc(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&d();i&&!r&&s&&d();const f=s&&!r&&!i?GR(s,l):Po(0),u=a.left+l.scrollLeft-c.x-f.x,p=a.top+l.scrollTop-c.y-f.y;return{x:u,y:p,width:a.width,height:a.height}}function Yx(e){return eo(e).position==="static"}function mC(e,t){if(!ga(e)||eo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Oo(e)===n&&(n=n.ownerDocument.body),n}function JR(e,t){const n=ti(e);if(dy(e))return n;if(!ga(e)){let s=ul(e);for(;s&&!Fu(s);){if(Zi(s)&&!Yx(s))return s;s=ul(s)}return n}let r=mC(e,t);for(;r&&cse(r)&&Yx(r);)r=mC(r,t);return r&&Fu(r)&&Yx(r)&&!W0(r)?n:r||fse(e)||n}const Nse=async function(e){const t=this.getOffsetParent||JR,n=this.getDimensions,r=await n(e.floating);return{reference:Sse(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function jse(e){return eo(e).direction==="rtl"}const Cse={convertOffsetParentRelativeRectToViewportRelativeRect:mse,getDocumentElement:Oo,getClippingRect:vse,getOffsetParent:JR,getElementRects:Nse,getClientRects:gse,getDimensions:kse,getScale:xu,isElement:Zi,isRTL:jse};function QR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ese(e,t){let n=null,r;const s=Oo(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const d=e.getBoundingClientRect(),{left:f,top:u,width:p,height:m}=d;if(l||t(),!p||!m)return;const g=Vh(u),b=Vh(s.clientWidth-(f+p)),v=Vh(s.clientHeight-(u+m)),y=Vh(f),w={rootMargin:-g+"px "+-b+"px "+-v+"px "+-y+"px",threshold:tc(0,Du(1,c))||1};let j=!0;function _(E){const O=E[0].intersectionRatio;if(O!==c){if(!j)return a();O?a(!1,O):r=setTimeout(()=>{a(!1,1e-7)},1e3)}O===1&&!QR(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(_,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return a(!0),i}function gC(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=U0(e),f=s||i?[...d?tp(d):[],...t?tp(t):[]]:[];f.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const u=d&&l?Ese(d,n):null;let p=-1,m=null;a&&(m=new ResizeObserver(y=>{let[k]=y;k&&k.target===d&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=m)==null||w.observe(t)})),n()}),d&&!c&&m.observe(d),t&&m.observe(t));let g,b=c?fc(e):null;c&&v();function v(){const y=fc(e);b&&!QR(b,y)&&n(),b=y,g=requestAnimationFrame(v)}return n(),()=>{var y;f.forEach(k=>{s&&k.removeEventListener("scroll",n),i&&k.removeEventListener("resize",n)}),u==null||u(),(y=m)==null||y.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const _se=ase,Pse=rse,Ase=lse,Ise=sse,yC=tse,Tse=(e,t,n)=>{const r=new Map,s={platform:Cse,...n},i={...s.platform,_c:r};return ese(e,t,{...s,platform:i})};var Rse=typeof document<"u",Lse=function(){},ym=Rse?h.useLayoutEffect:Lse;function jg(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(!jg(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!jg(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function ZR(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xC(e,t){const n=ZR(e);return Math.round(t*n)/n}function Gx(e){const t=h.useRef(e);return ym(()=>{t.current=e}),t}function wC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,u]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);jg(p,r)||m(r);const[g,b]=h.useState(null),[v,y]=h.useState(null),k=h.useCallback(A=>{A!==E.current&&(E.current=A,b(A))},[]),w=h.useCallback(A=>{A!==O.current&&(O.current=A,y(A))},[]),j=i||g,_=a||v,E=h.useRef(null),O=h.useRef(null),H=h.useRef(f),L=c!=null,F=Gx(c),D=Gx(s),R=Gx(d),W=h.useCallback(()=>{if(!E.current||!O.current)return;const A={placement:t,strategy:n,middleware:p};D.current&&(A.platform=D.current),Tse(E.current,O.current,A).then(P=>{const C={...P,isPositioned:R.current!==!1};M.current&&!jg(H.current,C)&&(H.current=C,Dr.flushSync(()=>{u(C)}))})},[p,t,n,D,R]);ym(()=>{d===!1&&H.current.isPositioned&&(H.current.isPositioned=!1,u(A=>({...A,isPositioned:!1})))},[d]);const M=h.useRef(!1);ym(()=>(M.current=!0,()=>{M.current=!1}),[]),ym(()=>{if(j&&(E.current=j),_&&(O.current=_),j&&_){if(F.current)return F.current(j,_,W);W()}},[j,_,W,F,L]);const $=h.useMemo(()=>({reference:E,floating:O,setReference:k,setFloating:w}),[k,w]),T=h.useMemo(()=>({reference:j,floating:_}),[j,_]),z=h.useMemo(()=>{const A={position:n,left:0,top:0};if(!T.floating)return A;const P=xC(T.floating,f.x),C=xC(T.floating,f.y);return l?{...A,transform:"translate("+P+"px, "+C+"px)",...ZR(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:C}},[n,l,T.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:W,refs:$,elements:T,floatingStyles:z}),[f,W,$,T,z])}const Ose=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?yC({element:r.current,padding:s}).fn(n):{}:r?yC({element:r,padding:s}).fn(n):{}}}},bC=(e,t)=>{const n=_se(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mse=(e,t)=>{const n=Ase(e);return{name:n.name,fn:n.fn,options:[e,t]}},$se=(e,t)=>{const n=Ise(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dse=(e,t)=>{const n=Pse(e);return{name:n.name,fn:n.fn,options:[e,t]}},Fse=(e,t)=>{const n=Ose(e);return{name:n.name,fn:n.fn,options:[e,t]}},zse={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},Hse={beaconOptions:{offset:-18}},e2={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Bse={isFixed:!1,locale:e2,placement:"bottom"},Wse={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Ft={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},Ar={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"},Ue={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},bo={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Rt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Vse="react-joyride-portal";function Use(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function iu(...e){return Ore({all:!0,isMergeableObject:t=>!(!ts.plainObject(t)||h.isValidElement(t))})(...e)}function t2(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function ea(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=Kx(e);if(i)(i.includes("{current}")||i.includes("{total}"))&&r&&s&&(i=i.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&t2(e.type)==="function")try{i=ea(e.type({}),t)}catch{i=Kx(n)}else i=Kx(n);return i}function Tr(e,t,n,...r){if(!e)return;const s=new Date,i=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}.${String(s.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${i}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Kse(e,t){const n=Use(t);return{...e,...n}}function np(){}function qse(e){return Object.keys(e)}function Cg(e,...t){if(!ts.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(!ts.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 Kb(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(t2(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(ts.string(s)&&s.includes("{current}"))return h.cloneElement(e,{children:r(s)});if(Array.isArray(s))return h.cloneElement(e,{children:s.map(i=>typeof i=="string"?r(i):Kb(i,t,n))});if(ts.function(e.type)&&!Object.values(e.props).length)try{return Kb(e.type({}),t,n)}catch{return e}return e}function kC(e){return qse(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function K0(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function SC(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 q0(e){return e?e.getBoundingClientRect():null}function Yse(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((i,a)=>i-a),s=Math.floor(r.length/2);return r.length%2===0?(r[s-1]+r[s])/2:r[s]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function Si(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 Gse(e,t,n){const r=q0(e),s=Gu(e),i=s?!s.isSameNode(Ts()):!1,a=n??Xu(e);let l=0,c=(r==null?void 0:r.top)??0;return i&&a?c=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!i&&!a&&(c+=l),s.isSameNode(Ts())||(c+=Ts().scrollTop)),Math.floor(c-t)}function Gu(e,t){if(!e)return Ts();const n=HR(e);if(n){if(n.isSameNode(Ts()))return t?document:Ts();if(!(n.scrollHeight>n.offsetHeight))return Ts()}return n}function Xse(e){const t=e.getBoundingClientRect(),n=Ts(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Jse(e,t){if(!e)return 0;const n=HR(e)??Ts(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=q0(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(n2(e)||Qse(e))){const f=e.getBoundingClientRect(),u=f.top-((s==null?void 0:s.top)??0),p=u+f.height,m=n.clientHeight,g=m*.2;u>=g&&p<=m-g?c=i:c=u+i}const d=Math.floor(c-t-r);return d<0?0:d}function Qse(e){return e.offsetParent!==document.body}function n2(e){if(!e)return!1;const t=Gu(e);return t?!t.isSameNode(Ts()):!1}function Xu(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?Xu(e.parentNode,t):!1}function Uh(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 NC(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Ue.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Gu(s):Ts(),l=a?!a.isSameNode(Ts()):!1;return(r.isFixed||Xu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Ts(){return document.scrollingElement??document.documentElement}function jC(e,t){const{duration:n,element:r}=t;let s=()=>{};const i=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=Bre.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Zse(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,i,a)=>s+s+i+i+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const r2={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Kh={...r2,borderRadius:4,padding:8};function eie(e,t){const{styles:n}=e,r=iu(n??{},t.styles??{});let{width:s}=t;K0()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const i={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return iu({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...r2,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(${Zse(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:{...Kh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Kh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Kh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Kh,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...i,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:s},tooltipContainer:{lineHeight:1.4,textAlign:"center"},tooltipTitle:{fontSize:18,margin:0},tooltipContent:{paddingBottom:12,paddingTop:12},tooltipFooter:{alignItems:"center",display:"flex",justifyContent:"flex-end"},tooltipFooterSpacer:{flex:1}},r)}const tie=["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 Y0(e,t){if(!t)return null;const n=iu(Bse,vC(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=iu(zse,e.options??{},vC(t,...tie)),s=eie(e,{...n,...r}),i=iu(Hse,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:iu(e2,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:nie(r.spotlightPadding),styles:s}}function nie(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 rie(e,t,n){const{action:r}=t,s=n&&[Ft.PREV,Ft.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function s2(e,t=!1){return ts.plainObject(e)?e.target?!0:(Tr(t,"tour","target is missing from the step"),!1):(Tr(t,"tour","step must be an object"),!1)}function i2(e,t=!1){return ts.array(e)?e.every(n=>s2(n,t)):(Tr(t,"tour","steps must be an array"),!1)}var sie=class{constructor(e){sr(this,"beaconPosition",null);sr(this,"debug");sr(this,"eventListeners",new Map);sr(this,"listeners",new Set);sr(this,"props");sr(this,"snapshot");sr(this,"state");sr(this,"steps");sr(this,"tooltipPosition",null);sr(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});sr(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);sr(this,"getServerSnapshot",()=>this.snapshot);sr(this,"getSnapshot",()=>this.snapshot);sr(this,"getEventState",()=>Cg(this.snapshot,"positioned"));sr(this,"getState",()=>Cg(this.snapshot,"positioned"));sr(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Tr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Ue.BEACON_BEFORE||this.state.lifecycle===Ue.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(i=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:i.onPosition;n&&n(t)});sr(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});sr(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});sr(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)}});sr(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));sr(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,i=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:i,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!$0(s,l)){this.snapshot=Object.freeze({...l});for(const c of this.listeners)c(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},s=ts.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,ts.number(t)&&Tr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):ts.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&Tr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Ft.INIT,controlled:s,index:i,lifecycle:Ue.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Rt.READY:Rt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Rt.WAITING&&e.size>0?{...e,status:Rt.RUNNING}:e}getStep(e){return Y0(this.props,this.steps[e??this.state.index])}};function iie(e){return new sie(e)}function CC(e,t){return Math.min(Math.max(e,0),t)}function oie(e,t,n){const r=h.useRef(t),s=h.useRef(n);return r.current=t,s.current=n,h.useMemo(()=>{const i=()=>e.current.getSnapshot();return{close:(v=null)=>{const{index:y,status:k}=i();k===Rt.RUNNING&&e.current.updateState({action:Ft.CLOSE,index:y+1,origin:v,lifecycle:Ue.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:v=>{const{controlled:y,size:k,status:w}=i();if(y){Tr(r.current,"tour","go() is not supported in controlled mode");return}w===Rt.RUNNING&&e.current.updateState({action:Ft.GO,index:v,lifecycle:Ue.COMPLETE,positioned:!1,scrolling:!1,status:v<k?w:Rt.FINISHED,waiting:!1})},info:()=>Cg(e.current.getSnapshot(),"positioned"),next:v=>{const{index:y,size:k,status:w}=i();w===Rt.RUNNING&&e.current.updateState({action:Ft.NEXT,index:CC(y+1,k),lifecycle:Ue.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:v}=i();v===Rt.RUNNING&&e.current.updateState({action:Ft.UPDATE,lifecycle:Ue.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:v=>{const{index:y,size:k,status:w}=i();w===Rt.RUNNING&&e.current.updateState({action:Ft.PREV,index:CC(y-1,k),lifecycle:Ue.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},reset:(v=!1)=>{const{controlled:y}=i();if(y){Tr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Ft.RESET,index:0,lifecycle:Ue.INIT,positioned:!1,scrolling:!1,status:v?Rt.RUNNING:Rt.READY,waiting:!1})},skip:v=>{const{status:y}=i();y===Rt.RUNNING&&e.current.updateState({action:Ft.SKIP,lifecycle:Ue.COMPLETE,origin:v,positioned:!1,scrolling:!1,status:Rt.SKIPPED,waiting:!1})},start:v=>{const{index:y,size:k}=i();s.current(),e.current.updateState({action:Ft.START,index:ts.number(v)?v:y,lifecycle:Ue.INIT,positioned:!1,scrolling:!1,status:k?Rt.RUNNING:Rt.WAITING,waiting:!1},!0)},stop:(v=!1)=>{const{index:y,status:k}=i();[Rt.FINISHED,Rt.SKIPPED].includes(k)||e.current.updateState({action:Ft.STOP,index:y+(v?1:0),lifecycle:Ue.COMPLETE,positioned:!1,scrolling:!1,status:Rt.PAUSED,waiting:!1})}}},[e])}const aie=new Set(["origin","positioned"]);function lie(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Tr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const i=n.current;if(n.current=s,!i)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==i[c]&&!aie.has(c)&&(a[c]={from:i[c],to:s[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||Tr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function cie(e,t,n){const r=h.useRef(e),s=h.useRef(t);return r.current=e,s.current=t,h.useCallback((i,a,l)=>{var d;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(d=r.current)==null||d.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Da(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],i=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(i):s===r&&i!==r},previous:t}}function uie(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:d,index:f,lifecycle:u,positioned:p,scrolling:m,size:g,status:b}=a,v=RR(l)??null,y=h.useRef(null),k=h.useRef(i),w=h.useRef(a),j=h.useRef(s),_=h.useRef(l),E=h.useRef(v),O=h.useRef(n),H=h.useRef(null),L=h.useRef(null),F=h.useRef(null);k.current=i,w.current=a,j.current=s,_.current=l,E.current=v,O.current=n;const D=()=>{H.current&&(clearInterval(H.current),H.current=null),L.current=null,F.current&&(F.current.cancel(),F.current=null)};h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:R}=Da(w.current,j.current);(R("action",[Ft.NEXT,Ft.PREV,Ft.SKIP,Ft.CLOSE])||y.current===Ft.CLOSE&&d===Ft.START)&&(y.current=d)},[d]),h.useEffect(()=>{if(!j.current)return()=>{D()};const{hasChanged:R}=Da(w.current,j.current),W=_.current;if(R("index")&&D(),b!==Rt.RUNNING||!W||u!==Ue.INIT)return()=>{D()};const{hasChangedTo:M}=Da(w.current,j.current);M("status",Rt.RUNNING)&&[Rt.IDLE,Rt.READY,Rt.PAUSED].includes(j.current.status)&&r(Ar.TOUR_START,W),c.current.cleanupPositionData();const{debug:$}=k.current;if(W.before&&!F.current){Tr($,`step:${f}`,"before()",W),F.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(Ar.STEP_BEFORE_HOOK,W,{action:y.current??w.current.action});const T=()=>{F.current=null,c.current.updateState({action:y.current??w.current.action,waiting:!1,lifecycle:Ue.READY})},z=new AbortController,A=W.beforeTimeout;F.current={cancel:()=>z.abort()};const P=A?setTimeout(()=>{z.signal.aborted||(Tr($,`step:${f}`,"before()","timed out",`${A}ms`),z.abort(),t(W,"before_hook"),r(Ar.ERROR,W,{error:new Error("Step before hook timed out")}),T())},A):null;W.before({...c.current.getState(),action:y.current??c.current.getState().action,step:W}).then(()=>{z.signal.aborted||(P&&clearTimeout(P),T())}).catch(C=>{z.signal.aborted||(P&&clearTimeout(P),t(W,"before_hook"),r(Ar.ERROR,W,{error:C instanceof Error?C:new Error(String(C))}),T())})}else if(!F.current){H.current&&L.current!==W.target&&D();const T=Si(W.target);if(T&&Uh(T))D(),c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:Ue.READY,waiting:!1});else if(W.targetWaitTimeout===0)c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:Ue.READY,waiting:!1});else if(!H.current){const{targetWaitTimeout:z}=W,A=Date.now();L.current=W.target,Tr($,`step:${f}`,"polling","started",`${z}ms`),c.current.updateState({waiting:!0}),H.current=setInterval(()=>{const P=Si(W.target),C=Date.now()-A,G=C>=z;(P&&Uh(P)||G)&&(Tr($,`step:${f}`,"polling",P&&Uh(P)?"found":"timed out",`${C}ms`),D(),c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:Ue.READY,waiting:!1}))},100)}}return()=>{D()}},[t,r,f,u,b,c]),h.useEffect(()=>{if(!j.current)return;const{hasChanged:R,hasChangedTo:W,previous:M}=Da(w.current,j.current),$=_.current;if(!$)return;const T=Si($.target),z=!!T;if(z&&Uh(T)){if(W("lifecycle",Ue.READY)&&M.lifecycle===Ue.INIT&&r(Ar.STEP_BEFORE,$,{action:y.current??w.current.action}),W("lifecycle",Ue.READY)){const A=w.current,P=rie($,A,k.current.continuous)?Ue.TOOLTIP:Ue.BEACON,C=Si($.scrollTarget??$.spotlightTarget??$.target),G=NC({isFirstStep:A.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:$,target:C,targetLifecycle:P}),Z=P===Ue.TOOLTIP?Ue.TOOLTIP_BEFORE:Ue.BEACON_BEFORE;Tr(k.current.debug,`step:${f}`,"scroll",G?"needed":"skipped"),c.current.updateState({action:Ft.UPDATE,lifecycle:Z,scrolling:G})}}else if(w.current.status===Rt.RUNNING&&u!==Ue.INIT&&u!==Ue.COMPLETE&&R("lifecycle")){Tr(k.current.debug,`step:${f}`,z?"Target not visible":"Target not mounted",$),t($,"target_not_found"),r(Ar.TARGET_NOT_FOUND,$);const A=w.current;A.controlled||c.current.updateState({action:Ft.UPDATE,index:A.index+(A.action===Ft.PREV?-1:1),lifecycle:Ue.INIT})}},[t,r,f,u,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:R,previous:W}=Da(w.current,j.current),M=_.current,$=E.current;if(M&&R("lifecycle",Ue.TOOLTIP_BEFORE)&&W.lifecycle===Ue.BEACON){const A=Si(M.scrollTarget??M.spotlightTarget??M.target);if(NC({isFirstStep:w.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:A,targetLifecycle:Ue.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const T=u===Ue.BEACON_BEFORE||u===Ue.TOOLTIP_BEFORE;if(M&&T&&!m){const A=u===Ue.TOOLTIP_BEFORE?Ue.TOOLTIP:Ue.BEACON;c.current.updateState({action:Ft.UPDATE,lifecycle:A})}M&&R("lifecycle",Ue.BEACON)&&r(Ar.BEACON,M),M&&R("lifecycle",Ue.TOOLTIP)&&r(Ar.TOOLTIP,M);const z=w.current;if((z.status===Rt.RUNNING||z.controlled&&z.status===Rt.PAUSED&&M)&&$&&R("lifecycle",Ue.COMPLETE)&&W.lifecycle===Ue.TOOLTIP&&(r(Ar.STEP_AFTER,$,{action:y.current??Ft.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle}),$.after)){r(Ar.STEP_AFTER_HOOK,$,{action:y.current??Ft.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle});try{$.after({...c.current.getState(),action:y.current??Ft.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle,step:$})}catch{}}},[r,u,p,m,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:R,previous:W}=Da(w.current,j.current),M=_.current,$=E.current;g&&!M&&u===Ue.INIT&&c.current.updateState({action:Ft.UPDATE,lifecycle:Ue.COMPLETE,status:Rt.FINISHED}),!w.current.controlled&&b===Rt.RUNNING&&R("lifecycle",Ue.COMPLETE)&&f<g&&c.current.updateState({action:Ft.UPDATE,lifecycle:Ue.INIT}),R("lifecycle",Ue.COMPLETE)&&f>=g&&c.current.updateState({action:Ft.UPDATE,lifecycle:Ue.COMPLETE,status:Rt.FINISHED});const T=M??$??Y0(k.current,k.current.steps[f-1]);if(T&&R("status",[Rt.FINISHED,Rt.SKIPPED])){let z;M?z=f:$?z=W.index??f:z=f-1,r(Ar.TOUR_END,T,{index:z}),w.current.controlled||O.current.reset(),y.current=null}M&&R("action",Ft.STOP)&&(y.current=null,r(Ar.TOUR_STATUS,M)),M&&R("action",Ft.RESET)&&(r(Ar.TOUR_STATUS,M),y.current=null)},[d,r,f,u,g,b,c])}function die({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:d}=n,f=h.useRef(void 0),u=h.useRef(r),p=h.useRef(e);u.current=r,p.current=e,h.useEffect(()=>{const m=f.current;if(f.current=n,!m||n===m)return;const{hasChanged:g}=Da(n,m);if($0(m.steps,d)||(i2(d,i)?s.current.setSteps(d):(Tr(i,"tour","Steps are not valid",d),t(Ar.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&p.current.start(c??a):p.current.stop();else if(ts.number(c)&&g("stepIndex")){const b=ts.number(m.stepIndex)&&m.stepIndex<c?Ft.NEXT:Ft.PREV;[Rt.FINISHED,Rt.SKIPPED].includes(u.current.status)||s.current.updateState({action:b,index:c,lifecycle:Ue.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,d,s])}function fie(e,t){var l,c,d,f;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:i}=t;if(i.scrollTarget||i.spotlightTarget)return Math.max(0,e);let a=e-i.spotlightPadding.top;if(r===Ue.BEACON_BEFORE&&(n!=null&&n.placement)){const u=pie(n);["bottom"].includes(n.placement)||(a+=Math.floor(u-s))}else if(r===Ue.TOOLTIP_BEFORE){const{placement:u}=i;if(u==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(c=i.floatingOptions)!=null&&c.hideArrow?0:i.arrowSize,g=i.offset+i.spotlightPadding.top+m;a-=p+g}else if(u==="left"||u==="right"){const p=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,m=((f=Si(i.target))==null?void 0:f.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+m/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function pie(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 hie({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:c,scrolling:d,status:f}=r,u=h.useRef(null),p=h.useRef(r),m=h.useRef(t),g=h.useRef(n),b=h.useRef(s);p.current=r,m.current=t,g.current=n,b.current=s,h.useEffect(()=>()=>{var v;(v=u.current)==null||v.call(u)},[]),h.useEffect(()=>{var _;if(!m.current||!b.current)return;const{hasChangedTo:v}=Da(p.current,m.current),y=b.current,{debug:k}=g.current,{scrollDuration:w}=y,j=l===Ue.BEACON_BEFORE||l===Ue.TOOLTIP_BEFORE;if(f===Rt.RUNNING&&j&&d&&v("positioned",!0)){const E=Si(y.scrollTarget??y.spotlightTarget??y.target),O=i.current.getPositionData("beacon"),H=Gu(E),L=H?!H.isSameNode(Ts()):!1;(_=u.current)==null||_.call(u),(async()=>{if(L&&!Xu(H)){const z=Ts(),A=Xse(H),P={initial:z.scrollTop,target:A,element:z,duration:w};e(Ar.SCROLL_START,y,{scroll:P});const{cancel:C,promise:G}=jC(A,{element:z,duration:w});u.current=C,await G,e(Ar.SCROLL_END,y,{scroll:P})}const D=Math.floor(Jse(E,y.scrollOffset))||0,R=L?D:fie(D,{beaconPosition:O,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Tr(k,`step:${a}`,"scroll",L?"custom":"document",`${D} → ${R}`);const W=H,M={initial:W.scrollTop,target:R,element:W,duration:w};e(Ar.SCROLL_START,y,{scroll:M});const{cancel:$,promise:T}=jC(R,{element:W,duration:w});u.current=$,await T,e(Ar.SCROLL_END,y,{scroll:M}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,d,f,i])}function mie(e){const t=Jne(()=>Kse(Wse,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=h.useRef(iie(t)),d=vA.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[f,u]=h.useState([]),p=h.useCallback((_,E)=>{u(O=>[...O,{reason:E,step:_}])},[]),m=h.useCallback(()=>{u([])},[]);lie(c,n);const g=oie(c,n,m),b=cie(s,g,c),{index:v,size:y,status:k}=d,w=RR(d),j=h.useMemo(()=>Y0(t,l[v]),[v,t,l]);return Qne(()=>{i&&y&&i2(l,n)&&g.start(a??r)}),Xne(()=>{i&&y&&k===Rt.IDLE&&c.current.updateState({status:Rt.READY})},[i,y,k]),die({controls:g,emitEvent:b,props:t,state:d,store:c}),uie({addFailure:p,controls:g,emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),hie({emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),{controls:g,failures:f,mergedProps:t,state:d,step:j,store:c}}function gie(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,s=!1;if(e)if(ts.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=Vse,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const yie={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function xie({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return np;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
225
- @keyframes joyride-loader-spin {
226
- to { transform: rotate(360deg); }
227
- }
228
- `)),document.head.appendChild(c),()=>{const d=document.getElementById("joyride-loader-animation");d!=null&&d.parentNode&&d.parentNode.removeChild(d)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const c=n;l=lt.createElement(c,{step:t})}else l=lt.createElement("div",{style:{...yie,height:s,width:i,borderTopColor:t.primaryColor}});return lt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const wie={height:0,isFixed:!1,left:0,top:0,width:0};function $d(e,t){const n=Si(e);if(!n)return wie;const r=q0(n),s=Xu(n),i=Gse(n,t.top,s);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:s,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:i,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function bie(e,t,n){const[r,s]=h.useState(()=>$d(e,t)),i=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),c=h.useRef(null),d=h.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(u=>{const p=$d(e,t);return u.top===p.top&&u.left===p.left&&u.width===p.width&&u.height===p.height&&u.isFixed===p.isFixed?u:p})},100)},[e,t]);h.useEffect(()=>{let u=null;const p=g=>{a.current=Gu(g,!0),a.current&&a.current.addEventListener("scroll",d,{passive:!0}),window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(d),c.current.observe(g)),s($d(e,t))},m=Si(e);return m?p(m):(u=new MutationObserver(()=>{const g=Si(e);g&&(u==null||u.disconnect(),u=null,p(g))}),u.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;u==null||u.disconnect(),a.current&&a.current.removeEventListener("scroll",d),window.removeEventListener("scroll",d),window.removeEventListener("resize",d),(g=c.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,d]),h.useEffect(()=>{l.current&&!n&&s($d(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=$d(e,t)),f}function vie(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function EC(e,t,n,r,s){if(n<=0||r<=0)return"";const i=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+i} ${t}`;return a+=`H${e+n-i}`,a+=`A${i} ${i} 0 0 1 ${e+n} ${t+i}`,a+=`V${t+r-i}`,a+=`A${i} ${i} 0 0 1 ${e+n-i} ${t+r}`,a+=`H${e+i}`,a+=`A${i} ${i} 0 0 1 ${e} ${t+r-i}`,a+=`V${t+i}`,a+=`A${i} ${i} 0 0 1 ${e+i} ${t}Z`,a}const kie=[Ue.BEACON_BEFORE,Ue.BEACON];function Sie(e){var T,z;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:d,spotlightPadding:f,spotlightRadius:u,spotlightTarget:p,styles:m,target:g,waiting:b}=e,v=Zne(),y=bie(p??g,f,d||b),k=h.useRef(null),w=(s===Ue.TOOLTIP||s===Ue.TOOLTIP_BEFORE)&&l!=="center",[j,_]=h.useState(!1),E=c?(T=k.current)==null?void 0:T.offsetParent:null,O=(E==null?void 0:E.clientWidth)??v.width,H=(E==null?void 0:E.clientHeight)??Yse()??v.height,L=((z=m.overlay)==null?void 0:z.backgroundColor)??"rgba(0, 0, 0, 0.5)",F=h.useMemo(()=>{const{backgroundColor:A,mixBlendMode:P,...C}=m.overlay;return{height:H,pointerEvents:"none",...C}},[H,m.overlay]),D=w&&!d&&!b;h.useEffect(()=>{D?requestAnimationFrame(()=>_(!0)):_(!1)},[D]);const R=n&&kie.includes(s),W=!n&&s!==Ue.TOOLTIP;if(r||!b&&(R||W))return null;let M="";if(D)if(c&&E){const A=Si(p??g);if(A){const P=SC(A),C=SC(E);M=EC(P.left-C.left-f.left,P.top-C.top-f.top,A.offsetWidth+f.left+f.right,A.offsetHeight+f.top+f.bottom,u)}}else M=EC(y.left,y.top,y.width,y.height,u);const $=vie(O,H,M);return lt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:F},lt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:H,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:O}},lt.createElement("path",{d:$,fill:L,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&lt.createElement("path",{d:M,fill:L,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(m.spotlight).length>0&&lt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function o2(e){const{children:t,element:n}=e;return n?Dr.createPortal(t,n):null}const Nie='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function jie(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return np;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(Nie)],{shiftKey:l}=i;if(!a.length)return;i.preventDefault();let c=document.activeElement?a.indexOf(document.activeElement):0;c===-1||!l&&c+1===a.length?c=0:l&&c===0?c=a.length-1:c+=l?-1:1,a[c].focus()};e.addEventListener("keydown",r,!1);let s;{const i=e.querySelector(t);i&&(s=setTimeout(()=>{i.focus({preventScroll:!0})},100))}return()=>{var i;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(i=n.current)==null||i.focus({preventScroll:!0})}},[e,t])}function ia(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 Cie(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...ia(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...ia(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...ia(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...ia(e,t,n)};default:return null}}function Eie(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...ia(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...ia(e,r,n)};case"left":return{right:-n,top:t.y??0,...ia(e,r,n)};case"right":return{left:-n,top:t.y??0,...ia(e,r,n)};default:return{}}}function _ie({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!ia(r,n,i))return null;c=lt.createElement("span",{style:{flexShrink:0}},lt.createElement(l,{base:n,placement:r,size:i}))}else{const d=Cie(r,n,i);if(!d)return null;c=lt.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},lt.createElement("polygon",{fill:"currentColor",points:d.points}))}return lt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...Eie(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function Pie(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:d,step:f,styles:u}=e,p=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return np;const v=document.createElement("style");v.id="joyride-beacon-animation",a&&v.setAttribute("nonce",a),v.appendChild(document.createTextNode(`
229
- @keyframes joyride-beacon-inner {
230
- 20% {
231
- opacity: 0.9;
232
- }
233
-
234
- 90% {
235
- opacity: 0.7;
236
- }
237
- }
238
-
239
- @keyframes joyride-beacon-outer {
240
- 0% {
241
- transform: scale(1);
242
- }
243
-
244
- 45% {
245
- opacity: 0.7;
246
- transform: scale(0.75);
247
- }
248
-
249
- 100% {
250
- opacity: 0.9;
251
- transform: scale(1);
252
- }
253
- }
254
- `)),document.head.appendChild(v);const y=setTimeout(()=>{ts.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(y);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const g=ea(i.open);let b;if(t){const v=t;b=lt.createElement(v,{continuous:n,index:r,isLastStep:s,size:d,step:f})}else b=lt.createElement("span",{style:u.beacon},lt.createElement("span",{style:u.beaconOuter}),lt.createElement("span",{style:u.beaconInner}));return lt.createElement("button",{ref:p,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:u.beaconWrapper,title:g,type:"button"},b)}function Aie({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return lt.createElement("button",{style:i,type:"button",...t},lt.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"},lt.createElement("g",null,lt.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 Iie(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:d,content:f,styles:u,title:p}=l,m={};d.includes("primary")&&(m.primary=lt.createElement("button",{"data-testid":"button-primary",style:u.buttonPrimary,type:"button",...i})),d.includes("skip")&&!s&&(m.skip=lt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:u.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(m.back=lt.createElement("button",{"data-testid":"button-back",style:u.buttonBack,type:"button",...t})),m.close=d.includes("close")&&lt.createElement(Aie,{"data-testid":"button-close",styles:u.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":ea(f),"aria-describedby":"joyride-tooltip-content"};return lt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:u.tooltip,...c,...g},lt.createElement("div",{style:u.tooltipContainer},p&&lt.createElement("h4",{id:"joyride-tooltip-title",style:u.tooltipTitle},p),lt.createElement("div",{id:"joyride-tooltip-content",style:u.tooltipContent},f)),d.some(b=>b==="back"||b==="primary"||b==="skip")&&lt.createElement("div",{style:u.tooltipFooter},lt.createElement("div",{style:u.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function Tie(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(bo.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(bo.BUTTON_CLOSE):n.close(bo.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(bo.BUTTON_PRIMARY);return}n.next(bo.BUTTON_PRIMARY)},f=y=>{y.preventDefault(),n.skip(bo.BUTTON_SKIP)},u=()=>{const{back:y,close:k,last:w,next:j,nextWithProgress:_,skip:E}=a.locale,O=ea(y),H=ea(k),L=ea(w),F=ea(j),D=ea(E);let R=k,W=H;if(t){if(R=j,W=F,a.showProgress&&!s){const M=ea(_,{step:r+1,steps:i});R=Kb(_,r+1,i),W=M}s&&(R=w,W=L)}return{backProps:{"aria-label":O,children:y,"data-action":"back",onClick:l,role:"button",title:O},closeProps:{"aria-label":H,children:k,"data-action":"close",onClick:c,role:"button",title:H},primaryProps:{"aria-label":W,children:R,"data-action":"primary",onClick:d,role:"button",title:W},skipProps:{"aria-label":D,children:E,"data-action":"skip",onClick:f,role:"button",title:D},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:m,tooltipComponent:g,...b}=a;let v;if(g){const y=g;v=lt.createElement(y,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b})}else v=lt.createElement(Iie,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return v}function Rie(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Lie(e,t,n){var r,s;return e?[Dse()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[$se({crossAxis:!1,fallbackPlacements:Rie(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Oie(e){var P,C,G,Z,V;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:d,shouldScroll:f,size:u,step:p,target:m,updateState:g}=e,b=h.useRef(null),v=h.useRef({}),y=h.useRef({}),k=p.placement==="center",w=p.placement==="auto",j=h.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})}),[]),_=h.useMemo(()=>n2(m)?Gu(m):void 0,[m]),E=h.useMemo(()=>Xu(m),[m]),O=h.useMemo(()=>_?{boundary:_,rootBoundary:"viewport"}:{},[_]),H=k||w?"bottom":p.placement,L=k?"fixed":((P=p.floatingOptions)==null?void 0:P.strategy)??(p.isFixed||E?"fixed":"absolute"),F=h.useMemo(()=>{var ne,ce,fe,he;return k?[{name:"center",fn:({rects:oe})=>({x:(window.innerWidth-oe.floating.width)/2,y:(window.innerHeight-oe.floating.height)/2})}]:[bC(({placement:oe})=>{var xe;let we="right";oe.startsWith("top")?we="top":oe.startsWith("bottom")?we="bottom":oe.startsWith("left")&&(we="left");const _e=p.spotlightTarget?0:p.spotlightPadding[we];return p.offset+_e+((xe=p.floatingOptions)!=null&&xe.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(ne=p.floatingOptions)==null?void 0:ne.hideArrow]),...Lie(w,p,H),Mse({padding:10,...O,...(ce=p.floatingOptions)==null?void 0:ce.shiftOptions}),...(fe=p.floatingOptions)!=null&&fe.hideArrow?[]:[Fse({element:b,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((he=p.floatingOptions)==null?void 0:he.middleware)??[]]},[k,p,w,H,O]),D=wC({...k?{elements:{reference:j}}:{},placement:H,strategy:L,middleware:F}),R=wC({strategy:L,placement:p.beaconPlacement??(w||k?"bottom":p.placement),middleware:h.useMemo(()=>{var ne,ce;return[bC(((ce=(ne=p.floatingOptions)==null?void 0:ne.beaconOptions)==null?void 0:ce.offset)??-18)]},[(G=(C=p.floatingOptions)==null?void 0:C.beaconOptions)==null?void 0:G.offset]),whileElementsMounted:gC});y.current=D.middlewareData,v.current=R.middlewareData,h.useEffect(()=>{var fe;const{floating:ne,reference:ce}=D.elements;if(!(!ce||!ne||s!==Ue.TOOLTIP))return gC(ce,ne,D.update,(fe=p.floatingOptions)==null?void 0:fe.autoUpdate)},[s,D.update,(Z=p.floatingOptions)==null?void 0:Z.autoUpdate,p.target,D.elements]),h.useEffect(()=>{!k&&m&&D.refs.setReference(m),m&&R.refs.setReference(m)},[R.refs,k,m,D.refs]),h.useEffect(()=>{D.isPositioned&&c("tooltip",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:y.current})},[c,D.isPositioned,D.placement,D.x,D.y]),h.useEffect(()=>{R.isPositioned&&c("beacon",{placement:R.placement,x:R.x??0,y:R.y??0,middlewareData:v.current})},[c,R.isPositioned,R.placement,R.x,R.y]);const W=p.zIndex+100,M=h.useCallback(ne=>{ne.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Ue.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),$=h.useCallback(ne=>{ne&&(D.refs.setFloating(ne),d(ne))},[D.refs,d]),{arrow:T,floater:z}=p.styles;let A=null;if(s===Ue.TOOLTIP||s===Ue.TOOLTIP_BEFORE){const ne=kC({...z,...D.floatingStyles,zIndex:W,opacity:a&&D.isPositioned?1:0,...!a&&{transition:"none"}});A=lt.createElement("div",{ref:$,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:ne},lt.createElement(Tie,{continuous:t,controls:n,index:r,isLastStep:r+1===u,size:u,step:p}),!k&&!((V=p.floatingOptions)!=null&&V.hideArrow)&&lt.createElement(_ie,{arrowComponent:p.arrowComponent,arrowRef:b,base:p.arrowBase,placement:D.placement,position:D.middlewareData.arrow,size:p.arrowSize,styles:T}))}else(s===Ue.BEACON||s===Ue.BEACON_BEFORE)&&(A=lt.createElement("div",{ref:R.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:kC({...R.floatingStyles,zIndex:W})},lt.createElement(Pie,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===u,locale:p.locale,nonce:i,onInteract:M,shouldFocus:f,size:u,step:p,styles:p.styles})));return lt.createElement(o2,{element:l},A)}function Mie(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:d,step:f,updateState:u}=e,[p,m]=h.useState(null);jie(f.disableFocusTrap?null:p,"[data-action=primary]");const g=Si(f.target),b=s===Ue.TOOLTIP;return!s2(f)||!ts.domElement(g)?null:lt.createElement(Oie,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:b,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:d,step:f,target:g,updateState:u})}function $ie({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,f=gie(c),{index:u,lifecycle:p,status:m}=n,g=m===Rt.RUNNING,[b,v]=h.useState(!1),y=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?k===0?v(!0):y.current=setTimeout(()=>{v(!0)},k):v(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[k,n.waiting]),h.useEffect(()=>{if(!g)return;const _=E=>{!r||p!==Ue.TOOLTIP||E.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(bo.KEYBOARD):e.close(bo.KEYBOARD))};return document.body.addEventListener("keydown",_,{passive:!0}),()=>{document.body.removeEventListener("keydown",_)}},[e,g,p,r]);const w=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(bo.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(bo.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===Ft.START&&!r.skipBeacon&&r.placement!=="center";return lt.createElement(lt.Fragment,null,p!==Ue.INIT&&lt.createElement(Mie,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:f,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(u!==0||d),step:r,updateState:s.current.updateState}),lt.createElement(o2,{element:f},lt.createElement(lt.Fragment,null,b&&lt.createElement(xie,{nonce:l,step:r}),!j&&lt.createElement(Sie,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:c?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Die(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=mie(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>Cg(s,"positioned"),[s]),step:i,Tour:K0()?lt.createElement($ie,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function Fie(e){const{Tour:t}=Die(e);return t}function zie(e){return K0()?lt.createElement(Fie,e):null}function Hie(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 Bie(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Wie(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Xx="af:onboarding";function Vie({page:e,hasNodes:t=!1}){const{t:n}=Ln(),[r,s]=h.useState(!1),[i,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?Hie(n):t?Bie(n):Wie(n),[e,t,n]);return h.useEffect(()=>{const d=localStorage.getItem(Xx);console.log("[Onboarding] localStorage:",d);const f=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",f,"page:",e),f.completed||f[e]){console.log("[Onboarding] skipped - already done"),s(!1),a([]);return}console.log("[Onboarding] starting with steps:",c),a(c),s(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const d=f=>{var g;const u=f.target.closest("button");if(!u||!u.closest(".react-joyride__tooltip"))return;const m=(g=u.textContent)==null?void 0:g.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const b=localStorage.getItem(Xx)||"{}",v=JSON.parse(b);m===n("onboarding:skip")?(v.projects=!0,v.flow=!0,v.completed=!0):v[e]=!0,localStorage.setItem(Xx,JSON.stringify(v)),a([]),s(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const y=document.querySelector(".af-create-btn");y&&y.click()},500))}};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(zie,{ref:l,steps:i,run:r,continuous:!0,showSkipButton:!0,showProgress:i.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function Uie(){const{navigate:e,path:t}=Ro(),[n,r]=h.useState([]),[s,i]=h.useState(!1);if(h.useEffect(()=>{let f=!1;const u=async()=>{try{const m=await fetch("/api/pipeline-recent-runs");if(!m.ok)return;const g=await m.json();if(f)return;const b=Array.isArray(g.runs)?g.runs:[];r(b.filter(v=>v&&v.status==="running"))}catch{}};u();const p=window.setInterval(u,3e3);return()=>{f=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=f=>{const u=new URLSearchParams({flowId:f.flowId,flowSource:f.flowSource||"workspace"});e(`/flow?${u.toString()}`),i(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,c=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(f=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(f.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(f),title:`${f.flowId} · ${f.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:f.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:f.runId.slice(0,12)})]},`${f.flowId}:${f.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):i(f=>!f),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}function a2(e){return e==="/likee-context"||e==="/likee_context"}class Kie extends h.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,i;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((i=this.state.info)==null?void 0:i.componentStack)||"");return o.jsx("div",{className:"af-auth-screen",children:o.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"error"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow UI Error"}),o.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),o.jsx("pre",{children:t}),n?o.jsx("pre",{children:n}):null]})})}}function qie({authUser:e}){const{path:t}=Ro();return t==="/projects"||t==="/"?o.jsx(Tc,{authUser:e}):t==="/nodes"?o.jsx(Tc,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Tc,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Tc,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Tc,{authUser:e,resourceKind:"skills"}):t==="/mcps"?o.jsx(_ne,{}):t==="/flow"?o.jsx(M7,{}):t==="/workspace"?o.jsx(oY,{}):t.startsWith("/display")?o.jsx(kR,{}):t==="/settings"?o.jsx(jne,{authUser:e}):t==="/feedback"?o.jsx(Cne,{}):a2(t)?o.jsx(IR,{}):o.jsx(Tc,{})}function Yie({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=h.useState(""),[i,a]=h.useState(""),[l,c]=h.useState(!1),[d,f]=h.useState(""),u=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}),f(g.error?String(g.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),f(String(m.message||m))}};h.useEffect(()=>{u()},[]);const p=async m=>{m.preventDefault(),c(!0),f("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),b=await g.json().catch(()=>({}));if(!g.ok)throw new Error(b.error||"登录失败");n({loading:!1,authenticated:!0,user:b.user||null,setupRequired:!1})}catch(g){f(String(g.message||g))}finally{c(!1)}};return t.loading?o.jsx("div",{className:"af-auth-screen",children:o.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):o.jsx("div",{className:"af-auth-screen",children:o.jsxs("form",{className:"af-auth-panel",onSubmit:p,children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow"}),o.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"用户名"}),o.jsx("input",{value:r,onChange:m=>s(m.target.value),autoComplete:"username",autoFocus:!0})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"密码"}),o.jsx("input",{type:"password",value:i,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?o.jsx("p",{className:"af-auth-error",children:d}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Gie({authUser:e,onLogout:t}){const{path:n}=Ro(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(Vie,{page:r?"flow":"projects"}):null,r?null:o.jsx(jM,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(qie,{authUser:e})}),o.jsx(Uie,{})]})}function Xie(){return o.jsx(Kie,{children:o.jsx(oM,{children:o.jsx(Jie,{})})})}function Jie(){const{path:e}=Ro();return e.startsWith("/display")?o.jsx(kR,{}):a2(e)?o.jsx(IR,{}):o.jsx(Yie,{children:({user:t,onLogout:n})=>o.jsx(Gie,{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 _C=document.querySelector('link[rel="icon"]');_C&&(_C.href=V_);Jx.createRoot(document.getElementById("root")).render(o.jsx(lt.StrictMode,{children:o.jsx(Xie,{})}));