@fieldwangai/agentflow 0.1.83 → 0.1.85

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,297 +0,0 @@
1
- var hM=Object.defineProperty;var mM=(e,t,n)=>t in e?hM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pr=(e,t,n)=>mM(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var ap=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yE={exports:{}},dy={},xE={exports:{}},Gt={};/**
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 qp=Symbol.for("react.element"),gM=Symbol.for("react.portal"),yM=Symbol.for("react.fragment"),xM=Symbol.for("react.strict_mode"),wM=Symbol.for("react.profiler"),bM=Symbol.for("react.provider"),vM=Symbol.for("react.context"),kM=Symbol.for("react.forward_ref"),SM=Symbol.for("react.suspense"),NM=Symbol.for("react.memo"),jM=Symbol.for("react.lazy"),Xk=Symbol.iterator;function CM(e){return e===null||typeof e!="object"?null:(e=Xk&&e[Xk]||e["@@iterator"],typeof e=="function"?e:null)}var wE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},bE=Object.assign,vE={};function Pd(e,t,n){this.props=e,this.context=t,this.refs=vE,this.updater=n||wE}Pd.prototype.isReactComponent={};Pd.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")};Pd.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function kE(){}kE.prototype=Pd.prototype;function Ov(e,t,n){this.props=e,this.context=t,this.refs=vE,this.updater=n||wE}var $v=Ov.prototype=new kE;$v.constructor=Ov;bE($v,Pd.prototype);$v.isPureReactComponent=!0;var Jk=Array.isArray,SE=Object.prototype.hasOwnProperty,Dv={current:null},NE={key:!0,ref:!0,__self:!0,__source:!0};function jE(e,t,n){var r,s={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)SE.call(t,r)&&!NE.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:qp,type:e,key:o,ref:a,props:s,_owner:Dv.current}}function EM(e,t){return{$$typeof:qp,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Fv(e){return typeof e=="object"&&e!==null&&e.$$typeof===qp}function _M(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Qk=/\/+/g;function hx(e,t){return typeof e=="object"&&e!==null&&e.key!=null?_M(""+e.key):t.toString(36)}function Tm(e,t,n,r,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case qp:case gM:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+hx(a,0):r,Jk(s)?(n="",e!=null&&(n=e.replace(Qk,"$&/")+"/"),Tm(s,t,n,"",function(d){return d})):s!=null&&(Fv(s)&&(s=EM(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Qk,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",Jk(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+hx(o,l);a+=Tm(o,t,n,c,s)}else if(c=CM(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+hx(o,l++),a+=Tm(o,t,n,c,s);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Oh(e,t,n){if(e==null)return e;var r=[],s=0;return Tm(e,r,"","",function(o){return t.call(n,o,s++)}),r}function AM(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 Es={current:null},Rm={transition:null},PM={ReactCurrentDispatcher:Es,ReactCurrentBatchConfig:Rm,ReactCurrentOwner:Dv};function CE(){throw Error("act(...) is not supported in production builds of React.")}Gt.Children={map:Oh,forEach:function(e,t,n){Oh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Oh(e,function(){t++}),t},toArray:function(e){return Oh(e,function(t){return t})||[]},only:function(e){if(!Fv(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Gt.Component=Pd;Gt.Fragment=yM;Gt.Profiler=wM;Gt.PureComponent=Ov;Gt.StrictMode=xM;Gt.Suspense=SM;Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=PM;Gt.act=CE;Gt.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=bE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Dv.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)SE.call(t,c)&&!NE.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:qp,type:e.type,key:s,ref:o,props:r,_owner:a}};Gt.createContext=function(e){return e={$$typeof:vM,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:bM,_context:e},e.Consumer=e};Gt.createElement=jE;Gt.createFactory=function(e){var t=jE.bind(null,e);return t.type=e,t};Gt.createRef=function(){return{current:null}};Gt.forwardRef=function(e){return{$$typeof:kM,render:e}};Gt.isValidElement=Fv;Gt.lazy=function(e){return{$$typeof:jM,_payload:{_status:-1,_result:e},_init:AM}};Gt.memo=function(e,t){return{$$typeof:NM,type:e,compare:t===void 0?null:t}};Gt.startTransition=function(e){var t=Rm.transition;Rm.transition={};try{e()}finally{Rm.transition=t}};Gt.unstable_act=CE;Gt.useCallback=function(e,t){return Es.current.useCallback(e,t)};Gt.useContext=function(e){return Es.current.useContext(e)};Gt.useDebugValue=function(){};Gt.useDeferredValue=function(e){return Es.current.useDeferredValue(e)};Gt.useEffect=function(e,t){return Es.current.useEffect(e,t)};Gt.useId=function(){return Es.current.useId()};Gt.useImperativeHandle=function(e,t,n){return Es.current.useImperativeHandle(e,t,n)};Gt.useInsertionEffect=function(e,t){return Es.current.useInsertionEffect(e,t)};Gt.useLayoutEffect=function(e,t){return Es.current.useLayoutEffect(e,t)};Gt.useMemo=function(e,t){return Es.current.useMemo(e,t)};Gt.useReducer=function(e,t,n){return Es.current.useReducer(e,t,n)};Gt.useRef=function(e){return Es.current.useRef(e)};Gt.useState=function(e){return Es.current.useState(e)};Gt.useSyncExternalStore=function(e,t,n){return Es.current.useSyncExternalStore(e,t,n)};Gt.useTransition=function(){return Es.current.useTransition()};Gt.version="18.3.1";xE.exports=Gt;var h=xE.exports;const yt=$l(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 IM=h,TM=Symbol.for("react.element"),RM=Symbol.for("react.fragment"),MM=Object.prototype.hasOwnProperty,LM=IM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,OM={key:!0,ref:!0,__self:!0,__source:!0};function EE(e,t,n){var r,s={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)MM.call(t,r)&&!OM.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:TM,type:e,key:o,ref:a,props:s,_owner:LM.current}}dy.Fragment=RM;dy.jsx=EE;dy.jsxs=EE;yE.exports=dy;var i=yE.exports,Dw={},_E={exports:{}},fi={},AE={exports:{}},PE={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(P,O){var _=P.length;P.push(O);e:for(;0<_;){var Z=_-1>>>1,ee=P[Z];if(0<s(ee,O))P[Z]=O,P[_]=ee,_=Z;else break e}}function n(P){return P.length===0?null:P[0]}function r(P){if(P.length===0)return null;var O=P[0],_=P.pop();if(_!==O){P[0]=_;e:for(var Z=0,ee=P.length,V=ee>>>1;Z<V;){var ae=2*(Z+1)-1,fe=P[ae],xe=ae+1,Se=P[xe];if(0>s(fe,_))xe<ee&&0>s(Se,fe)?(P[Z]=Se,P[xe]=_,Z=xe):(P[Z]=fe,P[ae]=_,Z=ae);else if(xe<ee&&0>s(Se,_))P[Z]=Se,P[xe]=_,Z=xe;else break e}}return O}function s(P,O){var _=P.sortIndex-O.sortIndex;return _!==0?_:P.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],p=1,u=null,f=3,m=!1,g=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var O=n(d);O!==null;){if(O.callback===null)r(d);else if(O.startTime<=P)r(d),O.sortIndex=O.expirationTime,t(c,O);else break;O=n(d)}}function j(P){if(w=!1,x(P),!g)if(n(c)!==null)g=!0,I(E);else{var O=n(d);O!==null&&F(j,O.startTime-P)}}function E(P,O){g=!1,w&&(w=!1,y($),$=-1),m=!0;var _=f;try{for(x(O),u=n(c);u!==null&&(!(u.expirationTime>O)||P&&!B());){var Z=u.callback;if(typeof Z=="function"){u.callback=null,f=u.priorityLevel;var ee=Z(u.expirationTime<=O);O=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),x(O)}else r(c);u=n(c)}if(u!==null)var V=!0;else{var ae=n(d);ae!==null&&F(j,ae.startTime-O),V=!1}return V}finally{u=null,f=_,m=!1}}var N=!1,T=null,$=-1,z=5,K=-1;function B(){return!(e.unstable_now()-K<z)}function L(){if(T!==null){var P=e.unstable_now();K=P;var O=!0;try{O=T(!0,P)}finally{O?D():(N=!1,T=null)}}else N=!1}var D;if(typeof b=="function")D=function(){b(L)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,M=R.port2;R.port1.onmessage=L,D=function(){M.postMessage(null)}}else D=function(){k(L,0)};function I(P){T=P,N||(N=!0,D())}function F(P,O){$=k(function(){P(e.unstable_now())},O)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(P){P.callback=null},e.unstable_continueExecution=function(){g||m||(g=!0,I(E))},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(P){switch(f){case 1:case 2:case 3:var O=3;break;default:O=f}var _=f;f=O;try{return P()}finally{f=_}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(P,O){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var _=f;f=P;try{return O()}finally{f=_}},e.unstable_scheduleCallback=function(P,O,_){var Z=e.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?Z+_:Z):_=Z,P){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=_+ee,P={id:p++,callback:O,priorityLevel:P,startTime:_,expirationTime:ee,sortIndex:-1},_>Z?(P.sortIndex=_,t(d,P),n(c)===null&&P===n(d)&&(w?(y($),$=-1):w=!0,F(j,_-Z))):(P.sortIndex=ee,t(c,P),g||m||(g=!0,I(E))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var O=f;return function(){var _=f;f=O;try{return P.apply(this,arguments)}finally{f=_}}}})(PE);AE.exports=PE;var $M=AE.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 DM=h,ui=$M;function Re(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 IE=new Set,lp={};function Bc(e,t){ld(e,t),ld(e+"Capture",t)}function ld(e,t){for(lp[e]=t,e=0;e<t.length;e++)IE.add(t[e])}var ja=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fw=Object.prototype.hasOwnProperty,FM=/^[: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]*$/,Zk={},eS={};function zM(e){return Fw.call(eS,e)?!0:Fw.call(Zk,e)?!1:FM.test(e)?eS[e]=!0:(Zk[e]=!0,!1)}function HM(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 BM(e,t,n,r){if(t===null||typeof t>"u"||HM(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 _s(e,t,n,r,s,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var ss={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ss[e]=new _s(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ss[t]=new _s(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ss[e]=new _s(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ss[e]=new _s(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){ss[e]=new _s(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ss[e]=new _s(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ss[e]=new _s(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ss[e]=new _s(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ss[e]=new _s(e,5,!1,e.toLowerCase(),null,!1,!1)});var zv=/[\-:]([a-z])/g;function Hv(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(zv,Hv);ss[t]=new _s(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(zv,Hv);ss[t]=new _s(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(zv,Hv);ss[t]=new _s(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ss[e]=new _s(e,1,!1,e.toLowerCase(),null,!1,!1)});ss.xlinkHref=new _s("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ss[e]=new _s(e,1,!1,e.toLowerCase(),null,!0,!0)});function Bv(e,t,n,r){var s=ss.hasOwnProperty(t)?ss[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(BM(t,n,s,r)&&(n=null),r||s===null?zM(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 Ta=DM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$h=Symbol.for("react.element"),Pu=Symbol.for("react.portal"),Iu=Symbol.for("react.fragment"),Wv=Symbol.for("react.strict_mode"),zw=Symbol.for("react.profiler"),TE=Symbol.for("react.provider"),RE=Symbol.for("react.context"),Vv=Symbol.for("react.forward_ref"),Hw=Symbol.for("react.suspense"),Bw=Symbol.for("react.suspense_list"),Kv=Symbol.for("react.memo"),ol=Symbol.for("react.lazy"),ME=Symbol.for("react.offscreen"),tS=Symbol.iterator;function uf(e){return e===null||typeof e!="object"?null:(e=tS&&e[tS]||e["@@iterator"],typeof e=="function"?e:null)}var ur=Object.assign,mx;function _f(e){if(mx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);mx=t&&t[1]||""}return`
34
- `+mx+e}var gx=!1;function yx(e,t){if(!e||gx)return"";gx=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
- `),o=r.stack.split(`
36
- `),a=s.length-1,l=o.length-1;1<=a&&0<=l&&s[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==o[l]){var 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{gx=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?_f(e):""}function WM(e){switch(e.tag){case 5:return _f(e.type);case 16:return _f("Lazy");case 13:return _f("Suspense");case 19:return _f("SuspenseList");case 0:case 2:case 15:return e=yx(e.type,!1),e;case 11:return e=yx(e.type.render,!1),e;case 1:return e=yx(e.type,!0),e;default:return""}}function Ww(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 Iu:return"Fragment";case Pu:return"Portal";case zw:return"Profiler";case Wv:return"StrictMode";case Hw:return"Suspense";case Bw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case RE:return(e.displayName||"Context")+".Consumer";case TE:return(e._context.displayName||"Context")+".Provider";case Vv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Kv:return t=e.displayName||null,t!==null?t:Ww(e.type)||"Memo";case ol:t=e._payload,e=e._init;try{return Ww(e(t))}catch{}}return null}function VM(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 Ww(t);case 8:return t===Wv?"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 Al(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function LE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function KM(e){var t=LE(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Dh(e){e._valueTracker||(e._valueTracker=KM(e))}function OE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=LE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function rg(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 Vw(e,t){var n=t.checked;return ur({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function nS(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Al(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 $E(e,t){t=t.checked,t!=null&&Bv(e,"checked",t,!1)}function Kw(e,t){$E(e,t);var n=Al(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")?Uw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Uw(e,t.type,Al(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function rS(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 Uw(e,t,n){(t!=="number"||rg(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Af=Array.isArray;function Gu(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=""+Al(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 qw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Re(91));return ur({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function sS(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Re(92));if(Af(n)){if(1<n.length)throw Error(Re(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Al(n)}}function DE(e,t){var n=Al(t.value),r=Al(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 iS(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function FE(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 Yw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?FE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Fh,zE=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(Fh=Fh||document.createElement("div"),Fh.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Fh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function cp(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ff={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},UM=["Webkit","ms","Moz","O"];Object.keys(Ff).forEach(function(e){UM.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ff[t]=Ff[e]})});function HE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ff.hasOwnProperty(e)&&Ff[e]?(""+t).trim():t+"px"}function BE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=HE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var qM=ur({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 Gw(e,t){if(t){if(qM[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Re(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Re(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Re(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Re(62))}}function Xw(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 Jw=null;function Uv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qw=null,Xu=null,Ju=null;function oS(e){if(e=Xp(e)){if(typeof Qw!="function")throw Error(Re(280));var t=e.stateNode;t&&(t=gy(t),Qw(e.stateNode,e.type,t))}}function WE(e){Xu?Ju?Ju.push(e):Ju=[e]:Xu=e}function VE(){if(Xu){var e=Xu,t=Ju;if(Ju=Xu=null,oS(e),t)for(e=0;e<t.length;e++)oS(t[e])}}function KE(e,t){return e(t)}function UE(){}var xx=!1;function qE(e,t,n){if(xx)return e(t,n);xx=!0;try{return KE(e,t,n)}finally{xx=!1,(Xu!==null||Ju!==null)&&(UE(),VE())}}function up(e,t){var n=e.stateNode;if(n===null)return null;var r=gy(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(Re(231,t,typeof n));return n}var Zw=!1;if(ja)try{var df={};Object.defineProperty(df,"passive",{get:function(){Zw=!0}}),window.addEventListener("test",df,df),window.removeEventListener("test",df,df)}catch{Zw=!1}function YM(e,t,n,r,s,o,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(p){this.onError(p)}}var zf=!1,sg=null,ig=!1,eb=null,GM={onError:function(e){zf=!0,sg=e}};function XM(e,t,n,r,s,o,a,l,c){zf=!1,sg=null,YM.apply(GM,arguments)}function JM(e,t,n,r,s,o,a,l,c){if(XM.apply(this,arguments),zf){if(zf){var d=sg;zf=!1,sg=null}else throw Error(Re(198));ig||(ig=!0,eb=d)}}function Wc(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 YE(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 aS(e){if(Wc(e)!==e)throw Error(Re(188))}function QM(e){var t=e.alternate;if(!t){if(t=Wc(e),t===null)throw Error(Re(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return aS(s),e;if(o===r)return aS(s),t;o=o.sibling}throw Error(Re(188))}if(n.return!==r.return)n=s,r=o;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=o;break}if(l===r){a=!0,r=s,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=s;break}if(l===r){a=!0,r=o,n=s;break}l=l.sibling}if(!a)throw Error(Re(189))}}if(n.alternate!==r)throw Error(Re(190))}if(n.tag!==3)throw Error(Re(188));return n.stateNode.current===n?e:t}function GE(e){return e=QM(e),e!==null?XE(e):null}function XE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=XE(e);if(t!==null)return t;e=e.sibling}return null}var JE=ui.unstable_scheduleCallback,lS=ui.unstable_cancelCallback,ZM=ui.unstable_shouldYield,eL=ui.unstable_requestPaint,jr=ui.unstable_now,tL=ui.unstable_getCurrentPriorityLevel,qv=ui.unstable_ImmediatePriority,QE=ui.unstable_UserBlockingPriority,og=ui.unstable_NormalPriority,nL=ui.unstable_LowPriority,ZE=ui.unstable_IdlePriority,fy=null,zo=null;function rL(e){if(zo&&typeof zo.onCommitFiberRoot=="function")try{zo.onCommitFiberRoot(fy,e,void 0,(e.current.flags&128)===128)}catch{}}var no=Math.clz32?Math.clz32:oL,sL=Math.log,iL=Math.LN2;function oL(e){return e>>>=0,e===0?32:31-(sL(e)/iL|0)|0}var zh=64,Hh=4194304;function Pf(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 ag(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=Pf(l):(o&=a,o!==0&&(r=Pf(o)))}else a=n&~s,a!==0?r=Pf(a):o!==0&&(r=Pf(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-no(t),s=1<<n,r|=e[n],t&=~s;return r}function aL(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 lL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-no(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=aL(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function tb(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function e_(){var e=zh;return zh<<=1,!(zh&4194240)&&(zh=64),e}function wx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Yp(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-no(t),e[t]=n}function cL(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-no(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Yv(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-no(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var vn=0;function t_(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var n_,Gv,r_,s_,i_,nb=!1,Bh=[],yl=null,xl=null,wl=null,dp=new Map,fp=new Map,cl=[],uL="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 cS(e,t){switch(e){case"focusin":case"focusout":yl=null;break;case"dragenter":case"dragleave":xl=null;break;case"mouseover":case"mouseout":wl=null;break;case"pointerover":case"pointerout":dp.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":fp.delete(t.pointerId)}}function ff(e,t,n,r,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},t!==null&&(t=Xp(t),t!==null&&Gv(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function dL(e,t,n,r,s){switch(t){case"focusin":return yl=ff(yl,e,t,n,r,s),!0;case"dragenter":return xl=ff(xl,e,t,n,r,s),!0;case"mouseover":return wl=ff(wl,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return dp.set(o,ff(dp.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,fp.set(o,ff(fp.get(o)||null,e,t,n,r,s)),!0}return!1}function o_(e){var t=gc(e.target);if(t!==null){var n=Wc(t);if(n!==null){if(t=n.tag,t===13){if(t=YE(n),t!==null){e.blockedOn=t,i_(e.priority,function(){r_(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Mm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=rb(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Jw=r,n.target.dispatchEvent(r),Jw=null}else return t=Xp(n),t!==null&&Gv(t),e.blockedOn=n,!1;t.shift()}return!0}function uS(e,t,n){Mm(e)&&n.delete(t)}function fL(){nb=!1,yl!==null&&Mm(yl)&&(yl=null),xl!==null&&Mm(xl)&&(xl=null),wl!==null&&Mm(wl)&&(wl=null),dp.forEach(uS),fp.forEach(uS)}function pf(e,t){e.blockedOn===t&&(e.blockedOn=null,nb||(nb=!0,ui.unstable_scheduleCallback(ui.unstable_NormalPriority,fL)))}function pp(e){function t(s){return pf(s,e)}if(0<Bh.length){pf(Bh[0],e);for(var n=1;n<Bh.length;n++){var r=Bh[n];r.blockedOn===e&&(r.blockedOn=null)}}for(yl!==null&&pf(yl,e),xl!==null&&pf(xl,e),wl!==null&&pf(wl,e),dp.forEach(t),fp.forEach(t),n=0;n<cl.length;n++)r=cl[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<cl.length&&(n=cl[0],n.blockedOn===null);)o_(n),n.blockedOn===null&&cl.shift()}var Qu=Ta.ReactCurrentBatchConfig,lg=!0;function pL(e,t,n,r){var s=vn,o=Qu.transition;Qu.transition=null;try{vn=1,Xv(e,t,n,r)}finally{vn=s,Qu.transition=o}}function hL(e,t,n,r){var s=vn,o=Qu.transition;Qu.transition=null;try{vn=4,Xv(e,t,n,r)}finally{vn=s,Qu.transition=o}}function Xv(e,t,n,r){if(lg){var s=rb(e,t,n,r);if(s===null)Ax(e,t,r,cg,n),cS(e,r);else if(dL(s,e,t,n,r))r.stopPropagation();else if(cS(e,r),t&4&&-1<uL.indexOf(e)){for(;s!==null;){var o=Xp(s);if(o!==null&&n_(o),o=rb(e,t,n,r),o===null&&Ax(e,t,r,cg,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else Ax(e,t,r,null,n)}}var cg=null;function rb(e,t,n,r){if(cg=null,e=Uv(r),e=gc(e),e!==null)if(t=Wc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=YE(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 cg=e,null}function a_(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(tL()){case qv:return 1;case QE:return 4;case og:case nL:return 16;case ZE:return 536870912;default:return 16}default:return 16}}var fl=null,Jv=null,Lm=null;function l_(){if(Lm)return Lm;var e,t=Jv,n=t.length,r,s="value"in fl?fl.value:fl.textContent,o=s.length;for(e=0;e<n&&t[e]===s[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===s[o-r];r++);return Lm=s.slice(e,1<r?1-r:void 0)}function Om(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 Wh(){return!0}function dS(){return!1}function pi(e){function t(n,r,s,o,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Wh:dS,this.isPropagationStopped=dS,this}return ur(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=Wh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Wh)},persist:function(){},isPersistent:Wh}),t}var Id={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qv=pi(Id),Gp=ur({},Id,{view:0,detail:0}),mL=pi(Gp),bx,vx,hf,py=ur({},Gp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zv,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!==hf&&(hf&&e.type==="mousemove"?(bx=e.screenX-hf.screenX,vx=e.screenY-hf.screenY):vx=bx=0,hf=e),bx)},movementY:function(e){return"movementY"in e?e.movementY:vx}}),fS=pi(py),gL=ur({},py,{dataTransfer:0}),yL=pi(gL),xL=ur({},Gp,{relatedTarget:0}),kx=pi(xL),wL=ur({},Id,{animationName:0,elapsedTime:0,pseudoElement:0}),bL=pi(wL),vL=ur({},Id,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),kL=pi(vL),SL=ur({},Id,{data:0}),pS=pi(SL),NL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jL={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"},CL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function EL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=CL[e])?!!t[e]:!1}function Zv(){return EL}var _L=ur({},Gp,{key:function(e){if(e.key){var t=NL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Om(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?jL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zv,charCode:function(e){return e.type==="keypress"?Om(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Om(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),AL=pi(_L),PL=ur({},py,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hS=pi(PL),IL=ur({},Gp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zv}),TL=pi(IL),RL=ur({},Id,{propertyName:0,elapsedTime:0,pseudoElement:0}),ML=pi(RL),LL=ur({},py,{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}),OL=pi(LL),$L=[9,13,27,32],e0=ja&&"CompositionEvent"in window,Hf=null;ja&&"documentMode"in document&&(Hf=document.documentMode);var DL=ja&&"TextEvent"in window&&!Hf,c_=ja&&(!e0||Hf&&8<Hf&&11>=Hf),mS=" ",gS=!1;function u_(e,t){switch(e){case"keyup":return $L.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function d_(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Tu=!1;function FL(e,t){switch(e){case"compositionend":return d_(t);case"keypress":return t.which!==32?null:(gS=!0,mS);case"textInput":return e=t.data,e===mS&&gS?null:e;default:return null}}function zL(e,t){if(Tu)return e==="compositionend"||!e0&&u_(e,t)?(e=l_(),Lm=Jv=fl=null,Tu=!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 c_&&t.locale!=="ko"?null:t.data;default:return null}}var HL={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 yS(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!HL[e.type]:t==="textarea"}function f_(e,t,n,r){WE(r),t=ug(t,"onChange"),0<t.length&&(n=new Qv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Bf=null,hp=null;function BL(e){S_(e,0)}function hy(e){var t=Lu(e);if(OE(t))return e}function WL(e,t){if(e==="change")return t}var p_=!1;if(ja){var Sx;if(ja){var Nx="oninput"in document;if(!Nx){var xS=document.createElement("div");xS.setAttribute("oninput","return;"),Nx=typeof xS.oninput=="function"}Sx=Nx}else Sx=!1;p_=Sx&&(!document.documentMode||9<document.documentMode)}function wS(){Bf&&(Bf.detachEvent("onpropertychange",h_),hp=Bf=null)}function h_(e){if(e.propertyName==="value"&&hy(hp)){var t=[];f_(t,hp,e,Uv(e)),qE(BL,t)}}function VL(e,t,n){e==="focusin"?(wS(),Bf=t,hp=n,Bf.attachEvent("onpropertychange",h_)):e==="focusout"&&wS()}function KL(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return hy(hp)}function UL(e,t){if(e==="click")return hy(t)}function qL(e,t){if(e==="input"||e==="change")return hy(t)}function YL(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var so=typeof Object.is=="function"?Object.is:YL;function mp(e,t){if(so(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(!Fw.call(t,s)||!so(e[s],t[s]))return!1}return!0}function bS(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function vS(e,t){var n=bS(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=bS(n)}}function m_(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?m_(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function g_(){for(var e=window,t=rg();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=rg(e.document)}return t}function t0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function GL(e){var t=g_(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&m_(n.ownerDocument.documentElement,n)){if(r!==null&&t0(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=vS(n,o);var a=vS(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var XL=ja&&"documentMode"in document&&11>=document.documentMode,Ru=null,sb=null,Wf=null,ib=!1;function kS(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ib||Ru==null||Ru!==rg(r)||(r=Ru,"selectionStart"in r&&t0(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}),Wf&&mp(Wf,r)||(Wf=r,r=ug(sb,"onSelect"),0<r.length&&(t=new Qv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Ru)))}function Vh(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Mu={animationend:Vh("Animation","AnimationEnd"),animationiteration:Vh("Animation","AnimationIteration"),animationstart:Vh("Animation","AnimationStart"),transitionend:Vh("Transition","TransitionEnd")},jx={},y_={};ja&&(y_=document.createElement("div").style,"AnimationEvent"in window||(delete Mu.animationend.animation,delete Mu.animationiteration.animation,delete Mu.animationstart.animation),"TransitionEvent"in window||delete Mu.transitionend.transition);function my(e){if(jx[e])return jx[e];if(!Mu[e])return e;var t=Mu[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in y_)return jx[e]=t[n];return e}var x_=my("animationend"),w_=my("animationiteration"),b_=my("animationstart"),v_=my("transitionend"),k_=new Map,SS="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 Dl(e,t){k_.set(e,t),Bc(t,[e])}for(var Cx=0;Cx<SS.length;Cx++){var Ex=SS[Cx],JL=Ex.toLowerCase(),QL=Ex[0].toUpperCase()+Ex.slice(1);Dl(JL,"on"+QL)}Dl(x_,"onAnimationEnd");Dl(w_,"onAnimationIteration");Dl(b_,"onAnimationStart");Dl("dblclick","onDoubleClick");Dl("focusin","onFocus");Dl("focusout","onBlur");Dl(v_,"onTransitionEnd");ld("onMouseEnter",["mouseout","mouseover"]);ld("onMouseLeave",["mouseout","mouseover"]);ld("onPointerEnter",["pointerout","pointerover"]);ld("onPointerLeave",["pointerout","pointerover"]);Bc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Bc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Bc("onBeforeInput",["compositionend","keypress","textInput","paste"]);Bc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Bc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Bc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var If="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(" "),ZL=new Set("cancel close invalid load scroll toggle".split(" ").concat(If));function NS(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,JM(r,t,void 0,e),e.currentTarget=null}function S_(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==o&&s.isPropagationStopped())break e;NS(s,l,d),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==o&&s.isPropagationStopped())break e;NS(s,l,d),o=c}}}if(ig)throw e=eb,ig=!1,eb=null,e}function Un(e,t){var n=t[ub];n===void 0&&(n=t[ub]=new Set);var r=e+"__bubble";n.has(r)||(N_(t,e,2,!1),n.add(r))}function _x(e,t,n){var r=0;t&&(r|=4),N_(n,e,r,t)}var Kh="_reactListening"+Math.random().toString(36).slice(2);function gp(e){if(!e[Kh]){e[Kh]=!0,IE.forEach(function(n){n!=="selectionchange"&&(ZL.has(n)||_x(n,!1,e),_x(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Kh]||(t[Kh]=!0,_x("selectionchange",!1,t))}}function N_(e,t,n,r){switch(a_(t)){case 1:var s=pL;break;case 4:s=hL;break;default:s=Xv}n=s.bind(null,t,n,e),s=void 0,!Zw||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 Ax(e,t,n,r,s){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var 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=gc(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}qE(function(){var d=o,p=Uv(n),u=[];e:{var f=k_.get(e);if(f!==void 0){var m=Qv,g=e;switch(e){case"keypress":if(Om(n)===0)break e;case"keydown":case"keyup":m=AL;break;case"focusin":g="focus",m=kx;break;case"focusout":g="blur",m=kx;break;case"beforeblur":case"afterblur":m=kx;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=fS;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=yL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=TL;break;case x_:case w_:case b_:m=bL;break;case v_:m=ML;break;case"scroll":m=mL;break;case"wheel":m=OL;break;case"copy":case"cut":case"paste":m=kL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=hS}var w=(t&4)!==0,k=!w&&e==="scroll",y=w?f!==null?f+"Capture":null:f;w=[];for(var b=d,x;b!==null;){x=b;var j=x.stateNode;if(x.tag===5&&j!==null&&(x=j,y!==null&&(j=up(b,y),j!=null&&w.push(yp(b,j,x)))),k)break;b=b.return}0<w.length&&(f=new m(f,g,null,n,p),u.push({event:f,listeners:w}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",f&&n!==Jw&&(g=n.relatedTarget||n.fromElement)&&(gc(g)||g[Ca]))break e;if((m||f)&&(f=p.window===p?p:(f=p.ownerDocument)?f.defaultView||f.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=d,g=g?gc(g):null,g!==null&&(k=Wc(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(w=fS,j="onMouseLeave",y="onMouseEnter",b="mouse",(e==="pointerout"||e==="pointerover")&&(w=hS,j="onPointerLeave",y="onPointerEnter",b="pointer"),k=m==null?f:Lu(m),x=g==null?f:Lu(g),f=new w(j,b+"leave",m,n,p),f.target=k,f.relatedTarget=x,j=null,gc(p)===d&&(w=new w(y,b+"enter",g,n,p),w.target=x,w.relatedTarget=k,j=w),k=j,m&&g)t:{for(w=m,y=g,b=0,x=w;x;x=xu(x))b++;for(x=0,j=y;j;j=xu(j))x++;for(;0<b-x;)w=xu(w),b--;for(;0<x-b;)y=xu(y),x--;for(;b--;){if(w===y||y!==null&&w===y.alternate)break t;w=xu(w),y=xu(y)}w=null}else w=null;m!==null&&jS(u,f,m,w,!1),g!==null&&k!==null&&jS(u,k,g,w,!0)}}e:{if(f=d?Lu(d):window,m=f.nodeName&&f.nodeName.toLowerCase(),m==="select"||m==="input"&&f.type==="file")var E=WL;else if(yS(f))if(p_)E=qL;else{E=KL;var N=VL}else(m=f.nodeName)&&m.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(E=UL);if(E&&(E=E(e,d))){f_(u,E,n,p);break e}N&&N(e,f,d),e==="focusout"&&(N=f._wrapperState)&&N.controlled&&f.type==="number"&&Uw(f,"number",f.value)}switch(N=d?Lu(d):window,e){case"focusin":(yS(N)||N.contentEditable==="true")&&(Ru=N,sb=d,Wf=null);break;case"focusout":Wf=sb=Ru=null;break;case"mousedown":ib=!0;break;case"contextmenu":case"mouseup":case"dragend":ib=!1,kS(u,n,p);break;case"selectionchange":if(XL)break;case"keydown":case"keyup":kS(u,n,p)}var T;if(e0)e:{switch(e){case"compositionstart":var $="onCompositionStart";break e;case"compositionend":$="onCompositionEnd";break e;case"compositionupdate":$="onCompositionUpdate";break e}$=void 0}else Tu?u_(e,n)&&($="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&($="onCompositionStart");$&&(c_&&n.locale!=="ko"&&(Tu||$!=="onCompositionStart"?$==="onCompositionEnd"&&Tu&&(T=l_()):(fl=p,Jv="value"in fl?fl.value:fl.textContent,Tu=!0)),N=ug(d,$),0<N.length&&($=new pS($,e,null,n,p),u.push({event:$,listeners:N}),T?$.data=T:(T=d_(n),T!==null&&($.data=T)))),(T=DL?FL(e,n):zL(e,n))&&(d=ug(d,"onBeforeInput"),0<d.length&&(p=new pS("onBeforeInput","beforeinput",null,n,p),u.push({event:p,listeners:d}),p.data=T))}S_(u,t)})}function yp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ug(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=up(e,n),o!=null&&r.unshift(yp(e,o,s)),o=up(e,t),o!=null&&r.push(yp(e,o,s))),e=e.return}return r}function xu(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function jS(e,t,n,r,s){for(var o=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=up(n,o),c!=null&&a.unshift(yp(n,c,l))):s||(c=up(n,o),c!=null&&a.push(yp(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var eO=/\r\n?/g,tO=/\u0000|\uFFFD/g;function CS(e){return(typeof e=="string"?e:""+e).replace(eO,`
38
- `).replace(tO,"")}function Uh(e,t,n){if(t=CS(t),CS(e)!==t&&n)throw Error(Re(425))}function dg(){}var ob=null,ab=null;function lb(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 cb=typeof setTimeout=="function"?setTimeout:void 0,nO=typeof clearTimeout=="function"?clearTimeout:void 0,ES=typeof Promise=="function"?Promise:void 0,rO=typeof queueMicrotask=="function"?queueMicrotask:typeof ES<"u"?function(e){return ES.resolve(null).then(e).catch(sO)}:cb;function sO(e){setTimeout(function(){throw e})}function Px(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),pp(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);pp(t)}function bl(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 _S(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 Td=Math.random().toString(36).slice(2),Oo="__reactFiber$"+Td,xp="__reactProps$"+Td,Ca="__reactContainer$"+Td,ub="__reactEvents$"+Td,iO="__reactListeners$"+Td,oO="__reactHandles$"+Td;function gc(e){var t=e[Oo];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ca]||n[Oo]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=_S(e);e!==null;){if(n=e[Oo])return n;e=_S(e)}return t}e=n,n=e.parentNode}return null}function Xp(e){return e=e[Oo]||e[Ca],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Lu(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Re(33))}function gy(e){return e[xp]||null}var db=[],Ou=-1;function Fl(e){return{current:e}}function Gn(e){0>Ou||(e.current=db[Ou],db[Ou]=null,Ou--)}function Dn(e,t){Ou++,db[Ou]=e.current,e.current=t}var Pl={},ms=Fl(Pl),Us=Fl(!1),_c=Pl;function cd(e,t){var n=e.type.contextTypes;if(!n)return Pl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qs(e){return e=e.childContextTypes,e!=null}function fg(){Gn(Us),Gn(ms)}function AS(e,t,n){if(ms.current!==Pl)throw Error(Re(168));Dn(ms,t),Dn(Us,n)}function j_(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(Re(108,VM(e)||"Unknown",s));return ur({},n,r)}function pg(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pl,_c=ms.current,Dn(ms,e),Dn(Us,Us.current),!0}function PS(e,t,n){var r=e.stateNode;if(!r)throw Error(Re(169));n?(e=j_(e,t,_c),r.__reactInternalMemoizedMergedChildContext=e,Gn(Us),Gn(ms),Dn(ms,e)):Gn(Us),Dn(Us,n)}var ma=null,yy=!1,Ix=!1;function C_(e){ma===null?ma=[e]:ma.push(e)}function aO(e){yy=!0,C_(e)}function zl(){if(!Ix&&ma!==null){Ix=!0;var e=0,t=vn;try{var n=ma;for(vn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ma=null,yy=!1}catch(s){throw ma!==null&&(ma=ma.slice(e+1)),JE(qv,zl),s}finally{vn=t,Ix=!1}}return null}var $u=[],Du=0,hg=null,mg=0,Si=[],Ni=0,Ac=null,xa=1,wa="";function uc(e,t){$u[Du++]=mg,$u[Du++]=hg,hg=e,mg=t}function E_(e,t,n){Si[Ni++]=xa,Si[Ni++]=wa,Si[Ni++]=Ac,Ac=e;var r=xa;e=wa;var s=32-no(r)-1;r&=~(1<<s),n+=1;var o=32-no(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,xa=1<<32-no(t)+s|n<<s|r,wa=o+e}else xa=1<<o|n<<s|r,wa=e}function n0(e){e.return!==null&&(uc(e,1),E_(e,1,0))}function r0(e){for(;e===hg;)hg=$u[--Du],$u[Du]=null,mg=$u[--Du],$u[Du]=null;for(;e===Ac;)Ac=Si[--Ni],Si[Ni]=null,wa=Si[--Ni],Si[Ni]=null,xa=Si[--Ni],Si[Ni]=null}var li=null,oi=null,rr=!1,Ji=null;function __(e,t){var n=Ei(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 IS(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,li=e,oi=bl(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,li=e,oi=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ac!==null?{id:xa,overflow:wa}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ei(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,li=e,oi=null,!0):!1;default:return!1}}function fb(e){return(e.mode&1)!==0&&(e.flags&128)===0}function pb(e){if(rr){var t=oi;if(t){var n=t;if(!IS(e,t)){if(fb(e))throw Error(Re(418));t=bl(n.nextSibling);var r=li;t&&IS(e,t)?__(r,n):(e.flags=e.flags&-4097|2,rr=!1,li=e)}}else{if(fb(e))throw Error(Re(418));e.flags=e.flags&-4097|2,rr=!1,li=e}}}function TS(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;li=e}function qh(e){if(e!==li)return!1;if(!rr)return TS(e),rr=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!lb(e.type,e.memoizedProps)),t&&(t=oi)){if(fb(e))throw A_(),Error(Re(418));for(;t;)__(e,t),t=bl(t.nextSibling)}if(TS(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Re(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){oi=bl(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}oi=null}}else oi=li?bl(e.stateNode.nextSibling):null;return!0}function A_(){for(var e=oi;e;)e=bl(e.nextSibling)}function ud(){oi=li=null,rr=!1}function s0(e){Ji===null?Ji=[e]:Ji.push(e)}var lO=Ta.ReactCurrentBatchConfig;function mf(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(Re(309));var r=n.stateNode}if(!r)throw Error(Re(147,e));var s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=s.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Re(284));if(!n._owner)throw Error(Re(290,e))}return e}function Yh(e,t){throw e=Object.prototype.toString.call(t),Error(Re(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function RS(e){var t=e._init;return t(e._payload)}function P_(e){function t(y,b){if(e){var x=y.deletions;x===null?(y.deletions=[b],y.flags|=16):x.push(b)}}function n(y,b){if(!e)return null;for(;b!==null;)t(y,b),b=b.sibling;return null}function r(y,b){for(y=new Map;b!==null;)b.key!==null?y.set(b.key,b):y.set(b.index,b),b=b.sibling;return y}function s(y,b){return y=Nl(y,b),y.index=0,y.sibling=null,y}function o(y,b,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<b?(y.flags|=2,b):x):(y.flags|=2,b)):(y.flags|=1048576,b)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,b,x,j){return b===null||b.tag!==6?(b=Dx(x,y.mode,j),b.return=y,b):(b=s(b,x),b.return=y,b)}function c(y,b,x,j){var E=x.type;return E===Iu?p(y,b,x.props.children,j,x.key):b!==null&&(b.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===ol&&RS(E)===b.type)?(j=s(b,x.props),j.ref=mf(y,b,x),j.return=y,j):(j=Wm(x.type,x.key,x.props,null,y.mode,j),j.ref=mf(y,b,x),j.return=y,j)}function d(y,b,x,j){return b===null||b.tag!==4||b.stateNode.containerInfo!==x.containerInfo||b.stateNode.implementation!==x.implementation?(b=Fx(x,y.mode,j),b.return=y,b):(b=s(b,x.children||[]),b.return=y,b)}function p(y,b,x,j,E){return b===null||b.tag!==7?(b=kc(x,y.mode,j,E),b.return=y,b):(b=s(b,x),b.return=y,b)}function u(y,b,x){if(typeof b=="string"&&b!==""||typeof b=="number")return b=Dx(""+b,y.mode,x),b.return=y,b;if(typeof b=="object"&&b!==null){switch(b.$$typeof){case $h:return x=Wm(b.type,b.key,b.props,null,y.mode,x),x.ref=mf(y,null,b),x.return=y,x;case Pu:return b=Fx(b,y.mode,x),b.return=y,b;case ol:var j=b._init;return u(y,j(b._payload),x)}if(Af(b)||uf(b))return b=kc(b,y.mode,x,null),b.return=y,b;Yh(y,b)}return null}function f(y,b,x,j){var E=b!==null?b.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return E!==null?null:l(y,b,""+x,j);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case $h:return x.key===E?c(y,b,x,j):null;case Pu:return x.key===E?d(y,b,x,j):null;case ol:return E=x._init,f(y,b,E(x._payload),j)}if(Af(x)||uf(x))return E!==null?null:p(y,b,x,j,null);Yh(y,x)}return null}function m(y,b,x,j,E){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(x)||null,l(b,y,""+j,E);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case $h:return y=y.get(j.key===null?x:j.key)||null,c(b,y,j,E);case Pu:return y=y.get(j.key===null?x:j.key)||null,d(b,y,j,E);case ol:var N=j._init;return m(y,b,x,N(j._payload),E)}if(Af(j)||uf(j))return y=y.get(x)||null,p(b,y,j,E,null);Yh(b,j)}return null}function g(y,b,x,j){for(var E=null,N=null,T=b,$=b=0,z=null;T!==null&&$<x.length;$++){T.index>$?(z=T,T=null):z=T.sibling;var K=f(y,T,x[$],j);if(K===null){T===null&&(T=z);break}e&&T&&K.alternate===null&&t(y,T),b=o(K,b,$),N===null?E=K:N.sibling=K,N=K,T=z}if($===x.length)return n(y,T),rr&&uc(y,$),E;if(T===null){for(;$<x.length;$++)T=u(y,x[$],j),T!==null&&(b=o(T,b,$),N===null?E=T:N.sibling=T,N=T);return rr&&uc(y,$),E}for(T=r(y,T);$<x.length;$++)z=m(T,y,$,x[$],j),z!==null&&(e&&z.alternate!==null&&T.delete(z.key===null?$:z.key),b=o(z,b,$),N===null?E=z:N.sibling=z,N=z);return e&&T.forEach(function(B){return t(y,B)}),rr&&uc(y,$),E}function w(y,b,x,j){var E=uf(x);if(typeof E!="function")throw Error(Re(150));if(x=E.call(x),x==null)throw Error(Re(151));for(var N=E=null,T=b,$=b=0,z=null,K=x.next();T!==null&&!K.done;$++,K=x.next()){T.index>$?(z=T,T=null):z=T.sibling;var B=f(y,T,K.value,j);if(B===null){T===null&&(T=z);break}e&&T&&B.alternate===null&&t(y,T),b=o(B,b,$),N===null?E=B:N.sibling=B,N=B,T=z}if(K.done)return n(y,T),rr&&uc(y,$),E;if(T===null){for(;!K.done;$++,K=x.next())K=u(y,K.value,j),K!==null&&(b=o(K,b,$),N===null?E=K:N.sibling=K,N=K);return rr&&uc(y,$),E}for(T=r(y,T);!K.done;$++,K=x.next())K=m(T,y,$,K.value,j),K!==null&&(e&&K.alternate!==null&&T.delete(K.key===null?$:K.key),b=o(K,b,$),N===null?E=K:N.sibling=K,N=K);return e&&T.forEach(function(L){return t(y,L)}),rr&&uc(y,$),E}function k(y,b,x,j){if(typeof x=="object"&&x!==null&&x.type===Iu&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case $h:e:{for(var E=x.key,N=b;N!==null;){if(N.key===E){if(E=x.type,E===Iu){if(N.tag===7){n(y,N.sibling),b=s(N,x.props.children),b.return=y,y=b;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===ol&&RS(E)===N.type){n(y,N.sibling),b=s(N,x.props),b.ref=mf(y,N,x),b.return=y,y=b;break e}n(y,N);break}else t(y,N);N=N.sibling}x.type===Iu?(b=kc(x.props.children,y.mode,j,x.key),b.return=y,y=b):(j=Wm(x.type,x.key,x.props,null,y.mode,j),j.ref=mf(y,b,x),j.return=y,y=j)}return a(y);case Pu:e:{for(N=x.key;b!==null;){if(b.key===N)if(b.tag===4&&b.stateNode.containerInfo===x.containerInfo&&b.stateNode.implementation===x.implementation){n(y,b.sibling),b=s(b,x.children||[]),b.return=y,y=b;break e}else{n(y,b);break}else t(y,b);b=b.sibling}b=Fx(x,y.mode,j),b.return=y,y=b}return a(y);case ol:return N=x._init,k(y,b,N(x._payload),j)}if(Af(x))return g(y,b,x,j);if(uf(x))return w(y,b,x,j);Yh(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,b!==null&&b.tag===6?(n(y,b.sibling),b=s(b,x),b.return=y,y=b):(n(y,b),b=Dx(x,y.mode,j),b.return=y,y=b),a(y)):n(y,b)}return k}var dd=P_(!0),I_=P_(!1),gg=Fl(null),yg=null,Fu=null,i0=null;function o0(){i0=Fu=yg=null}function a0(e){var t=gg.current;Gn(gg),e._currentValue=t}function hb(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 Zu(e,t){yg=e,i0=Fu=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Hs=!0),e.firstContext=null)}function Ai(e){var t=e._currentValue;if(i0!==e)if(e={context:e,memoizedValue:t,next:null},Fu===null){if(yg===null)throw Error(Re(308));Fu=e,yg.dependencies={lanes:0,firstContext:e}}else Fu=Fu.next=e;return t}var yc=null;function l0(e){yc===null?yc=[e]:yc.push(e)}function T_(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,l0(t)):(n.next=s.next,s.next=n),t.interleaved=n,Ea(e,r)}function Ea(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 al=!1;function c0(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function R_(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 Sa(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vl(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,rn&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Ea(e,n)}return s=r.interleaved,s===null?(t.next=t,l0(r)):(t.next=s.next,s.next=t),r.interleaved=t,Ea(e,n)}function $m(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,Yv(e,n)}}function MS(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function xg(e,t,n,r){var s=e.updateQueue;al=!1;var o=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?o=d:a.next=d,a=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==a&&(l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=c))}if(o!==null){var u=s.baseState;a=0,p=d=c=null,l=o;do{var f=l.lane,m=l.eventTime;if((r&f)===f){p!==null&&(p=p.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,w=l;switch(f=t,m=n,w.tag){case 1:if(g=w.payload,typeof g=="function"){u=g.call(m,u,f);break e}u=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=w.payload,f=typeof g=="function"?g.call(m,u,f):g,f==null)break e;u=ur({},u,f);break e;case 2:al=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else m={eventTime:m,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(d=p=m,c=u):p=p.next=m,a|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(p===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=p,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);Ic|=a,e.lanes=a,e.memoizedState=u}}function LS(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(Re(191,s));s.call(r)}}}var Jp={},Ho=Fl(Jp),wp=Fl(Jp),bp=Fl(Jp);function xc(e){if(e===Jp)throw Error(Re(174));return e}function u0(e,t){switch(Dn(bp,t),Dn(wp,e),Dn(Ho,Jp),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Yw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Yw(t,e)}Gn(Ho),Dn(Ho,t)}function fd(){Gn(Ho),Gn(wp),Gn(bp)}function M_(e){xc(bp.current);var t=xc(Ho.current),n=Yw(t,e.type);t!==n&&(Dn(wp,e),Dn(Ho,n))}function d0(e){wp.current===e&&(Gn(Ho),Gn(wp))}var lr=Fl(0);function wg(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 Tx=[];function f0(){for(var e=0;e<Tx.length;e++)Tx[e]._workInProgressVersionPrimary=null;Tx.length=0}var Dm=Ta.ReactCurrentDispatcher,Rx=Ta.ReactCurrentBatchConfig,Pc=0,cr=null,Fr=null,Gr=null,bg=!1,Vf=!1,vp=0,cO=0;function ds(){throw Error(Re(321))}function p0(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!so(e[n],t[n]))return!1;return!0}function h0(e,t,n,r,s,o){if(Pc=o,cr=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Dm.current=e===null||e.memoizedState===null?pO:hO,e=n(r,s),Vf){o=0;do{if(Vf=!1,vp=0,25<=o)throw Error(Re(301));o+=1,Gr=Fr=null,t.updateQueue=null,Dm.current=mO,e=n(r,s)}while(Vf)}if(Dm.current=vg,t=Fr!==null&&Fr.next!==null,Pc=0,Gr=Fr=cr=null,bg=!1,t)throw Error(Re(300));return e}function m0(){var e=vp!==0;return vp=0,e}function Io(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gr===null?cr.memoizedState=Gr=e:Gr=Gr.next=e,Gr}function Pi(){if(Fr===null){var e=cr.alternate;e=e!==null?e.memoizedState:null}else e=Fr.next;var t=Gr===null?cr.memoizedState:Gr.next;if(t!==null)Gr=t,Fr=e;else{if(e===null)throw Error(Re(310));Fr=e,e={memoizedState:Fr.memoizedState,baseState:Fr.baseState,baseQueue:Fr.baseQueue,queue:Fr.queue,next:null},Gr===null?cr.memoizedState=Gr=e:Gr=Gr.next=e}return Gr}function kp(e,t){return typeof t=="function"?t(e):t}function Mx(e){var t=Pi(),n=t.queue;if(n===null)throw Error(Re(311));n.lastRenderedReducer=e;var r=Fr,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=a=null,c=null,d=o;do{var p=d.lane;if((Pc&p)===p)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:p,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=u,a=r):c=c.next=u,cr.lanes|=p,Ic|=p}d=d.next}while(d!==null&&d!==o);c===null?a=r:c.next=l,so(r,t.memoizedState)||(Hs=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do o=s.lane,cr.lanes|=o,Ic|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Lx(e){var t=Pi(),n=t.queue;if(n===null)throw Error(Re(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do o=e(o,a.action),a=a.next;while(a!==s);so(o,t.memoizedState)||(Hs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function L_(){}function O_(e,t){var n=cr,r=Pi(),s=t(),o=!so(r.memoizedState,s);if(o&&(r.memoizedState=s,Hs=!0),r=r.queue,g0(F_.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Gr!==null&&Gr.memoizedState.tag&1){if(n.flags|=2048,Sp(9,D_.bind(null,n,r,s,t),void 0,null),Jr===null)throw Error(Re(349));Pc&30||$_(n,t,s)}return s}function $_(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=cr.updateQueue,t===null?(t={lastEffect:null,stores:null},cr.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function D_(e,t,n,r){t.value=n,t.getSnapshot=r,z_(t)&&H_(e)}function F_(e,t,n){return n(function(){z_(t)&&H_(e)})}function z_(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!so(e,n)}catch{return!0}}function H_(e){var t=Ea(e,1);t!==null&&ro(t,e,1,-1)}function OS(e){var t=Io();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:kp,lastRenderedState:e},t.queue=e,e=e.dispatch=fO.bind(null,cr,e),[t.memoizedState,e]}function Sp(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=cr.updateQueue,t===null?(t={lastEffect:null,stores:null},cr.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 B_(){return Pi().memoizedState}function Fm(e,t,n,r){var s=Io();cr.flags|=e,s.memoizedState=Sp(1|t,n,void 0,r===void 0?null:r)}function xy(e,t,n,r){var s=Pi();r=r===void 0?null:r;var o=void 0;if(Fr!==null){var a=Fr.memoizedState;if(o=a.destroy,r!==null&&p0(r,a.deps)){s.memoizedState=Sp(t,n,o,r);return}}cr.flags|=e,s.memoizedState=Sp(1|t,n,o,r)}function $S(e,t){return Fm(8390656,8,e,t)}function g0(e,t){return xy(2048,8,e,t)}function W_(e,t){return xy(4,2,e,t)}function V_(e,t){return xy(4,4,e,t)}function K_(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 U_(e,t,n){return n=n!=null?n.concat([e]):null,xy(4,4,K_.bind(null,t,e),n)}function y0(){}function q_(e,t){var n=Pi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&p0(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Y_(e,t){var n=Pi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&p0(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function G_(e,t,n){return Pc&21?(so(n,t)||(n=e_(),cr.lanes|=n,Ic|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Hs=!0),e.memoizedState=n)}function uO(e,t){var n=vn;vn=n!==0&&4>n?n:4,e(!0);var r=Rx.transition;Rx.transition={};try{e(!1),t()}finally{vn=n,Rx.transition=r}}function X_(){return Pi().memoizedState}function dO(e,t,n){var r=Sl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},J_(e))Q_(t,n);else if(n=T_(e,t,n,r),n!==null){var s=Cs();ro(n,e,r,s),Z_(n,t,r)}}function fO(e,t,n){var r=Sl(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(J_(e))Q_(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(s.hasEagerState=!0,s.eagerState=l,so(l,a)){var c=t.interleaved;c===null?(s.next=s,l0(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=T_(e,t,s,r),n!==null&&(s=Cs(),ro(n,e,r,s),Z_(n,t,r))}}function J_(e){var t=e.alternate;return e===cr||t!==null&&t===cr}function Q_(e,t){Vf=bg=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Z_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Yv(e,n)}}var vg={readContext:Ai,useCallback:ds,useContext:ds,useEffect:ds,useImperativeHandle:ds,useInsertionEffect:ds,useLayoutEffect:ds,useMemo:ds,useReducer:ds,useRef:ds,useState:ds,useDebugValue:ds,useDeferredValue:ds,useTransition:ds,useMutableSource:ds,useSyncExternalStore:ds,useId:ds,unstable_isNewReconciler:!1},pO={readContext:Ai,useCallback:function(e,t){return Io().memoizedState=[e,t===void 0?null:t],e},useContext:Ai,useEffect:$S,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fm(4194308,4,K_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fm(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fm(4,2,e,t)},useMemo:function(e,t){var n=Io();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Io();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=dO.bind(null,cr,e),[r.memoizedState,e]},useRef:function(e){var t=Io();return e={current:e},t.memoizedState=e},useState:OS,useDebugValue:y0,useDeferredValue:function(e){return Io().memoizedState=e},useTransition:function(){var e=OS(!1),t=e[0];return e=uO.bind(null,e[1]),Io().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=cr,s=Io();if(rr){if(n===void 0)throw Error(Re(407));n=n()}else{if(n=t(),Jr===null)throw Error(Re(349));Pc&30||$_(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,$S(F_.bind(null,r,o,e),[e]),r.flags|=2048,Sp(9,D_.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Io(),t=Jr.identifierPrefix;if(rr){var n=wa,r=xa;n=(r&~(1<<32-no(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=vp++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=cO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},hO={readContext:Ai,useCallback:q_,useContext:Ai,useEffect:g0,useImperativeHandle:U_,useInsertionEffect:W_,useLayoutEffect:V_,useMemo:Y_,useReducer:Mx,useRef:B_,useState:function(){return Mx(kp)},useDebugValue:y0,useDeferredValue:function(e){var t=Pi();return G_(t,Fr.memoizedState,e)},useTransition:function(){var e=Mx(kp)[0],t=Pi().memoizedState;return[e,t]},useMutableSource:L_,useSyncExternalStore:O_,useId:X_,unstable_isNewReconciler:!1},mO={readContext:Ai,useCallback:q_,useContext:Ai,useEffect:g0,useImperativeHandle:U_,useInsertionEffect:W_,useLayoutEffect:V_,useMemo:Y_,useReducer:Lx,useRef:B_,useState:function(){return Lx(kp)},useDebugValue:y0,useDeferredValue:function(e){var t=Pi();return Fr===null?t.memoizedState=e:G_(t,Fr.memoizedState,e)},useTransition:function(){var e=Lx(kp)[0],t=Pi().memoizedState;return[e,t]},useMutableSource:L_,useSyncExternalStore:O_,useId:X_,unstable_isNewReconciler:!1};function Yi(e,t){if(e&&e.defaultProps){t=ur({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function mb(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ur({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var wy={isMounted:function(e){return(e=e._reactInternals)?Wc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Cs(),s=Sl(e),o=Sa(r,s);o.payload=t,n!=null&&(o.callback=n),t=vl(e,o,s),t!==null&&(ro(t,e,s,r),$m(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Cs(),s=Sl(e),o=Sa(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=vl(e,o,s),t!==null&&(ro(t,e,s,r),$m(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Cs(),r=Sl(e),s=Sa(n,r);s.tag=2,t!=null&&(s.callback=t),t=vl(e,s,r),t!==null&&(ro(t,e,r,n),$m(t,e,r))}};function DS(e,t,n,r,s,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!mp(n,r)||!mp(s,o):!0}function eA(e,t,n){var r=!1,s=Pl,o=t.contextType;return typeof o=="object"&&o!==null?o=Ai(o):(s=qs(t)?_c:ms.current,r=t.contextTypes,o=(r=r!=null)?cd(e,s):Pl),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=wy,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function FS(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&&wy.enqueueReplaceState(t,t.state,null)}function gb(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},c0(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Ai(o):(o=qs(t)?_c:ms.current,s.context=cd(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(mb(e,t,o,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&wy.enqueueReplaceState(s,s.state,null),xg(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function pd(e,t){try{var n="",r=t;do n+=WM(r),r=r.return;while(r);var s=n}catch(o){s=`
39
- Error generating stack: `+o.message+`
40
- `+o.stack}return{value:e,source:t,stack:s,digest:null}}function Ox(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function yb(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var gO=typeof WeakMap=="function"?WeakMap:Map;function tA(e,t,n){n=Sa(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Sg||(Sg=!0,Eb=r),yb(e,t)},n}function nA(e,t,n){n=Sa(-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(){yb(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){yb(e,t),typeof r!="function"&&(kl===null?kl=new Set([this]):kl.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function zS(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new gO;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=PO.bind(null,e,t,n),t.then(e,e))}function HS(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 BS(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=Sa(-1,1),t.tag=2,vl(n,t,1))),n.lanes|=1),e)}var yO=Ta.ReactCurrentOwner,Hs=!1;function Ss(e,t,n,r){t.child=e===null?I_(t,null,n,r):dd(t,e.child,n,r)}function WS(e,t,n,r,s){n=n.render;var o=t.ref;return Zu(t,s),r=h0(e,t,n,r,o,s),n=m0(),e!==null&&!Hs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_a(e,t,s)):(rr&&n&&n0(t),t.flags|=1,Ss(e,t,r,s),t.child)}function VS(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!j0(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,rA(e,t,o,r,s)):(e=Wm(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:mp,n(a,r)&&e.ref===t.ref)return _a(e,t,s)}return t.flags|=1,e=Nl(o,r),e.ref=t.ref,e.return=t,t.child=e}function rA(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(mp(o,r)&&e.ref===t.ref)if(Hs=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Hs=!0);else return t.lanes=e.lanes,_a(e,t,s)}return xb(e,t,n,r,s)}function sA(e,t,n){var r=t.pendingProps,s=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dn(Hu,ri),ri|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Dn(Hu,ri),ri|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,Dn(Hu,ri),ri|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,Dn(Hu,ri),ri|=r;return Ss(e,t,s,n),t.child}function iA(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function xb(e,t,n,r,s){var o=qs(n)?_c:ms.current;return o=cd(t,o),Zu(t,s),n=h0(e,t,n,r,o,s),r=m0(),e!==null&&!Hs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_a(e,t,s)):(rr&&r&&n0(t),t.flags|=1,Ss(e,t,n,s),t.child)}function KS(e,t,n,r,s){if(qs(n)){var o=!0;pg(t)}else o=!1;if(Zu(t,s),t.stateNode===null)zm(e,t),eA(t,n,r),gb(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=Ai(d):(d=qs(n)?_c:ms.current,d=cd(t,d));var p=n.getDerivedStateFromProps,u=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function";u||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&FS(t,a,r,d),al=!1;var f=t.memoizedState;a.state=f,xg(t,r,a,s),c=t.memoizedState,l!==r||f!==c||Us.current||al?(typeof p=="function"&&(mb(t,n,p,r),c=t.memoizedState),(l=al||DS(t,n,l,r,f,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,R_(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Yi(t.type,l),a.props=d,u=t.pendingProps,f=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ai(c):(c=qs(n)?_c:ms.current,c=cd(t,c));var m=n.getDerivedStateFromProps;(p=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==u||f!==c)&&FS(t,a,r,c),al=!1,f=t.memoizedState,a.state=f,xg(t,r,a,s);var g=t.memoizedState;l!==u||f!==g||Us.current||al?(typeof m=="function"&&(mb(t,n,m,r),g=t.memoizedState),(d=al||DS(t,n,d,r,f,g,c)||!1)?(p||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),a.props=r,a.state=g,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return wb(e,t,n,r,o,s)}function wb(e,t,n,r,s,o){iA(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&PS(t,n,!1),_a(e,t,o);r=t.stateNode,yO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=dd(t,e.child,null,o),t.child=dd(t,null,l,o)):Ss(e,t,l,o),t.memoizedState=r.state,s&&PS(t,n,!0),t.child}function oA(e){var t=e.stateNode;t.pendingContext?AS(e,t.pendingContext,t.pendingContext!==t.context):t.context&&AS(e,t.context,!1),u0(e,t.containerInfo)}function US(e,t,n,r,s){return ud(),s0(s),t.flags|=256,Ss(e,t,n,r),t.child}var bb={dehydrated:null,treeContext:null,retryLane:0};function vb(e){return{baseLanes:e,cachePool:null,transitions:null}}function aA(e,t,n){var r=t.pendingProps,s=lr.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),Dn(lr,s&1),e===null)return pb(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=ky(a,r,0,null),e=kc(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=vb(n),t.memoizedState=bb,e):x0(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return xO(e,t,a,r,l,s,n);if(o){o=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=Nl(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=Nl(l,o):(o=kc(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?vb(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=bb,r}return o=e.child,e=o.sibling,r=Nl(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function x0(e,t){return t=ky({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Gh(e,t,n,r){return r!==null&&s0(r),dd(t,e.child,null,n),e=x0(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xO(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=Ox(Error(Re(422))),Gh(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=ky({mode:"visible",children:r.children},s,0,null),o=kc(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&dd(t,e.child,null,a),t.child.memoizedState=vb(a),t.memoizedState=bb,o);if(!(t.mode&1))return Gh(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Re(419)),r=Ox(o,r,void 0),Gh(e,t,a,r)}if(l=(a&e.childLanes)!==0,Hs||l){if(r=Jr,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,Ea(e,s),ro(r,e,s,-1))}return N0(),r=Ox(Error(Re(421))),Gh(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=IO.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,oi=bl(s.nextSibling),li=t,rr=!0,Ji=null,e!==null&&(Si[Ni++]=xa,Si[Ni++]=wa,Si[Ni++]=Ac,xa=e.id,wa=e.overflow,Ac=t),t=x0(t,r.children),t.flags|=4096,t)}function qS(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),hb(e.return,t,n)}function $x(e,t,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function lA(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Ss(e,t,r.children,n),r=lr.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&&qS(e,n,t);else if(e.tag===19)qS(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Dn(lr,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&&wg(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),$x(t,!1,s,n,o);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&wg(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}$x(t,!0,n,null,o);break;case"together":$x(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function zm(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function _a(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(Re(153));if(t.child!==null){for(e=t.child,n=Nl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Nl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function wO(e,t,n){switch(t.tag){case 3:oA(t),ud();break;case 5:M_(t);break;case 1:qs(t.type)&&pg(t);break;case 4:u0(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;Dn(gg,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Dn(lr,lr.current&1),t.flags|=128,null):n&t.child.childLanes?aA(e,t,n):(Dn(lr,lr.current&1),e=_a(e,t,n),e!==null?e.sibling:null);Dn(lr,lr.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return lA(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),Dn(lr,lr.current),r)break;return null;case 22:case 23:return t.lanes=0,sA(e,t,n)}return _a(e,t,n)}var cA,kb,uA,dA;cA=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}};kb=function(){};uA=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,xc(Ho.current);var o=null;switch(n){case"input":s=Vw(e,s),r=Vw(e,r),o=[];break;case"select":s=ur({},s,{value:void 0}),r=ur({},r,{value:void 0}),o=[];break;case"textarea":s=qw(e,s),r=qw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=dg)}Gw(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"&&(lp.hasOwnProperty(d)?o||(o=[]):(o=o||[]).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||(o||(o=[]),o.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(lp.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Un("scroll",e),o||l===c||(o=[])):(o=o||[]).push(d,c))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};dA=function(e,t,n,r){n!==r&&(t.flags|=4)};function gf(e,t){if(!rr)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 fs(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 bO(e,t,n){var r=t.pendingProps;switch(r0(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fs(t),null;case 1:return qs(t.type)&&fg(),fs(t),null;case 3:return r=t.stateNode,fd(),Gn(Us),Gn(ms),f0(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(qh(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ji!==null&&(Pb(Ji),Ji=null))),kb(e,t),fs(t),null;case 5:d0(t);var s=xc(bp.current);if(n=t.type,e!==null&&t.stateNode!=null)uA(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Re(166));return fs(t),null}if(e=xc(Ho.current),qh(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Oo]=t,r[xp]=o,e=(t.mode&1)!==0,n){case"dialog":Un("cancel",r),Un("close",r);break;case"iframe":case"object":case"embed":Un("load",r);break;case"video":case"audio":for(s=0;s<If.length;s++)Un(If[s],r);break;case"source":Un("error",r);break;case"img":case"image":case"link":Un("error",r),Un("load",r);break;case"details":Un("toggle",r);break;case"input":nS(r,o),Un("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Un("invalid",r);break;case"textarea":sS(r,o),Un("invalid",r)}Gw(n,o),s=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&Uh(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Uh(r.textContent,l,e),s=["children",""+l]):lp.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Un("scroll",r)}switch(n){case"input":Dh(r),rS(r,o,!0);break;case"textarea":Dh(r),iS(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=dg)}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=FE(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[Oo]=t,e[xp]=r,cA(e,t,!1,!1),t.stateNode=e;e:{switch(a=Xw(n,r),n){case"dialog":Un("cancel",e),Un("close",e),s=r;break;case"iframe":case"object":case"embed":Un("load",e),s=r;break;case"video":case"audio":for(s=0;s<If.length;s++)Un(If[s],e);s=r;break;case"source":Un("error",e),s=r;break;case"img":case"image":case"link":Un("error",e),Un("load",e),s=r;break;case"details":Un("toggle",e),s=r;break;case"input":nS(e,r),s=Vw(e,r),Un("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=ur({},r,{value:void 0}),Un("invalid",e);break;case"textarea":sS(e,r),s=qw(e,r),Un("invalid",e);break;default:s=r}Gw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?BE(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&zE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&cp(e,c):typeof c=="number"&&cp(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(lp.hasOwnProperty(o)?c!=null&&o==="onScroll"&&Un("scroll",e):c!=null&&Bv(e,o,c,a))}switch(n){case"input":Dh(e),rS(e,r,!1);break;case"textarea":Dh(e),iS(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Al(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Gu(e,!!r.multiple,o,!1):r.defaultValue!=null&&Gu(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=dg)}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 fs(t),null;case 6:if(e&&t.stateNode!=null)dA(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Re(166));if(n=xc(bp.current),xc(Ho.current),qh(t)){if(r=t.stateNode,n=t.memoizedProps,r[Oo]=t,(o=r.nodeValue!==n)&&(e=li,e!==null))switch(e.tag){case 3:Uh(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Uh(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Oo]=t,t.stateNode=r}return fs(t),null;case 13:if(Gn(lr),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rr&&oi!==null&&t.mode&1&&!(t.flags&128))A_(),ud(),t.flags|=98560,o=!1;else if(o=qh(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Re(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Re(317));o[Oo]=t}else ud(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;fs(t),o=!1}else Ji!==null&&(Pb(Ji),Ji=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||lr.current&1?Hr===0&&(Hr=3):N0())),t.updateQueue!==null&&(t.flags|=4),fs(t),null);case 4:return fd(),kb(e,t),e===null&&gp(t.stateNode.containerInfo),fs(t),null;case 10:return a0(t.type._context),fs(t),null;case 17:return qs(t.type)&&fg(),fs(t),null;case 19:if(Gn(lr),o=t.memoizedState,o===null)return fs(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)gf(o,!1);else{if(Hr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=wg(e),a!==null){for(t.flags|=128,gf(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Dn(lr,lr.current&1|2),t.child}e=e.sibling}o.tail!==null&&jr()>hd&&(t.flags|=128,r=!0,gf(o,!1),t.lanes=4194304)}else{if(!r)if(e=wg(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),gf(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!rr)return fs(t),null}else 2*jr()-o.renderingStartTime>hd&&n!==1073741824&&(t.flags|=128,r=!0,gf(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=jr(),t.sibling=null,n=lr.current,Dn(lr,r?n&1|2:n&1),t):(fs(t),null);case 22:case 23:return S0(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ri&1073741824&&(fs(t),t.subtreeFlags&6&&(t.flags|=8192)):fs(t),null;case 24:return null;case 25:return null}throw Error(Re(156,t.tag))}function vO(e,t){switch(r0(t),t.tag){case 1:return qs(t.type)&&fg(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return fd(),Gn(Us),Gn(ms),f0(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return d0(t),null;case 13:if(Gn(lr),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Re(340));ud()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Gn(lr),null;case 4:return fd(),null;case 10:return a0(t.type._context),null;case 22:case 23:return S0(),null;case 24:return null;default:return null}}var Xh=!1,ps=!1,kO=typeof WeakSet=="function"?WeakSet:Set,Je=null;function zu(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){hr(e,t,r)}else n.current=null}function Sb(e,t,n){try{n()}catch(r){hr(e,t,r)}}var YS=!1;function SO(e,t){if(ob=lg,e=g_(),t0(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,p=0,u=e,f=null;t:for(;;){for(var m;u!==n||s!==0&&u.nodeType!==3||(l=a+s),u!==o||r!==0&&u.nodeType!==3||(c=a+r),u.nodeType===3&&(a+=u.nodeValue.length),(m=u.firstChild)!==null;)f=u,u=m;for(;;){if(u===e)break t;if(f===n&&++d===s&&(l=a),f===o&&++p===r&&(c=a),(m=u.nextSibling)!==null)break;u=f,f=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(ab={focusedElem:e,selectionRange:n},lg=!1,Je=t;Je!==null;)if(t=Je,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Je=e;else for(;Je!==null;){t=Je;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 w=g.memoizedProps,k=g.memoizedState,y=t.stateNode,b=y.getSnapshotBeforeUpdate(t.elementType===t.type?w:Yi(t.type,w),k);y.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Re(163))}}catch(j){hr(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Je=e;break}Je=t.return}return g=YS,YS=!1,g}function Kf(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&Sb(t,n,o)}s=s.next}while(s!==r)}}function by(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 Nb(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 fA(e){var t=e.alternate;t!==null&&(e.alternate=null,fA(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Oo],delete t[xp],delete t[ub],delete t[iO],delete t[oO])),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 pA(e){return e.tag===5||e.tag===3||e.tag===4}function GS(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||pA(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 jb(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=dg));else if(r!==4&&(e=e.child,e!==null))for(jb(e,t,n),e=e.sibling;e!==null;)jb(e,t,n),e=e.sibling}function Cb(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(Cb(e,t,n),e=e.sibling;e!==null;)Cb(e,t,n),e=e.sibling}var ts=null,Gi=!1;function el(e,t,n){for(n=n.child;n!==null;)hA(e,t,n),n=n.sibling}function hA(e,t,n){if(zo&&typeof zo.onCommitFiberUnmount=="function")try{zo.onCommitFiberUnmount(fy,n)}catch{}switch(n.tag){case 5:ps||zu(n,t);case 6:var r=ts,s=Gi;ts=null,el(e,t,n),ts=r,Gi=s,ts!==null&&(Gi?(e=ts,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ts.removeChild(n.stateNode));break;case 18:ts!==null&&(Gi?(e=ts,n=n.stateNode,e.nodeType===8?Px(e.parentNode,n):e.nodeType===1&&Px(e,n),pp(e)):Px(ts,n.stateNode));break;case 4:r=ts,s=Gi,ts=n.stateNode.containerInfo,Gi=!0,el(e,t,n),ts=r,Gi=s;break;case 0:case 11:case 14:case 15:if(!ps&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&Sb(n,t,a),s=s.next}while(s!==r)}el(e,t,n);break;case 1:if(!ps&&(zu(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){hr(n,t,l)}el(e,t,n);break;case 21:el(e,t,n);break;case 22:n.mode&1?(ps=(r=ps)||n.memoizedState!==null,el(e,t,n),ps=r):el(e,t,n);break;default:el(e,t,n)}}function XS(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new kO),t.forEach(function(r){var s=TO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Vi(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:ts=l.stateNode,Gi=!1;break e;case 3:ts=l.stateNode.containerInfo,Gi=!0;break e;case 4:ts=l.stateNode.containerInfo,Gi=!0;break e}l=l.return}if(ts===null)throw Error(Re(160));hA(o,a,s),ts=null,Gi=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){hr(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)mA(t,e),t=t.sibling}function mA(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Vi(t,e),Ao(e),r&4){try{Kf(3,e,e.return),by(3,e)}catch(w){hr(e,e.return,w)}try{Kf(5,e,e.return)}catch(w){hr(e,e.return,w)}}break;case 1:Vi(t,e),Ao(e),r&512&&n!==null&&zu(n,n.return);break;case 5:if(Vi(t,e),Ao(e),r&512&&n!==null&&zu(n,n.return),e.flags&32){var s=e.stateNode;try{cp(s,"")}catch(w){hr(e,e.return,w)}}if(r&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&$E(s,o),Xw(l,a);var d=Xw(l,o);for(a=0;a<c.length;a+=2){var p=c[a],u=c[a+1];p==="style"?BE(s,u):p==="dangerouslySetInnerHTML"?zE(s,u):p==="children"?cp(s,u):Bv(s,p,u,d)}switch(l){case"input":Kw(s,o);break;case"textarea":DE(s,o);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m!=null?Gu(s,!!o.multiple,m,!1):f!==!!o.multiple&&(o.defaultValue!=null?Gu(s,!!o.multiple,o.defaultValue,!0):Gu(s,!!o.multiple,o.multiple?[]:"",!1))}s[xp]=o}catch(w){hr(e,e.return,w)}}break;case 6:if(Vi(t,e),Ao(e),r&4){if(e.stateNode===null)throw Error(Re(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(w){hr(e,e.return,w)}}break;case 3:if(Vi(t,e),Ao(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{pp(t.containerInfo)}catch(w){hr(e,e.return,w)}break;case 4:Vi(t,e),Ao(e);break;case 13:Vi(t,e),Ao(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(v0=jr())),r&4&&XS(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(ps=(d=ps)||p,Vi(t,e),ps=d):Vi(t,e),Ao(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!p&&e.mode&1)for(Je=e,p=e.child;p!==null;){for(u=Je=p;Je!==null;){switch(f=Je,m=f.child,f.tag){case 0:case 11:case 14:case 15:Kf(4,f,f.return);break;case 1:zu(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(w){hr(r,n,w)}}break;case 5:zu(f,f.return);break;case 22:if(f.memoizedState!==null){QS(u);continue}}m!==null?(m.return=f,Je=m):QS(u)}p=p.sibling}e:for(p=null,u=e;;){if(u.tag===5){if(p===null){p=u;try{s=u.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=u.stateNode,c=u.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=HE("display",a))}catch(w){hr(e,e.return,w)}}}else if(u.tag===6){if(p===null)try{u.stateNode.nodeValue=d?"":u.memoizedProps}catch(w){hr(e,e.return,w)}}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;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Vi(t,e),Ao(e),r&4&&XS(e);break;case 21:break;default:Vi(t,e),Ao(e)}}function Ao(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(pA(n)){var r=n;break e}n=n.return}throw Error(Re(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(cp(s,""),r.flags&=-33);var o=GS(e);Cb(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=GS(e);jb(e,l,a);break;default:throw Error(Re(161))}}catch(c){hr(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function NO(e,t,n){Je=e,gA(e)}function gA(e,t,n){for(var r=(e.mode&1)!==0;Je!==null;){var s=Je,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Xh;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||ps;l=Xh;var d=ps;if(Xh=a,(ps=c)&&!d)for(Je=s;Je!==null;)a=Je,c=a.child,a.tag===22&&a.memoizedState!==null?ZS(s):c!==null?(c.return=a,Je=c):ZS(s);for(;o!==null;)Je=o,gA(o),o=o.sibling;Je=s,Xh=l,ps=d}JS(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Je=o):JS(e)}}function JS(e){for(;Je!==null;){var t=Je;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:ps||by(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!ps)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Yi(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&LS(t,o,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}LS(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 p=d.memoizedState;if(p!==null){var u=p.dehydrated;u!==null&&pp(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Re(163))}ps||t.flags&512&&Nb(t)}catch(f){hr(t,t.return,f)}}if(t===e){Je=null;break}if(n=t.sibling,n!==null){n.return=t.return,Je=n;break}Je=t.return}}function QS(e){for(;Je!==null;){var t=Je;if(t===e){Je=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Je=n;break}Je=t.return}}function ZS(e){for(;Je!==null;){var t=Je;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{by(4,t)}catch(c){hr(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){hr(t,s,c)}}var o=t.return;try{Nb(t)}catch(c){hr(t,o,c)}break;case 5:var a=t.return;try{Nb(t)}catch(c){hr(t,a,c)}}}catch(c){hr(t,t.return,c)}if(t===e){Je=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Je=l;break}Je=t.return}}var jO=Math.ceil,kg=Ta.ReactCurrentDispatcher,w0=Ta.ReactCurrentOwner,_i=Ta.ReactCurrentBatchConfig,rn=0,Jr=null,Tr=null,ns=0,ri=0,Hu=Fl(0),Hr=0,Np=null,Ic=0,vy=0,b0=0,Uf=null,zs=null,v0=0,hd=1/0,ha=null,Sg=!1,Eb=null,kl=null,Jh=!1,pl=null,Ng=0,qf=0,_b=null,Hm=-1,Bm=0;function Cs(){return rn&6?jr():Hm!==-1?Hm:Hm=jr()}function Sl(e){return e.mode&1?rn&2&&ns!==0?ns&-ns:lO.transition!==null?(Bm===0&&(Bm=e_()),Bm):(e=vn,e!==0||(e=window.event,e=e===void 0?16:a_(e.type)),e):1}function ro(e,t,n,r){if(50<qf)throw qf=0,_b=null,Error(Re(185));Yp(e,n,r),(!(rn&2)||e!==Jr)&&(e===Jr&&(!(rn&2)&&(vy|=n),Hr===4&&ul(e,ns)),Ys(e,r),n===1&&rn===0&&!(t.mode&1)&&(hd=jr()+500,yy&&zl()))}function Ys(e,t){var n=e.callbackNode;lL(e,t);var r=ag(e,e===Jr?ns:0);if(r===0)n!==null&&lS(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&lS(n),t===1)e.tag===0?aO(eN.bind(null,e)):C_(eN.bind(null,e)),rO(function(){!(rn&6)&&zl()}),n=null;else{switch(t_(r)){case 1:n=qv;break;case 4:n=QE;break;case 16:n=og;break;case 536870912:n=ZE;break;default:n=og}n=NA(n,yA.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function yA(e,t){if(Hm=-1,Bm=0,rn&6)throw Error(Re(327));var n=e.callbackNode;if(ed()&&e.callbackNode!==n)return null;var r=ag(e,e===Jr?ns:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=jg(e,r);else{t=r;var s=rn;rn|=2;var o=wA();(Jr!==e||ns!==t)&&(ha=null,hd=jr()+500,vc(e,t));do try{_O();break}catch(l){xA(e,l)}while(!0);o0(),kg.current=o,rn=s,Tr!==null?t=0:(Jr=null,ns=0,t=Hr)}if(t!==0){if(t===2&&(s=tb(e),s!==0&&(r=s,t=Ab(e,s))),t===1)throw n=Np,vc(e,0),ul(e,r),Ys(e,jr()),n;if(t===6)ul(e,r);else{if(s=e.current.alternate,!(r&30)&&!CO(s)&&(t=jg(e,r),t===2&&(o=tb(e),o!==0&&(r=o,t=Ab(e,o))),t===1))throw n=Np,vc(e,0),ul(e,r),Ys(e,jr()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Re(345));case 2:dc(e,zs,ha);break;case 3:if(ul(e,r),(r&130023424)===r&&(t=v0+500-jr(),10<t)){if(ag(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Cs(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=cb(dc.bind(null,e,zs,ha),t);break}dc(e,zs,ha);break;case 4:if(ul(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-no(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=jr()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*jO(r/1960))-r,10<r){e.timeoutHandle=cb(dc.bind(null,e,zs,ha),r);break}dc(e,zs,ha);break;case 5:dc(e,zs,ha);break;default:throw Error(Re(329))}}}return Ys(e,jr()),e.callbackNode===n?yA.bind(null,e):null}function Ab(e,t){var n=Uf;return e.current.memoizedState.isDehydrated&&(vc(e,t).flags|=256),e=jg(e,t),e!==2&&(t=zs,zs=n,t!==null&&Pb(t)),e}function Pb(e){zs===null?zs=e:zs.push.apply(zs,e)}function CO(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],o=s.getSnapshot;s=s.value;try{if(!so(o(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ul(e,t){for(t&=~b0,t&=~vy,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-no(t),r=1<<n;e[n]=-1,t&=~r}}function eN(e){if(rn&6)throw Error(Re(327));ed();var t=ag(e,0);if(!(t&1))return Ys(e,jr()),null;var n=jg(e,t);if(e.tag!==0&&n===2){var r=tb(e);r!==0&&(t=r,n=Ab(e,r))}if(n===1)throw n=Np,vc(e,0),ul(e,t),Ys(e,jr()),n;if(n===6)throw Error(Re(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,dc(e,zs,ha),Ys(e,jr()),null}function k0(e,t){var n=rn;rn|=1;try{return e(t)}finally{rn=n,rn===0&&(hd=jr()+500,yy&&zl())}}function Tc(e){pl!==null&&pl.tag===0&&!(rn&6)&&ed();var t=rn;rn|=1;var n=_i.transition,r=vn;try{if(_i.transition=null,vn=1,e)return e()}finally{vn=r,_i.transition=n,rn=t,!(rn&6)&&zl()}}function S0(){ri=Hu.current,Gn(Hu)}function vc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,nO(n)),Tr!==null)for(n=Tr.return;n!==null;){var r=n;switch(r0(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&fg();break;case 3:fd(),Gn(Us),Gn(ms),f0();break;case 5:d0(r);break;case 4:fd();break;case 13:Gn(lr);break;case 19:Gn(lr);break;case 10:a0(r.type._context);break;case 22:case 23:S0()}n=n.return}if(Jr=e,Tr=e=Nl(e.current,null),ns=ri=t,Hr=0,Np=null,b0=vy=Ic=0,zs=Uf=null,yc!==null){for(t=0;t<yc.length;t++)if(n=yc[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=s,r.next=a}n.pending=r}yc=null}return e}function xA(e,t){do{var n=Tr;try{if(o0(),Dm.current=vg,bg){for(var r=cr.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}bg=!1}if(Pc=0,Gr=Fr=cr=null,Vf=!1,vp=0,w0.current=null,n===null||n.return===null){Hr=1,Np=t,Tr=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=ns,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,p=l,u=p.tag;if(!(p.mode&1)&&(u===0||u===11||u===15)){var f=p.alternate;f?(p.updateQueue=f.updateQueue,p.memoizedState=f.memoizedState,p.lanes=f.lanes):(p.updateQueue=null,p.memoizedState=null)}var m=HS(a);if(m!==null){m.flags&=-257,BS(m,a,l,o,t),m.mode&1&&zS(o,d,t),t=m,c=d;var g=t.updateQueue;if(g===null){var w=new Set;w.add(c),t.updateQueue=w}else g.add(c);break e}else{if(!(t&1)){zS(o,d,t),N0();break e}c=Error(Re(426))}}else if(rr&&l.mode&1){var k=HS(a);if(k!==null){!(k.flags&65536)&&(k.flags|=256),BS(k,a,l,o,t),s0(pd(c,l));break e}}o=c=pd(c,l),Hr!==4&&(Hr=2),Uf===null?Uf=[o]:Uf.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var y=tA(o,c,t);MS(o,y);break e;case 1:l=c;var b=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof b.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(kl===null||!kl.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var j=nA(o,l,t);MS(o,j);break e}}o=o.return}while(o!==null)}vA(n)}catch(E){t=E,Tr===n&&n!==null&&(Tr=n=n.return);continue}break}while(!0)}function wA(){var e=kg.current;return kg.current=vg,e===null?vg:e}function N0(){(Hr===0||Hr===3||Hr===2)&&(Hr=4),Jr===null||!(Ic&268435455)&&!(vy&268435455)||ul(Jr,ns)}function jg(e,t){var n=rn;rn|=2;var r=wA();(Jr!==e||ns!==t)&&(ha=null,vc(e,t));do try{EO();break}catch(s){xA(e,s)}while(!0);if(o0(),rn=n,kg.current=r,Tr!==null)throw Error(Re(261));return Jr=null,ns=0,Hr}function EO(){for(;Tr!==null;)bA(Tr)}function _O(){for(;Tr!==null&&!ZM();)bA(Tr)}function bA(e){var t=SA(e.alternate,e,ri);e.memoizedProps=e.pendingProps,t===null?vA(e):Tr=t,w0.current=null}function vA(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=vO(n,t),n!==null){n.flags&=32767,Tr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Hr=6,Tr=null;return}}else if(n=bO(n,t,ri),n!==null){Tr=n;return}if(t=t.sibling,t!==null){Tr=t;return}Tr=t=e}while(t!==null);Hr===0&&(Hr=5)}function dc(e,t,n){var r=vn,s=_i.transition;try{_i.transition=null,vn=1,AO(e,t,n,r)}finally{_i.transition=s,vn=r}return null}function AO(e,t,n,r){do ed();while(pl!==null);if(rn&6)throw Error(Re(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(Re(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(cL(e,o),e===Jr&&(Tr=Jr=null,ns=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Jh||(Jh=!0,NA(og,function(){return ed(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=_i.transition,_i.transition=null;var a=vn;vn=1;var l=rn;rn|=4,w0.current=null,SO(e,n),mA(n,e),GL(ab),lg=!!ob,ab=ob=null,e.current=n,NO(n),eL(),rn=l,vn=a,_i.transition=o}else e.current=n;if(Jh&&(Jh=!1,pl=e,Ng=s),o=e.pendingLanes,o===0&&(kl=null),rL(n.stateNode),Ys(e,jr()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Sg)throw Sg=!1,e=Eb,Eb=null,e;return Ng&1&&e.tag!==0&&ed(),o=e.pendingLanes,o&1?e===_b?qf++:(qf=0,_b=e):qf=0,zl(),null}function ed(){if(pl!==null){var e=t_(Ng),t=_i.transition,n=vn;try{if(_i.transition=null,vn=16>e?16:e,pl===null)var r=!1;else{if(e=pl,pl=null,Ng=0,rn&6)throw Error(Re(331));var s=rn;for(rn|=4,Je=e.current;Je!==null;){var o=Je,a=o.child;if(Je.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Je=d;Je!==null;){var p=Je;switch(p.tag){case 0:case 11:case 15:Kf(8,p,o)}var u=p.child;if(u!==null)u.return=p,Je=u;else for(;Je!==null;){p=Je;var f=p.sibling,m=p.return;if(fA(p),p===d){Je=null;break}if(f!==null){f.return=m,Je=f;break}Je=m}}}var g=o.alternate;if(g!==null){var w=g.child;if(w!==null){g.child=null;do{var k=w.sibling;w.sibling=null,w=k}while(w!==null)}}Je=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Je=a;else e:for(;Je!==null;){if(o=Je,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Kf(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,Je=y;break e}Je=o.return}}var b=e.current;for(Je=b;Je!==null;){a=Je;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Je=x;else e:for(a=b;Je!==null;){if(l=Je,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:by(9,l)}}catch(E){hr(l,l.return,E)}if(l===a){Je=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Je=j;break e}Je=l.return}}if(rn=s,zl(),zo&&typeof zo.onPostCommitFiberRoot=="function")try{zo.onPostCommitFiberRoot(fy,e)}catch{}r=!0}return r}finally{vn=n,_i.transition=t}}return!1}function tN(e,t,n){t=pd(n,t),t=tA(e,t,1),e=vl(e,t,1),t=Cs(),e!==null&&(Yp(e,1,t),Ys(e,t))}function hr(e,t,n){if(e.tag===3)tN(e,e,n);else for(;t!==null;){if(t.tag===3){tN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(kl===null||!kl.has(r))){e=pd(n,e),e=nA(t,e,1),t=vl(t,e,1),e=Cs(),t!==null&&(Yp(t,1,e),Ys(t,e));break}}t=t.return}}function PO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Cs(),e.pingedLanes|=e.suspendedLanes&n,Jr===e&&(ns&n)===n&&(Hr===4||Hr===3&&(ns&130023424)===ns&&500>jr()-v0?vc(e,0):b0|=n),Ys(e,t)}function kA(e,t){t===0&&(e.mode&1?(t=Hh,Hh<<=1,!(Hh&130023424)&&(Hh=4194304)):t=1);var n=Cs();e=Ea(e,t),e!==null&&(Yp(e,t,n),Ys(e,n))}function IO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),kA(e,n)}function TO(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(Re(314))}r!==null&&r.delete(t),kA(e,n)}var SA;SA=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Us.current)Hs=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Hs=!1,wO(e,t,n);Hs=!!(e.flags&131072)}else Hs=!1,rr&&t.flags&1048576&&E_(t,mg,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;zm(e,t),e=t.pendingProps;var s=cd(t,ms.current);Zu(t,n),s=h0(null,t,r,e,s,n);var o=m0();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,qs(r)?(o=!0,pg(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,c0(t),s.updater=wy,t.stateNode=s,s._reactInternals=t,gb(t,r,e,n),t=wb(null,t,r,!0,o,n)):(t.tag=0,rr&&o&&n0(t),Ss(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(zm(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=MO(r),e=Yi(r,e),s){case 0:t=xb(null,t,r,e,n);break e;case 1:t=KS(null,t,r,e,n);break e;case 11:t=WS(null,t,r,e,n);break e;case 14:t=VS(null,t,r,Yi(r.type,e),n);break e}throw Error(Re(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Yi(r,s),xb(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Yi(r,s),KS(e,t,r,s,n);case 3:e:{if(oA(t),e===null)throw Error(Re(387));r=t.pendingProps,o=t.memoizedState,s=o.element,R_(e,t),xg(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=pd(Error(Re(423)),t),t=US(e,t,r,n,s);break e}else if(r!==s){s=pd(Error(Re(424)),t),t=US(e,t,r,n,s);break e}else for(oi=bl(t.stateNode.containerInfo.firstChild),li=t,rr=!0,Ji=null,n=I_(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ud(),r===s){t=_a(e,t,n);break e}Ss(e,t,r,n)}t=t.child}return t;case 5:return M_(t),e===null&&pb(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,lb(r,s)?a=null:o!==null&&lb(r,o)&&(t.flags|=32),iA(e,t),Ss(e,t,a,n),t.child;case 6:return e===null&&pb(t),null;case 13:return aA(e,t,n);case 4:return u0(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=dd(t,null,r,n):Ss(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Yi(r,s),WS(e,t,r,s,n);case 7:return Ss(e,t,t.pendingProps,n),t.child;case 8:return Ss(e,t,t.pendingProps.children,n),t.child;case 12:return Ss(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,a=s.value,Dn(gg,r._currentValue),r._currentValue=a,o!==null)if(so(o.value,a)){if(o.children===s.children&&!Us.current){t=_a(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=Sa(-1,n&-n),c.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var p=d.pending;p===null?c.next=c:(c.next=p.next,p.next=c),d.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),hb(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Re(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),hb(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}Ss(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Zu(t,n),s=Ai(s),r=r(s),t.flags|=1,Ss(e,t,r,n),t.child;case 14:return r=t.type,s=Yi(r,t.pendingProps),s=Yi(r.type,s),VS(e,t,r,s,n);case 15:return rA(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Yi(r,s),zm(e,t),t.tag=1,qs(r)?(e=!0,pg(t)):e=!1,Zu(t,n),eA(t,r,s),gb(t,r,s,n),wb(null,t,r,!0,e,n);case 19:return lA(e,t,n);case 22:return sA(e,t,n)}throw Error(Re(156,t.tag))};function NA(e,t){return JE(e,t)}function RO(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 Ei(e,t,n,r){return new RO(e,t,n,r)}function j0(e){return e=e.prototype,!(!e||!e.isReactComponent)}function MO(e){if(typeof e=="function")return j0(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Vv)return 11;if(e===Kv)return 14}return 2}function Nl(e,t){var n=e.alternate;return n===null?(n=Ei(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 Wm(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")j0(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Iu:return kc(n.children,s,o,t);case Wv:a=8,s|=8;break;case zw:return e=Ei(12,n,t,s|2),e.elementType=zw,e.lanes=o,e;case Hw:return e=Ei(13,n,t,s),e.elementType=Hw,e.lanes=o,e;case Bw:return e=Ei(19,n,t,s),e.elementType=Bw,e.lanes=o,e;case ME:return ky(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case TE:a=10;break e;case RE:a=9;break e;case Vv:a=11;break e;case Kv:a=14;break e;case ol:a=16,r=null;break e}throw Error(Re(130,e==null?e:typeof e,""))}return t=Ei(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function kc(e,t,n,r){return e=Ei(7,e,r,t),e.lanes=n,e}function ky(e,t,n,r){return e=Ei(22,e,r,t),e.elementType=ME,e.lanes=n,e.stateNode={isHidden:!1},e}function Dx(e,t,n){return e=Ei(6,e,null,t),e.lanes=n,e}function Fx(e,t,n){return t=Ei(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function LO(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=wx(0),this.expirationTimes=wx(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wx(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function C0(e,t,n,r,s,o,a,l,c){return e=new LO(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ei(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},c0(o),e}function OO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Pu,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function jA(e){if(!e)return Pl;e=e._reactInternals;e:{if(Wc(e)!==e||e.tag!==1)throw Error(Re(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(qs(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Re(171))}if(e.tag===1){var n=e.type;if(qs(n))return j_(e,n,t)}return t}function CA(e,t,n,r,s,o,a,l,c){return e=C0(n,r,!0,e,s,o,a,l,c),e.context=jA(null),n=e.current,r=Cs(),s=Sl(n),o=Sa(r,s),o.callback=t??null,vl(n,o,s),e.current.lanes=s,Yp(e,s,r),Ys(e,r),e}function Sy(e,t,n,r){var s=t.current,o=Cs(),a=Sl(s);return n=jA(n),t.context===null?t.context=n:t.pendingContext=n,t=Sa(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=vl(s,t,a),e!==null&&(ro(e,s,a,o),$m(e,s,a)),a}function Cg(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 nN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function E0(e,t){nN(e,t),(e=e.alternate)&&nN(e,t)}function $O(){return null}var EA=typeof reportError=="function"?reportError:function(e){console.error(e)};function _0(e){this._internalRoot=e}Ny.prototype.render=_0.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Re(409));Sy(e,t,null,null)};Ny.prototype.unmount=_0.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Tc(function(){Sy(null,e,null,null)}),t[Ca]=null}};function Ny(e){this._internalRoot=e}Ny.prototype.unstable_scheduleHydration=function(e){if(e){var t=s_();e={blockedOn:null,target:e,priority:t};for(var n=0;n<cl.length&&t!==0&&t<cl[n].priority;n++);cl.splice(n,0,e),n===0&&o_(e)}};function A0(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function jy(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function rN(){}function DO(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=Cg(a);o.call(d)}}var a=CA(t,r,e,0,null,!1,!1,"",rN);return e._reactRootContainer=a,e[Ca]=a.current,gp(e.nodeType===8?e.parentNode:e),Tc(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Cg(c);l.call(d)}}var c=C0(e,0,!1,null,null,!1,!1,"",rN);return e._reactRootContainer=c,e[Ca]=c.current,gp(e.nodeType===8?e.parentNode:e),Tc(function(){Sy(t,c,n,r)}),c}function Cy(e,t,n,r,s){var o=n._reactRootContainer;if(o){var a=o;if(typeof s=="function"){var l=s;s=function(){var c=Cg(a);l.call(c)}}Sy(t,a,e,s)}else a=DO(n,t,e,s,r);return Cg(a)}n_=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Pf(t.pendingLanes);n!==0&&(Yv(t,n|1),Ys(t,jr()),!(rn&6)&&(hd=jr()+500,zl()))}break;case 13:Tc(function(){var r=Ea(e,1);if(r!==null){var s=Cs();ro(r,e,1,s)}}),E0(e,1)}};Gv=function(e){if(e.tag===13){var t=Ea(e,134217728);if(t!==null){var n=Cs();ro(t,e,134217728,n)}E0(e,134217728)}};r_=function(e){if(e.tag===13){var t=Sl(e),n=Ea(e,t);if(n!==null){var r=Cs();ro(n,e,t,r)}E0(e,t)}};s_=function(){return vn};i_=function(e,t){var n=vn;try{return vn=e,t()}finally{vn=n}};Qw=function(e,t,n){switch(t){case"input":if(Kw(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=gy(r);if(!s)throw Error(Re(90));OE(r),Kw(r,s)}}}break;case"textarea":DE(e,n);break;case"select":t=n.value,t!=null&&Gu(e,!!n.multiple,t,!1)}};KE=k0;UE=Tc;var FO={usingClientEntryPoint:!1,Events:[Xp,Lu,gy,WE,VE,k0]},yf={findFiberByHostInstance:gc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},zO={bundleType:yf.bundleType,version:yf.version,rendererPackageName:yf.rendererPackageName,rendererConfig:yf.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ta.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=GE(e),e===null?null:e.stateNode},findFiberByHostInstance:yf.findFiberByHostInstance||$O,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 Qh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Qh.isDisabled&&Qh.supportsFiber)try{fy=Qh.inject(zO),zo=Qh}catch{}}fi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=FO;fi.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!A0(t))throw Error(Re(200));return OO(e,t,null,n)};fi.createRoot=function(e,t){if(!A0(e))throw Error(Re(299));var n=!1,r="",s=EA;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=C0(e,1,!1,null,null,n,!1,r,s),e[Ca]=t.current,gp(e.nodeType===8?e.parentNode:e),new _0(t)};fi.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(Re(188)):(e=Object.keys(e).join(","),Error(Re(268,e)));return e=GE(t),e=e===null?null:e.stateNode,e};fi.flushSync=function(e){return Tc(e)};fi.hydrate=function(e,t,n){if(!jy(t))throw Error(Re(200));return Cy(null,e,t,!0,n)};fi.hydrateRoot=function(e,t,n){if(!A0(e))throw Error(Re(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=EA;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=CA(t,null,e,1,n??null,s,!1,o,a),e[Ca]=t.current,gp(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 Ny(t)};fi.render=function(e,t,n){if(!jy(t))throw Error(Re(200));return Cy(null,e,t,!1,n)};fi.unmountComponentAtNode=function(e){if(!jy(e))throw Error(Re(40));return e._reactRootContainer?(Tc(function(){Cy(null,null,e,!1,function(){e._reactRootContainer=null,e[Ca]=null})}),!0):!1};fi.unstable_batchedUpdates=k0;fi.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!jy(n))throw Error(Re(200));if(e==null||e._reactInternals===void 0)throw Error(Re(38));return Cy(e,t,n,!1,r)};fi.version="18.3.1-next-f1338f8080-20240426";function _A(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_A)}catch(e){console.error(e)}}_A(),_E.exports=fi;var Ir=_E.exports,sN=Ir;Dw.createRoot=sN.createRoot,Dw.hydrateRoot=sN.hydrateRoot;const AA=h.createContext(null);function Ib(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function HO(){const e=Ib(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function BO({children:e}){const[t,n]=h.useState(HO);h.useEffect(()=>{const o=()=>n(Ib(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=h.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Ib(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(AA.Provider,{value:s,children:e})}function Yo(){const e=h.useContext(AA);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function WO(){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 iN={};function Tb(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&iN[t[0]]||(typeof t[0]=="string"&&(iN[t[0]]=new Date),WO(...t))}const PA=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function oN(e,t,n){e.loadNamespaces(t,PA(e,n))}function aN(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,PA(e,r))}function VO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],s=t.options?t.options.fallbackLng:!1,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,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(o,e)))}function KO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Tb("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,e))return!1}}):VO(e,t,n)}const UO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,qO={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},YO=e=>qO[e],GO=e=>e.replace(UO,YO);let Rb={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:GO};function XO(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rb={...Rb,...e}}function JO(){return Rb}let IA;function QO(e){IA=e}function ZO(){return IA}const e$={type:"3rdParty",init(e){XO(e.options.react),QO(e)}},t$=h.createContext();class n${constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const r$=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function zn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=h.useContext(t$)||{},o=n||r||ZO();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new n$),!o){Tb("You will need to pass in an i18next instance by using initReactI18next");const x=(E,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(E)?E[E.length-1]:E,j=[x,{},!1];return j.t=x,j.i18n={},j.ready=!1,j}o.options.react&&o.options.react.wait!==void 0&&Tb("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...JO(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let d=e||s||o.options&&o.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(d);const p=(o.isInitialized||o.initializedStoreOnce)&&d.every(x=>KO(x,o,a));function u(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],c)}const[f,m]=h.useState(u);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const w=r$(g),k=h.useRef(!0);h.useEffect(()=>{const{bindI18n:x,bindI18nStore:j}=a;k.current=!0,!p&&!l&&(t.lng?aN(o,t.lng,d,()=>{k.current&&m(u)}):oN(o,d,()=>{k.current&&m(u)})),p&&w&&w!==g&&k.current&&m(u);function E(){k.current&&m(u)}return x&&o&&o.on(x,E),j&&o&&o.store.on(j,E),()=>{k.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,E)),j&&o&&j.split(" ").forEach(N=>o.store.off(N,E))}},[o,g]);const y=h.useRef(!0);h.useEffect(()=>{k.current&&!y.current&&m(u),y.current=!1},[o,c]);const b=[f,o,p];if(b.t=f,b.i18n=o,b.ready=p,p||!p&&!l)return b;throw new Promise(x=>{t.lng?aN(o,t.lng,d,()=>x()):oN(o,d,()=>x())})}const TA="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",s$=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],i$=[{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 o$(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function a$({authUser:e,onLogout:t}){const{path:n,navigate:r}=Yo(),{t:s}=zn(),[o,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}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:TA,alt:"",width:"36",height:"36",decoding:"async"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),i.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),i.jsx("nav",{className:"af-nav",children:s$.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(o$(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[i.jsx("span",{className:"material-symbols-outlined",children:l.icon}),i.jsx("span",{children:l.label||s(l.labelKey)})]},l.to))}),i.jsxs("div",{className:"af-sidebar-footer",children:[i.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[i.jsx("span",{className:"material-symbols-outlined",children:"person"}),i.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?i.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,i.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:i.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!o&&i$.map(l=>{const c=s(l.labelKey);return i.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:i.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const RA="agentflow.pipelineRecent",l$=50,c$=15;function u$(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function MA(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(RA);return e?u$(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 Zh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=MA(),o=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,l$);try{localStorage.setItem(RA,JSON.stringify(o))}catch{}}function d$(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 Mb(e,t){const n=Date.now(),r=Math.max(0,n-e),s=Math.floor(r/1e3);if(s<60)return t("flow:time.justNow");const o=Math.floor(s/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,d=new Date(c);if(d.setDate(d.getDate()-1),l.toDateString()===d.toDateString())return t("flow:time.yesterday");const p=Math.floor(a/24);return p<7?t("flow:time.daysAgo",{n:p}):`${l.getMonth()+1}/${l.getDate()}`}function f$(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 p$(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:d$(n,s.flowId),kind:"executed",at:s.at});for(const s of t)r.push({flowId:s.flowId,flowSource:s.flowSource,kind:"opened",at:s.at});return r.sort((s,o)=>o.at-s.at),r.slice(0,c$)}var si=Uint8Array,Bu=Uint16Array,h$=Int32Array,LA=new si([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]),OA=new si([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]),m$=new si([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$A=function(e,t){for(var n=new Bu(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new h$(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return{b:n,r:s}},DA=$A(LA,2),FA=DA.b,g$=DA.r;FA[28]=258,g$[258]=28;var y$=$A(OA,0),x$=y$.b,Lb=new Bu(32768);for(var Yn=0;Yn<32768;++Yn){var tl=(Yn&43690)>>1|(Yn&21845)<<1;tl=(tl&52428)>>2|(tl&13107)<<2,tl=(tl&61680)>>4|(tl&3855)<<4,Lb[Yn]=((tl&65280)>>8|(tl&255)<<8)>>1}var Yf=function(e,t,n){for(var r=e.length,s=0,o=new Bu(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new Bu(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new Bu(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],p=t-e[s],u=a[e[s]-1]++<<p,f=u|(1<<p)-1;u<=f;++u)l[Lb[u]>>c]=d}else for(l=new Bu(r),s=0;s<r;++s)e[s]&&(l[s]=Lb[a[e[s]-1]++]>>15-e[s]);return l},Qp=new si(288);for(var Yn=0;Yn<144;++Yn)Qp[Yn]=8;for(var Yn=144;Yn<256;++Yn)Qp[Yn]=9;for(var Yn=256;Yn<280;++Yn)Qp[Yn]=7;for(var Yn=280;Yn<288;++Yn)Qp[Yn]=8;var zA=new si(32);for(var Yn=0;Yn<32;++Yn)zA[Yn]=5;var w$=Yf(Qp,9,1),b$=Yf(zA,5,1),zx=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ki=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Hx=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},v$=function(e){return(e+7)/8|0},P0=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new si(e.subarray(t,n))},k$=["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"],ki=function(e,t,n){var r=new Error(t||k$[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ki),!n)throw r;return r},S$=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new si(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new si(s*3));var d=function(me){var we=n.length;if(me>we){var je=new si(Math.max(we*2,me));je.set(n),n=je}},p=t.f||0,u=t.p||0,f=t.b||0,m=t.l,g=t.d,w=t.m,k=t.n,y=s*8;do{if(!m){p=Ki(e,u,1);var b=Ki(e,u+1,3);if(u+=3,b)if(b==1)m=w$,g=b$,w=9,k=5;else if(b==2){var N=Ki(e,u,31)+257,T=Ki(e,u+10,15)+4,$=N+Ki(e,u+5,31)+1;u+=14;for(var z=new si($),K=new si(19),B=0;B<T;++B)K[m$[B]]=Ki(e,u+B*3,7);u+=T*3;for(var L=zx(K),D=(1<<L)-1,R=Yf(K,L,1),B=0;B<$;){var M=R[Ki(e,u,D)];u+=M&15;var x=M>>4;if(x<16)z[B++]=x;else{var I=0,F=0;for(x==16?(F=3+Ki(e,u,3),u+=2,I=z[B-1]):x==17?(F=3+Ki(e,u,7),u+=3):x==18&&(F=11+Ki(e,u,127),u+=7);F--;)z[B++]=I}}var P=z.subarray(0,N),O=z.subarray(N);w=zx(P),k=zx(O),m=Yf(P,w,1),g=Yf(O,k,1)}else ki(1);else{var x=v$(u)+4,j=e[x-4]|e[x-3]<<8,E=x+j;if(E>s){c&&ki(0);break}l&&d(f+j),n.set(e.subarray(x,E),f),t.b=f+=j,t.p=u=E*8,t.f=p;continue}if(u>y){c&&ki(0);break}}l&&d(f+131072);for(var _=(1<<w)-1,Z=(1<<k)-1,ee=u;;ee=u){var I=m[Hx(e,u)&_],V=I>>4;if(u+=I&15,u>y){c&&ki(0);break}if(I||ki(2),V<256)n[f++]=V;else if(V==256){ee=u,m=null;break}else{var ae=V-254;if(V>264){var B=V-257,fe=LA[B];ae=Ki(e,u,(1<<fe)-1)+FA[B],u+=fe}var xe=g[Hx(e,u)&Z],Se=xe>>4;xe||ki(3),u+=xe&15;var O=x$[Se];if(Se>3){var fe=OA[Se];O+=Hx(e,u)&(1<<fe)-1,u+=fe}if(u>y){c&&ki(0);break}l&&d(f+131072);var ue=f+ae;if(f<O){var Ee=o-O,le=Math.min(O,ue);for(Ee+f<0&&ki(3);f<le;++f)n[f]=r[Ee+f]}for(;f<ue;++f)n[f]=n[f-O]}}t.l=m,t.p=ee,t.b=f,t.f=p,m&&(p=1,t.m=w,t.d=g,t.n=k)}while(!p);return f!=n.length&&a?P0(n,0,f):n.subarray(0,f)},N$=new si(0),$o=function(e,t){return e[t]|e[t+1]<<8},Qi=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Bx=function(e,t){return Qi(e,t)+Qi(e,t+4)*4294967296};function j$(e,t){return S$(e,{i:2},t&&t.out,t&&t.dictionary)}var Ob=typeof TextDecoder<"u"&&new TextDecoder,C$=0;try{Ob.decode(N$,{stream:!0}),C$=1}catch{}var E$=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:P0(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 _$(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(Ob)return Ob.decode(e);var s=E$(e),o=s.s,n=s.r;return n.length&&ki(8),o}}var A$=function(e,t){return t+30+$o(e,t+26)+$o(e,t+28)},P$=function(e,t,n){var r=$o(e,t+28),s=_$(e.subarray(t+46,t+46+r),!($o(e,t+8)&2048)),o=t+46+r,a=Qi(e,t+20),l=n&&a==4294967295?I$(e,o):[a,Qi(e,t+24),Qi(e,t+42)],c=l[0],d=l[1],p=l[2];return[$o(e,t+10),c,d,s,o+$o(e,t+30)+$o(e,t+32),p]},I$=function(e,t){for(;$o(e,t)!=1;t+=4+$o(e,t+2));return[Bx(e,t+12),Bx(e,t+4),Bx(e,t+20)]};function T$(e,t){for(var n={},r=e.length-22;Qi(e,r)!=101010256;--r)(!r||e.length-r>65558)&&ki(13);var s=$o(e,r+8);if(!s)return{};var o=Qi(e,r+16),a=o==4294967295||s==65535;if(a){var l=Qi(e,r-12);a=Qi(e,l)==101075792,a&&(s=Qi(e,l+32),o=Qi(e,l+48))}for(var c=0;c<s;++c){var d=P$(e,o,a),p=d[0],u=d[1],f=d[2],m=d[3],g=d[4],w=d[5],k=A$(e,w);o=g,p?p==8?n[m]=j$(e.subarray(k,k+u),{out:new si(f)}):ki(14,"unknown compression type "+p):n[m]=P0(e,k,k+u)}return n}const R$=8*1024*1024,M$=500;function L$(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 O$(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function $$(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 D$=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function F$(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=T$(t),r=new Map;let s=0,o=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const p=L$(c);if(!p||O$(p))continue;const u=(d==null?void 0:d.length)??0;if(s+=u,s>R$||(o+=1,o>M$))return null;r.set(p,u)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=$$(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 D$.test(l)?l:null}catch{return null}}const Wx=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function z$({file:e,onClose:t,onImported:n}){const{t:r}=zn(),s=h.useId(),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(""),[d,p]=h.useState("user"),[u,f]=h.useState(!1),[m,g]=h.useState(""),[w,k]=h.useState(null),y=w??e;h.useEffect(()=>{const E=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(E)},[]),h.useEffect(()=>{let E=!1;return(async()=>{const N=y.name||"",T=N.toLowerCase();let $="";if(T.endsWith(".zip")){if($=await F$(y)||"",!$){const z=N.replace(/\.zip$/i,"");Wx.test(z)&&($=z)}}else if(T.endsWith(".yaml")||T.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");Wx.test(z)&&($=z)}E||c($)})(),()=>{E=!0}},[y]);const b=l.trim(),x=b.length>0&&Wx.test(b);async function j(E){if(E.preventDefault(),!(!x||u)){f(!0),g("");try{const N=new FormData;N.set("flowId",b),N.set("targetSpace",d),N.set("file",y,y.name);const T=await fetch("/api/flows/import",{method:"POST",body:N}),$=await T.json().catch(()=>({}));if(!T.ok){g(typeof $.error=="string"?$.error:r("project:importModal.importFailed"));return}n({id:$.flowId,source:$.flowSource??"user"})}catch(N){g(String((N==null?void 0:N.message)||N))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&t()},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:E=>E.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),i.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:E=>{var T;const N=(T=E.target.files)==null?void 0:T[0];N&&k(N),E.target.value=""}}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:E=>c(E.target.value),"aria-invalid":b.length>0&&!x}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),i.jsx("div",{className:"af-import-repick",children:i.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var E;return(E=a.current)==null?void 0:E.click()},children:r("project:importModal.changeFile")})}),m?i.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||u,children:r(u?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const H$=/^[a-zA-Z][a-zA-Z0-9_-]*$/,lN="af:newPipelineGuide";function B$({open:e,onClose:t,onCreated:n}){const{t:r}=zn(),s=h.useId(),o=h.useRef(null),[a,l]=h.useState(""),[c,d]=h.useState(""),[p,u]=h.useState("user"),[f,m]=h.useState(!1),[g,w]=h.useState(""),[k,y]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),d(""),u("user"),w(""),m(!1),localStorage.getItem(lN)==="true"&&y(!0);const T=requestAnimationFrame(()=>{var $;return($=o.current)==null?void 0:$.focus()});return()=>cancelAnimationFrame(T)},[e]);const b=()=>{localStorage.removeItem(lN),y(!1)};if(!e)return null;const x=a.trim(),j=x.length>0&&H$.test(x);async function E(N){if(N.preventDefault(),!(!j||f)){m(!0),w(""),b();try{const T=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:p})}),$=await T.json().catch(()=>({}));if(!T.ok){w(typeof $.error=="string"?$.error:r("project:newPipelineModal.createFailed"));return}n({id:$.flowId,source:$.flowSource??"user"})}catch(T){w(String((T==null?void 0:T.message)||T))}finally{m(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&(b(),t())},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{b(),t()},"aria-label":r("project:newPipelineModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),k?i.jsx("div",{className:"af-new-pipeline-guide",children:i.jsxs("div",{className:"af-new-pipeline-guide-content",children:[i.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),i.jsxs("div",{className:"af-new-pipeline-guide-text",children:[i.jsx("p",{children:i.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),i.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),i.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:b,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:E,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:N=>l(N.target.value),"aria-invalid":x.length>0&&!j}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(k?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(k?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:N=>d(N.target.value)}),k?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?i.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{b(),t()},disabled:f,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||f,children:r(f?"project:newPipelineModal.creating":k?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const HA="agentflow.pipelineViewPreference";function BA(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function WA(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(HA)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function W$(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(HA,JSON.stringify(e))}catch{}}function I0(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function V$(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function VA(e,t){const n=I0(t);return n==="pipeline"&&V$(e==null?void 0:e.source)?"workspace":n}function K$(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function KA(e,t,n,r=!1){if(!e)return;const s=WA();s[BA(e,t,r)]={view:I0(n),at:Date.now()},W$(s)}function U$(e,t="workspace"){if(!(e!=null&&e.id))return I0(t);const r=WA()[BA(e.id,e.source??"user",!!e.archived)],s=VA(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!K$(e)?"workspace":s}function Gf(e,t="workspace"){const n=VA(e,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 em(e,t="workspace"){return Gf(e,U$(e,t))}function q$(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),s=Math.max(n.length,r.length);for(let o=0;o<s;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function $b(e){return String((e==null?void 0:e.version)||"").trim()}function Y$(e){const t=$b(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 G$({onChanged:e,canManage:t=!1}){const[n,r]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=h.useState([]),[a,l]=h.useState(""),[c,d]=h.useState(""),[p,u]=h.useState("keyword"),[f,m]=h.useState([]),[g,w]=h.useState({}),[k,y]=h.useState(""),[b,x]=h.useState(""),[j,E]=h.useState(""),N=h.useCallback(async()=>{x("");try{const[L,D]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),R=await L.json().catch(()=>({}));L.ok&&r({available:!!R.available,version:typeof R.version=="string"?R.version:"",loggedIn:!!R.loggedIn,user:typeof R.user=="string"?R.user:"",error:typeof R.error=="string"?R.error:""});const M=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+D.status);o(Array.isArray(M.skills)?M.skills:[]),l(typeof M.skillsRoot=="string"?M.skillsRoot:""),w({})}catch(L){x(String(L.message||L))}},[]);h.useEffect(()=>{N()},[N]);const T=h.useCallback(async()=>{const L=c.trim();if(L){y("search"),x(""),E("");try{const D=await fetch(`/api/skillhub/search?q=${encodeURIComponent(L)}&mode=${encodeURIComponent(p)}`),R=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+D.status);m(Array.isArray(R.items)?R.items:[])}catch(D){x(String(D.message||D))}finally{y("")}}},[c,p]),$=h.useCallback(async(L,D=!1)=>{if(!t)return;const R=L&&typeof L=="object"?L:null,M=String(R?R.slug||R.name||R.collection||R.skillId||R.id:L||"").trim();if(M){y(`install:${M}`),x(""),E("");try{const I=R?{slug:R.slug||"",skillId:R.skillId||"",collection:R.collection||"",collectionName:R.collection&&R.name||"",target:"agentflow",agent:"codex",force:D}:{slug:M,target:"agentflow",agent:"codex",force:D},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),P=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof P.error=="string"?P.error:"HTTP "+F.status);E(D?`已更新 ${M}`:`已安装 ${M}`),await N(),typeof e=="function"&&await e()}catch(I){x(String(I.message||I))}finally{y("")}}},[t,N,e]),z=h.useCallback(async()=>{if(t&&s.length!==0){y("check-updates"),x(""),E("");try{const L=await Promise.all(s.map(async M=>{const I=String(M.name||"").trim();if(!I)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(I)}&mode=keyword`),P=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof P.error=="string"?P.error:"HTTP "+F.status);const O=Array.isArray(P.items)?P.items:[],_=O.find(ae=>ae.slug===I||ae.name===I||ae.id===I)||O[0],Z=$b(M),ee=String((_==null?void 0:_.version)||"").trim();let V="unknown";return _?Z&&ee?V=q$(Z,ee)<0?"update":"current":ee&&(V="remote-only"):V="missing",[I,{state:V,latestVersion:ee,installedVersion:Z,summary:(_==null?void 0:_.summary)||""}]}catch(F){return[I,{state:"error",error:String(F.message||F),installedVersion:$b(M)}]}})),D={};for(const M of L)M&&(D[M[0]]=M[1]);w(D);const R=Object.values(D).filter(M=>M.state==="update").length;E(R>0?`发现 ${R} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{y("")}}},[t,s]),K=h.useCallback(async L=>{if(!t)return;const D=String(L||"").trim();if(D){y(`uninstall:${D}`),x(""),E("");try{const R=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:D,target:"agentflow",agent:"codex"})}),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+R.status);E(`已卸载 ${D}`),await N(),typeof e=="function"&&await e()}catch(R){x(String(R.message||R))}finally{y("")}}},[t,N,e]),B=h.useCallback(async()=>{if(t){y("update-cli"),x(""),E("");try{const L=await fetch("/api/skillhub/update",{method:"POST"}),D=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof D.error=="string"?D.error:"HTTP "+L.status);E("SkillHub CLI 已更新"),await N()}catch(L){x(String(L.message||L))}finally{y("")}}},[t,N]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",i.jsx("code",{children:a})]}):null]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!k,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!k||s.length===0,children:k==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:!t||!!k,children:k==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),i.jsxs("div",{className:"af-set-skillhub-search",children:[i.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:p,onChange:L=>{u(L.target.value),m([])},children:[i.jsx("option",{value:"keyword",children:"关键词"}),i.jsx("option",{value:"skillId",children:"Skill ID"}),i.jsx("option",{value:"collectionId",children:"Collection ID"})]}),i.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:L=>d(L.target.value),onKeyDown:L=>{L.key==="Enter"&&T()},placeholder:p==="collectionId"?"输入 collection id,例如 1":p==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>T(),disabled:!c.trim()||k==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),k==="search"?"搜索中…":"搜索"]})]}),b?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:b}):null,j?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:j}):null,i.jsxs("div",{className:"af-set-skillhub-grid",children:[i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"已安装"}),i.jsx("span",{children:s.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(L=>{const D=g[L.name],R=!D||D.state==="update"||D.state==="remote-only"||D.state==="unknown"||D.state==="error",M=k===`install:${L.name}`?"更新中…":(D==null?void 0:D.state)==="current"?"已最新":(D==null?void 0:D.state)==="update"&&D.latestVersion?`更新到 v${D.latestVersion}`:(D==null?void 0:D.state)==="remote-only"&&D.latestVersion?`安装 v${D.latestVersion}`:"重装";return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:L.displayName||L.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:Y$(L)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:D?D.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",D.installedVersion?`v${D.installedVersion} -> `:"","v",D.latestVersion]}):D.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",D.latestVersion||D.installedVersion]}):D.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",D.latestVersion,",本地版本未知"]}):D.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):D.state==="error"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),i.jsxs("div",{className:"af-set-skillhub-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>$(L.name,!0),disabled:!t||!!k||!R,children:M}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>K(L.name),disabled:!t||!!k,children:"卸载"})]})]},`${L.agent}:${L.path}:${L.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:f.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:f.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):f.map(L=>{const D=L.slug||L.name,R=L.kind==="collection"||L.collection,M=!R&&s.some(I=>I.name===D||I.name===L.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:L.name||D}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[R?`collection:${L.collection}`:D,L.skillId?` · id:${L.skillId}`:"",L.version?` · ${L.version}`:""]}),L.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:L.summary}):null]}),i.jsx("button",{type:"button",className:M?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>$(L,M),disabled:!t||!!k,children:M?"更新":R?"安装合集":"安装"})]},L.id||D)})})]})]})]})}function jl(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 X$(e){return{version:1,collections:jl({collections:e})}}function J$(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function UA(e){const t=new Map,n=new Map;for(const r of Array.isArray(e)?e:[])r!=null&&r.key&&t.set(r.key,r.key),r!=null&&r.name&&(r!=null&&r.key)&&!n.has(r.name)&&n.set(r.name,r.key);return r=>{const s=String(r||"").trim();return s&&(t.get(s)||n.get(J$(s)))||""}}function Il(e,t){const n=UA(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function qA(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 YA(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function GA(e,t,n){const r=Il(e,n);if(r.length===0)return"empty";const s=r.filter(o=>t.has(o)).length;return s===0?"none":s===r.length?"all":"partial"}function Q$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=jl({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return Il(s,t)}function XA(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),o=String(t||"").trim().toLowerCase(),a=jl({collections:r}),l=Q$(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const d=localStorage.getItem(e);if(d!==null){const p=JSON.parse(d);if(Array.isArray(p)){const u=UA(n),f=Array.from(new Set(p.map(u).filter(Boolean)));if(s.length>0&&f.length===s.length)return c;const m=new Set(f),g=new Set(l),w=l.length>0&&l.every(y=>m.has(y)),k=a.some(y=>{if(!y.builtin||y.id===o||y.name.toLowerCase()===o)return!1;const b=Il(y,n);return b.length>0&&b.every(x=>m.has(x))});return l.length>0&&k&&!w?c:f}}}catch{}return c}function xf(e){return e==="builtin"?"af-proj-badge af-proj-badge--builtin":e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function Z$(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function eD(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 Db(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function JA(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 tD="project:defaultCardDesc";function QA(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(tD)}function nD(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nr({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return i.jsx("span",{className:t,children:s});const o=new RegExp(`(${nD(r)})`,"gi"),a=s.split(o);return i.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?i.jsx("mark",{className:"af-search-hit",children:l},c):i.jsx("span",{children:l},c))})}function rD(e,t,n){const r=[String(e.id),QA(e,n),JA(e),Db(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function sD(e,t,n){return t?rD(e,t,n).includes(t):!0}function iD(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 Vx(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function cN(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 uN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const oD=["all","agent","control","provide","marketplace"],aD=["all","agent","control","provide"],ZA="agentflow.projects.activityPanelOpen",Fb="agentflow.projects.activitySelected";function lD(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(ZA);return e!=="0"}function dN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function cD(){return typeof localStorage>"u"?"":localStorage.getItem(Fb)||""}function tm(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function nr(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 nl(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function eP(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 tP(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 zb(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 fN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||zb(e,t))}function uD(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function pN(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 dD(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 Kx(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function fD(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 pD(e,t){const n=e.map(p=>p.id),r=new Set(n),s=new Map(n.map(p=>[p,0])),o=new Map(n.map(p=>[p,[]]));t.forEach(p=>{var u;!r.has(p.sourceId)||!r.has(p.targetId)||(s.set(p.targetId,(s.get(p.targetId)||0)+1),(u=o.get(p.sourceId))==null||u.push(p.targetId))});const a=new Map,l=n.filter(p=>(s.get(p)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(p=>a.set(p,0));for(let p=0;p<l.length;p+=1){const u=l[p],f=(a.get(u)||0)+1;for(const m of o.get(u)||[])(!a.has(m)||f>a.get(m))&&(a.set(m,f),l.push(m))}n.forEach((p,u)=>{a.has(p)||a.set(p,u%3)});const c=new Map,d=new Map;return n.forEach(p=>{const u=a.get(p)||0,f=c.get(u)||0;c.set(u,f+1),d.set(p,{x:u*190,y:f*86})}),d}function hD(e){var w,k,y,b;const t=eP(e),n=tP(e),r=new Map(t.map((x,j)=>[zb(x,j),fN(x,j)])),s=t.map((x,j)=>({id:zb(x,j),title:fN(x,j),meta:uD(x)})),o=n.map((x,j)=>{const E=pN(x,"source"),N=pN(x,"target");return{key:(x==null?void 0:x.id)||`${E}-${N}-${j}`,sourceId:E,targetId:N,source:r.get(E)||E||"?",target:r.get(N)||N||"?",label:dD(x)}}),a=(k=(w=e==null?void 0:e.snippet)==null?void 0:w.ui)!=null&&k.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(b=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&b.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=pD(s,o),d=s.map(x=>{const j=fD(a[x.id])||c.get(x.id)||{x:0,y:0},E=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},N=Number(E.width),T=Number(E.height),$=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),z=Math.max(48,Math.min(76,Number.isFinite(T)?T*.46:54));return{...x,x:j.x,y:j.y,width:$,height:z}}),p=new Map(d.map(x=>[x.id,x])),u=o.map(x=>{const j=p.get(x.sourceId),E=p.get(x.targetId);if(!j||!E)return null;const N=j.x+j.width,T=j.y+j.height/2,$=E.x,z=E.y+E.height/2,K=Math.max(48,Math.abs($-N)*.45);return{...x,path:`M ${N} ${T} C ${N+K} ${T}, ${$-K} ${z}, ${$} ${z}`,labelX:(N+$)/2,labelY:(T+z)/2}}).filter(Boolean),f=d.reduce((x,j)=>({minX:Math.min(x.minX,j.x),minY:Math.min(x.minY,j.y),maxX:Math.max(x.maxX,j.x+j.width),maxY:Math.max(x.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,g=`${f.minX-m} ${f.minY-m} ${Math.max(360,f.maxX-f.minX+m*2)} ${Math.max(180,f.maxY-f.minY+m*2)}`;return{nodes:s,edges:o,diagram:{nodes:d,edges:u,viewBox:g}}}function wu({resourceKind:e="",authUser:t=null}){var As,po,Ri,Js,Qr,Jo;const{t:n}=zn(),{navigate:r,path:s}=Yo(),o=!!(t!=null&&t.isAdmin),[a,l]=h.useState(e||"all"),[c,d]=h.useState([]),[p,u]=h.useState([]),[f,m]=h.useState([]),[g,w]=h.useState([]),[k,y]=h.useState([]),[b,x]=h.useState(""),[j,E]=h.useState(!1),[N,T]=h.useState([]),[$,z]=h.useState(""),[K,B]=h.useState(""),[L,D]=h.useState(!1),[R,M]=h.useState(!1),[I,F]=h.useState(!1),[P,O]=h.useState(null),[_,Z]=h.useState(!1),[ee,V]=h.useState(""),[ae,fe]=h.useState(lD),[xe,Se]=h.useState(cD),[ue,Ee]=h.useState("all"),[le,me]=h.useState(""),[we,je]=h.useState("overview"),[Ye,tt]=h.useState({}),[ze,dt]=h.useState(""),[Ft,Ue]=h.useState({}),[pt,_n]=h.useState(""),[We,sn]=h.useState(""),[xt,kn]=h.useState({}),[pe,_e]=h.useState(""),[Ve,rt]=h.useState(""),[it,Mt]=h.useState(""),[wt,gn]=h.useState(""),[cn,Jn]=h.useState(""),[on,An]=h.useState(!1),[Pn,mr]=h.useState(""),[Cr,gr]=h.useState({hiddenBuiltins:[],promoted:[]}),Wt=h.useRef(0),Vt=h.useRef(0),ir=h.useRef(0),Er=h.useCallback(async()=>{var be,$e;const U=++Vt.current;z("");try{const Oe=await fetch("/api/flows");if(U!==Vt.current)return;if(!Oe.ok)throw new Error("HTTP "+Oe.status);const st=await Oe.json();if(U!==Vt.current)return;d(Array.isArray(st)?st:[])}catch(Oe){if(U!==Vt.current)return;d([]),z(String(Oe.message||Oe))}try{const Oe=await fetch("/api/pipeline-recent-runs");if(U!==Vt.current)return;if(Oe.ok){const st=await Oe.json();if(U!==Vt.current)return;T(Array.isArray(st.runs)?st.runs:[])}else T([])}catch{if(U!==Vt.current)return;T([])}if(t!=null&&t.isAdmin)try{const Oe=await fetch("/api/admin/builtin-flows");if(U!==Vt.current)return;const st=await Oe.json().catch(()=>({}));Oe.ok&&gr({hiddenBuiltins:Array.isArray((be=st==null?void 0:st.config)==null?void 0:be.hiddenBuiltins)?st.config.hiddenBuiltins:[],promoted:Array.isArray(($e=st==null?void 0:st.config)==null?void 0:$e.promoted)?st.config.promoted:[]})}catch{if(U!==Vt.current)return;gr({hiddenBuiltins:[],promoted:[]})}else gr({hiddenBuiltins:[],promoted:[]});D(!0)},[t==null?void 0:t.isAdmin]),dr=h.useCallback(async(U,be)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const $e=`${be}:${U.source}:${U.id}`;mr($e),z("");try{const Oe=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:be,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),st=await Oe.json().catch(()=>({}));if(!Oe.ok)throw new Error(st.error||"更新内置配置失败");await Er()}catch(Oe){z(String(Oe.message||Oe))}finally{mr("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,Er]),yr=h.useCallback(async()=>{const U=++ir.current;B(""),M(!1);const be=e==="my-nodes"?"/api/nodes?scope=owned":"/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";u([]),w([]),me("");try{const[Oe,st,un,bt]=await Promise.all([fetch(be),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Bn=await Oe.json().catch(()=>({})),vr=await st.json().catch(()=>({})),Mi=await un.json().catch(()=>({})),Mn=await bt.json().catch(()=>({}));if(!Oe.ok)throw new Error(Bn.error||"Nodes HTTP "+Oe.status);if(!st.ok)throw new Error(vr.error||"Skills HTTP "+st.status);if(!un.ok)throw new Error(Mi.error||"Collections HTTP "+un.status);if(!bt.ok)throw new Error(Mn.error||"Flow snippets HTTP "+bt.status);if(U!==ir.current)return;u(Array.isArray(Bn.nodes)?Bn.nodes:Array.isArray(Bn)?Bn:[]),m(Array.isArray(vr.skills)?vr.skills:[]),y(jl(Mi)),w(Array.isArray(Mn.snippets)?Mn.snippets:[])}catch(Oe){if(U!==ir.current)return;u([]),m([]),w([]),y([]),B(String(Oe.message||Oe))}finally{if(U!==ir.current)return;M(!0)}},[e]);h.useEffect(()=>{D(!1),Er(),yr()},[Er,yr]),h.useEffect(()=>{try{localStorage.setItem(ZA,ae?"1":"0")}catch{}},[ae]),h.useEffect(()=>{try{xe?localStorage.setItem(Fb,xe):localStorage.removeItem(Fb)}catch{}},[xe]),h.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(be=>be.json()).then(be=>{U||An(!!be.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const _r=h.useCallback(async U=>{if(!o)return;const be=jl({collections:U});E(!0),B("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X$(be))}),Oe=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Oe.error||"Collections HTTP "+$e.status);y(jl(Oe))}catch($e){B(String($e.message||$e))}finally{E(!1)}},[o]),Lr=h.useCallback(()=>{if(!o)return;const U=b.trim();if(!U)return;const be=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(bt=>bt.id));let Oe=be,st=2;for(;$e.has(Oe);)Oe=`${be}-${st++}`;const un=Date.now();_r([...k,{id:Oe,name:U,skillKeys:[],createdAt:un,updatedAt:un}]),x(""),Ee(`collection:${Oe}`)},[o,b,_r,k]),or=h.useCallback(U=>{if(!o)return;const be=k.find(Oe=>Oe.id===U);if(be!=null&&be.builtin)return;const $e=k.filter(Oe=>Oe.id!==U);ue===`collection:${U}`&&Ee("all"),_r($e)},[o,ue,_r,k]),xr=h.useCallback((U,be,$e)=>{if(!o)return;const Oe=String(be||"").trim();if(!Oe)return;const st=Date.now(),un=k.map(bt=>{if(bt.id!==U)return bt;const Bn=new Set(bt.skillKeys||[]);return $e?Bn.add(Oe):Bn.delete(Oe),{...bt,skillKeys:Array.from(Bn),updatedAt:st}});_r(un)},[o,_r,k]),Or=h.useCallback(async U=>{const be=U==null?void 0:U.packageId,$e=U==null?void 0:U.version;if(!be||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:be,version:$e})))return;const Oe=nr(U);rt(Oe),Mt(""),B("");try{const st=new URLSearchParams({id:be,version:$e}),un=await fetch(`/api/marketplace/node?${st.toString()}`,{method:"DELETE"}),bt=await un.json().catch(()=>({}));if(!un.ok||(bt==null?void 0:bt.ok)===!1){const Bn=Array.isArray(bt==null?void 0:bt.usage)&&bt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:bt.usage.length})}`:"";throw new Error(((bt==null?void 0:bt.error)||"Delete failed")+Bn)}Mt(n("project:deleteMyNodeSuccess",{id:be,version:$e})),Ue(Bn=>{const vr={...Bn};return delete vr[Oe],vr}),kn(Bn=>{const vr={};for(const[Mi,Mn]of Object.entries(Bn))Mi.startsWith(`${Oe}:`)||(vr[Mi]=Mn);return vr}),me(""),await yr()}catch(st){Mt(String(st.message||st))}finally{rt("")}},[yr,n]),ws=h.useCallback(async U=>{const be=U==null?void 0:U.id,$e=(U==null?void 0:U.version)||"1.0.0";if(!be||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:be,version:$e})))return;const Oe=nl(U);gn(Oe),Jn(""),B("");try{const st=new URLSearchParams({id:be,version:$e}),un=await fetch(`/api/marketplace/flow-snippet?${st.toString()}`,{method:"DELETE"}),bt=await un.json().catch(()=>({}));if(!un.ok||(bt==null?void 0:bt.ok)===!1)throw new Error((bt==null?void 0:bt.error)||"Delete failed");Jn(n("project:deleteMyFlowSuccess",{id:be,version:$e})),me(""),await yr()}catch(st){Jn(String(st.message||st))}finally{gn("")}},[yr,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),Ee("all"),me(""),je("overview");return}l(U=>U==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const U=new URLSearchParams(window.location.search),be=U.get("tab");let $e=!1;if(be==="nodes"){r("/nodes");return}if(be==="my-nodes"){r("/my-nodes");return}if(be==="my-flows"){r("/my-flows");return}if(be==="skills"){r("/skills");return}if(be==="archived"?(l("archived"),U.delete("tab"),$e=!0):be&&(l("all"),U.delete("tab"),$e=!0),U.get("new")==="1"&&(F(!0),U.delete("new"),$e=!0),$e){const Oe=U.toString();window.history.replaceState({},"",Oe?`/projects?${Oe}`:"/projects")}},[s,r]);const ar=h.useMemo(()=>p$(N,MA(),c),[N,c,s]),Ar=h.useMemo(()=>ar.filter(U=>iD(ee,U)),[ar,ee]),In=ee.trim().toLowerCase(),Tn=h.useMemo(()=>a==="archived"?c.filter(U=>U.archived):c.filter(U=>!U.archived),[c,a]),ce=h.useMemo(()=>Tn.filter(U=>sD(U,In,n)),[Tn,In,n]),he=h.useMemo(()=>new Set((Cr.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[Cr.promoted]),Q=h.useMemo(()=>(Cr.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[Cr.hiddenBuiltins]),ge=a==="nodes"||a==="my-nodes",qe=a==="my-nodes",Me=a==="my-flows",zt=h.useMemo(()=>p.filter(U=>qe&&U.source!=="marketplace"?!1:(ue==="all"||(ue==="marketplace"?U.source==="marketplace":U.type===ue))&&Vx(ee,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[p,qe,ee,ue]),Rn=h.useMemo(()=>{const U=new Map;for(const be of k)U.set(be.id,new Set(be.skillKeys||[]));return U},[k]),Hn=h.useMemo(()=>[{id:"all",label:"全部"},...k.map(U=>({id:`collection:${U.id}`,label:U.name,count:U.skillKeys.length,collection:U})),{id:"ungrouped",label:"未分组"}],[k]),wr=h.useMemo(()=>f.filter(U=>{var Oe;const be=nr(U);let $e=ue==="all";if(ue.startsWith("collection:")){const st=ue.slice(11);$e=!!((Oe=Rn.get(st))!=null&&Oe.has(be))}else ue==="ungrouped"&&($e=!Array.from(Rn.values()).some(st=>st.has(be)));return $e&&Vx(ee,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[f,ee,ue,Rn]),Ae=h.useMemo(()=>g.filter(U=>Vx(ee,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[g,ee]),Br=ge||Me||a==="skills",lt=h.useMemo(()=>zt.find(U=>nr(U)===le)||zt[0]||null,[zt,le]),pn=h.useMemo(()=>wr.find(U=>nr(U)===le)||wr[0]||null,[wr,le]),Zt=h.useMemo(()=>Ae.find(U=>nl(U)===le)||Ae[0]||null,[Ae,le]),br=pn?Ye[nr(pn)]:null,nt=lt?Ft[nr(lt)]:null,os=lt&&We?xt[`${nr(lt)}:${We}`]:null,hi=n(ge?"project:searchNodes":Me?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(a!=="skills"||!pn)return;const U=nr(pn);if(Ye[U])return;let be=!1;return dt(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then($e=>$e.json().then(Oe=>({ok:$e.ok,json:Oe}))).then(({ok:$e,json:Oe})=>{be||$e&&Oe.skill&&tt(st=>({...st,[U]:Oe.skill}))}).catch(()=>{}).finally(()=>{be||dt("")}),()=>{be=!0}},[a,pn,Ye]),h.useEffect(()=>{if(!ge||!lt)return;const U=nr(lt);if(Ft[U])return;let be=!1;return _n(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(lt.id)}`).then($e=>$e.json().then(Oe=>({ok:$e.ok,json:Oe}))).then(({ok:$e,json:Oe})=>{be||$e&&Ue(st=>({...st,[U]:Oe}))}).catch(()=>{}).finally(()=>{be||_n("")}),()=>{be=!0}},[ge,lt,Ft]),h.useEffect(()=>{if(!ge)return;const U=Array.isArray(nt==null?void 0:nt.files)?nt.files:[];sn(be=>{var $e;return be&&U.some(Oe=>Oe.path===be)?be:(($e=U[0])==null?void 0:$e.path)||""})},[ge,nt]),h.useEffect(()=>{if(!ge||!lt||!We)return;const U=`${nr(lt)}:${We}`;if(xt[U])return;let be=!1;return _e(U),fetch(`/api/nodes/file?id=${encodeURIComponent(lt.id)}&path=${encodeURIComponent(We)}`).then($e=>$e.json().then(Oe=>({ok:$e.ok,json:Oe}))).then(({ok:$e,json:Oe})=>{be||$e&&kn(st=>({...st,[U]:Oe}))}).catch(()=>{}).finally(()=>{be||_e("")}),()=>{be=!0}},[ge,lt,We,xt]),h.useEffect(()=>{Mt("")},[le,a]);const Ii=U=>{r(em(U,"workspace"))},co=U=>{Se(dN(U)),r(em({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},uo=h.useCallback(U=>{var be,$e;U.preventDefault(),U.stopPropagation(),($e=(be=U.dataTransfer)==null?void 0:be.types)!=null&&$e.includes("Files")&&(Wt.current+=1,Z(!0))},[]),fo=h.useCallback(U=>{U.preventDefault(),U.stopPropagation(),Wt.current-=1,Wt.current<=0&&(Wt.current=0,Z(!1))},[]),Ti=h.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),Sn=h.useCallback(U=>{var Oe,st;U.preventDefault(),U.stopPropagation(),Wt.current=0,Z(!1);const be=(st=(Oe=U.dataTransfer)==null?void 0:Oe.files)==null?void 0:st[0];if(!be)return;const $e=be.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||O(be)},[]);return i.jsxs("div",{className:"af-projects"+(_?" af-projects--drop-target":""),onDragEnter:uo,onDragLeave:fo,onDragOver:Ti,onDrop:Sn,children:[i.jsxs("header",{className:"af-projects-top",children:[e?i.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):i.jsxs("div",{className:"af-projects-tabs",children:[i.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),i.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),i.jsxs("div",{className:"af-projects-top-right",children:[i.jsxs("div",{className:"af-search-wrap",children:[i.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),i.jsx("input",{className:"af-search"+(ee.trim()?" af-search--has-clear":""),type:"search",placeholder:hi,"aria-label":hi,autoComplete:"off",value:ee,onChange:U=>V(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(V(""),U.currentTarget.blur())}}),ee.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>V(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Br?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>yr(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(ae?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":ae,"aria-controls":"af-recent-activity-panel",onClick:()=>fe(U=>!U),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>F(!0),children:n("project:createNew")})]})]})]}),i.jsxs("div",{className:"af-projects-body",children:[i.jsxs("section",{className:"af-projects-main",children:[i.jsxs("header",{className:"af-projects-section-head",children:[i.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:globalNodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),i.jsx("p",{className:"af-projects-sub",children:In?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?zt.length:a==="my-flows"?Ae.length:a==="skills"?wr.length:ce.length}):a==="my-nodes"?n("project:myNodesHint",{count:zt.length}):a==="my-flows"?n("project:myFlowsHint",{count:Ae.length}):a==="nodes"?n("project:nodesHint",{count:p.length}):a==="skills"?n("project:skillsHint",{count:f.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),$?i.jsx("p",{className:"af-err af-projects-api-hint",children:$}):null,K&&Br?i.jsx("p",{className:"af-err af-projects-api-hint",children:K}):null]}),Br?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(G$,{onChanged:yr,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:Me?"schema":ge?qe?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(Me?"project:myFlowsPurposeTitle":qe?"project:myNodesPurposeTitle":ge?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(Me?"project:myFlowsPurposeDesc":qe?"project:myNodesPurposeDesc":ge?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Me?null:i.jsx("div",{className:"af-resource-filter-row",children:(ge?(qe?aD:oD).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):Hn).map(U=>U.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(ue===U.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{Ee(U.id),me("")},children:[U.label,i.jsx("em",{children:U.count}),U.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!U.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:j,"aria-label":`删除 ${U.collection.name}`,onClick:()=>or(U.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},U.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(ue===U.id?" af-resource-filter--active":""),onClick:()=>{Ee(U.id),me("")},children:U.label},U.id))}),a==="skills"&&o?i.jsx("div",{className:"af-skill-collections-manager",children:i.jsxs("div",{className:"af-skill-collections-create",children:[i.jsx("input",{className:"af-set-input af-set-input--sm",value:b,onChange:U=>x(U.target.value),onKeyDown:U=>{U.key==="Enter"&&Lr()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!b.trim()||j,onClick:()=>Lr(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,ge?i.jsx("div",{className:"af-resource-grid",children:zt.length>0?zt.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(lt&&nr(U)===nr(lt)?" af-resource-card--active":""),onClick:()=>me(nr(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:xf(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:i.jsx(Nr,{query:ee,children:U.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Nr,{query:ee,children:cN(U.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Nr,{query:ee,children:U.label||U.displayName||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Nr,{query:ee,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Nr,{query:ee,children:U.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Nr,{query:ee,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):R?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:In?n("project:noNodeMatch",{query:ee.trim()}):n(qe?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Me?i.jsx("div",{className:"af-resource-grid",children:Ae.length>0?Ae.map(U=>{const be=eP(U),$e=tP(U),Oe=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):be.length,st=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):$e.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Zt&&nl(U)===nl(Zt)?" af-resource-card--active":""),onClick:()=>me(nl(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:xf("primary"),children:i.jsx(Nr,{query:ee,children:U.version?`v${U.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Nr,{query:ee,children:U.displayName||U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Nr,{query:ee,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Oe,edges:st})}),i.jsx("span",{children:i.jsx(Nr,{query:ee,children:U.id})})]}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Nr,{query:ee,children:uN(U)})})]})]},nl(U))}):R?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:In?n("project:noFlowSnippetMatch",{query:ee.trim()}):n("project:noMyFlows")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?i.jsx("div",{className:"af-resource-grid",children:wr.length>0?wr.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(pn&&nr(U)===nr(pn)?" af-resource-card--active":""),onClick:()=>me(nr(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:xf(U.source==="builtin"?"muted":"primary"),children:i.jsx(Nr,{query:ee,children:U.sourceLabel||U.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Nr,{query:ee,children:U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Nr,{query:ee,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Nr,{query:ee,children:U.path||U.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[k.filter(be=>be.skillKeys.includes(nr(U))).slice(0,3).map(be=>i.jsx("span",{children:be.name},be.id)),k.filter(be=>be.skillKeys.includes(nr(U))).length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)):R?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:In?n("project:noSkillMatch",{query:ee.trim()}):n("project:noSkills")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i.jsxs(i.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&Q.length>0?i.jsxs("div",{className:"af-project-admin-panel",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"已隐藏内置"}),i.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),i.jsx("div",{className:"af-project-admin-hidden-list",children:Q.map(U=>{const be=Pn===`show-builtin:builtin:${U}`;return i.jsxs("button",{type:"button",disabled:be,onClick:()=>dr({id:U,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:U}),i.jsx("em",{children:be?"恢复中":"恢复"})]},U)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[ce.length>0?ce.map(U=>{const be=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!he.has(U.id),$e=(t==null?void 0:t.isAdmin)&&U.source==="admin",Oe=(t==null?void 0:t.isAdmin)&&U.source==="builtin",st=Pn.endsWith(`:${U.source}:${U.id}`);return i.jsx("div",{className:Z$(U.source),role:"button",tabIndex:0,onClick:()=>Ii(U),onKeyDown:un=>{(un.key==="Enter"||un.key===" ")&&(un.preventDefault(),Ii(U))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:xf(Db(U.source,n).tone),children:i.jsx(Nr,{query:ee,children:Db(U.source,n).label})}),U.archived?i.jsx("span",{className:xf("muted"),children:i.jsx(Nr,{query:ee,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Nr,{query:ee,children:U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Nr,{query:ee,children:QA(U,n)})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Nr,{query:ee,children:JA(U)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:un=>un.stopPropagation(),onKeyDown:un=>un.stopPropagation(),children:[be?i.jsx("button",{type:"button",disabled:st,onClick:()=>dr(U,"promote"),children:"设为内置"}):null,$e?i.jsx("button",{type:"button",disabled:st,onClick:()=>dr(U,"unpromote"),children:"取消内置"}):null,Oe?i.jsx("button",{type:"button",disabled:st,onClick:()=>dr(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}`)}):L?Tn.length===0?i.jsxs("div",{className:"af-projects-empty-block",children:[i.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n($?"project:loadFailed":"project:noPipelines")}),!$&&c.length===0&&a==="all"?i.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:ee.trim()})})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),i.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>F(!0),children:[i.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),i.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),on?null:i.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[i.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),i.jsxs("span",{className:"af-hub-card__eyebrow",children:[i.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),i.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),i.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),i.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),i.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),i.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),Br?i.jsx("aside",{className:"af-resource-detail","aria-label":n(ge?"project:nodeDetail":Me?"project:flowDetail":"project:skillDetail"),children:ge&&lt?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),i.jsxs("div",{children:[i.jsx("h3",{children:lt.label||lt.displayName||lt.id}),i.jsx("p",{children:lt.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(we===U?" af-resource-detail-tab--active":""),onClick:()=>je(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),pt===nr(lt)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):we==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:lt.description||((As=nt==null?void 0:nt.node)==null?void 0:As.description)||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailType")}),i.jsx("dd",{children:lt.type||((po=nt==null?void 0:nt.node)==null?void 0:po.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:cN(lt.source,n)})]}),lt.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:lt.packageId})]}):null,lt.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:lt.version})]}):null,lt.packageDir||nt!=null&&nt.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:lt.packageDir||(nt==null?void 0:nt.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(nt==null?void 0:nt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),qe&&lt.source==="marketplace"?i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myNodeManagement")}),i.jsx("p",{children:n("project:deleteMyNodeHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Ve===nr(lt),onClick:()=>Or(lt),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ve===nr(lt)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),it?i.jsx("p",{className:"af-resource-action-message",children:it}):null]}):null,i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:nodesMeaning")})]})]}):we==="schema"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeSchema")}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeInputs")}),tm(((Ri=nt==null?void 0:nt.node)==null?void 0:Ri.inputs)||lt.inputs).length>0?tm(((Js=nt==null?void 0:nt.node)==null?void 0:Js.inputs)||lt.inputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),tm(((Qr=nt==null?void 0:nt.node)==null?void 0:Qr.outputs)||lt.outputs).length>0?tm(((Jo=nt==null?void 0:nt.node)==null?void 0:Jo.outputs)||lt.outputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):we==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),nt!=null&&nt.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(nt.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),nt!=null&&nt.body?i.jsxs(i.Fragment,{children:[i.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),i.jsx("pre",{className:"af-resource-skill-preview",children:nt.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):we==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(nt==null?void 0:nt.files)&&nt.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:nt.files.map(U=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(We===U.path?" af-node-file-item--active":""),onClick:()=>sn(U.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:U.path})]},U.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[pe===`${nr(lt)}:${We}`?n("project:loadingResources"):os!=null&&os.binary?n("project:binaryFile"):(os==null?void 0:os.content)||n("project:selectNodeFile"),os!=null&&os.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):i.jsx("p",{children:n("project:noNodeFiles")})]}):i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(nt==null?void 0:nt.usage)&&nt.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:nt.usage.map(U=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:U.flowId}),i.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:U.instances.map(be=>be.label||be.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):Me&&Zt?(()=>{const U=hD(Zt);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"schema"}),i.jsxs("div",{children:[i.jsx("h3",{children:Zt.displayName||Zt.name||Zt.id}),i.jsx("p",{children:Zt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Zt.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:Zt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:uN(Zt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Zt.nodeCount))?Number(Zt.nodeCount):U.nodes.length,edges:Number.isFinite(Number(Zt.edgeCount))?Number(Zt.edgeCount):U.edges.length})})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:myFlowsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myFlowManagement")}),i.jsx("p",{children:n("project:deleteMyFlowHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:wt===nl(Zt),onClick:()=>ws(Zt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),wt===nl(Zt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),cn?i.jsx("p",{className:"af-resource-action-message",children:cn}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:i.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),i.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(be=>i.jsxs("g",{children:[i.jsx("path",{d:be.path}),be.label?i.jsx("text",{x:be.labelX,y:be.labelY-5,textAnchor:"middle",children:Kx(be.label,18)}):null]},be.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.diagram.nodes.map((be,$e)=>i.jsxs("g",{transform:`translate(${be.x} ${be.y})`,children:[i.jsx("rect",{width:be.width,height:be.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:be.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:be.height/2+4,textAnchor:"middle",children:$e+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:be.height/2-3,children:Kx(be.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:be.height/2+16,children:Kx(be.meta||be.id,20)})]},be.id))})]})}):i.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),i.jsxs("details",{className:"af-flow-snippet-json",children:[i.jsx("summary",{children:n("project:flowSnippetJson")}),i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Zt.snippet||{},null,2)})]})]})]})})():a==="skills"&&pn?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:pn.name||pn.id}),i.jsx("p",{children:pn.sourceLabel||pn.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:pn.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:pn.sourceLabel||pn.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:pn.path||pn.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),k.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:k.map(U=>{const be=nr(pn),$e=U.skillKeys.includes(be);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:$e,disabled:j||!o,onChange:Oe=>xr(U.id,be,Oe.target.checked)}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:U.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[U.skillKeys.length," skills"]})]})]},U.id)})})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:skillsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:skillPreview")}),i.jsx("pre",{className:"af-resource-skill-preview",children:ze===nr(pn)?n("project:loadingResources"):(br==null?void 0:br.body)||(br==null?void 0:br.content)||n("project:skillPreviewEmpty")})]})]}):i.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):i.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(ae?"":" af-activity--hidden"),"aria-hidden":!ae,"aria-label":n("project:recentActivity"),children:[i.jsxs("h2",{className:"af-activity-title",children:[i.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),i.jsx("div",{className:"af-activity-list",children:Ar.length===0?i.jsx("p",{className:"af-activity-empty",children:ar.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Ar.map(U=>{const be=xe===dN(U);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(be?" af-activity-row--active":""),"aria-current":be?"page":void 0,onClick:()=>co(U),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Nr,{query:ee,children:U.flowId})}),i.jsx("span",{className:"af-activity-time",children:Mb(U.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:eD(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",Mb(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),i.jsx(B$,{open:I,onClose:()=>F(!1),onCreated:async U=>{F(!1),await Er();const be=U.source??"user";r(em({id:U.id,source:be},"workspace"))}}),P?i.jsx(z$,{file:P,onClose:()=>O(null),onImported:async U=>{O(null),await Er();const be=U.source??"user";r(em({id:U.id,source:be},"workspace"))}},`${P.name}-${P.size}-${P.lastModified}`):null]})}function Mr(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=Mr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var mD={value:()=>{}};function Ey(){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 Vm(n)}function Vm(e){this._=e}function gD(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}})}Vm.prototype=Ey.prototype={constructor:Vm,on:function(e,t){var n=this._,r=gD(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=yD(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(s=(e=r[o]).type)n[s]=hN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=hN(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 Vm(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function yD(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function hN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=mD,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Hb="http://www.w3.org/1999/xhtml";const mN={svg:"http://www.w3.org/2000/svg",xhtml:Hb,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _y(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),mN.hasOwnProperty(t)?{space:mN[t],local:e}:e}function xD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Hb&&t.documentElement.namespaceURI===Hb?t.createElement(e):t.createElementNS(n,e)}}function wD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function nP(e){var t=_y(e);return(t.local?wD:xD)(t)}function bD(){}function T0(e){return e==null?bD:function(){return this.querySelector(e)}}function vD(e){typeof e!="function"&&(e=T0(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,d,p=0;p<a;++p)(c=o[p])&&(d=e.call(c,c.__data__,p,o))&&("__data__"in c&&(d.__data__=c.__data__),l[p]=d);return new di(r,this._parents)}function kD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function SD(){return[]}function rP(e){return e==null?SD:function(){return this.querySelectorAll(e)}}function ND(e){return function(){return kD(e.apply(this,arguments))}}function jD(e){typeof e=="function"?e=ND(e):e=rP(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var a=t[o],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 di(r,s)}function sP(e){return function(){return this.matches(e)}}function iP(e){return function(t){return t.matches(e)}}var CD=Array.prototype.find;function ED(e){return function(){return CD.call(this.children,e)}}function _D(){return this.firstElementChild}function AD(e){return this.select(e==null?_D:ED(typeof e=="function"?e:iP(e)))}var PD=Array.prototype.filter;function ID(){return Array.from(this.children)}function TD(e){return function(){return PD.call(this.children,e)}}function RD(e){return this.selectAll(e==null?ID:TD(typeof e=="function"?e:iP(e)))}function MD(e){typeof e!="function"&&(e=sP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],c,d=0;d<a;++d)(c=o[d])&&e.call(c,c.__data__,d,o)&&l.push(c);return new di(r,this._parents)}function oP(e){return new Array(e.length)}function LD(){return new di(this._enter||this._groups.map(oP),this._parents)}function Eg(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Eg.prototype={constructor:Eg,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 OD(e){return function(){return e}}function $D(e,t,n,r,s,o){for(var a=0,l,c=t.length,d=o.length;a<d;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new Eg(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function DD(e,t,n,r,s,o,a){var l,c,d=new Map,p=t.length,u=o.length,f=new Array(p),m;for(l=0;l<p;++l)(c=t[l])&&(f[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,o[l],l,o)+"",(c=d.get(m))?(r[l]=c,c.__data__=o[l],d.delete(m)):n[l]=new Eg(e,o[l]);for(l=0;l<p;++l)(c=t[l])&&d.get(f[l])===c&&(s[l]=c)}function FD(e){return e.__data__}function zD(e,t){if(!arguments.length)return Array.from(this,FD);var n=t?DD:$D,r=this._parents,s=this._groups;typeof e!="function"&&(e=OD(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),d=0;d<o;++d){var p=r[d],u=s[d],f=u.length,m=HD(e.call(p,p&&p.__data__,d,r)),g=m.length,w=l[d]=new Array(g),k=a[d]=new Array(g),y=c[d]=new Array(f);n(p,u,w,k,y,m,t);for(var b=0,x=0,j,E;b<g;++b)if(j=w[b]){for(b>=x&&(x=b+1);!(E=k[x])&&++x<g;);j._next=E||null}}return a=new di(a,r),a._enter=l,a._exit=c,a}function HD(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function BD(){return new di(this._exit||this._groups.map(oP),this._parents)}function WD(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function VD(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,a=Math.min(s,o),l=new Array(s),c=0;c<a;++c)for(var d=n[c],p=r[c],u=d.length,f=l[c]=new Array(u),m,g=0;g<u;++g)(m=d[g]||p[g])&&(f[g]=m);for(;c<s;++c)l[c]=n[c];return new di(l,this._parents)}function KD(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],a;--s>=0;)(a=r[s])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function UD(e){e||(e=qD);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=s[o]=new Array(l),d,p=0;p<l;++p)(d=a[p])&&(c[p]=d);c.sort(t)}return new di(s,this._parents).order()}function qD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function YD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function GD(){return Array.from(this)}function XD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var a=r[s];if(a)return a}return null}function JD(){let e=0;for(const t of this)++e;return e}function QD(){return!this.node()}function ZD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,a=s.length,l;o<a;++o)(l=s[o])&&e.call(l,l.__data__,o,s);return this}function eF(e){return function(){this.removeAttribute(e)}}function tF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nF(e,t){return function(){this.setAttribute(e,t)}}function rF(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sF(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function iF(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 oF(e,t){var n=_y(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?tF:eF:typeof t=="function"?n.local?iF:sF:n.local?rF:nF)(n,t))}function aP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function aF(e){return function(){this.style.removeProperty(e)}}function lF(e,t,n){return function(){this.style.setProperty(e,t,n)}}function cF(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function uF(e,t,n){return arguments.length>1?this.each((t==null?aF:typeof t=="function"?cF:lF)(e,t,n??"")):md(this.node(),e)}function md(e,t){return e.style.getPropertyValue(t)||aP(e).getComputedStyle(e,null).getPropertyValue(t)}function dF(e){return function(){delete this[e]}}function fF(e,t){return function(){this[e]=t}}function pF(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function hF(e,t){return arguments.length>1?this.each((t==null?dF:typeof t=="function"?pF:fF)(e,t)):this.node()[e]}function lP(e){return e.trim().split(/^|\s+/)}function R0(e){return e.classList||new cP(e)}function cP(e){this._node=e,this._names=lP(e.getAttribute("class")||"")}cP.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 uP(e,t){for(var n=R0(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function dP(e,t){for(var n=R0(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function mF(e){return function(){uP(this,e)}}function gF(e){return function(){dP(this,e)}}function yF(e,t){return function(){(t.apply(this,arguments)?uP:dP)(this,e)}}function xF(e,t){var n=lP(e+"");if(arguments.length<2){for(var r=R0(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?yF:t?mF:gF)(n,t))}function wF(){this.textContent=""}function bF(e){return function(){this.textContent=e}}function vF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function kF(e){return arguments.length?this.each(e==null?wF:(typeof e=="function"?vF:bF)(e)):this.node().textContent}function SF(){this.innerHTML=""}function NF(e){return function(){this.innerHTML=e}}function jF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function CF(e){return arguments.length?this.each(e==null?SF:(typeof e=="function"?jF:NF)(e)):this.node().innerHTML}function EF(){this.nextSibling&&this.parentNode.appendChild(this)}function _F(){return this.each(EF)}function AF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function PF(){return this.each(AF)}function IF(e){var t=typeof e=="function"?e:nP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function TF(){return null}function RF(e,t){var n=typeof e=="function"?e:nP(e),r=t==null?TF:typeof t=="function"?t:T0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function MF(){var e=this.parentNode;e&&e.removeChild(this)}function LF(){return this.each(MF)}function OF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $F(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function DF(e){return this.select(e?$F:OF)}function FF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function zF(e){return function(t){e.call(this,t,this.__data__)}}function HF(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 BF(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function WF(e,t,n){return function(){var r=this.__on,s,o=zF(t);if(r){for(var a=0,l=r.length;a<l;++a)if((s=r[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function VF(e,t,n){var r=HF(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,p;c<d;++c)for(s=0,p=l[c];s<o;++s)if((a=r[s]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?WF:BF,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function fP(e,t,n){var r=aP(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 KF(e,t){return function(){return fP(this,e,t)}}function UF(e,t){return function(){return fP(this,e,t.apply(this,arguments))}}function qF(e,t){return this.each((typeof t=="function"?UF:KF)(e,t))}function*YF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&(yield a)}var pP=[null];function di(e,t){this._groups=e,this._parents=t}function Zp(){return new di([[document.documentElement]],pP)}function GF(){return this}di.prototype=Zp.prototype={constructor:di,select:vD,selectAll:jD,selectChild:AD,selectChildren:RD,filter:MD,data:zD,enter:LD,exit:BD,join:WD,merge:VD,selection:GF,order:KD,sort:UD,call:YD,nodes:GD,node:XD,size:JD,empty:QD,each:ZD,attr:oF,style:uF,property:hF,classed:xF,text:kF,html:CF,raise:_F,lower:PF,append:IF,insert:RF,remove:LF,clone:DF,datum:FF,on:VF,dispatch:qF,[Symbol.iterator]:YF};function ii(e){return typeof e=="string"?new di([[document.querySelector(e)]],[document.documentElement]):new di([[e]],pP)}function XF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xi(e,t){if(e=XF(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 JF={passive:!1},jp={capture:!0,passive:!1};function Ux(e){e.stopImmediatePropagation()}function td(e){e.preventDefault(),e.stopImmediatePropagation()}function hP(e){var t=e.document.documentElement,n=ii(e).on("dragstart.drag",td,jp);"onselectstart"in t?n.on("selectstart.drag",td,jp):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function mP(e,t){var n=e.document.documentElement,r=ii(e).on("dragstart.drag",null);t&&(r.on("click.drag",td,jp),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 nm=e=>()=>e;function Bb(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:d,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}Bb.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function QF(e){return!e.ctrlKey&&!e.button}function ZF(){return this.parentNode}function ez(e,t){return t??{x:e.x,y:e.y}}function tz(){return navigator.maxTouchPoints||"ontouchstart"in this}function gP(){var e=QF,t=ZF,n=ez,r=tz,s={},o=Ey("start","drag","end"),a=0,l,c,d,p,u=0;function f(j){j.on("mousedown.drag",m).filter(r).on("touchstart.drag",k).on("touchmove.drag",y,JF).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(j,E){if(!(p||!e.call(this,j,E))){var N=x(this,t.call(this,j,E),j,E,"mouse");N&&(ii(j.view).on("mousemove.drag",g,jp).on("mouseup.drag",w,jp),hP(j.view),Ux(j),d=!1,l=j.clientX,c=j.clientY,N("start",j))}}function g(j){if(td(j),!d){var E=j.clientX-l,N=j.clientY-c;d=E*E+N*N>u}s.mouse("drag",j)}function w(j){ii(j.view).on("mousemove.drag mouseup.drag",null),mP(j.view,d),td(j),s.mouse("end",j)}function k(j,E){if(e.call(this,j,E)){var N=j.changedTouches,T=t.call(this,j,E),$=N.length,z,K;for(z=0;z<$;++z)(K=x(this,T,j,E,N[z].identifier,N[z]))&&(Ux(j),K("start",j,N[z]))}}function y(j){var E=j.changedTouches,N=E.length,T,$;for(T=0;T<N;++T)($=s[E[T].identifier])&&(td(j),$("drag",j,E[T]))}function b(j){var E=j.changedTouches,N=E.length,T,$;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),T=0;T<N;++T)($=s[E[T].identifier])&&(Ux(j),$("end",j,E[T]))}function x(j,E,N,T,$,z){var K=o.copy(),B=Xi(z||N,E),L,D,R;if((R=n.call(j,new Bb("beforestart",{sourceEvent:N,target:f,identifier:$,active:a,x:B[0],y:B[1],dx:0,dy:0,dispatch:K}),T))!=null)return L=R.x-B[0]||0,D=R.y-B[1]||0,function M(I,F,P){var O=B,_;switch(I){case"start":s[$]=M,_=a++;break;case"end":delete s[$],--a;case"drag":B=Xi(P||F,E),_=a;break}K.call(I,j,new Bb(I,{sourceEvent:F,subject:R,target:f,identifier:$,active:_,x:B[0]+L,y:B[1]+D,dx:B[0]-O[0],dy:B[1]-O[1],dispatch:K}),T)}}return f.filter=function(j){return arguments.length?(e=typeof j=="function"?j:nm(!!j),f):e},f.container=function(j){return arguments.length?(t=typeof j=="function"?j:nm(j),f):t},f.subject=function(j){return arguments.length?(n=typeof j=="function"?j:nm(j),f):n},f.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:nm(!!j),f):r},f.on=function(){var j=o.on.apply(o,arguments);return j===o?f:j},f.clickDistance=function(j){return arguments.length?(u=(j=+j)*j,f):Math.sqrt(u)},f}function M0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function yP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function eh(){}var Cp=.7,_g=1/Cp,nd="\\s*([+-]?\\d+)\\s*",Ep="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nz=/^#([0-9a-f]{3,8})$/,rz=new RegExp(`^rgb\\(${nd},${nd},${nd}\\)$`),sz=new RegExp(`^rgb\\(${Bo},${Bo},${Bo}\\)$`),iz=new RegExp(`^rgba\\(${nd},${nd},${nd},${Ep}\\)$`),oz=new RegExp(`^rgba\\(${Bo},${Bo},${Bo},${Ep}\\)$`),az=new RegExp(`^hsl\\(${Ep},${Bo},${Bo}\\)$`),lz=new RegExp(`^hsla\\(${Ep},${Bo},${Bo},${Ep}\\)$`),gN={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};M0(eh,Rc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:yN,formatHex:yN,formatHex8:cz,formatHsl:uz,formatRgb:xN,toString:xN});function yN(){return this.rgb().formatHex()}function cz(){return this.rgb().formatHex8()}function uz(){return xP(this).formatHsl()}function xN(){return this.rgb().formatRgb()}function Rc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=nz.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?wN(t):n===3?new Bs(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?rm(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?rm(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=rz.exec(e))?new Bs(t[1],t[2],t[3],1):(t=sz.exec(e))?new Bs(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=iz.exec(e))?rm(t[1],t[2],t[3],t[4]):(t=oz.exec(e))?rm(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=az.exec(e))?kN(t[1],t[2]/100,t[3]/100,1):(t=lz.exec(e))?kN(t[1],t[2]/100,t[3]/100,t[4]):gN.hasOwnProperty(e)?wN(gN[e]):e==="transparent"?new Bs(NaN,NaN,NaN,0):null}function wN(e){return new Bs(e>>16&255,e>>8&255,e&255,1)}function rm(e,t,n,r){return r<=0&&(e=t=n=NaN),new Bs(e,t,n,r)}function dz(e){return e instanceof eh||(e=Rc(e)),e?(e=e.rgb(),new Bs(e.r,e.g,e.b,e.opacity)):new Bs}function Wb(e,t,n,r){return arguments.length===1?dz(e):new Bs(e,t,n,r??1)}function Bs(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}M0(Bs,Wb,yP(eh,{brighter(e){return e=e==null?_g:Math.pow(_g,e),new Bs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Cp:Math.pow(Cp,e),new Bs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Bs(Sc(this.r),Sc(this.g),Sc(this.b),Ag(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:bN,formatHex:bN,formatHex8:fz,formatRgb:vN,toString:vN}));function bN(){return`#${wc(this.r)}${wc(this.g)}${wc(this.b)}`}function fz(){return`#${wc(this.r)}${wc(this.g)}${wc(this.b)}${wc((isNaN(this.opacity)?1:this.opacity)*255)}`}function vN(){const e=Ag(this.opacity);return`${e===1?"rgb(":"rgba("}${Sc(this.r)}, ${Sc(this.g)}, ${Sc(this.b)}${e===1?")":`, ${e})`}`}function Ag(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Sc(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function wc(e){return e=Sc(e),(e<16?"0":"")+e.toString(16)}function kN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Zi(e,t,n,r)}function xP(e){if(e instanceof Zi)return new Zi(e.h,e.s,e.l,e.opacity);if(e instanceof eh||(e=Rc(e)),!e)return new Zi;if(e instanceof Zi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,l=o-s,c=(o+s)/2;return l?(t===o?a=(n-r)/l+(n<r)*6:n===o?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?o+s:2-o-s,a*=60):l=c>0&&c<1?0:a,new Zi(a,l,c,e.opacity)}function pz(e,t,n,r){return arguments.length===1?xP(e):new Zi(e,t,n,r??1)}function Zi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}M0(Zi,pz,yP(eh,{brighter(e){return e=e==null?_g:Math.pow(_g,e),new Zi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Cp:Math.pow(Cp,e),new Zi(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 Bs(qx(e>=240?e-240:e+120,s,r),qx(e,s,r),qx(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Zi(SN(this.h),sm(this.s),sm(this.l),Ag(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=Ag(this.opacity);return`${e===1?"hsl(":"hsla("}${SN(this.h)}, ${sm(this.s)*100}%, ${sm(this.l)*100}%${e===1?")":`, ${e})`}`}}));function SN(e){return e=(e||0)%360,e<0?e+360:e}function sm(e){return Math.max(0,Math.min(1,e||0))}function qx(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 L0=e=>()=>e;function hz(e,t){return function(n){return e+n*t}}function mz(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 gz(e){return(e=+e)==1?wP:function(t,n){return n-t?mz(t,n,e):L0(isNaN(t)?n:t)}}function wP(e,t){var n=t-e;return n?hz(e,n):L0(isNaN(e)?t:e)}const Pg=function e(t){var n=gz(t);function r(s,o){var a=n((s=Wb(s)).r,(o=Wb(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),d=wP(s.opacity,o.opacity);return function(p){return s.r=a(p),s.g=l(p),s.b=c(p),s.opacity=d(p),s+""}}return r.gamma=e,r}(1);function yz(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=e[s]*(1-o)+t[s]*o;return r}}function xz(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wz(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),o=new Array(n),a;for(a=0;a<r;++a)s[a]=Xf(e[a],t[a]);for(;a<n;++a)o[a]=t[a];return function(l){for(a=0;a<r;++a)o[a]=s[a](l);return o}}function bz(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Mo(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function vz(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]=Xf(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Vb=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yx=new RegExp(Vb.source,"g");function kz(e){return function(){return e}}function Sz(e){return function(t){return e(t)+""}}function bP(e,t){var n=Vb.lastIndex=Yx.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Vb.exec(e))&&(s=Yx.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Mo(r,s)})),n=Yx.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?Sz(c[0].x):kz(t):(t=c.length,function(d){for(var p=0,u;p<t;++p)l[(u=c[p]).i]=u.x(d);return l.join("")})}function Xf(e,t){var n=typeof t,r;return t==null||n==="boolean"?L0(t):(n==="number"?Mo:n==="string"?(r=Rc(t))?(t=r,Pg):bP:t instanceof Rc?Pg:t instanceof Date?bz:xz(t)?yz:Array.isArray(t)?wz:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?vz:Mo)(e,t)}var NN=180/Math.PI,Kb={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function vP(e,t,n,r,s,o){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:o,rotate:Math.atan2(t,e)*NN,skewX:Math.atan(c)*NN,scaleX:a,scaleY:l}}var im;function Nz(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Kb:vP(t.a,t.b,t.c,t.d,t.e,t.f)}function jz(e){return e==null||(im||(im=document.createElementNS("http://www.w3.org/2000/svg","g")),im.setAttribute("transform",e),!(e=im.transform.baseVal.consolidate()))?Kb:(e=e.matrix,vP(e.a,e.b,e.c,e.d,e.e,e.f))}function kP(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function o(d,p,u,f,m,g){if(d!==u||p!==f){var w=m.push("translate(",null,t,null,n);g.push({i:w-4,x:Mo(d,u)},{i:w-2,x:Mo(p,f)})}else(u||f)&&m.push("translate("+u+t+f+n)}function a(d,p,u,f){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),f.push({i:u.push(s(u)+"rotate(",null,r)-2,x:Mo(d,p)})):p&&u.push(s(u)+"rotate("+p+r)}function l(d,p,u,f){d!==p?f.push({i:u.push(s(u)+"skewX(",null,r)-2,x:Mo(d,p)}):p&&u.push(s(u)+"skewX("+p+r)}function c(d,p,u,f,m,g){if(d!==u||p!==f){var w=m.push(s(m)+"scale(",null,",",null,")");g.push({i:w-4,x:Mo(d,u)},{i:w-2,x:Mo(p,f)})}else(u!==1||f!==1)&&m.push(s(m)+"scale("+u+","+f+")")}return function(d,p){var u=[],f=[];return d=e(d),p=e(p),o(d.translateX,d.translateY,p.translateX,p.translateY,u,f),a(d.rotate,p.rotate,u,f),l(d.skewX,p.skewX,u,f),c(d.scaleX,d.scaleY,p.scaleX,p.scaleY,u,f),d=p=null,function(m){for(var g=-1,w=f.length,k;++g<w;)u[(k=f[g]).i]=k.x(m);return u.join("")}}}var Cz=kP(Nz,"px, ","px)","deg)"),Ez=kP(jz,", ",")",")"),_z=1e-12;function jN(e){return((e=Math.exp(e))+1/e)/2}function Az(e){return((e=Math.exp(e))-1/e)/2}function Pz(e){return((e=Math.exp(2*e))-1)/(e+1)}const Km=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],d=o[2],p=a[0],u=a[1],f=a[2],m=p-l,g=u-c,w=m*m+g*g,k,y;if(w<_z)y=Math.log(f/d)/t,k=function(T){return[l+T*m,c+T*g,d*Math.exp(t*T*y)]};else{var b=Math.sqrt(w),x=(f*f-d*d+r*w)/(2*d*n*b),j=(f*f-d*d-r*w)/(2*f*n*b),E=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(j*j+1)-j);y=(N-E)/t,k=function(T){var $=T*y,z=jN(E),K=d/(n*b)*(z*Pz(t*$+E)-Az(E));return[l+K*m,c+K*g,d*z/jN(t*$+E)]}}return k.duration=y*1e3*t/Math.SQRT2,k}return s.rho=function(o){var a=Math.max(.001,+o),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var gd=0,Tf=0,wf=0,SP=1e3,Ig,Rf,Tg=0,Mc=0,Ay=0,_p=typeof performance=="object"&&performance.now?performance:Date,NP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function O0(){return Mc||(NP(Iz),Mc=_p.now()+Ay)}function Iz(){Mc=0}function Rg(){this._call=this._time=this._next=null}Rg.prototype=jP.prototype={constructor:Rg,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?O0():+n)+(t==null?0:+t),!this._next&&Rf!==this&&(Rf?Rf._next=this:Ig=this,Rf=this),this._call=e,this._time=n,Ub()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ub())}};function jP(e,t,n){var r=new Rg;return r.restart(e,t,n),r}function Tz(){O0(),++gd;for(var e=Ig,t;e;)(t=Mc-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gd}function CN(){Mc=(Tg=_p.now())+Ay,gd=Tf=0;try{Tz()}finally{gd=0,Mz(),Mc=0}}function Rz(){var e=_p.now(),t=e-Tg;t>SP&&(Ay-=t,Tg=e)}function Mz(){for(var e,t=Ig,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:Ig=n);Rf=e,Ub(r)}function Ub(e){if(!gd){Tf&&(Tf=clearTimeout(Tf));var t=e-Mc;t>24?(e<1/0&&(Tf=setTimeout(CN,e-_p.now()-Ay)),wf&&(wf=clearInterval(wf))):(wf||(Tg=_p.now(),wf=setInterval(Rz,SP)),gd=1,NP(CN))}}function EN(e,t,n){var r=new Rg;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var Lz=Ey("start","end","cancel","interrupt"),Oz=[],CP=0,_N=1,qb=2,Um=3,AN=4,Yb=5,qm=6;function Py(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;$z(e,n,{name:t,index:r,group:s,on:Lz,tween:Oz,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:CP})}function $0(e,t){var n=ao(e,t);if(n.state>CP)throw new Error("too late; already scheduled");return n}function Go(e,t){var n=ao(e,t);if(n.state>Um)throw new Error("too late; already running");return n}function ao(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function $z(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=jP(o,0,n.time);function o(d){n.state=_N,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var p,u,f,m;if(n.state!==_N)return c();for(p in r)if(m=r[p],m.name===n.name){if(m.state===Um)return EN(a);m.state===AN?(m.state=qm,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[p]):+p<t&&(m.state=qm,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[p])}if(EN(function(){n.state===Um&&(n.state=AN,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=qb,n.on.call("start",e,e.__data__,n.index,n.group),n.state===qb){for(n.state=Um,s=new Array(f=n.tween.length),p=0,u=-1;p<f;++p)(m=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++u]=m);s.length=u+1}}function l(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=Yb,1),u=-1,f=s.length;++u<f;)s[u].call(e,p);n.state===Yb&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=qm,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Ym(e,t){var n=e.__transition,r,s,o=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}s=r.state>qb&&r.state<Yb,r.state=qm,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function Dz(e){return this.each(function(){Ym(this,e)})}function Fz(e,t){var n,r;return function(){var s=Go(this,e),o=s.tween;if(o!==n){r=n=o;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}s.tween=r}}function zz(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Go(this,e),a=o.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)}o.tween=s}}function Hz(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ao(this.node(),n).tween,s=0,o=r.length,a;s<o;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?Fz:zz)(n,e,t))}function D0(e,t,n){var r=e._id;return e.each(function(){var s=Go(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ao(s,r).value[t]}}function EP(e,t){var n;return(typeof t=="number"?Mo:t instanceof Rc?Pg:(n=Rc(t))?(t=n,Pg):bP)(e,t)}function Bz(e){return function(){this.removeAttribute(e)}}function Wz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vz(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttribute(e);return a===s?null:a===r?o:o=t(r=a,n)}}function Kz(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?o:o=t(r=a,n)}}function Uz(e,t,n){var r,s,o;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?o:(s=c,o=t(r=a,l)))}}function qz(e,t,n){var r,s,o;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?o:(s=c,o=t(r=a,l)))}}function Yz(e,t){var n=_y(e),r=n==="transform"?Ez:EP;return this.attrTween(e,typeof t=="function"?(n.local?qz:Uz)(n,r,D0(this,"attr."+e,t)):t==null?(n.local?Wz:Bz)(n):(n.local?Kz:Vz)(n,r,t))}function Gz(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Xz(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Jz(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Xz(e,o)),n}return s._value=t,s}function Qz(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Gz(e,o)),n}return s._value=t,s}function Zz(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=_y(e);return this.tween(n,(r.local?Jz:Qz)(r,t))}function e3(e,t){return function(){$0(this,e).delay=+t.apply(this,arguments)}}function t3(e,t){return t=+t,function(){$0(this,e).delay=t}}function n3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?e3:t3)(t,e)):ao(this.node(),t).delay}function r3(e,t){return function(){Go(this,e).duration=+t.apply(this,arguments)}}function s3(e,t){return t=+t,function(){Go(this,e).duration=t}}function i3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?r3:s3)(t,e)):ao(this.node(),t).duration}function o3(e,t){if(typeof t!="function")throw new Error;return function(){Go(this,e).ease=t}}function a3(e){var t=this._id;return arguments.length?this.each(o3(t,e)):ao(this.node(),t).ease}function l3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Go(this,e).ease=n}}function c3(e){if(typeof e!="function")throw new Error;return this.each(l3(this._id,e))}function u3(e){typeof e!="function"&&(e=sP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],c,d=0;d<a;++d)(c=o[d])&&e.call(c,c.__data__,d,o)&&l.push(c);return new Aa(r,this._parents,this._name,this._id)}function d3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],d=n[l],p=c.length,u=a[l]=new Array(p),f,m=0;m<p;++m)(f=c[m]||d[m])&&(u[m]=f);for(;l<r;++l)a[l]=t[l];return new Aa(a,this._parents,this._name,this._id)}function f3(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 p3(e,t,n){var r,s,o=f3(t)?$0:Go;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function h3(e,t){var n=this._id;return arguments.length<2?ao(this.node(),n).on.on(e):this.each(p3(n,e,t))}function m3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function g3(){return this.on("end.remove",m3(this._id))}function y3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=T0(e));for(var r=this._groups,s=r.length,o=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,d=o[a]=new Array(c),p,u,f=0;f<c;++f)(p=l[f])&&(u=e.call(p,p.__data__,f,l))&&("__data__"in p&&(u.__data__=p.__data__),d[f]=u,Py(d[f],t,n,f,d,ao(p,n)));return new Aa(o,this._parents,t,n)}function x3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var c=r[l],d=c.length,p,u=0;u<d;++u)if(p=c[u]){for(var f=e.call(p,p.__data__,u,c),m,g=ao(p,n),w=0,k=f.length;w<k;++w)(m=f[w])&&Py(m,t,n,w,f,g);o.push(f),a.push(p)}return new Aa(o,a,t,n)}var w3=Zp.prototype.constructor;function b3(){return new w3(this._groups,this._parents)}function v3(e,t){var n,r,s;return function(){var o=md(this,e),a=(this.style.removeProperty(e),md(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function _P(e){return function(){this.style.removeProperty(e)}}function k3(e,t,n){var r,s=n+"",o;return function(){var a=md(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function S3(e,t,n){var r,s,o;return function(){var a=md(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),md(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function N3(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Go(this,e),d=c.on,p=c.value[o]==null?l||(l=_P(t)):void 0;(d!==n||s!==p)&&(r=(n=d).copy()).on(a,s=p),c.on=r}}function j3(e,t,n){var r=(e+="")=="transform"?Cz:EP;return t==null?this.styleTween(e,v3(e,r)).on("end.style."+e,_P(e)):typeof t=="function"?this.styleTween(e,S3(e,r,D0(this,"style."+e,t))).each(N3(this._id,e)):this.styleTween(e,k3(e,r,t),n).on("end.style."+e,null)}function C3(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function E3(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&C3(e,a,n)),r}return o._value=t,o}function _3(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,E3(e,t,n??""))}function A3(e){return function(){this.textContent=e}}function P3(e){return function(){var t=e(this);this.textContent=t??""}}function I3(e){return this.tween("text",typeof e=="function"?P3(D0(this,"text",e)):A3(e==null?"":e+""))}function T3(e){return function(t){this.textContent=e.call(this,t)}}function R3(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&T3(s)),t}return r._value=e,r}function M3(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,R3(e))}function L3(){for(var e=this._name,t=this._id,n=AP(),r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,d=0;d<l;++d)if(c=a[d]){var p=ao(c,t);Py(c,e,n,d,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Aa(r,this._parents,e,n)}function O3(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,a){var l={value:a},c={value:function(){--s===0&&o()}};n.each(function(){var d=Go(this,r),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&o()})}var $3=0;function Aa(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function AP(){return++$3}var fa=Zp.prototype;Aa.prototype={constructor:Aa,select:y3,selectAll:x3,selectChild:fa.selectChild,selectChildren:fa.selectChildren,filter:u3,merge:d3,selection:b3,transition:L3,call:fa.call,nodes:fa.nodes,node:fa.node,size:fa.size,empty:fa.empty,each:fa.each,on:h3,attr:Yz,attrTween:Zz,style:j3,styleTween:_3,text:I3,textTween:M3,remove:g3,tween:Hz,delay:n3,duration:i3,ease:a3,easeVarying:c3,end:O3,[Symbol.iterator]:fa[Symbol.iterator]};function D3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var F3={time:null,delay:0,duration:250,ease:D3};function z3(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 H3(e){var t,n;e instanceof Aa?(t=e._id,e=e._name):(t=AP(),(n=F3).time=O0(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,d=0;d<l;++d)(c=a[d])&&Py(c,e,t,d,a,n||z3(c,t));return new Aa(r,this._parents,e,t)}Zp.prototype.interrupt=Dz;Zp.prototype.transition=H3;const om=e=>()=>e;function B3(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 ba(e,t,n){this.k=e,this.x=t,this.y=n}ba.prototype={constructor:ba,scale:function(e){return e===1?this:new ba(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ba(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 Iy=new ba(1,0,0);PP.prototype=ba.prototype;function PP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Iy;return e.__zoom}function Gx(e){e.stopImmediatePropagation()}function bf(e){e.preventDefault(),e.stopImmediatePropagation()}function W3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function V3(){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 PN(){return this.__zoom||Iy}function K3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function U3(){return navigator.maxTouchPoints||"ontouchstart"in this}function q3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function IP(){var e=W3,t=V3,n=q3,r=K3,s=U3,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Km,d=Ey("start","zoom","end"),p,u,f,m=500,g=150,w=0,k=10;function y(R){R.property("__zoom",PN).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",K).filter(s).on("touchstart.zoom",B).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(R,M,I,F){var P=R.selection?R.selection():R;P.property("__zoom",PN),R!==P?E(R,M,I,F):P.interrupt().each(function(){N(this,arguments).event(F).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},y.scaleBy=function(R,M,I,F){y.scaleTo(R,function(){var P=this.__zoom.k,O=typeof M=="function"?M.apply(this,arguments):M;return P*O},I,F)},y.scaleTo=function(R,M,I,F){y.transform(R,function(){var P=t.apply(this,arguments),O=this.__zoom,_=I==null?j(P):typeof I=="function"?I.apply(this,arguments):I,Z=O.invert(_),ee=typeof M=="function"?M.apply(this,arguments):M;return n(x(b(O,ee),_,Z),P,a)},I,F)},y.translateBy=function(R,M,I,F){y.transform(R,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,F)},y.translateTo=function(R,M,I,F,P){y.transform(R,function(){var O=t.apply(this,arguments),_=this.__zoom,Z=F==null?j(O):typeof F=="function"?F.apply(this,arguments):F;return n(Iy.translate(Z[0],Z[1]).scale(_.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof I=="function"?-I.apply(this,arguments):-I),O,a)},F,P)};function b(R,M){return M=Math.max(o[0],Math.min(o[1],M)),M===R.k?R:new ba(M,R.x,R.y)}function x(R,M,I){var F=M[0]-I[0]*R.k,P=M[1]-I[1]*R.k;return F===R.x&&P===R.y?R:new ba(R.k,F,P)}function j(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function E(R,M,I,F){R.on("start.zoom",function(){N(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(F).end()}).tween("zoom",function(){var P=this,O=arguments,_=N(P,O).event(F),Z=t.apply(P,O),ee=I==null?j(Z):typeof I=="function"?I.apply(P,O):I,V=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),ae=P.__zoom,fe=typeof M=="function"?M.apply(P,O):M,xe=c(ae.invert(ee).concat(V/ae.k),fe.invert(ee).concat(V/fe.k));return function(Se){if(Se===1)Se=fe;else{var ue=xe(Se),Ee=V/ue[2];Se=new ba(Ee,ee[0]-ue[0]*Ee,ee[1]-ue[1]*Ee)}_.zoom(null,Se)}})}function N(R,M,I){return!I&&R.__zooming||new T(R,M)}function T(R,M){this.that=R,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,M),this.taps=0}T.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,M){return this.mouse&&R!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var M=ii(this.that).datum();d.call(R,this.that,new B3(R,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),M)}};function $(R,...M){if(!e.apply(this,arguments))return;var I=N(this,M).event(R),F=this.__zoom,P=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),O=Xi(R);if(I.wheel)(I.mouse[0][0]!==O[0]||I.mouse[0][1]!==O[1])&&(I.mouse[1]=F.invert(I.mouse[0]=O)),clearTimeout(I.wheel);else{if(F.k===P)return;I.mouse=[O,F.invert(O)],Ym(this),I.start()}bf(R),I.wheel=setTimeout(_,g),I.zoom("mouse",n(x(b(F,P),I.mouse[0],I.mouse[1]),I.extent,a));function _(){I.wheel=null,I.end()}}function z(R,...M){if(f||!e.apply(this,arguments))return;var I=R.currentTarget,F=N(this,M,!0).event(R),P=ii(R.view).on("mousemove.zoom",ee,!0).on("mouseup.zoom",V,!0),O=Xi(R,I),_=R.clientX,Z=R.clientY;hP(R.view),Gx(R),F.mouse=[O,this.__zoom.invert(O)],Ym(this),F.start();function ee(ae){if(bf(ae),!F.moved){var fe=ae.clientX-_,xe=ae.clientY-Z;F.moved=fe*fe+xe*xe>w}F.event(ae).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=Xi(ae,I),F.mouse[1]),F.extent,a))}function V(ae){P.on("mousemove.zoom mouseup.zoom",null),mP(ae.view,F.moved),bf(ae),F.event(ae).end()}}function K(R,...M){if(e.apply(this,arguments)){var I=this.__zoom,F=Xi(R.changedTouches?R.changedTouches[0]:R,this),P=I.invert(F),O=I.k*(R.shiftKey?.5:2),_=n(x(b(I,O),F,P),t.apply(this,M),a);bf(R),l>0?ii(this).transition().duration(l).call(E,_,F,R):ii(this).call(y.transform,_,F,R)}}function B(R,...M){if(e.apply(this,arguments)){var I=R.touches,F=I.length,P=N(this,M,R.changedTouches.length===F).event(R),O,_,Z,ee;for(Gx(R),_=0;_<F;++_)Z=I[_],ee=Xi(Z,this),ee=[ee,this.__zoom.invert(ee),Z.identifier],P.touch0?!P.touch1&&P.touch0[2]!==ee[2]&&(P.touch1=ee,P.taps=0):(P.touch0=ee,O=!0,P.taps=1+!!p);p&&(p=clearTimeout(p)),O&&(P.taps<2&&(u=ee[0],p=setTimeout(function(){p=null},m)),Ym(this),P.start())}}function L(R,...M){if(this.__zooming){var I=N(this,M).event(R),F=R.changedTouches,P=F.length,O,_,Z,ee;for(bf(R),O=0;O<P;++O)_=F[O],Z=Xi(_,this),I.touch0&&I.touch0[2]===_.identifier?I.touch0[0]=Z:I.touch1&&I.touch1[2]===_.identifier&&(I.touch1[0]=Z);if(_=I.that.__zoom,I.touch1){var V=I.touch0[0],ae=I.touch0[1],fe=I.touch1[0],xe=I.touch1[1],Se=(Se=fe[0]-V[0])*Se+(Se=fe[1]-V[1])*Se,ue=(ue=xe[0]-ae[0])*ue+(ue=xe[1]-ae[1])*ue;_=b(_,Math.sqrt(Se/ue)),Z=[(V[0]+fe[0])/2,(V[1]+fe[1])/2],ee=[(ae[0]+xe[0])/2,(ae[1]+xe[1])/2]}else if(I.touch0)Z=I.touch0[0],ee=I.touch0[1];else return;I.zoom("touch",n(x(_,Z,ee),I.extent,a))}}function D(R,...M){if(this.__zooming){var I=N(this,M).event(R),F=R.changedTouches,P=F.length,O,_;for(Gx(R),f&&clearTimeout(f),f=setTimeout(function(){f=null},m),O=0;O<P;++O)_=F[O],I.touch0&&I.touch0[2]===_.identifier?delete I.touch0:I.touch1&&I.touch1[2]===_.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(_=Xi(_,this),Math.hypot(u[0]-_[0],u[1]-_[1])<k)){var Z=ii(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return y.wheelDelta=function(R){return arguments.length?(r=typeof R=="function"?R:om(+R),y):r},y.filter=function(R){return arguments.length?(e=typeof R=="function"?R:om(!!R),y):e},y.touchable=function(R){return arguments.length?(s=typeof R=="function"?R:om(!!R),y):s},y.extent=function(R){return arguments.length?(t=typeof R=="function"?R:om([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),y):t},y.scaleExtent=function(R){return arguments.length?(o[0]=+R[0],o[1]=+R[1],y):[o[0],o[1]]},y.translateExtent=function(R){return arguments.length?(a[0][0]=+R[0][0],a[1][0]=+R[1][0],a[0][1]=+R[0][1],a[1][1]=+R[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(R){return arguments.length?(n=R,y):n},y.duration=function(R){return arguments.length?(l=+R,y):l},y.interpolate=function(R){return arguments.length?(c=R,y):c},y.on=function(){var R=d.on.apply(d,arguments);return R===d?y:R},y.clickDistance=function(R){return arguments.length?(w=(R=+R)*R,y):Math.sqrt(w)},y.tapDistance=function(R){return arguments.length?(k=+R,y):k},y}const Uo={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."},Ap=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],TP=["Enter"," ","Escape"],RP={"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 yd;(function(e){e.Strict="strict",e.Loose="loose"})(yd||(yd={}));var Nc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Nc||(Nc={}));var Pp;(function(e){e.Partial="partial",e.Full="full"})(Pp||(Pp={}));const MP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var dl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(dl||(dl={}));var js;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(js||(js={}));var Qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Qe||(Qe={}));const IN={[Qe.Left]:Qe.Right,[Qe.Right]:Qe.Left,[Qe.Top]:Qe.Bottom,[Qe.Bottom]:Qe.Top};function LP(e){return e===null?null:e?"valid":"invalid"}const OP=e=>"id"in e&&"source"in e&&"target"in e,Y3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),F0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),th=(e,t=[0,0])=>{const{width:n,height:r}=Ra(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},G3=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const o=typeof s=="string";let a=!t.nodeLookup&&!o?s:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(s):F0(s)?s:t.nodeLookup.get(s.id));const l=a?Mg(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ty(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ry(n)},nh=(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=Ty(n,Mg(s)),r=!0)}),r?Ry(n):{x:0,y:0,width:0,height:0}},z0=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...sh(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:p,selectable:u=!0,hidden:f=!1}=d;if(a&&!u||f)continue;const m=p.width??d.width??d.initialWidth??null,g=p.height??d.height??d.initialHeight??null,w=Ip(l,wd(d)),k=(m??0)*(g??0),y=o&&w>0;(!d.internals.handleBounds||y||w>=k||d.dragging)&&c.push(d)}return c},X3=(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 J3(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 Q3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=J3(e,a),c=nh(l),d=H0(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??o,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function $P({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let u=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Uo.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(u=[[c,d],[c+m,d+g]])}else l&&bd(a.extent)&&(u=[[a.extent[0][0]+c,a.extent[0][1]+d],[a.extent[1][0]+c,a.extent[1][1]+d]]);const f=bd(u)?Lc(t,u,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Uo.error015())),{position:{x:f.x-c+(a.measured.width??0)*p[0],y:f.y-d+(a.measured.height??0)*p[1]},positionAbsolute:f}}async function Z3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(f=>f.id)),a=[];for(const f of n){if(f.deletable===!1)continue;const m=o.has(f.id),g=!m&&f.parentId&&a.find(w=>w.id===f.parentId);(m||g)&&a.push(f)}const l=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),p=X3(a,c);for(const f of c)l.has(f.id)&&!p.find(g=>g.id===f.id)&&p.push(f);if(!s)return{edges:p,nodes:a};const u=await s({nodes:a,edges:p});return typeof u=="boolean"?u?{edges:p,nodes:a}:{edges:[],nodes:[]}:u}const xd=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Lc=(e={x:0,y:0},t,n)=>({x:xd(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:xd(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function DP(e,t,n){const{width:r,height:s}=Ra(n),{x:o,y:a}=n.internals.positionAbsolute;return Lc(e,[[o,a],[o+r,a+s]],t)}const TN=(e,t,n)=>e<t?xd(Math.abs(e-t),1,t)/t:e>n?-xd(Math.abs(e-n),1,t)/t:0,FP=(e,t,n=15,r=40)=>{const s=TN(e.x,r,t.width-r)*n,o=TN(e.y,r,t.height-r)*n;return[s,o]},Ty=(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)}),Gb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ry=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),wd=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=F0(e)?e.internals.positionAbsolute:th(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Mg=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=F0(e)?e.internals.positionAbsolute:th(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},zP=(e,t)=>Ry(Ty(Gb(e),Gb(t))),Ip=(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)},RN=e=>eo(e.width)&&eo(e.height)&&eo(e.x)&&eo(e.y),eo=e=>!isNaN(e)&&isFinite(e),eH=(e,t)=>{},rh=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),sh=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?rh(l,a):l},Lg=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function bu(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 tH(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=bu(e,n),s=bu(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=bu(e.top??e.y??0,n),s=bu(e.bottom??e.y??0,n),o=bu(e.left??e.x??0,t),a=bu(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:o,x:o+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function nH(e,t,n,r,s,o){const{x:a,y:l}=Lg(e,[t,n,r]),{x:c,y:d}=Lg({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=s-c,u=o-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(u)}}const H0=(e,t,n,r,s,o)=>{const a=tH(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),p=xd(d,r,s),u=e.x+e.width/2,f=e.y+e.height/2,m=t/2-u*p,g=n/2-f*p,w=nH(e,m,g,p,t,n),k={left:Math.min(w.left-a.left,0),top:Math.min(w.top-a.top,0),right:Math.min(w.right-a.right,0),bottom:Math.min(w.bottom-a.bottom,0)};return{x:m-k.left+k.right,y:g-k.top+k.bottom,zoom:p}},Tp=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function bd(e){return e!=null&&e!=="parent"}function Ra(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 HP(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 BP(e,t={width:0,height:0},n,r,s){const o={...e},a=r.get(n);if(a){const l=a.origin||s;o.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],o.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return o}function MN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function rH(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function sH(e){return{...RP,...e||{}}}function Jf(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=to(e),l=sh({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?rh(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const B0=e=>({width:e.offsetWidth,height:e.offsetHeight}),WP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},iH=["INPUT","SELECT","TEXTAREA"];function VP(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:iH.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const KP=e=>"clientX"in e,to=(e,t)=>{var o,a;const n=KP(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},LN=(e,t,n,r,s)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...B0(a)}})};function UP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,d=t*.125+o*.375+l*.375+r*.125,p=Math.abs(c-e),u=Math.abs(d-t);return[c,d,p,u]}function am(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ON({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Qe.Left:return[t-am(t-r,o),n];case Qe.Right:return[t+am(r-t,o),n];case Qe.Top:return[t,n-am(n-s,o)];case Qe.Bottom:return[t,n+am(s-n,o)]}}function qP({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:s,targetPosition:o=Qe.Top,curvature:a=.25}){const[l,c]=ON({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,p]=ON({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[u,f,m,g]=UP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:p});return[`M${e},${t} C${l},${c} ${d},${p} ${r},${s}`,u,f,m,g]}function YP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[o,l,s,a]}function oH({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function aH({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=Ty(Mg(e),Mg(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Ip(a,Ry(o))>0}const lH=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,cH=(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)),rd=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||lH;let s;return OP(e)?s={...e}:s={...e,id:r(e)},cH(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function GP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=YP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const $N={[Qe.Left]:{x:-1,y:0},[Qe.Right]:{x:1,y:0},[Qe.Top]:{x:0,y:-1},[Qe.Bottom]:{x:0,y:1}},uH=({source:e,sourcePosition:t=Qe.Bottom,target:n})=>t===Qe.Left||t===Qe.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},DN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dH({source:e,sourcePosition:t=Qe.Bottom,target:n,targetPosition:r=Qe.Top,center:s,offset:o,stepPosition:a}){const l=$N[t],c=$N[r],d={x:e.x+l.x*o,y:e.y+l.y*o},p={x:n.x+c.x*o,y:n.y+c.y*o},u=uH({source:d,sourcePosition:t,target:p}),f=u.x!==0?"x":"y",m=u[f];let g=[],w,k;const y={x:0,y:0},b={x:0,y:0},[,,x,j]=YP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[f]*c[f]===-1){f==="x"?(w=s.x??d.x+(p.x-d.x)*a,k=s.y??(d.y+p.y)/2):(w=s.x??(d.x+p.x)/2,k=s.y??d.y+(p.y-d.y)*a);const $=[{x:w,y:d.y},{x:w,y:p.y}],z=[{x:d.x,y:k},{x:p.x,y:k}];l[f]===m?g=f==="x"?$:z:g=f==="x"?z:$}else{const $=[{x:d.x,y:p.y}],z=[{x:p.x,y:d.y}];if(f==="x"?g=l.x===m?z:$:g=l.y===m?$:z,t===r){const R=Math.abs(e[f]-n[f]);if(R<=o){const M=Math.min(o-1,o-R);l[f]===m?y[f]=(d[f]>e[f]?-1:1)*M:b[f]=(p[f]>n[f]?-1:1)*M}}if(t!==r){const R=f==="x"?"y":"x",M=l[f]===c[R],I=d[R]>p[R],F=d[R]<p[R];(l[f]===1&&(!M&&I||M&&F)||l[f]!==1&&(!M&&F||M&&I))&&(g=f==="x"?$:z)}const K={x:d.x+y.x,y:d.y+y.y},B={x:p.x+b.x,y:p.y+b.y},L=Math.max(Math.abs(K.x-g[0].x),Math.abs(B.x-g[0].x)),D=Math.max(Math.abs(K.y-g[0].y),Math.abs(B.y-g[0].y));L>=D?(w=(K.x+B.x)/2,k=g[0].y):(w=g[0].x,k=(K.y+B.y)/2)}const E={x:d.x+y.x,y:d.y+y.y},N={x:p.x+b.x,y:p.y+b.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],w,k,x,j]}function fH(e,t,n,r){const s=Math.min(DN(e,t)/2,DN(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+s*d},${a}Q ${o},${a} ${o},${a+s*p}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${a+s*c}Q ${o},${a} ${o+s*l},${a}`}function Xb({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:s,targetPosition:o=Qe.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:p=.5}){const[u,f,m,g,w]=dH({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:d,stepPosition:p});let k=`M${u[0].x} ${u[0].y}`;for(let y=1;y<u.length-1;y++)k+=fH(u[y-1],u[y],u[y+1],a);return k+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[k,f,m,g,w]}function FN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function pH(e){var u;const{sourceNode:t,targetNode:n}=e;if(!FN(t)||!FN(n))return null;const r=t.internals.handleBounds||zN(t.handles),s=n.internals.handleBounds||zN(n.handles),o=HN((r==null?void 0:r.source)??[],e.sourceHandle),a=HN(e.connectionMode===yd.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!o||!a)return(u=e.onError)==null||u.call(e,"008",Uo.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Qe.Bottom,c=(a==null?void 0:a.position)||Qe.Top,d=Oc(t,o,l),p=Oc(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:c}}function zN(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 Oc(e,t,n=Qe.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Ra(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Qe.Top:return{x:s+a/2,y:o};case Qe.Right:return{x:s+a,y:o+l/2};case Qe.Bottom:return{x:s+a/2,y:o+l};case Qe.Left:return{x:s,y:o+l/2}}}function HN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jb(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function hH(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const o=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=Jb(c,t);o.has(d)||(a.push({id:d,color:c.color||n,...c}),o.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const XP=1e3,mH=10,W0={nodeOrigin:[0,0],nodeExtent:Ap,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},gH={...W0,checkEquality:!0};function V0(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function yH(e,t,n){const r=V0(W0,n);for(const s of e.values())if(s.parentId)U0(s,e,t,r);else{const o=th(s,r.nodeOrigin),a=bd(s.extent)?s.extent:r.nodeExtent,l=Lc(o,a,Ra(s));s.internals.positionAbsolute=l}}function xH(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const o={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(o):s.type==="target"&&r.push(o)}return{source:n,target:r}}function K0(e){return e==="manual"}function Qb(e,t,n,r={}){var p,u;const s=V0(gH,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!K0(s.zIndexMode)?XP:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let m=a.get(f.id);if(s.checkEquality&&f===(m==null?void 0:m.internals.userNode))t.set(f.id,m);else{const g=th(f,s.nodeOrigin),w=bd(f.extent)?f.extent:s.nodeExtent,k=Lc(g,w,Ra(f));m={...s.defaults,...f,measured:{width:(p=f.measured)==null?void 0:p.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:k,handleBounds:xH(f,m),z:JP(f,l,s.zIndexMode),userNode:f}},t.set(f.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),f.parentId&&U0(m,t,n,r,o),d||(d=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function wH(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 U0(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=V0(W0,r),d=e.parentId,p=t.get(d);if(!p){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}wH(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&c==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*mH),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const u=o&&!K0(c)?XP:0,{x:f,y:m,z:g}=bH(e,p,a,l,u,c),{positionAbsolute:w}=e.internals,k=f!==w.x||m!==w.y;(k||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:f,y:m}:w,z:g}})}function JP(e,t,n){const r=eo(e.zIndex)?e.zIndex:0;return K0(n)?r:r+(e.selected?t:0)}function bH(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=Ra(e),d=th(e,n),p=bd(e.extent)?Lc(d,e.extent,c):d;let u=Lc({x:a+p.x,y:l+p.y},r,c);e.extent==="parent"&&(u=DP(u,c,t));const f=JP(e,s,o),m=t.internals.z??0;return{x:u.x,y:u.y,z:m>=f?m+1:f}}function q0(e,t,n,r=[0,0]){var a;const s=[],o=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const d=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??wd(c),p=zP(d,l.rect);o.set(l.parentId,{expandedRect:p,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},d)=>{var x;const p=c.internals.positionAbsolute,u=Ra(c),f=c.origin??r,m=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,g=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,w=Math.max(u.width,Math.round(l.width)),k=Math.max(u.height,Math.round(l.height)),y=(w-u.width)*f[0],b=(k-u.height)*f[1];(m>0||g>0||y||b)&&(s.push({id:d,type:"position",position:{x:c.position.x-m+y,y:c.position.y-g+b}}),(x=n.get(d))==null||x.forEach(j=>{e.some(E=>E.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:w+(m?f[0]*m-y:0),height:k+(g?f[1]*g-b:0)}})}),s}function vH(e,t,n,r,s,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],p=window.getComputedStyle(l),{m22:u}=new window.DOMMatrixReadOnly(p.transform),f=[];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 w=B0(m.nodeElement),k=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(k||!g.internals.handleBounds||m.force))){const b=m.nodeElement.getBoundingClientRect(),x=bd(g.extent)?g.extent:o;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=DP(j,w,t.get(g.parentId)):x&&(j=Lc(j,x,w));const E={...g,measured:w,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:LN("source",m.nodeElement,b,u,g.id),target:LN("target",m.nodeElement,b,u,g.id)}}};t.set(g.id,E),g.parentId&&U0(E,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,k&&(d.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:wd(E,s)}))}}if(f.length>0){const m=q0(f,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function kH({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,o]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function BN(e,t,n,r,s,o){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),o){a=`${s}-${e}-${o}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function QP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:o,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:o,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${o}-${l}`,p=`${o}-${l}--${s}-${a}`;BN("source",c,p,e,s,a),BN("target",c,d,e,o,l),t.set(r.id,r)}}function ZP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ZP(n,t):!1}function WN(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 SH(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!ZP(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(o);l&&s.set(o,{id:o,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function Xx({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[d,p]of t){const u=(a=n.get(d))==null?void 0:a.internals.userNode;u&&s.push({...u,position:p.position,dragging:r})}if(!e)return[s[0],s];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:s[0],s]}function NH({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const o={x:n-s.distance.x,y:r-s.distance.y},a=rh(o,t);return{x:a.x-o.x,y:a.y-o.y}}function jH({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,c=!1,d={x:0,y:0},p=null,u=!1,f=null,m=!1,g=!1,w=null;function k({noDragClassName:b,handleSelector:x,domNode:j,isSelectable:E,nodeId:N,nodeClickDistance:T=0}){f=ii(j);function $({x:L,y:D}){const{nodeLookup:R,nodeExtent:M,snapGrid:I,snapToGrid:F,nodeOrigin:P,onNodeDrag:O,onSelectionDrag:_,onError:Z,updateNodePositions:ee}=t();o={x:L,y:D};let V=!1;const ae=l.size>1,fe=ae&&M?Gb(nh(l)):null,xe=ae&&F?NH({dragItems:l,snapGrid:I,x:L,y:D}):null;for(const[Se,ue]of l){if(!R.has(Se))continue;let Ee={x:L-ue.distance.x,y:D-ue.distance.y};F&&(Ee=xe?{x:Math.round(Ee.x+xe.x),y:Math.round(Ee.y+xe.y)}:rh(Ee,I));let le=null;if(ae&&M&&!ue.extent&&fe){const{positionAbsolute:je}=ue.internals,Ye=je.x-fe.x+M[0][0],tt=je.x+ue.measured.width-fe.x2+M[1][0],ze=je.y-fe.y+M[0][1],dt=je.y+ue.measured.height-fe.y2+M[1][1];le=[[Ye,ze],[tt,dt]]}const{position:me,positionAbsolute:we}=$P({nodeId:Se,nextPosition:Ee,nodeLookup:R,nodeExtent:le||M,nodeOrigin:P,onError:Z});V=V||ue.position.x!==me.x||ue.position.y!==me.y,ue.position=me,ue.internals.positionAbsolute=we}if(g=g||V,!!V&&(ee(l,!0),w&&(r||O||!N&&_))){const[Se,ue]=Xx({nodeId:N,dragItems:l,nodeLookup:R});r==null||r(w,l,Se,ue),O==null||O(w,Se,ue),N||_==null||_(w,ue)}}async function z(){if(!p)return;const{transform:L,panBy:D,autoPanSpeed:R,autoPanOnNodeDrag:M}=t();if(!M){c=!1,cancelAnimationFrame(a);return}const[I,F]=FP(d,p,R);(I!==0||F!==0)&&(o.x=(o.x??0)-I/L[2],o.y=(o.y??0)-F/L[2],await D({x:I,y:F})&&$(o)),a=requestAnimationFrame(z)}function K(L){var ae;const{nodeLookup:D,multiSelectionActive:R,nodesDraggable:M,transform:I,snapGrid:F,snapToGrid:P,selectNodesOnDrag:O,onNodeDragStart:_,onSelectionDragStart:Z,unselectNodesAndEdges:ee}=t();u=!0,(!O||!E)&&!R&&N&&((ae=D.get(N))!=null&&ae.selected||ee()),E&&O&&N&&(e==null||e(N));const V=Jf(L.sourceEvent,{transform:I,snapGrid:F,snapToGrid:P,containerBounds:p});if(o=V,l=SH(D,M,V,N),l.size>0&&(n||_||!N&&Z)){const[fe,xe]=Xx({nodeId:N,dragItems:l,nodeLookup:D});n==null||n(L.sourceEvent,l,fe,xe),_==null||_(L.sourceEvent,fe,xe),N||Z==null||Z(L.sourceEvent,xe)}}const B=gP().clickDistance(T).on("start",L=>{const{domNode:D,nodeDragThreshold:R,transform:M,snapGrid:I,snapToGrid:F}=t();p=(D==null?void 0:D.getBoundingClientRect())||null,m=!1,g=!1,w=L.sourceEvent,R===0&&K(L),o=Jf(L.sourceEvent,{transform:M,snapGrid:I,snapToGrid:F,containerBounds:p}),d=to(L.sourceEvent,p)}).on("drag",L=>{const{autoPanOnNodeDrag:D,transform:R,snapGrid:M,snapToGrid:I,nodeDragThreshold:F,nodeLookup:P}=t(),O=Jf(L.sourceEvent,{transform:R,snapGrid:M,snapToGrid:I,containerBounds:p});if(w=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!P.has(N))&&(m=!0),!m){if(!c&&D&&u&&(c=!0,z()),!u){const _=to(L.sourceEvent,p),Z=_.x-d.x,ee=_.y-d.y;Math.sqrt(Z*Z+ee*ee)>F&&K(L)}(o.x!==O.xSnapped||o.y!==O.ySnapped)&&l&&u&&(d=to(L.sourceEvent,p),$(O))}}).on("end",L=>{if(!(!u||m)&&(c=!1,u=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:D,updateNodePositions:R,onNodeDragStop:M,onSelectionDragStop:I}=t();if(g&&(R(l,!1),g=!1),s||M||!N&&I){const[F,P]=Xx({nodeId:N,dragItems:l,nodeLookup:D,dragging:!1});s==null||s(L.sourceEvent,l,F,P),M==null||M(L.sourceEvent,F,P),N||I==null||I(L.sourceEvent,P)}}}).filter(L=>{const D=L.target;return!L.button&&(!b||!WN(D,`.${b}`,j))&&(!x||WN(D,x,j))});f.call(B)}function y(){f==null||f.on(".drag",null)}return{update:k,destroy:y}}function CH(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Ip(s,wd(o))>0&&r.push(o);return r}const EH=250;function _H(e,t,n,r){var l,c;let s=[],o=1/0;const a=CH(e,n,t+EH);for(const d of a){const p=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((c=d.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of p){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:f,y:m}=Oc(d,u,u.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(m-e.y,2));g>t||(g<o?(s=[{...u,x:f,y:m}],o=g):g===o&&s.push({...u,x:f,y:m}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(p=>p.type===d)??s[0]}return s[0]}function eI(e,t,n,r,s,o=!1){var d,p,u;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((u=a.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?l==null?void 0:l.find(f=>f.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...Oc(a,c,c.position,!0)}:c}function tI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function AH(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const nI=()=>!0;function PH(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:p,flowId:u,panBy:f,cancelConnection:m,onConnectStart:g,onConnect:w,onConnectEnd:k,isValidConnection:y=nI,onReconnectEnd:b,updateConnection:x,getTransform:j,getFromHandle:E,autoPanSpeed:N,dragThreshold:T=1,handleDomNode:$}){const z=WP(e.target);let K=0,B;const{x:L,y:D}=to(e),R=tI(o,$),M=l==null?void 0:l.getBoundingClientRect();let I=!1;if(!M||!R)return;const F=eI(s,R,r,c,t);if(!F)return;let P=to(e,M),O=!1,_=null,Z=!1,ee=null;function V(){if(!p||!M)return;const[me,we]=FP(P,M,N);f({x:me,y:we}),K=requestAnimationFrame(V)}const ae={...F,nodeId:s,type:R,position:F.position},fe=c.get(s);let Se={inProgress:!0,isValid:null,from:Oc(fe,ae,Qe.Left,!0),fromHandle:ae,fromPosition:ae.position,fromNode:fe,to:P,toHandle:null,toPosition:IN[ae.position],toNode:null,pointer:P};function ue(){I=!0,x(Se),g==null||g(e,{nodeId:s,handleId:r,handleType:R})}T===0&&ue();function Ee(me){if(!I){const{x:dt,y:Ft}=to(me),Ue=dt-L,pt=Ft-D;if(!(Ue*Ue+pt*pt>T*T))return;ue()}if(!E()||!ae){le(me);return}const we=j();P=to(me,M),B=_H(sh(P,we,!1,[1,1]),n,c,ae),O||(V(),O=!0);const je=rI(me,{handle:B,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:z,lib:d,flowId:u,nodeLookup:c});ee=je.handleDomNode,_=je.connection,Z=AH(!!B,je.isValid);const Ye=c.get(s),tt=Ye?Oc(Ye,ae,Qe.Left,!0):Se.from,ze={...Se,from:tt,isValid:Z,to:je.toHandle&&Z?Lg({x:je.toHandle.x,y:je.toHandle.y},we):P,toHandle:je.toHandle,toPosition:Z&&je.toHandle?je.toHandle.position:IN[ae.position],toNode:je.toHandle?c.get(je.toHandle.nodeId):null,pointer:P};x(ze),Se=ze}function le(me){if(!("touches"in me&&me.touches.length>0)){if(I){(B||ee)&&_&&Z&&(w==null||w(_));const{inProgress:we,...je}=Se,Ye={...je,toPosition:Se.toHandle?Se.toPosition:null};k==null||k(me,Ye),o&&(b==null||b(me,Ye))}m(),cancelAnimationFrame(K),O=!1,Z=!1,_=null,ee=null,z.removeEventListener("mousemove",Ee),z.removeEventListener("mouseup",le),z.removeEventListener("touchmove",Ee),z.removeEventListener("touchend",le)}}z.addEventListener("mousemove",Ee),z.addEventListener("mouseup",le),z.addEventListener("touchmove",Ee),z.addEventListener("touchend",le)}function rI(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:d=nI,nodeLookup:p}){const u=o==="target",f=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}=to(e),w=a.elementFromPoint(m,g),k=w!=null&&w.classList.contains(`${l}-flow__handle`)?w:f,y={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const b=tI(void 0,k),x=k.getAttribute("data-nodeid"),j=k.getAttribute("data-handleid"),E=k.classList.contains("connectable"),N=k.classList.contains("connectableend");if(!x||!b)return y;const T={source:u?x:r,sourceHandle:u?j:s,target:u?r:x,targetHandle:u?s:j};y.connection=T;const z=E&&N&&(n===yd.Strict?u&&b==="source"||!u&&b==="target":x!==r||j!==s);y.isValid=z&&d(T),y.toHandle=eI(x,b,j,p,n,!0)}return y}const Zb={onPointerDown:PH,isValid:rI};function IH({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ii(e);function o({translateExtent:l,width:c,height:d,zoomStep:p=1,pannable:u=!0,zoomable:f=!0,inversePan:m=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const j=n(),E=x.sourceEvent.ctrlKey&&Tp()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*p,T=j[2]*Math.pow(2,N*E);t.scaleTo(T)};let w=[0,0];const k=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(w=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},y=x=>{const j=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const E=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[E[0]-w[0],E[1]-w[1]];w=E;const T=r()*Math.max(j[2],Math.log(j[2]))*(m?-1:1),$={x:j[0]-N[0]*T,y:j[1]-N[1]*T},z=[[0,0],[c,d]];t.setViewportConstrained({x:$.x,y:$.y,zoom:j[2]},z,l)},b=IP().on("start",k).on("zoom",u?y:null).on("zoom.wheel",f?g:null);s.call(b,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:Xi}}const My=e=>({x:e.x,y:e.y,zoom:e.k}),Jx=({x:e,y:t,zoom:n})=>Iy.translate(e,t).scale(n),Wu=(e,t)=>e.target.closest(`.${t}`),sI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),TH=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Qx=(e,t=0,n=TH,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},iI=e=>{const t=e.ctrlKey&&Tp()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function RH({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return p=>{if(Wu(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(p.ctrlKey&&a){const k=Xi(p),y=iI(p),b=u*Math.pow(2,y);r.scaleTo(n,b,k,p);return}const f=p.deltaMode===1?20:1;let m=s===Nc.Vertical?0:p.deltaX*f,g=s===Nc.Horizontal?0:p.deltaY*f;!Tp()&&p.shiftKey&&s!==Nc.Vertical&&(m=p.deltaY*f,g=0),r.translateBy(n,-(m/u)*o,-(g/u)*o,{internal:!0});const w=My(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(p,w),e.panScrollTimeout=setTimeout(()=>{d==null||d(p,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,w))}}function MH({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=Wu(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function LH({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=My(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 OH({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&sI(t,e.mouseButton??0)),(a=o.sourceEvent)!=null&&a.sync||r([o.transform.x,o.transform.y,o.transform.k]),s&&!((l=o.sourceEvent)!=null&&l.internal)&&(s==null||s(o.sourceEvent,My(o.transform)))}}function $H({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:o}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,o&&sI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=My(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function DH({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:p}){return u=>{var k;const f=e||t,m=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Wu(u,`${d}-flow__node`)||Wu(u,`${d}-flow__edge`)))return!0;if(!r&&!f&&!s&&!o&&!n||a||p&&!g||Wu(u,l)&&g||Wu(u,c)&&(!g||s&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((k=u.touches)==null?void 0:k.length)>1)return u.preventDefault(),!1;if(!f&&!s&&!m&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&w}}function FH({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),u=IP().scaleExtent([t,n]).translateExtent(r),f=ii(e).call(u);b({x:s.x,y:s.y,zoom:xd(s.zoom,t,n)},[[0,0],[p.width,p.height]],r);const m=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(iI);function w(B,L){return f?new Promise(D=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?Xf:Km).transform(Qx(f,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>D(!0)),B)}):Promise.resolve(!1)}function k({noWheelClassName:B,noPanClassName:L,onPaneContextMenu:D,userSelectionActive:R,panOnScroll:M,panOnDrag:I,panOnScrollMode:F,panOnScrollSpeed:P,preventScrolling:O,zoomOnPinch:_,zoomOnScroll:Z,zoomOnDoubleClick:ee,zoomActivationKeyPressed:V,lib:ae,onTransformChange:fe,connectionInProgress:xe,paneClickDistance:Se,selectionOnDrag:ue}){R&&!d.isZoomingOrPanning&&y();const Ee=M&&!V&&!R;u.clickDistance(ue?1/0:!eo(Se)||Se<0?0:Se);const le=Ee?RH({zoomPanValues:d,noWheelClassName:B,d3Selection:f,d3Zoom:u,panOnScrollMode:F,panOnScrollSpeed:P,zoomOnPinch:_,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):MH({noWheelClassName:B,preventScrolling:O,d3ZoomHandler:m});if(f.on("wheel.zoom",le,{passive:!1}),!R){const we=LH({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});u.on("start",we);const je=OH({zoomPanValues:d,panOnDrag:I,onPaneContextMenu:!!D,onPanZoom:o,onTransformChange:fe});u.on("zoom",je);const Ye=$H({zoomPanValues:d,panOnDrag:I,panOnScroll:M,onPaneContextMenu:D,onPanZoomEnd:l,onDraggingChange:c});u.on("end",Ye)}const me=DH({zoomActivationKeyPressed:V,panOnDrag:I,zoomOnScroll:Z,panOnScroll:M,zoomOnDoubleClick:ee,zoomOnPinch:_,userSelectionActive:R,noPanClassName:L,noWheelClassName:B,lib:ae,connectionInProgress:xe});u.filter(me),ee?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function b(B,L,D){const R=Jx(B),M=u==null?void 0:u.constrain()(R,L,D);return M&&await w(M),new Promise(I=>I(M))}async function x(B,L){const D=Jx(B);return await w(D,L),new Promise(R=>R(D))}function j(B){if(f){const L=Jx(B),D=f.property("__zoom");(D.k!==B.zoom||D.x!==B.x||D.y!==B.y)&&(u==null||u.transform(f,L,null,{sync:!0}))}}function E(){const B=f?PP(f.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function N(B,L){return f?new Promise(D=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?Xf:Km).scaleTo(Qx(f,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>D(!0)),B)}):Promise.resolve(!1)}function T(B,L){return f?new Promise(D=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?Xf:Km).scaleBy(Qx(f,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>D(!0)),B)}):Promise.resolve(!1)}function $(B){u==null||u.scaleExtent(B)}function z(B){u==null||u.translateExtent(B)}function K(B){const L=!eo(B)||B<0?0:B;u==null||u.clickDistance(L)}return{update:k,destroy:y,setViewport:x,setViewportConstrained:b,getViewport:E,scaleTo:N,scaleBy:T,setScaleExtent:$,setTranslateExtent:z,syncViewport:j,setClickDistance:K}}var vd;(function(e){e.Line="line",e.Handle="handle"})(vd||(vd={}));function zH({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:o}){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&&o&&(c[1]=c[1]*-1),c}function VN(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 rl(e,t){return Math.max(0,t-e)}function sl(e,t){return Math.max(0,e-t)}function lm(e,t,n){return Math.max(0,t-e,e-n)}function KN(e,t){return e?!t:t}function HH(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:p,isVertical:u}=t,f=p&&u,{xSnapped:m,ySnapped:g}=n,{minWidth:w,maxWidth:k,minHeight:y,maxHeight:b}=r,{x,y:j,width:E,height:N,aspectRatio:T}=e;let $=Math.floor(p?m-e.pointerX:0),z=Math.floor(u?g-e.pointerY:0);const K=E+(c?-$:$),B=N+(d?-z:z),L=-o[0]*E,D=-o[1]*N;let R=lm(K,w,k),M=lm(B,y,b);if(a){let P=0,O=0;c&&$<0?P=rl(x+$+L,a[0][0]):!c&&$>0&&(P=sl(x+K+L,a[1][0])),d&&z<0?O=rl(j+z+D,a[0][1]):!d&&z>0&&(O=sl(j+B+D,a[1][1])),R=Math.max(R,P),M=Math.max(M,O)}if(l){let P=0,O=0;c&&$>0?P=sl(x+$,l[0][0]):!c&&$<0&&(P=rl(x+K,l[1][0])),d&&z>0?O=sl(j+z,l[0][1]):!d&&z<0&&(O=rl(j+B,l[1][1])),R=Math.max(R,P),M=Math.max(M,O)}if(s){if(p){const P=lm(K/T,y,b)*T;if(R=Math.max(R,P),a){let O=0;!c&&!d||c&&!d&&f?O=sl(j+D+K/T,a[1][1])*T:O=rl(j+D+(c?$:-$)/T,a[0][1])*T,R=Math.max(R,O)}if(l){let O=0;!c&&!d||c&&!d&&f?O=rl(j+K/T,l[1][1])*T:O=sl(j+(c?$:-$)/T,l[0][1])*T,R=Math.max(R,O)}}if(u){const P=lm(B*T,w,k)/T;if(M=Math.max(M,P),a){let O=0;!c&&!d||d&&!c&&f?O=sl(x+B*T+L,a[1][0])/T:O=rl(x+(d?z:-z)*T+L,a[0][0])/T,M=Math.max(M,O)}if(l){let O=0;!c&&!d||d&&!c&&f?O=rl(x+B*T,l[1][0])/T:O=sl(x+(d?z:-z)*T,l[0][0])/T,M=Math.max(M,O)}}}z=z+(z<0?M:-M),$=$+($<0?R:-R),s&&(f?K>B*T?z=(KN(c,d)?-$:$)/T:$=(KN(c,d)?-z:z)*T:p?(z=$/T,d=c):($=z*T,c=d));const I=c?x+$:x,F=d?j+z:j;return{width:E+(c?-$:$),height:N+(d?-z:z),x:o[0]*$*(c?-1:1)+I,y:o[1]*z*(d?-1:1)+F}}const oI={width:0,height:0,x:0,y:0},BH={...oI,pointerX:0,pointerY:0,aspectRatio:1};function WH(e){return[[0,0],[e.measured.width,e.measured.height]]}function VH(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,c=n[1]*a;return[[r-l,s-c],[r+o-l,s+a-c]]}function KH({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=ii(e);let a={controlDirection:VN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:p,keepAspectRatio:u,resizeDirection:f,onResizeStart:m,onResize:g,onResizeEnd:w,shouldResize:k}){let y={...oI},b={...BH};a={boundaries:p,resizeDirection:f,keepAspectRatio:u,controlDirection:VN(d)};let x,j=null,E=[],N,T,$,z=!1;const K=gP().on("start",B=>{const{nodeLookup:L,transform:D,snapGrid:R,snapToGrid:M,nodeOrigin:I,paneDomNode:F}=n();if(x=L.get(t),!x)return;j=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:P,ySnapped:O}=Jf(B.sourceEvent,{transform:D,snapGrid:R,snapToGrid:M,containerBounds:j});y={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},b={...y,pointerX:P,pointerY:O,aspectRatio:y.width/y.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=L.get(x.parentId),T=N&&x.extent==="parent"?WH(N):void 0),E=[],$=void 0;for(const[_,Z]of L)if(Z.parentId===t&&(E.push({id:_,position:{...Z.position},extent:Z.extent}),Z.extent==="parent"||Z.expandParent)){const ee=VH(Z,x,Z.origin??I);$?$=[[Math.min(ee[0][0],$[0][0]),Math.min(ee[0][1],$[0][1])],[Math.max(ee[1][0],$[1][0]),Math.max(ee[1][1],$[1][1])]]:$=ee}m==null||m(B,{...y})}).on("drag",B=>{const{transform:L,snapGrid:D,snapToGrid:R,nodeOrigin:M}=n(),I=Jf(B.sourceEvent,{transform:L,snapGrid:D,snapToGrid:R,containerBounds:j}),F=[];if(!x)return;const{x:P,y:O,width:_,height:Z}=y,ee={},V=x.origin??M,{width:ae,height:fe,x:xe,y:Se}=HH(b,a.controlDirection,I,a.boundaries,a.keepAspectRatio,V,T,$),ue=ae!==_,Ee=fe!==Z,le=xe!==P&&ue,me=Se!==O&&Ee;if(!le&&!me&&!ue&&!Ee)return;if((le||me||V[0]===1||V[1]===1)&&(ee.x=le?xe:y.x,ee.y=me?Se:y.y,y.x=ee.x,y.y=ee.y,E.length>0)){const tt=xe-P,ze=Se-O;for(const dt of E)dt.position={x:dt.position.x-tt+V[0]*(ae-_),y:dt.position.y-ze+V[1]*(fe-Z)},F.push(dt)}if((ue||Ee)&&(ee.width=ue&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ae:y.width,ee.height=Ee&&(!a.resizeDirection||a.resizeDirection==="vertical")?fe:y.height,y.width=ee.width,y.height=ee.height),N&&x.expandParent){const tt=V[0]*(ee.width??0);ee.x&&ee.x<tt&&(y.x=tt,b.x=b.x-(ee.x-tt));const ze=V[1]*(ee.height??0);ee.y&&ee.y<ze&&(y.y=ze,b.y=b.y-(ee.y-ze))}const we=zH({width:y.width,prevWidth:_,height:y.height,prevHeight:Z,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),je={...y,direction:we};(k==null?void 0:k(B,je))!==!1&&(z=!0,g==null||g(B,je),r(ee,F))}).on("end",B=>{z&&(w==null||w(B,{...y}),s==null||s({...y}),z=!1)});o.call(K)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var aI={exports:{}},lI={},cI={exports:{}},uI={};/**
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 kd=h;function UH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qH=typeof Object.is=="function"?Object.is:UH,YH=kd.useState,GH=kd.useEffect,XH=kd.useLayoutEffect,JH=kd.useDebugValue;function QH(e,t){var n=t(),r=YH({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return XH(function(){s.value=n,s.getSnapshot=t,Zx(s)&&o({inst:s})},[e,n,t]),GH(function(){return Zx(s)&&o({inst:s}),e(function(){Zx(s)&&o({inst:s})})},[e]),JH(n),n}function Zx(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!qH(e,n)}catch{return!0}}function ZH(e,t){return t()}var e5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?ZH:QH;uI.useSyncExternalStore=kd.useSyncExternalStore!==void 0?kd.useSyncExternalStore:e5;cI.exports=uI;var dI=cI.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 Ly=h,t5=dI;function n5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var r5=typeof Object.is=="function"?Object.is:n5,s5=t5.useSyncExternalStore,i5=Ly.useRef,o5=Ly.useEffect,a5=Ly.useMemo,l5=Ly.useDebugValue;lI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=i5(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=a5(function(){function c(m){if(!d){if(d=!0,p=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,r5(p,m))return g;var w=r(m);return s!==void 0&&s(g,w)?(p=m,g):(p=m,u=w)}var d=!1,p,u,f=n===void 0?null:n;return[function(){return c(t())},f===null?void 0:function(){return c(f())}]},[t,n,r,s]);var l=s5(e,o[0],o[1]);return o5(function(){a.hasValue=!0,a.value=l},[l]),l5(l),l};aI.exports=lI;var c5=aI.exports;const u5=$l(c5),d5={},UN=e=>{let t;const n=new Set,r=(p,u)=>{const f=typeof p=="function"?p(t):p;if(!Object.is(f,t)){const m=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(d5?"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},f5=e=>e?UN(e):UN,{useDebugValue:p5}=yt,{useSyncExternalStoreWithSelector:h5}=u5,m5=e=>e;function fI(e,t=m5,n){const r=h5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return p5(r),r}const qN=(e,t)=>{const n=f5(e),r=(s,o=t)=>fI(n,s,o);return Object.assign(r,n),r},g5=(e,t)=>e?qN(e,t):qN;function sr(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 Oy=h.createContext(null),y5=Oy.Provider,pI=Uo.error001();function en(e,t){const n=h.useContext(Oy);if(n===null)throw new Error(pI);return fI(n,e,t)}function Xn(){const e=h.useContext(Oy);if(e===null)throw new Error(pI);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const YN={display:"none"},x5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},hI="react-flow__node-desc",mI="react-flow__edge-desc",w5="react-flow__aria-live",b5=e=>e.ariaLiveMessage,v5=e=>e.ariaLabelConfig;function k5({rfId:e}){const t=en(b5);return i.jsx("div",{id:`${w5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:x5,children:t})}function S5({rfId:e,disableKeyboardA11y:t}){const n=en(v5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${hI}-${e}`,style:YN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${mI}-${e}`,style:YN,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(k5,{rfId:e})]})}const Sd=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Mr(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});Sd.displayName="Panel";function N5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(Sd,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const j5=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}},cm=e=>e.id;function C5(e,t){return sr(e.selectedNodes.map(cm),t.selectedNodes.map(cm))&&sr(e.selectedEdges.map(cm),t.selectedEdges.map(cm))}function E5({onSelectionChange:e}){const t=Xn(),{selectedNodes:n,selectedEdges:r}=en(j5,C5);return h.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const _5=e=>!!e.onSelectionChangeHandlers;function A5({onSelectionChange:e}){const t=en(_5);return e||t?i.jsx(E5,{onSelectionChange:e}):null}const ev=typeof window<"u"?h.useLayoutEffect:h.useEffect,gI=[0,0],P5={x:0,y:0,zoom:1},I5=["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"],GN=[...I5,"rfId"],T5=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}),XN={translateExtent:Ap,nodeOrigin:gI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function R5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=en(T5,sr),d=Xn();ev(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=XN,l()}),[]);const p=h.useRef(XN);return ev(()=>{for(const u of GN){const f=e[u],m=p.current[u];f!==m&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?r(f):u==="maxZoom"?s(f):u==="translateExtent"?o(f):u==="nodeExtent"?a(f):u==="ariaLabelConfig"?d.setState({ariaLabelConfig:sH(f)}):u==="fitView"?d.setState({fitViewQueued:f}):u==="fitViewOptions"?d.setState({fitViewOptions:f}):d.setState({[u]:f})))}p.current=e},GN.map(u=>e[u])),null}function JN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function M5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=JN(),o=()=>n(s!=null&&s.matches?"dark":"light");return o(),s==null||s.addEventListener("change",o),()=>{s==null||s.removeEventListener("change",o)}},[e]),t!==null?t:(r=JN())!=null&&r.matches?"dark":"light"}const QN=typeof document<"u"?document:null;function Rp(e=null,t={target:QN,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),s=h.useRef(!1),o=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
- `)),p=d.reduce((u,f)=>u.concat(...f),[]);return[d,p]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??QN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=m=>{var k,y;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&VP(m))return!1;const w=ej(m.code,l);if(o.current.add(m[w]),ZN(a,o.current,!1)){const b=((y=(k=m.composedPath)==null?void 0:k.call(m))==null?void 0:y[0])||m.target,x=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&m.preventDefault(),r(!0)}},u=m=>{const g=ej(m.code,l);ZN(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(m[g]),m.key==="Meta"&&o.current.clear(),s.current=!1},f=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",p),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",p),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function ZN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ej(e,t){return t.includes(e)?"code":"key"}const L5=()=>{const e=Xn();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,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=H0(t,r,s,o,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:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},p=n.snapGrid??s,u=n.snapToGrid??o;return sh(d,r,u,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=Lg(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function yI(e,t){const n=[],r=new Map,s=[];for(const o of e)if(o.type==="add"){s.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const c of a)O5(c,l);n.push(l)}return s.length&&s.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function O5(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 Og(e,t){return yI(e,t)}function Y0(e,t){return yI(e,t)}function fc(e,t){return{id:e,type:"select",selected:t}}function Vu(e,t=new Set,n=!1){const r=[];for(const[s,o]of e){const a=t.has(s);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(fc(o.id,a)))}return r}function tj({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),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:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function nj(e){return{id:e.id,type:"remove"}}const rj=e=>Y3(e),$5=e=>OP(e);function xI(e){return h.forwardRef(e)}function sj(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>D5(()=>n(s=>s+BigInt(1))));return ev(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function D5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const wI=h.createContext(null);function F5({children:e}){const t=Xn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:p,onNodesChange:u,nodeLookup:f,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let w=c;for(const y of l)w=typeof y=="function"?y(w):y;let k=tj({items:w,lookup:f});for(const y of g.values())k=y(k);p&&d(w),k.length>0?u==null||u(k):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:b,setNodes:x}=t.getState();y&&x(b)})},[]),r=sj(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:p,onEdgesChange:u,edgeLookup:f}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;p?d(m):u&&u(tj({items:m,lookup:f}))},[]),o=sj(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(wI.Provider,{value:a,children:e})}function z5(){const e=h.useContext(wI);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const H5=e=>!!e.panZoom;function Hl(){const e=L5(),t=Xn(),n=z5(),r=en(H5),s=h.useMemo(()=>{const o=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var y,b;const{nodeLookup:f,nodeOrigin:m}=t.getState(),g=rj(u)?u:f.get(u.id),w=g.parentId?BP(g.position,g.measured,g.parentId,f,m):g.position,k={...g,position:w,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return wd(k)},d=(u,f,m={replace:!1})=>{a(g=>g.map(w=>{if(w.id===u){const k=typeof f=="function"?f(w):f;return m.replace&&rj(k)?k:{...w,...k}}return w}))},p=(u,f,m={replace:!1})=>{l(g=>g.map(w=>{if(w.id===u){const k=typeof f=="function"?f(w):f;return m.replace&&$5(k)?k:{...w,...k}}return w}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var f;return(f=o(u))==null?void 0:f.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:m}=t.getState(),[g,w,k]=m;return{nodes:u.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:g,y:w,zoom:k}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:m,edges:g,onNodesDelete:w,onEdgesDelete:k,triggerNodeChanges:y,triggerEdgeChanges:b,onDelete:x,onBeforeDelete:j}=t.getState(),{nodes:E,edges:N}=await Z3({nodesToRemove:u,edgesToRemove:f,nodes:m,edges:g,onBeforeDelete:j}),T=N.length>0,$=E.length>0;if(T){const z=N.map(nj);k==null||k(N),b(z)}if($){const z=E.map(nj);w==null||w(E),y(z)}return($||T)&&(x==null||x({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(u,f=!0,m)=>{const g=RN(u),w=g?u:c(u),k=m!==void 0;return w?(m||t.getState().nodes).filter(y=>{const b=t.getState().nodeLookup.get(y.id);if(b&&!g&&(y.id===u.id||!b.internals.positionAbsolute))return!1;const x=wd(k?y:b),j=Ip(x,w);return f&&j>0||j>=x.width*x.height||j>=w.width*w.height}):[]},isNodeIntersecting:(u,f,m=!0)=>{const w=RN(u)?u:c(u);if(!w)return!1;const k=Ip(w,f);return m&&k>0||k>=f.width*f.height||k>=w.width*w.height},updateNode:d,updateNodeData:(u,f,m={replace:!1})=>{d(u,g=>{const w=typeof f=="function"?f(g):f;return m.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},m)},updateEdge:p,updateEdgeData:(u,f,m={replace:!1})=>{p(u,g=>{const w=typeof f=="function"?f(g):f;return m.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},m)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:m}=t.getState();return G3(u,{nodeLookup:f,nodeOrigin:m})},getHandleConnections:({type:u,id:f,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}-${u}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:f,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}${u?f?`-${u}-${f}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const f=t.getState().fitViewResolver??rH();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(m=>[...m]),f.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const ij=e=>e.selected,B5=typeof window<"u"?window:void 0;function W5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Xn(),{deleteElements:r}=Hl(),s=Rp(e,{actInsideInputWithModifier:!1}),o=Rp(t,{target:B5});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(ij),edges:a.filter(ij)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function V5(e){const t=Xn();h.useEffect(()=>{const n=()=>{var s,o,a,l;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=B0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Uo.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 $y={position:"absolute",width:"100%",height:"100%",top:0,left:0},K5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function U5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=Nc.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:p,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:m=!0,children:g,noWheelClassName:w,noPanClassName:k,onViewportChange:y,isControlledViewport:b,paneClickDistance:x,selectionOnDrag:j}){const E=Xn(),N=h.useRef(null),{userSelectionActive:T,lib:$,connectionInProgress:z}=en(K5,sr),K=Rp(f),B=h.useRef();V5(N);const L=h.useCallback(D=>{y==null||y({x:D[0],y:D[1],zoom:D[2]}),b||E.setState({transform:D})},[y,b]);return h.useEffect(()=>{if(N.current){B.current=FH({domNode:N.current,minZoom:p,maxZoom:u,translateExtent:d,viewport:c,onDraggingChange:I=>E.setState(F=>F.paneDragging===I?F:{paneDragging:I}),onPanZoomStart:(I,F)=>{const{onViewportChangeStart:P,onMoveStart:O}=E.getState();O==null||O(I,F),P==null||P(F)},onPanZoom:(I,F)=>{const{onViewportChange:P,onMove:O}=E.getState();O==null||O(I,F),P==null||P(F)},onPanZoomEnd:(I,F)=>{const{onViewportChangeEnd:P,onMoveEnd:O}=E.getState();O==null||O(I,F),P==null||P(F)}});const{x:D,y:R,zoom:M}=B.current.getViewport();return E.setState({panZoom:B.current,transform:[D,R,M],domNode:N.current.closest(".react-flow")}),()=>{var I;(I=B.current)==null||I.destroy()}}},[]),h.useEffect(()=>{var D;(D=B.current)==null||D.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:K,preventScrolling:m,noPanClassName:k,userSelectionActive:T,noWheelClassName:w,lib:$,onTransformChange:L,connectionInProgress:z,selectionOnDrag:j,paneClickDistance:x})},[e,t,n,r,s,o,a,l,K,m,k,T,w,$,L,z,j,x]),i.jsx("div",{className:"react-flow__renderer",ref:N,style:$y,children:g})}const q5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Y5(){const{userSelectionActive:e,userSelectionRect:t}=en(q5,sr);return e&&t?i.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const ew=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},G5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function X5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Pp.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:p,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:m,children:g}){const w=Xn(),{userSelectionActive:k,elementsSelectable:y,dragging:b,connectionInProgress:x}=en(G5,sr),j=y&&(e||k),E=h.useRef(null),N=h.useRef(),T=h.useRef(new Set),$=h.useRef(new Set),z=h.useRef(!1),K=P=>{if(z.current||x){z.current=!1;return}c==null||c(P),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},B=P=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){P.preventDefault();return}d==null||d(P)},L=p?P=>p(P):void 0,D=P=>{z.current&&(P.stopPropagation(),z.current=!1)},R=P=>{var fe,xe;const{domNode:O}=w.getState();if(N.current=O==null?void 0:O.getBoundingClientRect(),!N.current)return;const _=P.target===E.current;if(!_&&!!P.target.closest(".nokey")||!e||!(o&&_||t)||P.button!==0||!P.isPrimary)return;(xe=(fe=P.target)==null?void 0:fe.setPointerCapture)==null||xe.call(fe,P.pointerId),z.current=!1;const{x:V,y:ae}=to(P.nativeEvent,N.current);w.setState({userSelectionRect:{width:0,height:0,startX:V,startY:ae,x:V,y:ae}}),_||(P.stopPropagation(),P.preventDefault())},M=P=>{const{userSelectionRect:O,transform:_,nodeLookup:Z,edgeLookup:ee,connectionLookup:V,triggerNodeChanges:ae,triggerEdgeChanges:fe,defaultEdgeOptions:xe,resetSelectedElements:Se}=w.getState();if(!N.current||!O)return;const{x:ue,y:Ee}=to(P.nativeEvent,N.current),{startX:le,startY:me}=O;if(!z.current){const ze=t?0:s;if(Math.hypot(ue-le,Ee-me)<=ze)return;Se(),a==null||a(P)}z.current=!0;const we={startX:le,startY:me,x:ue<le?ue:le,y:Ee<me?Ee:me,width:Math.abs(ue-le),height:Math.abs(Ee-me)},je=T.current,Ye=$.current;T.current=new Set(z0(Z,we,_,n===Pp.Partial,!0).map(ze=>ze.id)),$.current=new Set;const tt=(xe==null?void 0:xe.selectable)??!0;for(const ze of T.current){const dt=V.get(ze);if(dt)for(const{edgeId:Ft}of dt.values()){const Ue=ee.get(Ft);Ue&&(Ue.selectable??tt)&&$.current.add(Ft)}}if(!MN(je,T.current)){const ze=Vu(Z,T.current,!0);ae(ze)}if(!MN(Ye,$.current)){const ze=Vu(ee,$.current);fe(ze)}w.setState({userSelectionRect:we,userSelectionActive:!0,nodesSelectionActive:!1})},I=P=>{var O,_;P.button===0&&((_=(O=P.target)==null?void 0:O.releasePointerCapture)==null||_.call(O,P.pointerId),!k&&P.target===E.current&&w.getState().userSelectionRect&&(K==null||K(P)),w.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l==null||l(P),w.setState({nodesSelectionActive:T.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Mr(["react-flow__pane",{draggable:F,dragging:b,selection:e}]),onClick:j?void 0:ew(K,E),onContextMenu:ew(B,E),onWheel:ew(L,E),onPointerEnter:j?void 0:u,onPointerMove:j?M:f,onPointerUp:j?I:void 0,onPointerDownCapture:j?R:void 0,onClickCapture:j?D:void 0,onPointerLeave:m,ref:E,style:$y,children:[g,i.jsx(Y5,{})]})}function tv({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",Uo.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):s([e])}function bI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=Xn(),[c,d]=h.useState(!1),p=h.useRef();return h.useEffect(()=>{p.current=jH({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{tv({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var u;(u=p.current)==null||u.destroy()}},[n,r,t,o,e,s,a]),c}const J5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function vI(){const e=Xn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:p}=e.getState(),u=new Map,f=J5(a),m=s?o[0]:5,g=s?o[1]:5,w=n.direction.x*m*n.factor,k=n.direction.y*g*n.factor;for(const[,y]of d){if(!f(y))continue;let b={x:y.internals.positionAbsolute.x+w,y:y.internals.positionAbsolute.y+k};s&&(b=rh(b,o));const{position:x,positionAbsolute:j}=$P({nodeId:y.id,nextPosition:b,nodeLookup:d,nodeExtent:r,nodeOrigin:p,onError:l});y.position=x,y.internals.positionAbsolute=j,u.set(y.id,y)}c(u)},[])}const G0=h.createContext(null),Q5=G0.Provider;G0.Consumer;const kI=()=>h.useContext(G0),Z5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),eB=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,p=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:p,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===yd.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:p&&d}};function tB({type:e="source",position:t=Qe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:p,onTouchStart:u,...f},m){var M,I;const g=a||null,w=e==="target",k=Xn(),y=kI(),{connectOnClick:b,noPanClassName:x,rfId:j}=en(Z5,sr),{connectingFrom:E,connectingTo:N,clickConnecting:T,isPossibleEndHandle:$,connectionInProcess:z,clickConnectionInProcess:K,valid:B}=en(eB(y,g,e),sr);y||(I=(M=k.getState()).onError)==null||I.call(M,"010",Uo.error010());const L=F=>{const{defaultEdgeOptions:P,onConnect:O,hasDefaultEdges:_}=k.getState(),Z={...P,...F};if(_){const{edges:ee,setEdges:V}=k.getState();V(rd(Z,ee))}O==null||O(Z),l==null||l(Z)},D=F=>{if(!y)return;const P=KP(F.nativeEvent);if(s&&(P&&F.button===0||!P)){const O=k.getState();Zb.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:w,handleId:g,nodeId:y,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(..._)=>{var Z,ee;return(ee=(Z=k.getState()).onConnectEnd)==null?void 0:ee.call(Z,..._)},updateConnection:O.updateConnection,onConnect:L,isValidConnection:n||((..._)=>{var Z,ee;return((ee=(Z=k.getState()).isValidConnection)==null?void 0:ee.call(Z,..._))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}P?p==null||p(F):u==null||u(F)},R=F=>{const{onClickConnectStart:P,onClickConnectEnd:O,connectionClickStartHandle:_,connectionMode:Z,isValidConnection:ee,lib:V,rfId:ae,nodeLookup:fe,connection:xe}=k.getState();if(!y||!_&&!s)return;if(!_){P==null||P(F.nativeEvent,{nodeId:y,handleId:g,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Se=WP(F.target),ue=n||ee,{connection:Ee,isValid:le}=Zb.isValid(F.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:Z,fromNodeId:_.nodeId,fromHandleId:_.id||null,fromType:_.type,isValidConnection:ue,flowId:ae,doc:Se,lib:V,nodeLookup:fe});le&&Ee&&L(Ee);const me=structuredClone(xe);delete me.inProgress,me.toPosition=me.toHandle?me.toHandle.position:null,O==null||O(F,me),k.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${j}-${y}-${g}-${e}`,className:Mr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,d,{source:!w,target:w,connectable:r,connectablestart:s,connectableend:o,clickconnecting:T,connectingfrom:E,connectingto:N,valid:B,connectionindicator:r&&(!z||$)&&(z||K?o:s)}]),onMouseDown:D,onTouchStart:D,onClick:b?R:void 0,ref:m,...f,children:c})}const gs=h.memo(xI(tB));function nB({data:e,isConnectable:t,sourcePosition:n=Qe.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(gs,{type:"source",position:n,isConnectable:t})]})}function rB({data:e,isConnectable:t,targetPosition:n=Qe.Top,sourcePosition:r=Qe.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(gs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(gs,{type:"source",position:r,isConnectable:t})]})}function sB(){return null}function iB({data:e,isConnectable:t,targetPosition:n=Qe.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(gs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const $g={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},oj={input:nB,default:rB,output:iB,group:sB};function oB(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 aB=e=>{const{width:t,height:n,x:r,y:s}=nh(e.nodeLookup,{filter:o=>!!o.selected});return{width:eo(t)?t:null,height:eo(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 lB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Xn(),{width:s,height:o,transformString:a,userSelectionActive:l}=en(aB,sr),c=vI(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const p=!l&&s!==null&&o!==null;if(bI({nodeRef:d,disabled:!p}),!p)return null;const u=e?m=>{const g=r.getState().nodes.filter(w=>w.selected);e(m,g)}:void 0,f=m=>{Object.prototype.hasOwnProperty.call($g,m.key)&&(m.preventDefault(),c({direction:$g[m.key],factor:m.shiftKey?4:1}))};return i.jsx("div",{className:Mr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:o}})})}const aj=typeof window<"u"?window:void 0,cB=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function SI({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:p,selectionMode:u,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:w,zoomActivationKeyCode:k,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:j,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:T,panOnDrag:$,defaultViewport:z,translateExtent:K,minZoom:B,maxZoom:L,preventScrolling:D,onSelectionContextMenu:R,noWheelClassName:M,noPanClassName:I,disableKeyboardA11y:F,onViewportChange:P,isControlledViewport:O}){const{nodesSelectionActive:_,userSelectionActive:Z}=en(cB,sr),ee=Rp(d,{target:aj}),V=Rp(w,{target:aj}),ae=V||$,fe=V||j,xe=p&&ae!==!0,Se=ee||Z||xe;return W5({deleteKeyCode:c,multiSelectionKeyCode:g}),i.jsx(U5,{onPaneContextMenu:o,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:x,panOnScroll:fe,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:T,panOnDrag:!ee&&ae,defaultViewport:z,translateExtent:K,minZoom:B,maxZoom:L,zoomActivationKeyCode:k,preventScrolling:D,noWheelClassName:M,noPanClassName:I,onViewportChange:P,isControlledViewport:O,paneClickDistance:l,selectionOnDrag:xe,children:i.jsxs(X5,{onSelectionStart:f,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:ae,isSelecting:!!Se,selectionMode:u,selectionKeyPressed:ee,paneClickDistance:l,selectionOnDrag:xe,children:[e,_&&i.jsx(lB,{onSelectionContextMenu:R,noPanClassName:I,disableKeyboardA11y:F})]})})}SI.displayName="FlowRenderer";const uB=h.memo(SI),dB=e=>t=>e?z0(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 fB(e){return en(h.useCallback(dB(e),[e]),sr)}const pB=e=>e.updateNodeInternals;function hB(){const e=en(pB),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function mB({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Xn(),o=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),d=h.useRef(t),p=n&&!!e.internals.handleBounds;return h.useEffect(()=>{o.current&&!e.hidden&&(!p||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[p,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(o.current){const u=d.current!==t,f=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||f||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function gB({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:p,resizeObserver:u,noDragClassName:f,noPanClassName:m,disableKeyboardA11y:g,rfId:w,nodeTypes:k,nodeClickDistance:y,onError:b}){const{node:x,internals:j,isParent:E}=en(ue=>{const Ee=ue.nodeLookup.get(e),le=ue.parentLookup.has(e);return{node:Ee,internals:Ee.internals,isParent:le}},sr);let N=x.type||"default",T=(k==null?void 0:k[N])||oj[N];T===void 0&&(b==null||b("003",Uo.error003(N)),N="default",T=(k==null?void 0:k.default)||oj.default);const $=!!(x.draggable||l&&typeof x.draggable>"u"),z=!!(x.selectable||c&&typeof x.selectable>"u"),K=!!(x.connectable||d&&typeof x.connectable>"u"),B=!!(x.focusable||p&&typeof x.focusable>"u"),L=Xn(),D=HP(x),R=mB({node:x,nodeType:N,hasDimensions:D,resizeObserver:u}),M=bI({nodeRef:R,disabled:x.hidden||!$,noDragClassName:f,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:y}),I=vI();if(x.hidden)return null;const F=Ra(x),P=oB(x),O=z||$||t||n||r||s,_=n?ue=>n(ue,{...j.userNode}):void 0,Z=r?ue=>r(ue,{...j.userNode}):void 0,ee=s?ue=>s(ue,{...j.userNode}):void 0,V=o?ue=>o(ue,{...j.userNode}):void 0,ae=a?ue=>a(ue,{...j.userNode}):void 0,fe=ue=>{const{selectNodesOnDrag:Ee,nodeDragThreshold:le}=L.getState();z&&(!Ee||!$||le>0)&&tv({id:e,store:L,nodeRef:R}),t&&t(ue,{...j.userNode})},xe=ue=>{if(!(VP(ue.nativeEvent)||g)){if(TP.includes(ue.key)&&z){const Ee=ue.key==="Escape";tv({id:e,store:L,unselect:Ee,nodeRef:R})}else if($&&x.selected&&Object.prototype.hasOwnProperty.call($g,ue.key)){ue.preventDefault();const{ariaLabelConfig:Ee}=L.getState();L.setState({ariaLiveMessage:Ee["node.a11yDescription.ariaLiveMessage"]({direction:ue.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),I({direction:$g[ue.key],factor:ue.shiftKey?4:1})}}},Se=()=>{var Ye;if(g||!((Ye=R.current)!=null&&Ye.matches(":focus-visible")))return;const{transform:ue,width:Ee,height:le,autoPanOnNodeFocus:me,setCenter:we}=L.getState();if(!me)return;z0(new Map([[e,x]]),{x:0,y:0,width:Ee,height:le},ue,!0).length>0||we(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:ue[2]})};return i.jsx("div",{className:Mr(["react-flow__node",`react-flow__node-${N}`,{[m]:$},x.className,{selected:x.selected,selectable:z,parent:E,draggable:$,dragging:M}]),ref:R,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:O?"all":"none",visibility:D?"visible":"hidden",...x.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:_,onMouseMove:Z,onMouseLeave:ee,onContextMenu:V,onClick:fe,onDoubleClick:ae,onKeyDown:B?xe:void 0,tabIndex:B?0:void 0,onFocus:B?Se:void 0,role:x.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${hI}-${w}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(Q5,{value:e,children:i.jsx(T,{id:e,data:x.data,type:N,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:x.selected??!1,selectable:z,draggable:$,deletable:x.deletable??!0,isConnectable:K,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:M,dragHandle:x.dragHandle,zIndex:j.z,parentId:x.parentId,...F})})})}var yB=h.memo(gB);const xB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function NI(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=en(xB,sr),a=fB(e.onlyRenderVisibleElements),l=hB();return i.jsx("div",{className:"react-flow__nodes",style:$y,children:a.map(c=>i.jsx(yB,{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:o},c))})}NI.displayName="NodeRenderer";const wB=h.memo(NI);function bB(e){return en(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 o=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);o&&a&&aH({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),sr)}const vB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return i.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},kB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return i.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},lj={[js.Arrow]:vB,[js.ArrowClosed]:kB};function SB(e){const t=Xn();return h.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(lj,e)?lj[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Uo.error009(e)),null)},[e])}const NB=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=SB(t);return c?i.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:i.jsx(c,{color:n,strokeWidth:a})}):null},jI=({defaultColor:e,rfId:t})=>{const n=en(o=>o.edges),r=en(o=>o.defaultEdgeOptions),s=h.useMemo(()=>hH(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?i.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:i.jsx("defs",{children:s.map(o=>i.jsx(NB,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};jI.displayName="MarkerDefinitions";var jB=h.memo(jI);function CI({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...p}){const[u,f]=h.useState({x:1,y:0,width:0,height:0}),m=Mr(["react-flow__edge-textwrapper",d]),g=h.useRef(null);return h.useEffect(()=>{if(g.current){const w=g.current.getBBox();f({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...p,children:[s&&i.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:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}CI.displayName="EdgeText";const CB=h.memo(CI);function Dy({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...p}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...p,d:e,fill:"none",className:Mr(["react-flow__edge-path",p.className])}),d?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&eo(t)&&eo(n)?i.jsx(CB,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function cj({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Qe.Left||e===Qe.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function EI({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:s,targetPosition:o=Qe.Top}){const[a,l]=cj({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=cj({pos:o,x1:r,y1:s,x2:e,y2:t}),[p,u,f,m]=UP({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}`,p,u,f,m]}function _I(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:y})=>{const[b,x,j]=EI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),E=e.isInternal?void 0:t;return i.jsx(Dy,{id:E,path:b,labelX:x,labelY:j,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:y})})}const EB=_I({isInternal:!1}),AI=_I({isInternal:!0});EB.displayName="SimpleBezierEdge";AI.displayName="SimpleBezierEdgeInternal";function PI(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:u,style:f,sourcePosition:m=Qe.Bottom,targetPosition:g=Qe.Top,markerEnd:w,markerStart:k,pathOptions:y,interactionWidth:b})=>{const[x,j,E]=Xb({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:o,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),N=e.isInternal?void 0:t;return i.jsx(Dy,{id:N,path:x,labelX:j,labelY:E,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:u,style:f,markerEnd:w,markerStart:k,interactionWidth:b})})}const II=PI({isInternal:!1}),TI=PI({isInternal:!0});II.displayName="SmoothStepEdge";TI.displayName="SmoothStepEdgeInternal";function RI(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(II,{...n,id:r,pathOptions:h.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const _B=RI({isInternal:!1}),MI=RI({isInternal:!0});_B.displayName="StepEdge";MI.displayName="StepEdgeInternal";function LI(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:u,style:f,markerEnd:m,markerStart:g,interactionWidth:w})=>{const[k,y,b]=GP({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(Dy,{id:x,path:k,labelX:y,labelY:b,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:u,style:f,markerEnd:m,markerStart:g,interactionWidth:w})})}const AB=LI({isInternal:!1}),OI=LI({isInternal:!0});AB.displayName="StraightEdge";OI.displayName="StraightEdgeInternal";function $I(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=Qe.Bottom,targetPosition:l=Qe.Top,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,pathOptions:y,interactionWidth:b})=>{const[x,j,E]=qP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:y==null?void 0:y.curvature}),N=e.isInternal?void 0:t;return i.jsx(Dy,{id:N,path:x,labelX:j,labelY:E,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m,style:g,markerEnd:w,markerStart:k,interactionWidth:b})})}const PB=$I({isInternal:!1}),DI=$I({isInternal:!0});PB.displayName="BezierEdge";DI.displayName="BezierEdgeInternal";const uj={default:DI,straight:OI,step:MI,smoothstep:TI,simplebezier:AI},dj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},IB=(e,t,n)=>n===Qe.Left?e-t:n===Qe.Right?e+t:e,TB=(e,t,n)=>n===Qe.Top?e-t:n===Qe.Bottom?e+t:e,fj="react-flow__edgeupdater";function pj({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:a,type:l}){return i.jsx("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:a,className:Mr([fj,`${fj}-${l}`]),cx:IB(t,r,e),cy:TB(n,r,e),r,stroke:"transparent",fill:"transparent"})}function RB({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:p,onReconnectEnd:u,setReconnecting:f,setUpdateHover:m}){const g=Xn(),w=(j,E)=>{if(j.button!==0)return;const{autoPanOnConnect:N,domNode:T,connectionMode:$,connectionRadius:z,lib:K,onConnectStart:B,cancelConnection:L,nodeLookup:D,rfId:R,panBy:M,updateConnection:I}=g.getState(),F=E.type==="target",P=(Z,ee)=>{f(!1),u==null||u(Z,n,E.type,ee)},O=Z=>d==null?void 0:d(n,Z),_=(Z,ee)=>{f(!0),p==null||p(j,n,E.type),B==null||B(Z,ee)};Zb.onPointerDown(j.nativeEvent,{autoPanOnConnect:N,connectionMode:$,connectionRadius:z,domNode:T,handleId:E.id,nodeId:E.nodeId,nodeLookup:D,isTarget:F,edgeUpdaterType:E.type,lib:K,flowId:R,cancelConnection:L,panBy:M,isValidConnection:(...Z)=>{var ee,V;return((V=(ee=g.getState()).isValidConnection)==null?void 0:V.call(ee,...Z))??!0},onConnect:O,onConnectStart:_,onConnectEnd:(...Z)=>{var ee,V;return(V=(ee=g.getState()).onConnectEnd)==null?void 0:V.call(ee,...Z)},onReconnectEnd:P,updateConnection:I,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},k=j=>w(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=j=>w(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>m(!0),x=()=>m(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(pj,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:b,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(pj,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:x,type:"target"})]})}function MB({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:p,onReconnect:u,onReconnectStart:f,onReconnectEnd:m,rfId:g,edgeTypes:w,noPanClassName:k,onError:y,disableKeyboardA11y:b}){let x=en(we=>we.edgeLookup.get(e));const j=en(we=>we.defaultEdgeOptions);x=j?{...j,...x}:x;let E=x.type||"default",N=(w==null?void 0:w[E])||uj[E];N===void 0&&(y==null||y("011",Uo.error011(E)),E="default",N=(w==null?void 0:w.default)||uj.default);const T=!!(x.focusable||t&&typeof x.focusable>"u"),$=typeof u<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),z=!!(x.selectable||r&&typeof x.selectable>"u"),K=h.useRef(null),[B,L]=h.useState(!1),[D,R]=h.useState(!1),M=Xn(),{zIndex:I,sourceX:F,sourceY:P,targetX:O,targetY:_,sourcePosition:Z,targetPosition:ee}=en(h.useCallback(we=>{const je=we.nodeLookup.get(x.source),Ye=we.nodeLookup.get(x.target);if(!je||!Ye)return{zIndex:x.zIndex,...dj};const tt=pH({id:e,sourceNode:je,targetNode:Ye,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:we.connectionMode,onError:y});return{zIndex:oH({selected:x.selected,zIndex:x.zIndex,sourceNode:je,targetNode:Ye,elevateOnSelect:we.elevateEdgesOnSelect,zIndexMode:we.zIndexMode}),...tt||dj}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),sr),V=h.useMemo(()=>x.markerStart?`url('#${Jb(x.markerStart,g)}')`:void 0,[x.markerStart,g]),ae=h.useMemo(()=>x.markerEnd?`url('#${Jb(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||F===null||P===null||O===null||_===null)return null;const fe=we=>{var ze;const{addSelectedEdges:je,unselectNodesAndEdges:Ye,multiSelectionActive:tt}=M.getState();z&&(M.setState({nodesSelectionActive:!1}),x.selected&&tt?(Ye({nodes:[],edges:[x]}),(ze=K.current)==null||ze.blur()):je([e])),s&&s(we,x)},xe=o?we=>{o(we,{...x})}:void 0,Se=a?we=>{a(we,{...x})}:void 0,ue=l?we=>{l(we,{...x})}:void 0,Ee=c?we=>{c(we,{...x})}:void 0,le=d?we=>{d(we,{...x})}:void 0,me=we=>{var je;if(!b&&TP.includes(we.key)&&z){const{unselectNodesAndEdges:Ye,addSelectedEdges:tt}=M.getState();we.key==="Escape"?((je=K.current)==null||je.blur(),Ye({edges:[x]})):tt([e])}};return i.jsx("svg",{style:{zIndex:I},children:i.jsxs("g",{className:Mr(["react-flow__edge",`react-flow__edge-${E}`,x.className,k,{selected:x.selected,animated:x.animated,inactive:!z&&!s,updating:B,selectable:z}]),onClick:fe,onDoubleClick:xe,onContextMenu:Se,onMouseEnter:ue,onMouseMove:Ee,onMouseLeave:le,onKeyDown:T?me:void 0,tabIndex:T?0:void 0,role:x.ariaRole??(T?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":T?`${mI}-${g}`:void 0,ref:K,...x.domAttributes,children:[!D&&i.jsx(N,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:z,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:F,sourceY:P,targetX:O,targetY:_,sourcePosition:Z,targetPosition:ee,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:V,markerEnd:ae,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),$&&i.jsx(RB,{edge:x,isReconnectable:$,reconnectRadius:p,onReconnect:u,onReconnectStart:f,onReconnectEnd:m,sourceX:F,sourceY:P,targetX:O,targetY:_,sourcePosition:Z,targetPosition:ee,setUpdateHover:L,setReconnecting:R})]})})}var LB=h.memo(MB);const OB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function FI({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:p,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:w}){const{edgesFocusable:k,edgesReconnectable:y,elementsSelectable:b,onError:x}=en(OB,sr),j=bB(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(jB,{defaultColor:e,rfId:n}),j.map(E=>i.jsx(LB,{id:E,edgesFocusable:k,edgesReconnectable:y,elementsSelectable:b,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:p,reconnectRadius:u,onDoubleClick:f,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:w},E))]})}FI.displayName="EdgeRenderer";const $B=h.memo(FI),DB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function FB({children:e}){const t=en(DB);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function zB(e){const t=Hl(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const HB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function BB(e){const t=en(HB),n=Xn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function WB(e){return e.connection.inProgress?{...e.connection,to:sh(e.connection.to,e.transform)}:{...e.connection}}function VB(e){return WB}function KB(e){const t=VB();return en(t,sr)}const UB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function qB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=en(UB,sr);return!(o&&s&&c)?null:i.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:i.jsx("g",{className:Mr(["react-flow__connection",LP(l)]),children:i.jsx(zI,{style:t,type:n,CustomComponent:r,isValid:l})})})}const zI=({style:e,type:t=dl.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:p,toHandle:u,toPosition:f,pointer:m}=KB();if(!s)return;if(n)return i.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:f,connectionStatus:LP(r),toNode:p,toHandle:u,pointer:m});let g="";const w={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case dl.Bezier:[g]=qP(w);break;case dl.SimpleBezier:[g]=EI(w);break;case dl.Step:[g]=Xb({...w,borderRadius:0});break;case dl.SmoothStep:[g]=Xb(w);break;default:[g]=GP(w)}return i.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};zI.displayName="ConnectionLine";const YB={};function hj(e=YB){h.useRef(e),Xn(),h.useEffect(()=>{},[e])}function GB(){Xn(),h.useRef(!1),h.useEffect(()=>{},[])}function HI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:w,connectionLineComponent:k,connectionLineContainerStyle:y,selectionKeyCode:b,selectionOnDrag:x,selectionMode:j,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:T,deleteKeyCode:$,onlyRenderVisibleElements:z,elementsSelectable:K,defaultViewport:B,translateExtent:L,minZoom:D,maxZoom:R,preventScrolling:M,defaultMarkerColor:I,zoomOnScroll:F,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:_,panOnScrollMode:Z,zoomOnDoubleClick:ee,panOnDrag:V,onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:xe,onPaneMouseLeave:Se,onPaneScroll:ue,onPaneContextMenu:Ee,paneClickDistance:le,nodeClickDistance:me,onEdgeContextMenu:we,onEdgeMouseEnter:je,onEdgeMouseMove:Ye,onEdgeMouseLeave:tt,reconnectRadius:ze,onReconnect:dt,onReconnectStart:Ft,onReconnectEnd:Ue,noDragClassName:pt,noWheelClassName:_n,noPanClassName:We,disableKeyboardA11y:sn,nodeExtent:xt,rfId:kn,viewport:pe,onViewportChange:_e}){return hj(e),hj(t),GB(),zB(n),BB(pe),i.jsx(uB,{onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:xe,onPaneMouseLeave:Se,onPaneContextMenu:Ee,onPaneScroll:ue,paneClickDistance:le,deleteKeyCode:$,selectionKeyCode:b,selectionOnDrag:x,selectionMode:j,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:T,elementsSelectable:K,zoomOnScroll:F,zoomOnPinch:P,zoomOnDoubleClick:ee,panOnScroll:O,panOnScrollSpeed:_,panOnScrollMode:Z,panOnDrag:V,defaultViewport:B,translateExtent:L,minZoom:D,maxZoom:R,onSelectionContextMenu:u,preventScrolling:M,noDragClassName:pt,noWheelClassName:_n,noPanClassName:We,disableKeyboardA11y:sn,onViewportChange:_e,isControlledViewport:!!pe,children:i.jsxs(FB,{children:[i.jsx($B,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:dt,onReconnectStart:Ft,onReconnectEnd:Ue,onlyRenderVisibleElements:z,onEdgeContextMenu:we,onEdgeMouseEnter:je,onEdgeMouseMove:Ye,onEdgeMouseLeave:tt,reconnectRadius:ze,defaultMarkerColor:I,noPanClassName:We,disableKeyboardA11y:sn,rfId:kn}),i.jsx(qB,{style:w,type:g,component:k,containerStyle:y}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(wB,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:p,nodeClickDistance:me,onlyRenderVisibleElements:z,noPanClassName:We,noDragClassName:pt,disableKeyboardA11y:sn,nodeExtent:xt,rfId:kn}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}HI.displayName="GraphView";const XB=h.memo(HI),mj=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:p,nodeExtent:u,zIndexMode:f="basic"}={})=>{const m=new Map,g=new Map,w=new Map,k=new Map,y=r??t??[],b=n??e??[],x=p??[0,0],j=u??Ap;QP(w,k,y);const{nodesInitialized:E}=Qb(b,m,g,{nodeOrigin:x,nodeExtent:j,zIndexMode:f});let N=[0,0,1];if(a&&s&&o){const T=nh(m,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:$,y:z,zoom:K}=H0(T,s,o,c,d,(l==null?void 0:l.padding)??.1);N=[$,z,K]}return{rfId:"1",width:s??0,height:o??0,transform:N,nodes:b,nodesInitialized:E,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:k,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Ap,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:yd.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...MP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:eH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:RP,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:p,nodeExtent:u,zIndexMode:f})=>g5((m,g)=>{async function w(){const{nodeLookup:k,panZoom:y,fitViewOptions:b,fitViewResolver:x,width:j,height:E,minZoom:N,maxZoom:T}=g();y&&(await Q3({nodes:k,width:j,height:E,panZoom:y,minZoom:N,maxZoom:T},b),x==null||x.resolve(!0),m({fitViewResolver:null}))}return{...mj({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:p,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:k=>{const{nodeLookup:y,parentLookup:b,nodeOrigin:x,elevateNodesOnSelect:j,fitViewQueued:E,zIndexMode:N,nodesSelectionActive:T}=g(),{nodesInitialized:$,hasSelectedNodes:z}=Qb(k,y,b,{nodeOrigin:x,nodeExtent:u,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:N}),K=T&&z;E&&$?(w(),m({nodes:k,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:K})):m({nodes:k,nodesInitialized:$,nodesSelectionActive:K})},setEdges:k=>{const{connectionLookup:y,edgeLookup:b}=g();QP(y,b,k),m({edges:k})},setDefaultNodesAndEdges:(k,y)=>{if(k){const{setNodes:b}=g();b(k),m({hasDefaultNodes:!0})}if(y){const{setEdges:b}=g();b(y),m({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:y,nodeLookup:b,parentLookup:x,domNode:j,nodeOrigin:E,nodeExtent:N,debug:T,fitViewQueued:$,zIndexMode:z}=g(),{changes:K,updatedInternals:B}=vH(k,b,x,j,E,N,z);B&&(yH(b,x,{nodeOrigin:E,nodeExtent:N,zIndexMode:z}),$?(w(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(K==null?void 0:K.length)>0&&(T&&console.log("React Flow: trigger node changes",K),y==null||y(K)))},updateNodePositions:(k,y=!1)=>{const b=[];let x=[];const{nodeLookup:j,triggerNodeChanges:E,connection:N,updateConnection:T,onNodesChangeMiddlewareMap:$}=g();for(const[z,K]of k){const B=j.get(z),L=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(K!=null&&K.position)),D={id:z,type:"position",position:L?{x:Math.max(0,K.position.x),y:Math.max(0,K.position.y)}:K.position,dragging:y};if(B&&N.inProgress&&N.fromNode.id===B.id){const R=Oc(B,N.fromHandle,Qe.Left,!0);T({...N,from:R})}L&&B.parentId&&b.push({id:z,parentId:B.parentId,rect:{...K.internals.positionAbsolute,width:K.measured.width??0,height:K.measured.height??0}}),x.push(D)}if(b.length>0){const{parentLookup:z,nodeOrigin:K}=g(),B=q0(b,j,z,K);x.push(...B)}for(const z of $.values())x=z(x);E(x)},triggerNodeChanges:k=>{const{onNodesChange:y,setNodes:b,nodes:x,hasDefaultNodes:j,debug:E}=g();if(k!=null&&k.length){if(j){const N=Og(k,x);b(N)}E&&console.log("React Flow: trigger node changes",k),y==null||y(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:y,setEdges:b,edges:x,hasDefaultEdges:j,debug:E}=g();if(k!=null&&k.length){if(j){const N=Y0(k,x);b(N)}E&&console.log("React Flow: trigger edge changes",k),y==null||y(k)}},addSelectedNodes:k=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:E}=g();if(y){const N=k.map(T=>fc(T,!0));j(N);return}j(Vu(x,new Set([...k]),!0)),E(Vu(b))},addSelectedEdges:k=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:E}=g();if(y){const N=k.map(T=>fc(T,!0));E(N);return}E(Vu(b,new Set([...k]))),j(Vu(x,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:y}={})=>{const{edges:b,nodes:x,nodeLookup:j,triggerNodeChanges:E,triggerEdgeChanges:N}=g(),T=k||x,$=y||b,z=[];for(const B of T){if(!B.selected)continue;const L=j.get(B.id);L&&(L.selected=!1),z.push(fc(B.id,!1))}const K=[];for(const B of $)B.selected&&K.push(fc(B.id,!1));E(z),N(K)},setMinZoom:k=>{const{panZoom:y,maxZoom:b}=g();y==null||y.setScaleExtent([k,b]),m({minZoom:k})},setMaxZoom:k=>{const{panZoom:y,minZoom:b}=g();y==null||y.setScaleExtent([b,k]),m({maxZoom:k})},setTranslateExtent:k=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(k),m({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:y,triggerNodeChanges:b,triggerEdgeChanges:x,elementsSelectable:j}=g();if(!j)return;const E=y.reduce((T,$)=>$.selected?[...T,fc($.id,!1)]:T,[]),N=k.reduce((T,$)=>$.selected?[...T,fc($.id,!1)]:T,[]);b(E),x(N)},setNodeExtent:k=>{const{nodes:y,nodeLookup:b,parentLookup:x,nodeOrigin:j,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:T}=g();k[0][0]===N[0][0]&&k[0][1]===N[0][1]&&k[1][0]===N[1][0]&&k[1][1]===N[1][1]||(Qb(y,b,x,{nodeOrigin:j,nodeExtent:k,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:T}),m({nodeExtent:k}))},panBy:k=>{const{transform:y,width:b,height:x,panZoom:j,translateExtent:E}=g();return kH({delta:k,panZoom:j,transform:y,translateExtent:E,width:b,height:x})},setCenter:async(k,y,b)=>{const{width:x,height:j,maxZoom:E,panZoom:N}=g();if(!N)return Promise.resolve(!1);const T=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:E;return await N.setViewport({x:x/2-k*T,y:j/2-y*T,zoom:T},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...MP}})},updateConnection:k=>{m({connection:k})},reset:()=>m({...mj()})}},Object.is);function Fy({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:p,nodeExtent:u,zIndexMode:f,children:m}){const[g]=h.useState(()=>JB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:p,nodeExtent:u,zIndexMode:f}));return i.jsx(y5,{value:g,children:i.jsx(F5,{children:m})})}function QB({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:p,nodeOrigin:u,nodeExtent:f,zIndexMode:m}){return h.useContext(Oy)?i.jsx(i.Fragment,{children:e}):i.jsx(Fy,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:p,nodeOrigin:u,nodeExtent:f,zIndexMode:m,children:e})}const ZB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function e4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:p,onMoveStart:u,onMoveEnd:f,onConnect:m,onConnectStart:g,onConnectEnd:w,onClickConnectStart:k,onClickConnectEnd:y,onNodeMouseEnter:b,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:T,onNodeDrag:$,onNodeDragStop:z,onNodesDelete:K,onEdgesDelete:B,onDelete:L,onSelectionChange:D,onSelectionDragStart:R,onSelectionDrag:M,onSelectionDragStop:I,onSelectionContextMenu:F,onSelectionStart:P,onSelectionEnd:O,onBeforeDelete:_,connectionMode:Z,connectionLineType:ee=dl.Bezier,connectionLineStyle:V,connectionLineComponent:ae,connectionLineContainerStyle:fe,deleteKeyCode:xe="Backspace",selectionKeyCode:Se="Shift",selectionOnDrag:ue=!1,selectionMode:Ee=Pp.Full,panActivationKeyCode:le="Space",multiSelectionKeyCode:me=Tp()?"Meta":"Control",zoomActivationKeyCode:we=Tp()?"Meta":"Control",snapToGrid:je,snapGrid:Ye,onlyRenderVisibleElements:tt=!1,selectNodesOnDrag:ze,nodesDraggable:dt,autoPanOnNodeFocus:Ft,nodesConnectable:Ue,nodesFocusable:pt,nodeOrigin:_n=gI,edgesFocusable:We,edgesReconnectable:sn,elementsSelectable:xt=!0,defaultViewport:kn=P5,minZoom:pe=.5,maxZoom:_e=2,translateExtent:Ve=Ap,preventScrolling:rt=!0,nodeExtent:it,defaultMarkerColor:Mt="#b1b1b7",zoomOnScroll:wt=!0,zoomOnPinch:gn=!0,panOnScroll:cn=!1,panOnScrollSpeed:Jn=.5,panOnScrollMode:on=Nc.Free,zoomOnDoubleClick:An=!0,panOnDrag:Pn=!0,onPaneClick:mr,onPaneMouseEnter:Cr,onPaneMouseMove:gr,onPaneMouseLeave:Wt,onPaneScroll:Vt,onPaneContextMenu:ir,paneClickDistance:Er=1,nodeClickDistance:dr=0,children:yr,onReconnect:_r,onReconnectStart:Lr,onReconnectEnd:or,onEdgeContextMenu:xr,onEdgeDoubleClick:Or,onEdgeMouseEnter:ws,onEdgeMouseMove:ar,onEdgeMouseLeave:Ar,reconnectRadius:In=10,onNodesChange:Tn,onEdgesChange:ce,noDragClassName:he="nodrag",noWheelClassName:Q="nowheel",noPanClassName:ge="nopan",fitView:qe,fitViewOptions:Me,connectOnClick:zt,attributionPosition:Rn,proOptions:Hn,defaultEdgeOptions:wr,elevateNodesOnSelect:Ae=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:lt=!1,autoPanOnConnect:pn,autoPanOnNodeDrag:Zt,autoPanSpeed:br,connectionRadius:nt,isValidConnection:os,onError:hi,style:Ii,id:co,nodeDragThreshold:uo,connectionDragThreshold:fo,viewport:Ti,onViewportChange:Sn,width:As,height:po,colorMode:Ri="light",debug:Js,onScroll:Qr,ariaLabelConfig:Jo,zIndexMode:U="basic",...be},$e){const Oe=co||"1",st=M5(Ri),un=h.useCallback(bt=>{bt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Qr==null||Qr(bt)},[Qr]);return i.jsx("div",{"data-testid":"rf__wrapper",...be,onScroll:un,style:{...Ii,...ZB},ref:$e,className:Mr(["react-flow",s,st]),id:co,role:"application",children:i.jsxs(QB,{nodes:e,edges:t,width:As,height:po,fitView:qe,fitViewOptions:Me,minZoom:pe,maxZoom:_e,nodeOrigin:_n,nodeExtent:it,zIndexMode:U,children:[i.jsx(R5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:w,onClickConnectStart:k,onClickConnectEnd:y,nodesDraggable:dt,autoPanOnNodeFocus:Ft,nodesConnectable:Ue,nodesFocusable:pt,edgesFocusable:We,edgesReconnectable:sn,elementsSelectable:xt,elevateNodesOnSelect:Ae,elevateEdgesOnSelect:Br,minZoom:pe,maxZoom:_e,nodeExtent:it,onNodesChange:Tn,onEdgesChange:ce,snapToGrid:je,snapGrid:Ye,connectionMode:Z,translateExtent:Ve,connectOnClick:zt,defaultEdgeOptions:wr,fitView:qe,fitViewOptions:Me,onNodesDelete:K,onEdgesDelete:B,onDelete:L,onNodeDragStart:T,onNodeDrag:$,onNodeDragStop:z,onSelectionDrag:M,onSelectionDragStart:R,onSelectionDragStop:I,onMove:p,onMoveStart:u,onMoveEnd:f,noPanClassName:ge,nodeOrigin:_n,rfId:Oe,autoPanOnConnect:pn,autoPanOnNodeDrag:Zt,autoPanSpeed:br,onError:hi,connectionRadius:nt,isValidConnection:os,selectNodesOnDrag:ze,nodeDragThreshold:uo,connectionDragThreshold:fo,onBeforeDelete:_,debug:Js,ariaLabelConfig:Jo,zIndexMode:U}),i.jsx(XB,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:ee,connectionLineStyle:V,connectionLineComponent:ae,connectionLineContainerStyle:fe,selectionKeyCode:Se,selectionOnDrag:ue,selectionMode:Ee,deleteKeyCode:xe,multiSelectionKeyCode:me,panActivationKeyCode:le,zoomActivationKeyCode:we,onlyRenderVisibleElements:tt,defaultViewport:kn,translateExtent:Ve,minZoom:pe,maxZoom:_e,preventScrolling:rt,zoomOnScroll:wt,zoomOnPinch:gn,zoomOnDoubleClick:An,panOnScroll:cn,panOnScrollSpeed:Jn,panOnScrollMode:on,panOnDrag:Pn,onPaneClick:mr,onPaneMouseEnter:Cr,onPaneMouseMove:gr,onPaneMouseLeave:Wt,onPaneScroll:Vt,onPaneContextMenu:ir,paneClickDistance:Er,nodeClickDistance:dr,onSelectionContextMenu:F,onSelectionStart:P,onSelectionEnd:O,onReconnect:_r,onReconnectStart:Lr,onReconnectEnd:or,onEdgeContextMenu:xr,onEdgeDoubleClick:Or,onEdgeMouseEnter:ws,onEdgeMouseMove:ar,onEdgeMouseLeave:Ar,reconnectRadius:In,defaultMarkerColor:Mt,noDragClassName:he,noWheelClassName:Q,noPanClassName:ge,rfId:Oe,disableKeyboardA11y:lt,nodeExtent:it,viewport:Ti,onViewportChange:Sn}),i.jsx(A5,{onSelectionChange:D}),yr,i.jsx(N5,{proOptions:Hn,position:Rn}),i.jsx(S5,{rfId:Oe,disableKeyboardA11y:lt})]})})}var X0=xI(e4);function J0(){const e=Xn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],o=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function BI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(o=>Og(s,o)),[]);return[t,n,r]}function WI(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(o=>Y0(s,o)),[]);return[t,n,r]}function t4({dimensions:e,lineWidth:t,variant:n,className:r}){return i.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Mr(["react-flow__background-pattern",n,r])})}function n4({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Mr(["react-flow__background-pattern","dots",t])})}var Cl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Cl||(Cl={}));const r4={[Cl.Dots]:1,[Cl.Lines]:1,[Cl.Cross]:6},s4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function VI({id:e,variant:t=Cl.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:d,patternClassName:p}){const u=h.useRef(null),{transform:f,patternId:m}=en(s4,sr),g=r||r4[t],w=t===Cl.Dots,k=t===Cl.Cross,y=Array.isArray(n)?n:[n,n],b=[y[0]*f[2]||1,y[1]*f[2]||1],x=g*f[2],j=Array.isArray(o)?o:[o,o],E=k?[x,x]:b,N=[j[0]*f[2]||1+E[0]/2,j[1]*f[2]||1+E[1]/2],T=`${m}${e||""}`;return i.jsxs("svg",{className:Mr(["react-flow__background",d]),style:{...c,...$y,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[i.jsx("pattern",{id:T,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:w?i.jsx(n4,{radius:x/2,className:p}):i.jsx(t4,{dimensions:E,lineWidth:s,variant:t,className:p})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${T})`})]})}VI.displayName="Background";const Q0=h.memo(VI);function i4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:i.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function o4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:i.jsx("path",{d:"M0 0h32v4.2H0z"})})}function a4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:i.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function l4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function c4(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function um({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Mr(["react-flow__controls-button",t]),...n,children:e})}const u4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function KI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:p,position:u="bottom-left",orientation:f="vertical","aria-label":m}){const g=Xn(),{isInteractive:w,minZoomReached:k,maxZoomReached:y,ariaLabelConfig:b}=en(u4,sr),{zoomIn:x,zoomOut:j,fitView:E}=Hl(),N=()=>{x(),o==null||o()},T=()=>{j(),a==null||a()},$=()=>{E(s),l==null||l()},z=()=>{g.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),c==null||c(!w)},K=f==="horizontal"?"horizontal":"vertical";return i.jsxs(Sd,{className:Mr(["react-flow__controls",K,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??b["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(um,{onClick:N,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:y,children:i.jsx(i4,{})}),i.jsx(um,{onClick:T,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:k,children:i.jsx(o4,{})})]}),n&&i.jsx(um,{className:"react-flow__controls-fitview",onClick:$,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:i.jsx(a4,{})}),r&&i.jsx(um,{className:"react-flow__controls-interactive",onClick:z,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:w?i.jsx(c4,{}):i.jsx(l4,{})}),p]})}KI.displayName="Controls";const d4=h.memo(KI);function f4({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:p,shapeRendering:u,selected:f,onClick:m}){const{background:g,backgroundColor:w}=o||{},k=a||g||w;return i.jsx("rect",{className:Mr(["react-flow__minimap-node",{selected:f},d]),x:t,y:n,rx:p,ry:p,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?y=>m(y,e):void 0})}const p4=h.memo(f4),h4=e=>e.nodes.map(t=>t.id),tw=e=>e instanceof Function?e:()=>e;function m4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=p4,onClick:a}){const l=en(h4,sr),c=tw(t),d=tw(e),p=tw(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(f=>i.jsx(y4,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:u},f))})}function g4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:p,y:u,width:f,height:m}=en(g=>{const w=g.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const k=w.internals.userNode,{x:y,y:b}=w.internals.positionAbsolute,{width:x,height:j}=Ra(k);return{node:k,x:y,y:b,width:x,height:j}},sr);return!d||d.hidden||!HP(d)?null:i.jsx(l,{x:p,y:u,width:f,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:o,shapeRendering:a,onClick:c,id:d.id})}const y4=h.memo(g4);var x4=h.memo(m4);const w4=200,b4=150,v4=e=>!e.hidden,k4=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?zP(nh(e.nodeLookup,{filter:v4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},S4="react-flow__minimap-desc";function UI({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:p,maskStrokeWidth:u,position:f="bottom-right",onClick:m,onNodeClick:g,pannable:w=!1,zoomable:k=!1,ariaLabel:y,inversePan:b,zoomStep:x=1,offsetScale:j=5}){const E=Xn(),N=h.useRef(null),{boundingRect:T,viewBB:$,rfId:z,panZoom:K,translateExtent:B,flowWidth:L,flowHeight:D,ariaLabelConfig:R}=en(k4,sr),M=(e==null?void 0:e.width)??w4,I=(e==null?void 0:e.height)??b4,F=T.width/M,P=T.height/I,O=Math.max(F,P),_=O*M,Z=O*I,ee=j*O,V=T.x-(_-T.width)/2-ee,ae=T.y-(Z-T.height)/2-ee,fe=_+ee*2,xe=Z+ee*2,Se=`${S4}-${z}`,ue=h.useRef(0),Ee=h.useRef();ue.current=O,h.useEffect(()=>{if(N.current&&K)return Ee.current=IH({domNode:N.current,panZoom:K,getTransform:()=>E.getState().transform,getViewScale:()=>ue.current}),()=>{var je;(je=Ee.current)==null||je.destroy()}},[K]),h.useEffect(()=>{var je;(je=Ee.current)==null||je.update({translateExtent:B,width:L,height:D,inversePan:b,pannable:w,zoomStep:x,zoomable:k})},[w,k,b,x,B,L,D]);const le=m?je=>{var ze;const[Ye,tt]=((ze=Ee.current)==null?void 0:ze.pointer(je))||[0,0];m(je,{x:Ye,y:tt})}:void 0,me=g?h.useCallback((je,Ye)=>{const tt=E.getState().nodeLookup.get(Ye).internals.userNode;g(je,tt)},[]):void 0,we=y??R["minimap.ariaLabel"];return i.jsx(Sd,{position:f,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 p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*O:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Mr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:M,height:I,viewBox:`${V} ${ae} ${fe} ${xe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Se,ref:N,onClick:le,children:[we&&i.jsx("title",{id:Se,children:we}),i.jsx(x4,{onClick:me,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-ee},${ae-ee}h${fe+ee*2}v${xe+ee*2}h${-fe-ee*2}z
66
- M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}UI.displayName="MiniMap";const N4=h.memo(UI),j4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,C4={[vd.Line]:"right",[vd.Handle]:"bottom-right"};function E4({nodeId:e,position:t,variant:n=vd.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:m=!0,shouldResize:g,onResizeStart:w,onResize:k,onResizeEnd:y}){const b=kI(),x=typeof e=="string"?e:b,j=Xn(),E=h.useRef(null),N=n===vd.Handle,T=en(h.useCallback(j4(N&&m),[N,m]),sr),$=h.useRef(null),z=t??C4[n];h.useEffect(()=>{if(!(!E.current||!x))return $.current||($.current=KH({domNode:E.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:B,transform:L,snapGrid:D,snapToGrid:R,nodeOrigin:M,domNode:I}=j.getState();return{nodeLookup:B,transform:L,snapGrid:D,snapToGrid:R,nodeOrigin:M,paneDomNode:I}},onChange:(B,L)=>{const{triggerNodeChanges:D,nodeLookup:R,parentLookup:M,nodeOrigin:I}=j.getState(),F=[],P={x:B.x,y:B.y},O=R.get(x);if(O&&O.expandParent&&O.parentId){const _=O.origin??I,Z=B.width??O.measured.width??0,ee=B.height??O.measured.height??0,V={id:O.id,parentId:O.parentId,rect:{width:Z,height:ee,...BP({x:B.x??O.position.x,y:B.y??O.position.y},{width:Z,height:ee},O.parentId,R,_)}},ae=q0([V],R,M,I);F.push(...ae),P.x=B.x?Math.max(_[0]*Z,B.x):void 0,P.y=B.y?Math.max(_[1]*ee,B.y):void 0}if(P.x!==void 0&&P.y!==void 0){const _={id:x,type:"position",position:{...P}};F.push(_)}if(B.width!==void 0&&B.height!==void 0){const Z={id:x,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};F.push(Z)}for(const _ of L){const Z={..._,type:"position"};F.push(Z)}D(F)},onEnd:({width:B,height:L})=>{const D={id:x,type:"dimensions",resizing:!1,dimensions:{width:B,height:L}};j.getState().triggerNodeChanges([D])}})),$.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:p},keepAspectRatio:u,resizeDirection:f,onResizeStart:w,onResize:k,onResizeEnd:y,shouldResize:g}),()=>{var B;(B=$.current)==null||B.destroy()}},[z,l,c,d,p,u,w,k,y,g]);const K=z.split("-");return i.jsx("div",{className:Mr(["react-flow__resize-control","nodrag",...K,n,r]),ref:E,style:{...s,scale:T,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:o})}const Z0=h.memo(E4);function _4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const A4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,I4={};function gj(e,t){return(I4.jsx?P4:A4).test(e)}const T4=/[ \t\n\f\r]/g;function R4(e){return typeof e=="object"?e.type==="text"?yj(e.value):!1:yj(e)}function yj(e){return e.replace(T4,"")===""}let ih=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};ih.prototype.normal={};ih.prototype.property={};ih.prototype.space=void 0;function qI(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new ih(n,r,t)}function nv(e){return e.toLowerCase()}class Xs{constructor(t,n){this.attribute=n,this.property=t}}Xs.prototype.attribute="";Xs.prototype.booleanish=!1;Xs.prototype.boolean=!1;Xs.prototype.commaOrSpaceSeparated=!1;Xs.prototype.commaSeparated=!1;Xs.prototype.defined=!1;Xs.prototype.mustUseProperty=!1;Xs.prototype.number=!1;Xs.prototype.overloadedBoolean=!1;Xs.prototype.property="";Xs.prototype.spaceSeparated=!1;Xs.prototype.space=void 0;let M4=0;const Ot=Vc(),Pr=Vc(),rv=Vc(),Le=Vc(),On=Vc(),sd=Vc(),ni=Vc();function Vc(){return 2**++M4}const sv=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ot,booleanish:Pr,commaOrSpaceSeparated:ni,commaSeparated:sd,number:Le,overloadedBoolean:rv,spaceSeparated:On},Symbol.toStringTag,{value:"Module"})),nw=Object.keys(sv);class ek extends Xs{constructor(t,n,r,s){let o=-1;if(super(t,n),xj(this,"space",s),typeof r=="number")for(;++o<nw.length;){const a=nw[o];xj(this,nw[o],(r&sv[a])===sv[a])}}}ek.prototype.defined=!0;function xj(e,t,n){n&&(e[t]=n)}function Rd(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new ek(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[nv(r)]=r,n[nv(o.attribute)]=r}return new ih(t,n,e.space)}const YI=Rd({properties:{ariaActiveDescendant:null,ariaAtomic:Pr,ariaAutoComplete:null,ariaBusy:Pr,ariaChecked:Pr,ariaColCount:Le,ariaColIndex:Le,ariaColSpan:Le,ariaControls:On,ariaCurrent:null,ariaDescribedBy:On,ariaDetails:null,ariaDisabled:Pr,ariaDropEffect:On,ariaErrorMessage:null,ariaExpanded:Pr,ariaFlowTo:On,ariaGrabbed:Pr,ariaHasPopup:null,ariaHidden:Pr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:On,ariaLevel:Le,ariaLive:null,ariaModal:Pr,ariaMultiLine:Pr,ariaMultiSelectable:Pr,ariaOrientation:null,ariaOwns:On,ariaPlaceholder:null,ariaPosInSet:Le,ariaPressed:Pr,ariaReadOnly:Pr,ariaRelevant:null,ariaRequired:Pr,ariaRoleDescription:On,ariaRowCount:Le,ariaRowIndex:Le,ariaRowSpan:Le,ariaSelected:Pr,ariaSetSize:Le,ariaSort:null,ariaValueMax:Le,ariaValueMin:Le,ariaValueNow:Le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function GI(e,t){return t in e?e[t]:t}function XI(e,t){return GI(e,t.toLowerCase())}const L4=Rd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:sd,acceptCharset:On,accessKey:On,action:null,allow:null,allowFullScreen:Ot,allowPaymentRequest:Ot,allowUserMedia:Ot,alt:null,as:null,async:Ot,autoCapitalize:null,autoComplete:On,autoFocus:Ot,autoPlay:Ot,blocking:On,capture:null,charSet:null,checked:Ot,cite:null,className:On,cols:Le,colSpan:null,content:null,contentEditable:Pr,controls:Ot,controlsList:On,coords:Le|sd,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ot,defer:Ot,dir:null,dirName:null,disabled:Ot,download:rv,draggable:Pr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ot,formTarget:null,headers:On,height:Le,hidden:rv,high:Le,href:null,hrefLang:null,htmlFor:On,httpEquiv:On,id:null,imageSizes:null,imageSrcSet:null,inert:Ot,inputMode:null,integrity:null,is:null,isMap:Ot,itemId:null,itemProp:On,itemRef:On,itemScope:Ot,itemType:On,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ot,low:Le,manifest:null,max:null,maxLength:Le,media:null,method:null,min:null,minLength:Le,multiple:Ot,muted:Ot,name:null,nonce:null,noModule:Ot,noValidate:Ot,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ot,optimum:Le,pattern:null,ping:On,placeholder:null,playsInline:Ot,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ot,referrerPolicy:null,rel:On,required:Ot,reversed:Ot,rows:Le,rowSpan:Le,sandbox:On,scope:null,scoped:Ot,seamless:Ot,selected:Ot,shadowRootClonable:Ot,shadowRootDelegatesFocus:Ot,shadowRootMode:null,shape:null,size:Le,sizes:null,slot:null,span:Le,spellCheck:Pr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Le,step:null,style:null,tabIndex:Le,target:null,title:null,translate:null,type:null,typeMustMatch:Ot,useMap:null,value:Pr,width:Le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:On,axis:null,background:null,bgColor:null,border:Le,borderColor:null,bottomMargin:Le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ot,declare:Ot,event:null,face:null,frame:null,frameBorder:null,hSpace:Le,leftMargin:Le,link:null,longDesc:null,lowSrc:null,marginHeight:Le,marginWidth:Le,noResize:Ot,noHref:Ot,noShade:Ot,noWrap:Ot,object:null,profile:null,prompt:null,rev:null,rightMargin:Le,rules:null,scheme:null,scrolling:Pr,standby:null,summary:null,text:null,topMargin:Le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Le,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ot,disableRemotePlayback:Ot,prefix:null,property:null,results:Le,security:null,unselectable:null},space:"html",transform:XI}),O4=Rd({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:ni,accentHeight:Le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Le,amplitude:Le,arabicForm:null,ascent:Le,attributeName:null,attributeType:null,azimuth:Le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Le,by:null,calcMode:null,capHeight:Le,className:On,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:Le,diffuseConstant:Le,direction:null,display:null,dur:null,divisor:Le,dominantBaseline:null,download:Ot,dx:null,dy:null,edgeMode:null,editable:null,elevation:Le,enableBackground:null,end:null,event:null,exponent:Le,externalResourcesRequired:null,fill:null,fillOpacity:Le,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:sd,g2:sd,glyphName:sd,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Le,horizOriginX:Le,horizOriginY:Le,id:null,ideographic:Le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Le,k:Le,k1:Le,k2:Le,k3:Le,k4:Le,kernelMatrix:ni,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Le,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:Le,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:Le,overlineThickness:Le,paintOrder:null,panose1:null,path:null,pathLength:Le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:On,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Le,pointsAtY:Le,pointsAtZ:Le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ni,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ni,rev:ni,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ni,requiredFeatures:ni,requiredFonts:ni,requiredFormats:ni,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:Le,specularExponent:Le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Le,strikethroughThickness:Le,string:null,stroke:null,strokeDashArray:ni,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Le,strokeOpacity:Le,strokeWidth:null,style:null,surfaceScale:Le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ni,tabIndex:Le,tableValues:null,target:null,targetX:Le,targetY:Le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ni,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Le,underlineThickness:Le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Le,values:null,vAlphabetic:Le,vMathematical:Le,vectorEffect:null,vHanging:Le,vIdeographic:Le,version:null,vertAdvY:Le,vertOriginX:Le,vertOriginY:Le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:GI}),JI=Rd({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()}}),QI=Rd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:XI}),ZI=Rd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),$4={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"},D4=/[A-Z]/g,wj=/-[a-z]/g,F4=/^data[-\w.:]+$/i;function z4(e,t){const n=nv(t);let r=t,s=Xs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&F4.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(wj,B4);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!wj.test(o)){let a=o.replace(D4,H4);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=ek}return new s(r,t)}function H4(e){return"-"+e.toLowerCase()}function B4(e){return e.charAt(1).toUpperCase()}const W4=qI([YI,L4,JI,QI,ZI],"html"),tk=qI([YI,O4,JI,QI,ZI],"svg");function V4(e){return e.join(" ").trim()}var nk={},bj=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,K4=/\n/g,U4=/^\s*/,q4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Y4=/^:\s*/,G4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,X4=/^[;\s]*/,J4=/^\s+|\s+$/g,Q4=`
67
- `,vj="/",kj="*",hc="",Z4="comment",e6="declaration";function t6(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 w=g.match(K4);w&&(n+=w.length);var k=g.lastIndexOf(Q4);r=~k?g.length-k:r+g.length}function o(){var g={line:n,column:r};return function(w){return w.position=new a(g),d(),w}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var w=new Error(t.source+":"+n+":"+r+": "+g);if(w.reason=g,w.filename=t.source,w.line=n,w.column=r,w.source=e,!t.silent)throw w}function c(g){var w=g.exec(e);if(w){var k=w[0];return s(k),e=e.slice(k.length),w}}function d(){c(U4)}function p(g){var w;for(g=g||[];w=u();)w!==!1&&g.push(w);return g}function u(){var g=o();if(!(vj!=e.charAt(0)||kj!=e.charAt(1))){for(var w=2;hc!=e.charAt(w)&&(kj!=e.charAt(w)||vj!=e.charAt(w+1));)++w;if(w+=2,hc===e.charAt(w-1))return l("End of comment missing");var k=e.slice(2,w-2);return r+=2,s(k),e=e.slice(w),r+=2,g({type:Z4,comment:k})}}function f(){var g=o(),w=c(q4);if(w){if(u(),!c(Y4))return l("property missing ':'");var k=c(G4),y=g({type:e6,property:Sj(w[0].replace(bj,hc)),value:k?Sj(k[0].replace(bj,hc)):hc});return c(X4),y}}function m(){var g=[];p(g);for(var w;w=f();)w!==!1&&(g.push(w),p(g));return g}return d(),m()}function Sj(e){return e?e.replace(J4,hc):hc}var n6=t6,r6=ap&&ap.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(nk,"__esModule",{value:!0});nk.default=i6;const s6=r6(n6);function i6(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,s6.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;s?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var zy={};Object.defineProperty(zy,"__esModule",{value:!0});zy.camelCase=void 0;var o6=/^--[a-zA-Z0-9_-]+$/,a6=/-([a-z])/g,l6=/^[^-]+$/,c6=/^-(webkit|moz|ms|o|khtml)-/,u6=/^-(ms)-/,d6=function(e){return!e||l6.test(e)||o6.test(e)},f6=function(e,t){return t.toUpperCase()},Nj=function(e,t){return"".concat(t,"-")},p6=function(e,t){return t===void 0&&(t={}),d6(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(u6,Nj):e=e.replace(c6,Nj),e.replace(a6,f6))};zy.camelCase=p6;var h6=ap&&ap.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},m6=h6(nk),g6=zy;function iv(e,t){var n={};return!e||typeof e!="string"||(0,m6.default)(e,function(r,s){r&&s&&(n[(0,g6.camelCase)(r,t)]=s)}),n}iv.default=iv;var y6=iv;const x6=$l(y6),eT=tT("end"),rk=tT("start");function tT(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 w6(e){const t=rk(e),n=eT(e);if(t&&n)return{start:t,end:n}}function Qf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?jj(e.position):"start"in e||"end"in e?jj(e):"line"in e||"column"in e?ov(e):""}function ov(e){return Cj(e&&e.line)+":"+Cj(e&&e.column)}function jj(e){return ov(e&&e.start)+"-"+ov(e&&e.end)}function Cj(e){return e&&typeof e=="number"?e:1}class ys extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(a=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=Qf(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ys.prototype.file="";ys.prototype.name="";ys.prototype.reason="";ys.prototype.message="";ys.prototype.stack="";ys.prototype.column=void 0;ys.prototype.line=void 0;ys.prototype.ancestors=void 0;ys.prototype.cause=void 0;ys.prototype.fatal=void 0;ys.prototype.place=void 0;ys.prototype.ruleId=void 0;ys.prototype.source=void 0;const sk={}.hasOwnProperty,b6=new Map,v6=/[A-Z]/g,k6=new Set(["table","tbody","thead","tfoot","tr"]),S6=new Set(["td","th"]),nT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function N6(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=T6(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=I6(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"?tk:W4,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=rT(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function rT(e,t,n){if(t.type==="element")return j6(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return C6(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return _6(e,t,n);if(t.type==="mdxjsEsm")return E6(e,t);if(t.type==="root")return A6(e,t,n);if(t.type==="text")return P6(e,t)}function j6(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=tk,e.schema=s),e.ancestors.push(t);const o=iT(e,t.tagName,!1),a=R6(e,t);let l=ok(e,t);return k6.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!R4(c):!0})),sT(e,a,o,t),ik(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function C6(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Mp(e,t.position)}function E6(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Mp(e,t.position)}function _6(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=tk,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:iT(e,t.name,!0),a=M6(e,t),l=ok(e,t);return sT(e,a,o,t),ik(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function A6(e,t,n){const r={};return ik(r,ok(e,t)),e.create(t,e.Fragment,r,n)}function P6(e,t){return t.value}function sT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ik(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function I6(e,t,n){return r;function r(s,o,a,l){const d=Array.isArray(a.children)?n:t;return l?d(o,a,l):d(o,a)}}function T6(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=rk(r);return t(s,o,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function R6(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&sk.call(t.properties,s)){const o=L6(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&S6.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function M6(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Mp(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else Mp(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function ok(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:b6;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=rT(e,o,a);l!==void 0&&n.push(l)}return n}function L6(e,t,n){const r=z4(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?_4(n):V4(n)),r.property==="style"){let s=typeof n=="object"?n:O6(e,String(n));return e.stylePropertyNameCase==="css"&&(s=$6(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?$4[r.property]||r.property:r.attribute,n]}}function O6(e,t){try{return x6(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new ys("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=nT+"#cannot-parse-style-attribute",s}}function iT(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,a;for(;++o<s.length;){const l=gj(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=gj(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return sk.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Mp(e)}function Mp(e,t){const n=new ys("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=nT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function $6(e){const t={};let n;for(n in e)sk.call(e,n)&&(t[D6(n)]=e[n]);return t}function D6(e){let t=e.replace(v6,F6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function F6(e){return"-"+e.toLowerCase()}const rw={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"]},z6={};function H6(e,t){const n=z6,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return oT(e,r,s)}function oT(e,t,n){if(B6(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 Ej(e.children,t,n)}return Array.isArray(e)?Ej(e,t,n):""}function Ej(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=oT(e[s],t,n);return r.join("")}function B6(e){return!!(e&&typeof e=="object")}const _j=document.createElement("i");function ak(e){const t="&"+e+";";_j.innerHTML=t;const n=_j.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function qo(e,t,n,r){const s=e.length;let o=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function ji(e,t){return e.length>0?(qo(e,e.length,0,t),e):t}const Aj={}.hasOwnProperty;function W6(e){const t={};let n=-1;for(;++n<e.length;)V6(t,e[n]);return t}function V6(e,t){let n;for(n in t){const s=(Aj.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Aj.call(s,a)||(s[a]=[]);const l=o[a];K6(s[a],Array.isArray(l)?l:l?[l]:[])}}}function K6(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);qo(e,0,0,r)}function aT(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 id(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Do=Bl(/[A-Za-z]/),ai=Bl(/[\dA-Za-z]/),U6=Bl(/[#-'*+\--9=?A-Z^-~]/);function av(e){return e!==null&&(e<32||e===127)}const lv=Bl(/\d/),q6=Bl(/[\dA-Fa-f]/),Y6=Bl(/[!-/:-@[-`{-~]/);function Et(e){return e!==null&&e<-2}function Gs(e){return e!==null&&(e<0||e===32)}function fn(e){return e===-2||e===-1||e===32}const G6=Bl(new RegExp("\\p{P}|\\p{S}","u")),X6=Bl(/\s/);function Bl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Md(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&ai(e.charCodeAt(n+1))&&ai(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),s=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Fn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return fn(c)?(e.enter(n),l(c)):t(c)}function l(c){return fn(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const J6={tokenize:Q6};function Q6(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Fn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),o(l)}function o(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 Et(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const Z6={tokenize:e8},Pj={tokenize:t8};function e8(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,d)(x)}return d(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&b();const j=t.events.length;let E=j,N;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){N=t.events[E][1].end;break}y(r);let T=j;for(;T<t.events.length;)t.events[T][1].end={...N},T++;return qo(t.events,E+1,0,t.events.slice(j)),t.events.length=T,d(x)}return l(x)}function d(x){if(r===n.length){if(!s)return f(x);if(s.currentConstruct&&s.currentConstruct.concrete)return g(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Pj,p,u)(x)}function p(x){return s&&b(),y(r),f(x)}function u(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(x)}function f(x){return t.containerState={},e.attempt(Pj,m,g)(x)}function m(x){return r++,n.push([t.currentConstruct,t.containerState]),f(x)}function g(x){if(x===null){s&&b(),y(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),w(x)}function w(x){if(x===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return Et(x)?(e.consume(x),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),w)}function k(x,j){const E=t.sliceStream(x);if(j&&E.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(E),t.parser.lazy[x.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<a&&(!s.events[N][1].end||s.events[N][1].end.offset>a))return;const T=t.events.length;let $=T,z,K;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(z){K=t.events[$][1].end;break}z=!0}for(y(r),N=T;N<t.events.length;)t.events[N][1].end={...K},N++;qo(t.events,$+1,0,t.events.slice(T)),t.events.length=N}}function y(x){let j=n.length;for(;j-- >x;){const E=n[j];t.containerState=E[1],E[0].exit.call(t,e)}n.length=x}function b(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function t8(e,t,n){return Fn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ij(e){if(e===null||Gs(e)||X6(e))return 1;if(G6(e))return 2}function lk(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const cv={name:"attention",resolveAll:n8,tokenize:r8};function n8(e,t){let n=-1,r,s,o,a,l,c,d,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;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},f={...e[n][1].start};Tj(u,-c),Tj(f,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:f},o={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=ji(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=ji(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=ji(d,lk(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=ji(d,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,d=ji(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,qo(e,r-1,n-r+3,d),n=r+d.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function r8(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=Ij(r);let o;return a;function a(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const d=e.exit("attentionSequence"),p=Ij(c),u=!p||p===2&&s||n.includes(c),f=!s||s===2&&p||n.includes(r);return d._open=!!(o===42?u:u&&(s||!f)),d._close=!!(o===42?f:f&&(p||!u)),t(c)}}function Tj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const s8={name:"autolink",tokenize:i8};function i8(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"),o}function o(m){return Do(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||ai(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||ai(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||av(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),p):U6(m)?(e.consume(m),d):n(m)}function p(m){return ai(m)?u(m):n(m)}function u(m){return m===46?(e.consume(m),r=0,p):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):f(m)}function f(m){if((m===45||ai(m))&&r++<63){const g=m===45?f:u;return e.consume(m),g}return n(m)}}const Hy={partial:!0,tokenize:o8};function o8(e,t,n){return r;function r(o){return fn(o)?Fn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Et(o)?t(o):n(o)}}const lT={continuation:{tokenize:l8},exit:c8,name:"blockQuote",tokenize:a8};function a8(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return fn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function l8(e,t,n){const r=this;return s;function s(a){return fn(a)?Fn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(lT,t,n)(a)}}function c8(e){e.exit("blockQuote")}const cT={name:"characterEscape",tokenize:u8};function u8(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return Y6(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const uT={name:"characterReference",tokenize:d8};function d8(e,t,n){const r=this;let s=0,o,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"),o=31,a=ai,p(u))}function d(u){return u===88||u===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(u),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=q6,p):(e.enter("characterReferenceValue"),o=7,a=lv,p(u))}function p(u){if(u===59&&s){const f=e.exit("characterReferenceValue");return a===ai&&!ak(r.sliceSerialize(f))?n(u):(e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(u)&&s++<o?(e.consume(u),p):n(u)}}const Rj={partial:!0,tokenize:p8},Mj={concrete:!0,name:"codeFenced",tokenize:f8};function f8(e,t,n){const r=this,s={partial:!0,tokenize:E};let o=0,a=0,l;return c;function c(N){return d(N)}function d(N){const T=r.events[r.events.length-1];return o=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(N)}function p(N){return N===l?(a++,e.consume(N),p):a<3?n(N):(e.exit("codeFencedFenceSequence"),fn(N)?Fn(e,u,"whitespace")(N):u(N))}function u(N){return N===null||Et(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(Rj,w,j)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(N))}function f(N){return N===null||Et(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(N)):fn(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Fn(e,m,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),f)}function m(N){return N===null||Et(N)?u(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||Et(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),u(N)):N===96&&N===l?n(N):(e.consume(N),g)}function w(N){return e.attempt(s,j,k)(N)}function k(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y}function y(N){return o>0&&fn(N)?Fn(e,b,"linePrefix",o+1)(N):b(N)}function b(N){return N===null||Et(N)?e.check(Rj,w,j)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||Et(N)?(e.exit("codeFlowValue"),b(N)):(e.consume(N),x)}function j(N){return e.exit("codeFenced"),t(N)}function E(N,T,$){let z=0;return K;function K(M){return N.enter("lineEnding"),N.consume(M),N.exit("lineEnding"),B}function B(M){return N.enter("codeFencedFence"),fn(M)?Fn(N,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):L(M)}function L(M){return M===l?(N.enter("codeFencedFenceSequence"),D(M)):$(M)}function D(M){return M===l?(z++,N.consume(M),D):z>=a?(N.exit("codeFencedFenceSequence"),fn(M)?Fn(N,R,"whitespace")(M):R(M)):$(M)}function R(M){return M===null||Et(M)?(N.exit("codeFencedFence"),T(M)):$(M)}}}function p8(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const sw={name:"codeIndented",tokenize:m8},h8={partial:!0,tokenize:g8};function m8(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),Fn(e,o,"linePrefix",5)(d)}function o(d){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):Et(d)?e.attempt(h8,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||Et(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function g8(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):Et(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Fn(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):Et(a)?s(a):n(a)}}const y8={name:"codeText",previous:w8,resolve:x8,tokenize:b8};function x8(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 w8(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function b8(e,t,n){let r=0,s,o;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?(o=e.enter("codeTextSequence"),s=0,p(u)):Et(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||Et(u)?(e.exit("codeTextData"),c(u)):(e.consume(u),d)}function p(u){return u===96?(e.consume(u),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(u)):(o.type="codeTextData",d(u))}}class v8{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&vf(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),vf(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vf(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);vf(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vf(this.left,n.reverse())}}}function vf(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 dT(e){const t={};let n=-1,r,s,o,a,l,c,d;const p=new v8(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,k8(p,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=p.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...p.get(s)[1].start},l=p.slice(s,n),l.unshift(r),p.splice(s,n-s+1,l))}}return qo(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!d}function k8(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let p,u,f=-1,m=n,g=0,w=0;const k=[w];for(;m;){for(;e.get(++s)[1]!==m;);o.push(s),m._tokenizer||(p=r.sliceStream(m),m.next||p.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=n;++f<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(w=f+1,k.push(w),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):k.pop(),f=k.length;f--;){const y=l.slice(k[f],k[f+1]),b=o.pop();c.push([b,b+y.length-1]),e.splice(b,2,y)}for(c.reverse(),f=-1;++f<c.length;)d[g+c[f][0]]=g+c[f][1],g+=c[f][1]-c[f][0]-1;return d}const S8={resolve:j8,tokenize:C8},N8={partial:!0,tokenize:E8};function j8(e){return dT(e),e}function C8(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?o(l):Et(l)?e.check(N8,a,o)(l):(e.consume(l),s)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function E8(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Fn(e,o,"linePrefix")}function o(a){if(a===null||Et(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 fT(e,t,n,r,s,o,a,l,c){const d=c||Number.POSITIVE_INFINITY;let p=0;return u;function u(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),f):y===null||y===32||y===41||av(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),w(y))}function f(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(l),f(y)):y===null||y===60||Et(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 w(y){return!p&&(y===null||y===41||Gs(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):p<d&&y===40?(e.consume(y),p++,w):y===41?(e.consume(y),p--,w):y===null||y===32||y===40||av(y)?n(y):(e.consume(y),y===92?k:w)}function k(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function pT(e,t,n,r,s,o){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(o),p}function p(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(o),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):Et(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||Et(m)||l++>999?(e.exit("chunkString"),p(m)):(e.consume(m),c||(c=!fn(m)),m===92?f:u)}function f(m){return m===91||m===92||m===93?(e.consume(m),l++,u):u(m)}}function hT(e,t,n,r,s,o){let a;return l;function l(f){return f===34||f===39||f===40?(e.enter(r),e.enter(s),e.consume(f),e.exit(s),a=f===40?41:f,c):n(f)}function c(f){return f===a?(e.enter(s),e.consume(f),e.exit(s),e.exit(r),t):(e.enter(o),d(f))}function d(f){return f===a?(e.exit(o),c(a)):f===null?n(f):Et(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Fn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(f))}function p(f){return f===a||f===null||Et(f)?(e.exit("chunkString"),d(f)):(e.consume(f),f===92?u:p)}function u(f){return f===a||f===92?(e.consume(f),p):p(f)}}function Zf(e,t){let n;return r;function r(s){return Et(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):fn(s)?Fn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const _8={name:"definition",tokenize:P8},A8={partial:!0,tokenize:I8};function P8(e,t,n){const r=this;let s;return o;function o(m){return e.enter("definition"),a(m)}function a(m){return pT.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=id(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 Gs(m)?Zf(e,d)(m):d(m)}function d(m){return fT(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function p(m){return e.attempt(A8,u,u)(m)}function u(m){return fn(m)?Fn(e,f,"whitespace")(m):f(m)}function f(m){return m===null||Et(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function I8(e,t,n){return r;function r(l){return Gs(l)?Zf(e,s)(l):n(l)}function s(l){return hT(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return fn(l)?Fn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||Et(l)?t(l):n(l)}}const T8={name:"hardBreakEscape",tokenize:R8};function R8(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Et(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const M8={name:"headingAtx",resolve:L8,tokenize:O8};function L8(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},qo(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function O8(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||Gs(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),c(p)):p===null||Et(p)?(e.exit("atxHeading"),t(p)):fn(p)?Fn(e,l,"whitespace")(p):(e.enter("atxHeadingText"),d(p))}function c(p){return p===35?(e.consume(p),c):(e.exit("atxHeadingSequence"),l(p))}function d(p){return p===null||p===35||Gs(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),d)}}const $8=["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"],Lj=["pre","script","style","textarea"],D8={concrete:!0,name:"htmlFlow",resolveTo:H8,tokenize:B8},F8={partial:!0,tokenize:V8},z8={partial:!0,tokenize:W8};function H8(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 B8(e,t,n){const r=this;let s,o,a,l,c;return d;function d(V){return p(V)}function p(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),u}function u(V){return V===33?(e.consume(V),f):V===47?(e.consume(V),o=!0,w):V===63?(e.consume(V),s=3,r.interrupt?t:_):Do(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function f(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,g):Do(V)?(e.consume(V),s=4,r.interrupt?t:_):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:_):n(V)}function g(V){const ae="CDATA[";return V===ae.charCodeAt(l++)?(e.consume(V),l===ae.length?r.interrupt?t:L:g):n(V)}function w(V){return Do(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function k(V){if(V===null||V===47||V===62||Gs(V)){const ae=V===47,fe=a.toLowerCase();return!ae&&!o&&Lj.includes(fe)?(s=1,r.interrupt?t(V):L(V)):$8.includes(a.toLowerCase())?(s=6,ae?(e.consume(V),y):r.interrupt?t(V):L(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):o?b(V):x(V))}return V===45||ai(V)?(e.consume(V),a+=String.fromCharCode(V),k):n(V)}function y(V){return V===62?(e.consume(V),r.interrupt?t:L):n(V)}function b(V){return fn(V)?(e.consume(V),b):K(V)}function x(V){return V===47?(e.consume(V),K):V===58||V===95||Do(V)?(e.consume(V),j):fn(V)?(e.consume(V),x):K(V)}function j(V){return V===45||V===46||V===58||V===95||ai(V)?(e.consume(V),j):E(V)}function E(V){return V===61?(e.consume(V),N):fn(V)?(e.consume(V),E):x(V)}function N(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),c=V,T):fn(V)?(e.consume(V),N):$(V)}function T(V){return V===c?(e.consume(V),c=null,z):V===null||Et(V)?n(V):(e.consume(V),T)}function $(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||Gs(V)?E(V):(e.consume(V),$)}function z(V){return V===47||V===62||fn(V)?x(V):n(V)}function K(V){return V===62?(e.consume(V),B):n(V)}function B(V){return V===null||Et(V)?L(V):fn(V)?(e.consume(V),B):n(V)}function L(V){return V===45&&s===2?(e.consume(V),I):V===60&&s===1?(e.consume(V),F):V===62&&s===4?(e.consume(V),Z):V===63&&s===3?(e.consume(V),_):V===93&&s===5?(e.consume(V),O):Et(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(F8,ee,D)(V)):V===null||Et(V)?(e.exit("htmlFlowData"),D(V)):(e.consume(V),L)}function D(V){return e.check(z8,R,ee)(V)}function R(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),M}function M(V){return V===null||Et(V)?D(V):(e.enter("htmlFlowData"),L(V))}function I(V){return V===45?(e.consume(V),_):L(V)}function F(V){return V===47?(e.consume(V),a="",P):L(V)}function P(V){if(V===62){const ae=a.toLowerCase();return Lj.includes(ae)?(e.consume(V),Z):L(V)}return Do(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),P):L(V)}function O(V){return V===93?(e.consume(V),_):L(V)}function _(V){return V===62?(e.consume(V),Z):V===45&&s===2?(e.consume(V),_):L(V)}function Z(V){return V===null||Et(V)?(e.exit("htmlFlowData"),ee(V)):(e.consume(V),Z)}function ee(V){return e.exit("htmlFlow"),t(V)}}function W8(e,t,n){const r=this;return s;function s(a){return Et(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function V8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Hy,t,n)}}const K8={name:"htmlText",tokenize:U8};function U8(e,t,n){const r=this;let s,o,a;return l;function l(_){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(_),c}function c(_){return _===33?(e.consume(_),d):_===47?(e.consume(_),E):_===63?(e.consume(_),x):Do(_)?(e.consume(_),$):n(_)}function d(_){return _===45?(e.consume(_),p):_===91?(e.consume(_),o=0,g):Do(_)?(e.consume(_),b):n(_)}function p(_){return _===45?(e.consume(_),m):n(_)}function u(_){return _===null?n(_):_===45?(e.consume(_),f):Et(_)?(a=u,F(_)):(e.consume(_),u)}function f(_){return _===45?(e.consume(_),m):u(_)}function m(_){return _===62?I(_):_===45?f(_):u(_)}function g(_){const Z="CDATA[";return _===Z.charCodeAt(o++)?(e.consume(_),o===Z.length?w:g):n(_)}function w(_){return _===null?n(_):_===93?(e.consume(_),k):Et(_)?(a=w,F(_)):(e.consume(_),w)}function k(_){return _===93?(e.consume(_),y):w(_)}function y(_){return _===62?I(_):_===93?(e.consume(_),y):w(_)}function b(_){return _===null||_===62?I(_):Et(_)?(a=b,F(_)):(e.consume(_),b)}function x(_){return _===null?n(_):_===63?(e.consume(_),j):Et(_)?(a=x,F(_)):(e.consume(_),x)}function j(_){return _===62?I(_):x(_)}function E(_){return Do(_)?(e.consume(_),N):n(_)}function N(_){return _===45||ai(_)?(e.consume(_),N):T(_)}function T(_){return Et(_)?(a=T,F(_)):fn(_)?(e.consume(_),T):I(_)}function $(_){return _===45||ai(_)?(e.consume(_),$):_===47||_===62||Gs(_)?z(_):n(_)}function z(_){return _===47?(e.consume(_),I):_===58||_===95||Do(_)?(e.consume(_),K):Et(_)?(a=z,F(_)):fn(_)?(e.consume(_),z):I(_)}function K(_){return _===45||_===46||_===58||_===95||ai(_)?(e.consume(_),K):B(_)}function B(_){return _===61?(e.consume(_),L):Et(_)?(a=B,F(_)):fn(_)?(e.consume(_),B):z(_)}function L(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),s=_,D):Et(_)?(a=L,F(_)):fn(_)?(e.consume(_),L):(e.consume(_),R)}function D(_){return _===s?(e.consume(_),s=void 0,M):_===null?n(_):Et(_)?(a=D,F(_)):(e.consume(_),D)}function R(_){return _===null||_===34||_===39||_===60||_===61||_===96?n(_):_===47||_===62||Gs(_)?z(_):(e.consume(_),R)}function M(_){return _===47||_===62||Gs(_)?z(_):n(_)}function I(_){return _===62?(e.consume(_),e.exit("htmlTextData"),e.exit("htmlText"),t):n(_)}function F(_){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),P}function P(_){return fn(_)?Fn(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):O(_)}function O(_){return e.enter("htmlTextData"),a(_)}}const ck={name:"labelEnd",resolveAll:X8,resolveTo:J8,tokenize:Q8},q8={tokenize:Z8},Y8={tokenize:eW},G8={tokenize:tW};function X8(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&&qo(e,0,e.length,n),e}function J8(e,t){let n=e.length,r=0,s,o,a,l;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=ji(l,e.slice(o+1,o+r+3)),l=ji(l,[["enter",p,t]]),l=ji(l,lk(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=ji(l,[["exit",p,t],e[a-2],e[a-1],["exit",d,t]]),l=ji(l,e.slice(a+1)),l=ji(l,[["exit",c,t]]),qo(e,o,e.length,l),e}function Q8(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return l;function l(f){return o?o._inactive?u(f):(a=r.parser.defined.includes(id(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),c):n(f)}function c(f){return f===40?e.attempt(q8,p,a?p:u)(f):f===91?e.attempt(Y8,p,a?d:u)(f):a?p(f):u(f)}function d(f){return e.attempt(G8,p,u)(f)}function p(f){return t(f)}function u(f){return o._balanced=!0,n(f)}}function Z8(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 Gs(u)?Zf(e,o)(u):o(u)}function o(u){return u===41?p(u):fT(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return Gs(u)?Zf(e,c)(u):p(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?hT(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):p(u)}function d(u){return Gs(u)?Zf(e,p)(u):p(u)}function p(u){return u===41?(e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),e.exit("resource"),t):n(u)}}function eW(e,t,n){const r=this;return s;function s(l){return pT.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(id(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function tW(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const nW={name:"labelStartImage",resolveAll:ck.resolveAll,tokenize:rW};function rW(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const sW={name:"labelStartLink",resolveAll:ck.resolveAll,tokenize:iW};function iW(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const iw={name:"lineEnding",tokenize:oW};function oW(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Fn(e,t,"linePrefix")}}const Gm={name:"thematicBreak",tokenize:aW};function aW(e,t,n){let r=0,s;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||Et(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),fn(d)?Fn(e,l,"whitespace")(d):l(d))}}const Fs={continuation:{tokenize:dW},exit:pW,name:"list",tokenize:uW},lW={partial:!0,tokenize:hW},cW={partial:!0,tokenize:fW};function uW(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:lv(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(Gm,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 lv(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(Hy,r.interrupt?n:p,e.attempt(lW,f,u))}function p(m){return r.containerState.initialBlankLine=!0,o++,f(m)}function u(m){return fn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),f):n(m)}function f(m){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function dW(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Hy,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Fn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!fn(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(cW,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Fn(e,e.attempt(Fs,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function fW(e,t,n){const r=this;return Fn(e,s,"listItemIndent",r.containerState.size+1);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function pW(e){e.exit(this.containerState.type)}function hW(e,t,n){const r=this;return Fn(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=r.events[r.events.length-1];return!fn(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Oj={name:"setextUnderline",resolveTo:mW,tokenize:gW};function mW(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function gW(e,t,n){const r=this;let s;return o;function o(d){let p=r.events.length,u;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){u=r.events[p][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"),fn(d)?Fn(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||Et(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const yW={tokenize:xW};function xW(e){const t=this,n=e.attempt(Hy,r,e.attempt(this.parser.constructs.flowInitial,s,Fn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(S8,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const wW={resolveAll:gT()},bW=mT("string"),vW=mT("text");function mT(e){return{resolveAll:gT(e==="text"?kW:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,l);return a;function a(p){return d(p)?o(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),c}function c(p){return d(p)?(n.exit("data"),o(p)):(n.consume(p),c)}function d(p){if(p===null)return!0;const u=s[p];let f=-1;if(u)for(;++f<u.length;){const m=u[f];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function gT(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function kW(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,a=-1,l=0,c;for(;o--;){const d=s[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const SW={42:Fs,43:Fs,45:Fs,48:Fs,49:Fs,50:Fs,51:Fs,52:Fs,53:Fs,54:Fs,55:Fs,56:Fs,57:Fs,62:lT},NW={91:_8},jW={[-2]:sw,[-1]:sw,32:sw},CW={35:M8,42:Gm,45:[Oj,Gm],60:D8,61:Oj,95:Gm,96:Mj,126:Mj},EW={38:uT,92:cT},_W={[-5]:iw,[-4]:iw,[-3]:iw,33:nW,38:uT,42:cv,60:[s8,K8],91:sW,92:[T8,cT],93:ck,95:cv,96:y8},AW={null:[cv,wW]},PW={null:[42,95]},IW={null:[]},TW=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:PW,contentInitial:NW,disable:IW,document:SW,flow:CW,flowInitial:jW,insideSpan:AW,string:EW,text:_W},Symbol.toStringTag,{value:"Module"}));function RW(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let a=[],l=[];const c={attempt:T(E),check:T(N),consume:b,enter:x,exit:j,interrupt:T(N,{interrupt:!0})},d={code:null,containerState:{},defineSkip:w,events:[],now:g,parser:e,previous:null,sliceSerialize:f,sliceStream:m,write:u};let p=t.tokenize.call(d,c);return t.resolveAll&&o.push(t),d;function u(B){return a=ji(a,B),k(),a[a.length-1]!==null?[]:($(t,0),d.events=lk(o,d.events,d),d.events)}function f(B,L){return LW(m(B),L)}function m(B){return MW(a,B)}function g(){const{_bufferIndex:B,_index:L,line:D,column:R,offset:M}=r;return{_bufferIndex:B,_index:L,line:D,column:R,offset:M}}function w(B){s[B.line]=B.column,K()}function k(){let B;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<L.length;)y(L.charCodeAt(r._bufferIndex));else y(L)}}function y(B){p=p(B)}function b(B){Et(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,K()):B!==-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=B}function x(B,L){const D=L||{};return D.type=B,D.start=g(),d.events.push(["enter",D,d]),l.push(D),D}function j(B){const L=l.pop();return L.end=g(),d.events.push(["exit",L,d]),L}function E(B,L){$(B,L.from)}function N(B,L){L.restore()}function T(B,L){return D;function D(R,M,I){let F,P,O,_;return Array.isArray(R)?ee(R):"tokenize"in R?ee([R]):Z(R);function Z(xe){return Se;function Se(ue){const Ee=ue!==null&&xe[ue],le=ue!==null&&xe.null,me=[...Array.isArray(Ee)?Ee:Ee?[Ee]:[],...Array.isArray(le)?le:le?[le]:[]];return ee(me)(ue)}}function ee(xe){return F=xe,P=0,xe.length===0?I:V(xe[P])}function V(xe){return Se;function Se(ue){return _=z(),O=xe,xe.partial||(d.currentConstruct=xe),xe.name&&d.parser.constructs.disable.null.includes(xe.name)?fe():xe.tokenize.call(L?Object.assign(Object.create(d),L):d,c,ae,fe)(ue)}}function ae(xe){return B(O,_),M}function fe(xe){return _.restore(),++P<F.length?V(F[P]):I}}}function $(B,L){B.resolveAll&&!o.includes(B)&&o.push(B),B.resolve&&qo(d.events,L,d.events.length-L,B.resolve(d.events.slice(L),d)),B.resolveTo&&(d.events=B.resolveTo(d.events,d))}function z(){const B=g(),L=d.previous,D=d.currentConstruct,R=d.events.length,M=Array.from(l);return{from:R,restore:I};function I(){r=B,d.previous=L,d.currentConstruct=D,d.events.length=R,l=M,K()}}function K(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function MW(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,o)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function LW(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
68
- `;break}case-3:{a=`\r
69
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(o)}s=o===-2,r.push(a)}return r.join("")}function OW(e){const r={constructs:W6([TW,...(e||{}).extensions||[]]),content:s(J6),defined:[],document:s(Z6),flow:s(yW),lazy:{},string:s(bW),text:s(vW)};return r;function s(o){return a;function a(l){return RW(r,o,l)}}}function $W(e){for(;!dT(e););return e}const $j=/[\0\t\n\r]/g;function DW(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let d,p,u,f,m;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),u=0,t="",n&&(o.charCodeAt(0)===65279&&u++,n=void 0);u<o.length;){if($j.lastIndex=u,d=$j.exec(o),f=d&&d.index!==void 0?d.index:o.length,m=o.charCodeAt(f),!d){t=o.slice(u);break}if(m===10&&u===f&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),u<f&&(c.push(o.slice(u,f)),e+=f-u),m){case 0:{c.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,c.push(-2);e++<p;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}u=f+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const FW=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function zW(e){return e.replace(FW,HW)}function HW(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return aT(n.slice(o?2:1),o?16:10)}return ak(n)||e}const yT={}.hasOwnProperty;function BW(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),WW(n)($W(OW(n).document().write(DW()(e,t,!0))))}function WW(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ue),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(tt),blockQuote:o(le),characterEscape:z,characterReference:z,codeFenced:o(me),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(me,a),codeText:o(we,a),codeTextData:z,data:z,codeFlowValue:z,definition:o(je),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Ye),hardBreakEscape:o(ze),hardBreakTrailing:o(ze),htmlFlow:o(dt,a),htmlFlowData:z,htmlText:o(dt,a),htmlTextData:z,image:o(Ft),label:a,link:o(Ue),listItem:o(_n),listItemValue:f,listOrdered:o(pt,u),listUnordered:o(pt),paragraph:o(We),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(tt),strong:o(sn),thematicBreak:o(kn)},exit:{atxHeading:c(),atxHeadingSequence:E,autolink:c(),autolinkEmail:Ee,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:K,characterReferenceMarkerHexadecimal:fe,characterReferenceMarkerNumeric:fe,characterReferenceValue:xe,characterReference:Se,codeFenced:c(k),codeFencedFence:w,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:K,codeIndented:c(y),codeText:c(M),codeTextData:K,data:K,definition:c(),definitionDestinationString:j,definitionLabelString:b,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(D),htmlFlowData:K,htmlText:c(R),htmlTextData:K,image:c(F),label:O,labelText:P,lineEnding:B,link:c(I),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ae,resourceDestinationString:_,resourceTitleString:Z,resource:ee,setextHeading:c($),setextHeadingLineSequence:T,setextHeadingText:N,strong:c(),thematicBreak:c()}};xT(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(pe){let _e={type:"root",children:[]};const Ve={stack:[_e],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:p,data:n},rt=[];let it=-1;for(;++it<pe.length;)if(pe[it][1].type==="listOrdered"||pe[it][1].type==="listUnordered")if(pe[it][0]==="enter")rt.push(it);else{const Mt=rt.pop();it=s(pe,Mt,it)}for(it=-1;++it<pe.length;){const Mt=t[pe[it][0]];yT.call(Mt,pe[it][1].type)&&Mt[pe[it][1].type].call(Object.assign({sliceSerialize:pe[it][2].sliceSerialize},Ve),pe[it][1])}if(Ve.tokenStack.length>0){const Mt=Ve.tokenStack[Ve.tokenStack.length-1];(Mt[1]||Dj).call(Ve,void 0,Mt[0])}for(_e.position={start:il(pe.length>0?pe[0][1].start:{line:1,column:1,offset:0}),end:il(pe.length>0?pe[pe.length-2][1].end:{line:1,column:1,offset:0})},it=-1;++it<t.transforms.length;)_e=t.transforms[it](_e)||_e;return _e}function s(pe,_e,Ve){let rt=_e-1,it=-1,Mt=!1,wt,gn,cn,Jn;for(;++rt<=Ve;){const on=pe[rt];switch(on[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{on[0]==="enter"?it++:it--,Jn=void 0;break}case"lineEndingBlank":{on[0]==="enter"&&(wt&&!Jn&&!it&&!cn&&(cn=rt),Jn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Jn=void 0}if(!it&&on[0]==="enter"&&on[1].type==="listItemPrefix"||it===-1&&on[0]==="exit"&&(on[1].type==="listUnordered"||on[1].type==="listOrdered")){if(wt){let An=rt;for(gn=void 0;An--;){const Pn=pe[An];if(Pn[1].type==="lineEnding"||Pn[1].type==="lineEndingBlank"){if(Pn[0]==="exit")continue;gn&&(pe[gn][1].type="lineEndingBlank",Mt=!0),Pn[1].type="lineEnding",gn=An}else if(!(Pn[1].type==="linePrefix"||Pn[1].type==="blockQuotePrefix"||Pn[1].type==="blockQuotePrefixWhitespace"||Pn[1].type==="blockQuoteMarker"||Pn[1].type==="listItemIndent"))break}cn&&(!gn||cn<gn)&&(wt._spread=!0),wt.end=Object.assign({},gn?pe[gn][1].start:on[1].end),pe.splice(gn||rt,0,["exit",wt,on[2]]),rt++,Ve++}if(on[1].type==="listItemPrefix"){const An={type:"listItem",_spread:!1,start:Object.assign({},on[1].start),end:void 0};wt=An,pe.splice(rt,0,["enter",An,on[2]]),rt++,Ve++,cn=void 0,Jn=!0}}}return pe[_e][1]._spread=Mt,Ve}function o(pe,_e){return Ve;function Ve(rt){l.call(this,pe(rt),rt),_e&&_e.call(this,rt)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(pe,_e,Ve){this.stack[this.stack.length-1].children.push(pe),this.stack.push(pe),this.tokenStack.push([_e,Ve||void 0]),pe.position={start:il(_e.start),end:void 0}}function c(pe){return _e;function _e(Ve){pe&&pe.call(this,Ve),d.call(this,Ve)}}function d(pe,_e){const Ve=this.stack.pop(),rt=this.tokenStack.pop();if(rt)rt[0].type!==pe.type&&(_e?_e.call(this,pe,rt[0]):(rt[1]||Dj).call(this,pe,rt[0]));else throw new Error("Cannot close `"+pe.type+"` ("+Qf({start:pe.start,end:pe.end})+"): it’s not open");Ve.position.end=il(pe.end)}function p(){return H6(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function f(pe){if(this.data.expectingFirstListItemValue){const _e=this.stack[this.stack.length-2];_e.start=Number.parseInt(this.sliceSerialize(pe),10),this.data.expectingFirstListItemValue=void 0}}function m(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.lang=pe}function g(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.meta=pe}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.value=pe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.value=pe.replace(/(\r?\n|\r)$/g,"")}function b(pe){const _e=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=_e,Ve.identifier=id(this.sliceSerialize(pe)).toLowerCase()}function x(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.title=pe}function j(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.url=pe}function E(pe){const _e=this.stack[this.stack.length-1];if(!_e.depth){const Ve=this.sliceSerialize(pe).length;_e.depth=Ve}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function T(pe){const _e=this.stack[this.stack.length-1];_e.depth=this.sliceSerialize(pe).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function z(pe){const Ve=this.stack[this.stack.length-1].children;let rt=Ve[Ve.length-1];(!rt||rt.type!=="text")&&(rt=xt(),rt.position={start:il(pe.start),end:void 0},Ve.push(rt)),this.stack.push(rt)}function K(pe){const _e=this.stack.pop();_e.value+=this.sliceSerialize(pe),_e.position.end=il(pe.end)}function B(pe){const _e=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ve=_e.children[_e.children.length-1];Ve.position.end=il(pe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(_e.type)&&(z.call(this,pe),K.call(this,pe))}function L(){this.data.atHardBreak=!0}function D(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.value=pe}function R(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.value=pe}function M(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.value=pe}function I(){const pe=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";pe.type+="Reference",pe.referenceType=_e,delete pe.url,delete pe.title}else delete pe.identifier,delete pe.label;this.data.referenceType=void 0}function F(){const pe=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";pe.type+="Reference",pe.referenceType=_e,delete pe.url,delete pe.title}else delete pe.identifier,delete pe.label;this.data.referenceType=void 0}function P(pe){const _e=this.sliceSerialize(pe),Ve=this.stack[this.stack.length-2];Ve.label=zW(_e),Ve.identifier=id(_e).toLowerCase()}function O(){const pe=this.stack[this.stack.length-1],_e=this.resume(),Ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ve.type==="link"){const rt=pe.children;Ve.children=rt}else Ve.alt=_e}function _(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.url=pe}function Z(){const pe=this.resume(),_e=this.stack[this.stack.length-1];_e.title=pe}function ee(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function ae(pe){const _e=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=_e,Ve.identifier=id(this.sliceSerialize(pe)).toLowerCase(),this.data.referenceType="full"}function fe(pe){this.data.characterReferenceType=pe.type}function xe(pe){const _e=this.sliceSerialize(pe),Ve=this.data.characterReferenceType;let rt;Ve?(rt=aT(_e,Ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):rt=ak(_e);const it=this.stack[this.stack.length-1];it.value+=rt}function Se(pe){const _e=this.stack.pop();_e.position.end=il(pe.end)}function ue(pe){K.call(this,pe);const _e=this.stack[this.stack.length-1];_e.url=this.sliceSerialize(pe)}function Ee(pe){K.call(this,pe);const _e=this.stack[this.stack.length-1];_e.url="mailto:"+this.sliceSerialize(pe)}function le(){return{type:"blockquote",children:[]}}function me(){return{type:"code",lang:null,meta:null,value:""}}function we(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ye(){return{type:"emphasis",children:[]}}function tt(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function dt(){return{type:"html",value:""}}function Ft(){return{type:"image",title:null,url:"",alt:null}}function Ue(){return{type:"link",title:null,url:"",children:[]}}function pt(pe){return{type:"list",ordered:pe.type==="listOrdered",start:null,spread:pe._spread,children:[]}}function _n(pe){return{type:"listItem",spread:pe._spread,checked:null,children:[]}}function We(){return{type:"paragraph",children:[]}}function sn(){return{type:"strong",children:[]}}function xt(){return{type:"text",value:""}}function kn(){return{type:"thematicBreak"}}}function il(e){return{line:e.line,column:e.column,offset:e.offset}}function xT(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?xT(e,r):VW(e,r)}}function VW(e,t){let n;for(n in t)if(yT.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 Dj(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Qf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Qf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Qf({start:t.start,end:t.end})+") is still open")}function KW(e){const t=this;t.parser=n;function n(r){return BW(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function UW(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 qW(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function YW(e,t){const n=t.value?t.value+`
71
- `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function GW(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XW(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JW(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Md(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const 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 QW(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 ZW(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function wT(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function e9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return wT(e,t);const s={src:Md(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function t9(e,t){const n={src:Md(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function n9(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 r9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return wT(e,t);const s={href:Md(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function s9(e,t){const n={href:Md(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function i9(e,t,n){const r=e.all(t),s=n?o9(n):bT(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let u;p&&p.type==="element"&&p.tagName==="p"?u=p:(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:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const p=r[l];(s||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),p.type==="element"&&p.tagName==="p"&&!s?a.push(...p.children):a.push(p)}const 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:o,children:a};return e.patch(t,d),e.applyData(t,d)}function o9(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=bT(n[r])}return t}function bT(e){const t=e.spread;return t??e.children.length>1}function a9(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function l9(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function c9(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function u9(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function d9(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=rk(t.children[1]),c=eT(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function f9(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const d=[];for(;++c<l;){const u=t.children[c],f={},m=a?a[c]:void 0;m&&(f.align=m);let g={type:"element",tagName:o,properties:f,children:[]};u&&(g.children=e.all(u),e.patch(u,g),g=e.applyData(u,g)),d.push(g)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,p),e.applyData(t,p)}function p9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Fj=9,zj=32;function h9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(Hj(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(Hj(t.slice(s),s>0,!1)),o.join("")}function Hj(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===Fj||o===zj;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===Fj||o===zj;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function m9(e,t){const n={type:"text",value:h9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function g9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const y9={blockquote:UW,break:qW,code:YW,delete:GW,emphasis:XW,footnoteReference:JW,heading:QW,html:ZW,imageReference:e9,image:t9,inlineCode:n9,linkReference:r9,link:s9,listItem:i9,list:a9,paragraph:l9,root:c9,strong:u9,table:d9,tableCell:p9,tableRow:f9,text:m9,thematicBreak:g9,toml:dm,yaml:dm,definition:dm,footnoteDefinition:dm};function dm(){}const vT=-1,By=0,ep=1,Dg=2,uk=3,dk=4,fk=5,pk=6,kT=7,ST=8,Bj=typeof self=="object"?self:globalThis,x9=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,a]=t[s];switch(o){case By:case vT:return n(a,s);case ep:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Dg:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case uk:return n(new Date(a),s);case dk:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case fk:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case pk:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case kT:{const{name:l,message:c}=a;return n(new Bj[l](c),s)}case ST: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 Bj[o](a),s)};return r},Wj=e=>x9(new Map,e)(0),vu="",{toString:w9}={},{keys:b9}=Object,kf=e=>{const t=typeof e;if(t!=="object"||!e)return[By,t];const n=w9.call(e).slice(8,-1);switch(n){case"Array":return[ep,vu];case"Object":return[Dg,vu];case"Date":return[uk,vu];case"RegExp":return[dk,vu];case"Map":return[fk,vu];case"Set":return[pk,vu];case"DataView":return[ep,n]}return n.includes("Array")?[ep,n]:n.includes("Error")?[kT,n]:[Dg,n]},fm=([e,t])=>e===By&&(t==="function"||t==="symbol"),v9=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=kf(a);switch(l){case By:{let p=a;switch(c){case"bigint":l=ST,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);p=null;break;case"undefined":return s([vT],a)}return s([l,p],a)}case ep:{if(c){let f=a;return c==="DataView"?f=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(f=new Uint8Array(a)),s([c,[...f]],a)}const p=[],u=s([l,p],a);for(const f of a)p.push(o(f));return u}case Dg:{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 o(a.toJSON());const p=[],u=s([l,p],a);for(const f of b9(a))(e||!fm(kf(a[f])))&&p.push([o(f),o(a[f])]);return u}case uk:return s([l,a.toISOString()],a);case dk:{const{source:p,flags:u}=a;return s([l,{source:p,flags:u}],a)}case fk:{const p=[],u=s([l,p],a);for(const[f,m]of a)(e||!(fm(kf(f))||fm(kf(m))))&&p.push([o(f),o(m)]);return u}case pk:{const p=[],u=s([l,p],a);for(const f of a)(e||!fm(kf(f)))&&p.push(o(f));return u}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return o},Vj=(e,{json:t,lossy:n}={})=>{const r=[];return v9(!(t||n),!!t,new Map,r)(e),r},Fg=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Wj(Vj(e,t)):structuredClone(e):(e,t)=>Wj(Vj(e,t));function k9(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 S9(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function N9(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||k9,r=e.options.footnoteBackLabel||S9,s=e.options.footnoteLabel||"Footnotes",o=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 p=e.all(d),u=String(d.identifier).toUpperCase(),f=Md(u.toLowerCase());let m=0;const g=[],w=e.footnoteCounts.get(u);for(;w!==void 0&&++m<=w;){g.length>0&&g.push({type:"text",value:" "});let b=typeof n=="string"?n:n(c,m);typeof b=="string"&&(b={type:"text",value:b}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const k=p[p.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const b=k.children[k.children.length-1];b&&b.type==="text"?b.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else p.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(p,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Fg(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 NT=function(e){if(e==null)return _9;if(typeof e=="function")return Wy(e);if(typeof e=="object")return Array.isArray(e)?j9(e):C9(e);if(typeof e=="string")return E9(e);throw new Error("Expected function, string, or object as test")};function j9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=NT(e[n]);return Wy(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function C9(e){const t=e;return Wy(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function E9(e){return Wy(t);function t(n){return n&&n.type===e}}function Wy(e){return t;function t(n,r,s){return!!(A9(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function _9(){return!0}function A9(e){return e!==null&&typeof e=="object"&&"type"in e}const jT=[],P9=!0,Kj=!1,I9="skip";function T9(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=NT(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,p){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(f,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return f;function f(){let m=jT,g,w,k;if((!t||o(c,d,p[p.length-1]||void 0))&&(m=R9(n(c,p)),m[0]===Kj))return m;if("children"in c&&c.children){const y=c;if(y.children&&m[0]!==I9)for(w=(r?y.children.length:-1)+a,k=p.concat(y);w>-1&&w<y.children.length;){const b=y.children[w];if(g=l(b,w,k)(),g[0]===Kj)return g;w=typeof g[1]=="number"?g[1]:w+a}}return m}}}function R9(e){return Array.isArray(e)?e:typeof e=="number"?[P9,e]:e==null?jT:[e]}function CT(e,t,n,r){let s,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,s=n):(o=t,a=n,s=r),T9(e,o,l,s);function l(c,d){const p=d[d.length-1],u=p?p.children.indexOf(c):void 0;return a(c,u,p)}}const uv={}.hasOwnProperty,M9={};function L9(e,t){const n=t||M9,r=new Map,s=new Map,o=new Map,a={...y9,...n.handlers},l={all:d,applyData:$9,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:O9,wrap:F9};return CT(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const u=p.type==="definition"?r:s,f=String(p.identifier).toUpperCase();u.has(f)||u.set(f,p)}}),l;function c(p,u){const f=p.type,m=l.handlers[f];if(uv.call(l.handlers,f)&&m)return m(l,p,u);if(l.options.passThrough&&l.options.passThrough.includes(f)){if("children"in p){const{children:w,...k}=p,y=Fg(k);return y.children=l.all(p),y}return Fg(p)}return(l.options.unknownHandler||D9)(l,p,u)}function d(p){const u=[];if("children"in p){const f=p.children;let m=-1;for(;++m<f.length;){const g=l.one(f[m],p);if(g){if(m&&f[m-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Uj(g.value)),!Array.isArray(g)&&g.type==="element")){const w=g.children[0];w&&w.type==="text"&&(w.value=Uj(w.value))}Array.isArray(g)?u.push(...g):u.push(g)}}}return u}}function O9(e,t){e.position&&(t.position=w6(e))}function $9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Fg(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function D9(e,t){const n=t.data||{},r="value"in t&&!(uv.call(n,"hProperties")||uv.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 F9(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 Uj(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function qj(e,t){const n=L9(e,t),r=n.one(e,void 0),s=N9(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
79
- `},s),o}function z9(e,t){return e&&"run"in e?async function(n,r){const s=qj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return qj(n,{file:r,...e||t})}}function Yj(e){if(e)throw e}var Xm=Object.prototype.hasOwnProperty,ET=Object.prototype.toString,Gj=Object.defineProperty,Xj=Object.getOwnPropertyDescriptor,Jj=function(t){return typeof Array.isArray=="function"?Array.isArray(t):ET.call(t)==="[object Array]"},Qj=function(t){if(!t||ET.call(t)!=="[object Object]")return!1;var n=Xm.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Xm.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Xm.call(t,s)},Zj=function(t,n){Gj&&n.name==="__proto__"?Gj(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},e1=function(t,n){if(n==="__proto__")if(Xm.call(t,n)){if(Xj)return Xj(t,n).value}else return;return t[n]},H9=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,d=arguments.length,p=!1;for(typeof l=="boolean"&&(p=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=e1(l,n),s=e1(t,n),l!==s&&(p&&s&&(Qj(s)||(o=Jj(s)))?(o?(o=!1,a=r&&Jj(r)?r:[]):a=r&&Qj(r)?r:{},Zj(l,{name:n,newValue:e(p,a,s)})):typeof s<"u"&&Zj(l,{name:n,newValue:s}));return l};const ow=$l(H9);function dv(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 B9(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...d){const p=e[++o];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,p?W9(p,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function W9(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 p=d;if(l&&n)throw p;return s(p)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,s):c instanceof Error?s(c):o(c))}function s(a,...l){n||(n=!0,t(a,...l))}function o(a){s(null,a)}}const To={basename:V9,dirname:K9,extname:U9,join:q9,sep:"/"};function V9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');oh(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else a<0&&(o=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function K9(e){if(oh(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 U9(e){oh(e);let t=e.length,n=-1,r=0,s=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function q9(...e){let t=-1,n;for(;++t<e.length;)oh(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Y9(n)}function Y9(e){oh(e);const t=e.codePointAt(0)===47;let n=G9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function G9(e,t){let n="",r=0,s=-1,o=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||o===1))if(s!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(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,o=0;continue}}else if(n.length>0){n="",r=0,s=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function oh(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const X9={cwd:J9};function J9(){return"/"}function fv(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Q9(e){if(typeof e=="string")e=new URL(e);else if(!fv(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 Z9(e)}function Z9(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 aw=["history","path","basename","stem","extname","dirname"];class _T{constructor(t){let n;t?fv(t)?n={path:t}:typeof t=="string"||eV(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":X9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<aw.length;){const o=aw[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)aw.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?To.basename(this.path):void 0}set basename(t){cw(t,"basename"),lw(t,"basename"),this.path=To.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?To.dirname(this.path):void 0}set dirname(t){t1(this.basename,"dirname"),this.path=To.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?To.extname(this.path):void 0}set extname(t){if(lw(t,"extname"),t1(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=To.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){fv(t)&&(t=Q9(t)),cw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?To.basename(this.path,this.extname):void 0}set stem(t){cw(t,"stem"),lw(t,"stem"),this.path=To.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 ys(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 lw(e,t){if(e&&e.includes(To.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+To.sep+"`")}function cw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function t1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function eV(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const tV=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},nV={}.hasOwnProperty;class hk extends tV{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=B9()}copy(){const t=new hk;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ow(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(fw("data",this.frozen),this.namespace[t]=n,this):nV.call(this.namespace,t)&&this.namespace[t]||void 0:t?(fw("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=pm(t),r=this.parser||this.Parser;return uw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),uw("process",this.parser||this.Parser),dw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=pm(t),c=r.parse(l);r.run(c,l,function(p,u,f){if(p||!u||!f)return d(p);const m=u,g=r.stringify(m,f);iV(g)?f.value=g:f.result=g,d(p,f)});function d(p,u){p||!u?a(p):o?o(u):n(void 0,u)}}}processSync(t){let n=!1,r;return this.freeze(),uw("processSync",this.parser||this.Parser),dw("processSync",this.compiler||this.Compiler),this.process(t,s),r1("processSync","process",n),r;function s(o,a){n=!0,Yj(o),r=a}}run(t,n,r){n1(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const c=pm(n);s.run(t,c,d);function d(p,u,f){const m=u||t;p?l(p):a?a(m):r(void 0,m,f)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),r1("runSync","run",r),s;function o(a,l){Yj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=pm(n),s=this.compiler||this.Compiler;return dw("stringify",s),n1(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(fw("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 o(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[p,...u]=d;c(p,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=ow(!0,s.settings,d.settings))}function l(d){let p=-1;if(d!=null)if(Array.isArray(d))for(;++p<d.length;){const u=d[p];o(u)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,p){let u=-1,f=-1;for(;++u<r.length;)if(r[u][0]===d){f=u;break}if(f===-1)r.push([d,...p]);else if(p.length>0){let[m,...g]=p;const w=r[f][1];dv(w)&&dv(m)&&(m=ow(!0,w,m)),r[f]=[d,m,...g]}}}}const rV=new hk().freeze();function uw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function dw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function fw(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 n1(e){if(!dv(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function r1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pm(e){return sV(e)?e:new _T(e)}function sV(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function iV(e){return typeof e=="string"||oV(e)}function oV(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const aV="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",s1=[],i1={allowDangerousHtml:!0},lV=/^(https?|ircs?|mailto|xmpp)$/i,cV=[{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 ah(e){const t=uV(e),n=dV(e);return fV(t.runSync(t.parse(n),n),e)}function uV(e){const t=e.rehypePlugins||s1,n=e.remarkPlugins||s1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...i1}:i1;return rV().use(KW).use(n).use(z9,r).use(t)}function dV(e){const t=e.children||"",n=new _T;return typeof t=="string"&&(n.value=t),n}function fV(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||pV;for(const p of cV)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+aV+p.id,void 0);return CT(e,d),N6(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function d(p,u,f){if(p.type==="raw"&&f&&typeof u=="number")return a?f.children.splice(u,1):f.children[u]={type:"text",value:p.value},u;if(p.type==="element"){let m;for(m in rw)if(Object.hasOwn(rw,m)&&Object.hasOwn(p.properties,m)){const g=p.properties[m],w=rw[m];(w===null||w.includes(p.tagName))&&(p.properties[m]=c(String(g||""),m,p))}}if(p.type==="element"){let m=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!m&&r&&typeof u=="number"&&(m=!r(p,u,f)),m&&f&&typeof u=="number")return l&&p.children?f.children.splice(u,1,...p.children):f.children.splice(u,1),u}}}function pV(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||lV.test(e.slice(0,t))?e:""}function hV(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function zg(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>zg(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${zg(t[r])}`).join(",")}}`}function o1(e){return zg({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 Lp(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function a1(e){return zg({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 l1(e,t){return!hV(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function c1(e,t=!1){const n=new Map;for(const r of e){const s=Lp(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function mV(e,t,n,r){const s=new Map(e.map(b=>[b.id,b])),o=new Set(n.map(b=>b.id)),a=new Set,l=[],c=[],d=n.map(b=>{const x=s.get(b.id);return x?o1(x)===o1(b)?(a.add(b.id),x):(c.push(b.id),l1(b,x)):(l.push(b.id),b)}),p=c1(t),u=c1(r,!0),f=new Set,m=[],g=[],w=r.map(b=>{const x=Lp(b),j=p.get(x);return j?a1(j)===a1(b)?(f.add(x),j):(g.push(x),l1(b,j)):(m.push(x),b)}),k=e.filter(b=>!o.has(b.id)).map(b=>b.id),y=t.map(b=>Lp(b)).filter(b=>!u.has(b));return{nodes:d,edges:w,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:k,addedEdgeKeys:m,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:y.length,edgeReused:f.size,nextEdgeCount:u.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function AT(e){return typeof e>"u"||e===null}function gV(e){return typeof e=="object"&&e!==null}function yV(e){return Array.isArray(e)?e:AT(e)?[]:[e]}function xV(e,t){var n,r,s,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n<r;n+=1)s=o[n],e[s]=t[s];return e}function wV(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function bV(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var vV=AT,kV=gV,SV=yV,NV=wV,jV=bV,CV=xV,zr={isNothing:vV,isObject:kV,toArray:SV,repeat:NV,isNegativeZero:jV,extend:CV};function PT(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 Op(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=PT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Op.prototype=Object.create(Error.prototype);Op.prototype.constructor=Op;Op.prototype.toString=function(t){return this.name+": "+PT(this,t)};var Ns=Op;function pw(e,t,n,r,s){var o="",a="",l=Math.floor(s/2)-1;return r-t>l&&(o=" ... ",t=r-l+o.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+o.length}}function hw(e,t){return zr.repeat(" ",t-e.length)+e}function EV(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],o,a=-1;o=n.exec(e.buffer);)s.push(o.index),r.push(o.index+o[0].length),e.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",c,d,p=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+p+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=pw(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),u),l=zr.repeat(" ",t.indent)+hw((e.line-c+1).toString(),p)+" | "+d.str+`
82
- `+l;for(d=pw(e.buffer,r[a],s[a],e.position,u),l+=zr.repeat(" ",t.indent)+hw((e.line+1).toString(),p)+" | "+d.str+`
83
- `,l+=zr.repeat("-",t.indent+p+3+d.pos)+`^
84
- `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=pw(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),u),l+=zr.repeat(" ",t.indent)+hw((e.line+c+1).toString(),p)+" | "+d.str+`
85
- `;return l.replace(/\n$/,"")}var _V=EV,AV=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],PV=["scalar","sequence","mapping"];function IV(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function TV(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(AV.indexOf(n)===-1)throw new Ns('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=IV(t.styleAliases||null),PV.indexOf(this.kind)===-1)throw new Ns('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var rs=TV;function u1(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(s=a)}),n[s]=r}),n}function RV(){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 pv(e){return this.extend(e)}pv.prototype.extend=function(t){var n=[],r=[];if(t instanceof rs)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 Ns("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof rs))throw new Ns("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Ns("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new Ns("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof rs))throw new Ns("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(pv.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=u1(s,"implicit"),s.compiledExplicit=u1(s,"explicit"),s.compiledTypeMap=RV(s.compiledImplicit,s.compiledExplicit),s};var IT=pv,TT=new rs("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),RT=new rs("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),MT=new rs("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),LT=new IT({explicit:[TT,RT,MT]});function MV(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function LV(){return null}function OV(e){return e===null}var OT=new rs("tag:yaml.org,2002:null",{kind:"scalar",resolve:MV,construct:LV,predicate:OV,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function $V(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 DV(e){return e==="true"||e==="True"||e==="TRUE"}function FV(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var $T=new rs("tag:yaml.org,2002:bool",{kind:"scalar",resolve:$V,construct:DV,predicate:FV,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 zV(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function HV(e){return 48<=e&&e<=55}function BV(e){return 48<=e&&e<=57}function WV(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(!zV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!HV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!BV(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function VV(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 KV(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!zr.isNegativeZero(e)}var DT=new rs("tag:yaml.org,2002:int",{kind:"scalar",resolve:WV,construct:VV,predicate:KV,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"]}}),UV=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function qV(e){return!(e===null||!UV.test(e)||e[e.length-1]==="_")}function YV(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 GV=/^[-+]?[0-9]+e/;function XV(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(zr.isNegativeZero(e))return"-0.0";return n=e.toString(10),GV.test(n)?n.replace("e",".e"):n}function JV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||zr.isNegativeZero(e))}var FT=new rs("tag:yaml.org,2002:float",{kind:"scalar",resolve:qV,construct:YV,predicate:JV,represent:XV,defaultStyle:"lowercase"}),zT=LT.extend({implicit:[OT,$T,DT,FT]}),HT=zT,BT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),WT=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 QV(e){return e===null?!1:BT.exec(e)!==null||WT.exec(e)!==null}function ZV(e){var t,n,r,s,o,a,l,c=0,d=null,p,u,f;if(t=BT.exec(e),t===null&&(t=WT.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(p=+t[10],u=+(t[11]||0),d=(p*60+u)*6e4,t[9]==="-"&&(d=-d)),f=new Date(Date.UTC(n,r,s,o,a,l,c)),d&&f.setTime(f.getTime()-d),f}function eK(e){return e.toISOString()}var VT=new rs("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:QV,construct:ZV,instanceOf:Date,represent:eK});function tK(e){return e==="<<"||e===null}var KT=new rs("tag:yaml.org,2002:merge",{kind:"scalar",resolve:tK}),mk=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
- \r`;function nK(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=mk;for(n=0;n<s;n++)if(t=o.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function rK(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=mk,a=0,l=[];for(t=0;t<s;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(t));return n=s%4*6,n===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):n===18?(l.push(a>>10&255),l.push(a>>2&255)):n===12&&l.push(a>>4&255),new Uint8Array(l)}function sK(e){var t="",n=0,r,s,o=e.length,a=mk;for(r=0;r<o;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return s=o%3,s===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):s===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):s===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function iK(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var UT=new rs("tag:yaml.org,2002:binary",{kind:"scalar",resolve:nK,construct:rK,predicate:iK,represent:sK}),oK=Object.prototype.hasOwnProperty,aK=Object.prototype.toString;function lK(e){if(e===null)return!0;var t=[],n,r,s,o,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,aK.call(s)!=="[object Object]")return!1;for(o in s)if(oK.call(s,o))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function cK(e){return e!==null?e:[]}var qT=new rs("tag:yaml.org,2002:omap",{kind:"sequence",resolve:lK,construct:cK}),uK=Object.prototype.toString;function dK(e){if(e===null)return!0;var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],uK.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function fK(e){if(e===null)return[];var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),o[t]=[s[0],r[s[0]]];return o}var YT=new rs("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:dK,construct:fK}),pK=Object.prototype.hasOwnProperty;function hK(e){if(e===null)return!0;var t,n=e;for(t in n)if(pK.call(n,t)&&n[t]!==null)return!1;return!0}function mK(e){return e!==null?e:{}}var GT=new rs("tag:yaml.org,2002:set",{kind:"mapping",resolve:hK,construct:mK}),gk=HT.extend({implicit:[VT,KT],explicit:[UT,qT,YT,GT]}),Tl=Object.prototype.hasOwnProperty,Hg=1,XT=2,JT=3,Bg=4,mw=1,gK=2,d1=3,yK=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,xK=/[\x85\u2028\u2029]/,wK=/[,\[\]\{\}]/,QT=/^(?:!|!!|![a-z\-]+!)$/i,ZT=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function f1(e){return Object.prototype.toString.call(e)}function Wo(e){return e===10||e===13}function jc(e){return e===9||e===32}function Ws(e){return e===9||e===32||e===10||e===13}function Ku(e){return e===44||e===91||e===93||e===123||e===125}function bK(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function vK(e){return e===120?2:e===117?4:e===85?8:0}function kK(e){return 48<=e&&e<=57?e-48:-1}function p1(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 SK(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function eR(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var tR=new Array(256),nR=new Array(256);for(var ku=0;ku<256;ku++)tR[ku]=p1(ku)?1:0,nR[ku]=p1(ku);function NK(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||gk,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 rR(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=_V(n),new Ns(t,n)}function ut(e,t){throw rR(e,t)}function Wg(e,t){e.onWarning&&e.onWarning.call(null,rR(e,t))}var h1={YAML:function(t,n,r){var s,o,a;t.version!==null&&ut(t,"duplication of %YAML directive"),r.length!==1&&ut(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&ut(t,"ill-formed argument of the YAML directive"),o=parseInt(s[1],10),a=parseInt(s[2],10),o!==1&&ut(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&Wg(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,o;r.length!==2&&ut(t,"TAG directive accepts exactly two arguments"),s=r[0],o=r[1],QT.test(s)||ut(t,"ill-formed tag handle (first argument) of the TAG directive"),Tl.call(t.tagMap,s)&&ut(t,'there is a previously declared suffix for "'+s+'" tag handle'),ZT.test(o)||ut(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{ut(t,"tag prefix is malformed: "+o)}t.tagMap[s]=o}};function El(e,t,n,r){var s,o,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,o=l.length;s<o;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||ut(e,"expected valid JSON character");else yK.test(l)&&ut(e,"the stream contains non-printable characters");e.result+=l}}function m1(e,t,n,r){var s,o,a,l;for(zr.isObject(n)||ut(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)o=s[a],Tl.call(t,o)||(eR(t,o,n[o]),r[o]=!0)}function Uu(e,t,n,r,s,o,a,l,c){var d,p;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,p=s.length;d<p;d+=1)Array.isArray(s[d])&&ut(e,"nested arrays are not supported inside keys"),typeof s=="object"&&f1(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&f1(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(d=0,p=o.length;d<p;d+=1)m1(e,t,o[d],n);else m1(e,t,o,n);else!e.json&&!Tl.call(n,s)&&Tl.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,ut(e,"duplicated mapping key")),eR(t,s,o),delete n[s];return t}function yk(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++):ut(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Rr(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;jc(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(Wo(s))for(yk(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&&Wg(e,"deficient indentation"),r}function Vy(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||Ws(n)))}function xk(e,t){t===1?e.result+=" ":t>1&&(e.result+=zr.repeat(`
88
- `,t-1))}function jK(e,t,n){var r,s,o,a,l,c,d,p,u=e.kind,f=e.result,m;if(m=e.input.charCodeAt(e.position),Ws(m)||Ku(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),Ws(s)||n&&Ku(s)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,l=!1;m!==0;){if(m===58){if(s=e.input.charCodeAt(e.position+1),Ws(s)||n&&Ku(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),Ws(r))break}else{if(e.position===e.lineStart&&Vy(e)||n&&Ku(m))break;if(Wo(m))if(c=e.line,d=e.lineStart,p=e.lineIndent,Rr(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=p;break}}l&&(El(e,o,a,!1),xk(e,e.line-c),o=a=e.position,l=!1),jc(m)||(a=e.position+1),m=e.input.charCodeAt(++e.position)}return El(e,o,a,!1),e.result?!0:(e.kind=u,e.result=f,!1)}function CK(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(El(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 Wo(n)?(El(e,r,s,!0),xk(e,Rr(e,!1,t)),r=s=e.position):e.position===e.lineStart&&Vy(e)?ut(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);ut(e,"unexpected end of the stream within a single quoted scalar")}function EK(e,t){var n,r,s,o,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return El(e,n,e.position,!0),e.position++,!0;if(l===92){if(El(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Wo(l))Rr(e,!1,t);else if(l<256&&tR[l])e.result+=nR[l],e.position++;else if((a=vK(l))>0){for(s=a,o=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=bK(l))>=0?o=(o<<4)+a:ut(e,"expected hexadecimal character");e.result+=SK(o),e.position++}else ut(e,"unknown escape sequence");n=r=e.position}else Wo(l)?(El(e,n,r,!0),xk(e,Rr(e,!1,t)),n=r=e.position):e.position===e.lineStart&&Vy(e)?ut(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}ut(e,"unexpected end of the stream within a double quoted scalar")}function _K(e,t){var n=!0,r,s,o,a=e.tag,l,c=e.anchor,d,p,u,f,m,g=Object.create(null),w,k,y,b;if(b=e.input.charCodeAt(e.position),b===91)p=93,m=!1,l=[];else if(b===123)p=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),b=e.input.charCodeAt(++e.position);b!==0;){if(Rr(e,!0,t),b=e.input.charCodeAt(e.position),b===p)return e.position++,e.tag=a,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;n?b===44&&ut(e,"expected the node content, but found ','"):ut(e,"missed comma between flow collection entries"),k=w=y=null,u=f=!1,b===63&&(d=e.input.charCodeAt(e.position+1),Ws(d)&&(u=f=!0,e.position++,Rr(e,!0,t))),r=e.line,s=e.lineStart,o=e.position,Nd(e,t,Hg,!1,!0),k=e.tag,w=e.result,Rr(e,!0,t),b=e.input.charCodeAt(e.position),(f||e.line===r)&&b===58&&(u=!0,b=e.input.charCodeAt(++e.position),Rr(e,!0,t),Nd(e,t,Hg,!1,!0),y=e.result),m?Uu(e,l,g,k,w,y,r,s,o):u?l.push(Uu(e,null,g,k,w,y,r,s,o)):l.push(w),Rr(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(n=!0,b=e.input.charCodeAt(++e.position)):n=!1}ut(e,"unexpected end of the stream within a flow collection")}function AK(e,t){var n,r,s=mw,o=!1,a=!1,l=t,c=0,d=!1,p,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)mw===s?s=u===43?d1:gK:ut(e,"repeat of a chomping mode identifier");else if((p=kK(u))>=0)p===0?ut(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?ut(e,"repeat of an indentation width identifier"):(l=t+p-1,a=!0);else break;if(jc(u)){do u=e.input.charCodeAt(++e.position);while(jc(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!Wo(u)&&u!==0)}for(;u!==0;){for(yk(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),Wo(u)){c++;continue}if(e.lineIndent<l){s===d1?e.result+=zr.repeat(`
89
- `,o?1+c:c):s===mw&&o&&(e.result+=`
90
- `);break}for(r?jc(u)?(d=!0,e.result+=zr.repeat(`
91
- `,o?1+c:c)):d?(d=!1,e.result+=zr.repeat(`
92
- `,c+1)):c===0?o&&(e.result+=" "):e.result+=zr.repeat(`
93
- `,c):e.result+=zr.repeat(`
94
- `,o?1+c:c),o=!0,a=!0,c=0,n=e.position;!Wo(u)&&u!==0;)u=e.input.charCodeAt(++e.position);El(e,n,e.position,!1)}return!0}function g1(e,t){var n,r=e.tag,s=e.anchor,o=[],a,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ut(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!Ws(a))));){if(l=!0,e.position++,Rr(e,!0,-1)&&e.lineIndent<=t){o.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Nd(e,t,JT,!1,!0),o.push(e.result),Rr(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)ut(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=o,!0):!1}function PK(e,t,n){var r,s,o,a,l,c,d=e.tag,p=e.anchor,u={},f=Object.create(null),m=null,g=null,w=null,k=!1,y=!1,b;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),b=e.input.charCodeAt(e.position);b!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ut(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),o=e.line,(b===63||b===58)&&Ws(r))b===63?(k&&(Uu(e,u,f,m,g,null,a,l,c),m=g=w=null),y=!0,k=!0,s=!0):k?(k=!1,s=!0):ut(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,b=r;else{if(a=e.line,l=e.lineStart,c=e.position,!Nd(e,n,XT,!1,!0))break;if(e.line===o){for(b=e.input.charCodeAt(e.position);jc(b);)b=e.input.charCodeAt(++e.position);if(b===58)b=e.input.charCodeAt(++e.position),Ws(b)||ut(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(Uu(e,u,f,m,g,null,a,l,c),m=g=w=null),y=!0,k=!1,s=!1,m=e.tag,g=e.result;else if(y)ut(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=p,!0}else if(y)ut(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=p,!0}if((e.line===o||e.lineIndent>t)&&(k&&(a=e.line,l=e.lineStart,c=e.position),Nd(e,t,Bg,!0,s)&&(k?g=e.result:w=e.result),k||(Uu(e,u,f,m,g,w,a,l,c),m=g=w=null),Rr(e,!0,-1),b=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&b!==0)ut(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&Uu(e,u,f,m,g,null,a,l,c),y&&(e.tag=d,e.anchor=p,e.kind="mapping",e.result=u),y}function IK(e){var t,n=!1,r=!1,s,o,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&ut(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(o=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):ut(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!Ws(a);)a===33&&(r?ut(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),QT.test(s)||ut(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);o=e.input.slice(t,e.position),wK.test(o)&&ut(e,"tag suffix cannot contain flow indicator characters")}o&&!ZT.test(o)&&ut(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{ut(e,"tag name is malformed: "+o)}return n?e.tag=o:Tl.call(e.tagMap,s)?e.tag=e.tagMap[s]+o:s==="!"?e.tag="!"+o:s==="!!"?e.tag="tag:yaml.org,2002:"+o:ut(e,'undeclared tag handle "'+s+'"'),!0}function TK(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ut(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Ws(n)&&!Ku(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ut(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function RK(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&&!Ws(r)&&!Ku(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ut(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Tl.call(e.anchorMap,n)||ut(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Rr(e,!0,-1),!0}function Nd(e,t,n,r,s){var o,a,l,c=1,d=!1,p=!1,u,f,m,g,w,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=Bg===n||JT===n,r&&Rr(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;IK(e)||TK(e);)Rr(e,!0,-1)?(d=!0,l=o,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||s),(c===1||Bg===n)&&(Hg===n||XT===n?w=t:w=t+1,k=e.position-e.lineStart,c===1?l&&(g1(e,k)||PK(e,k,w))||_K(e,w)?p=!0:(a&&AK(e,w)||CK(e,w)||EK(e,w)?p=!0:RK(e)?(p=!0,(e.tag!==null||e.anchor!==null)&&ut(e,"alias node should not have any properties")):jK(e,w,Hg===n)&&(p=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(p=l&&g1(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&ut(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,f=e.implicitTypes.length;u<f;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(Tl.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,f=m.length;u<f;u+=1)if(e.tag.slice(0,m[u].tag.length)===m[u].tag){g=m[u];break}g||ut(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&ut(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)):ut(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||p}function MK(e){var t=e.position,n,r,s,o=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(Rr(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(o=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!Ws(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&ut(e,"directive name must not be less than one character in length");a!==0;){for(;jc(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!Wo(a));break}if(Wo(a))break;for(n=e.position;a!==0&&!Ws(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&yk(e),Tl.call(h1,r)?h1[r](e,r,s):Wg(e,'unknown document directive "'+r+'"')}if(Rr(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,Rr(e,!0,-1)):o&&ut(e,"directives end mark is expected"),Nd(e,e.lineIndent-1,Bg,!1,!0),Rr(e,!0,-1),e.checkLineBreaks&&xK.test(e.input.slice(t,e.position))&&Wg(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Vy(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Rr(e,!0,-1));return}if(e.position<e.length-1)ut(e,"end of the stream or a document separator is expected");else return}function sR(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 NK(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ut(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;)MK(n);return n.documents}function LK(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=sR(e,n);if(typeof t!="function")return r;for(var s=0,o=r.length;s<o;s+=1)t(r[s])}function OK(e,t){var n=sR(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new Ns("expected a single document in the stream, but found more")}}var $K=LK,DK=OK,iR={loadAll:$K,load:DK},oR=Object.prototype.toString,aR=Object.prototype.hasOwnProperty,wk=65279,FK=9,$p=10,zK=13,HK=32,BK=33,WK=34,hv=35,VK=37,KK=38,UK=39,qK=42,lR=44,YK=45,Vg=58,GK=61,XK=62,JK=63,QK=64,cR=91,uR=93,ZK=96,dR=123,e7=124,fR=125,xs={};xs[0]="\\0";xs[7]="\\a";xs[8]="\\b";xs[9]="\\t";xs[10]="\\n";xs[11]="\\v";xs[12]="\\f";xs[13]="\\r";xs[27]="\\e";xs[34]='\\"';xs[92]="\\\\";xs[133]="\\N";xs[160]="\\_";xs[8232]="\\L";xs[8233]="\\P";var t7=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],n7=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function r7(e,t){var n,r,s,o,a,l,c;if(t===null)return{};for(n={},r=Object.keys(t),s=0,o=r.length;s<o;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),c=e.compiledTypeMap.fallback[a],c&&aR.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function s7(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 Ns("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+zr.repeat("0",r-t.length)+t}var i7=1,Dp=2;function o7(e){this.schema=e.schema||gk,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=zr.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=r7(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==='"'?Dp:i7,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 y1(e,t){for(var n=zr.repeat(" ",t),r=0,s=-1,o="",a,l=e.length;r<l;)s=e.indexOf(`
96
- `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
- `&&(o+=n),o+=a;return o}function mv(e,t){return`
98
- `+zr.repeat(" ",e.indent*t)}function a7(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 Kg(e){return e===HK||e===FK}function Fp(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==wk||65536<=e&&e<=1114111}function x1(e){return Fp(e)&&e!==wk&&e!==zK&&e!==$p}function w1(e,t,n){var r=x1(e),s=r&&!Kg(e);return(n?r:r&&e!==lR&&e!==cR&&e!==uR&&e!==dR&&e!==fR)&&e!==hv&&!(t===Vg&&!s)||x1(t)&&!Kg(t)&&e===hv||t===Vg&&s}function l7(e){return Fp(e)&&e!==wk&&!Kg(e)&&e!==YK&&e!==JK&&e!==Vg&&e!==lR&&e!==cR&&e!==uR&&e!==dR&&e!==fR&&e!==hv&&e!==KK&&e!==qK&&e!==BK&&e!==e7&&e!==GK&&e!==XK&&e!==UK&&e!==WK&&e!==VK&&e!==QK&&e!==ZK}function c7(e){return!Kg(e)&&e!==Vg}function Mf(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 pR(e){var t=/^\n* /;return t.test(e)}var hR=1,gv=2,mR=3,gR=4,Cu=5;function u7(e,t,n,r,s,o,a,l){var c,d=0,p=null,u=!1,f=!1,m=r!==-1,g=-1,w=l7(Mf(e,0))&&c7(Mf(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Mf(e,c),!Fp(d))return Cu;w=w&&w1(d,p,l),p=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Mf(e,c),d===$p)u=!0,m&&(f=f||c-g-1>r&&e[g+1]!==" ",g=c);else if(!Fp(d))return Cu;w=w&&w1(d,p,l),p=d}f=f||m&&c-g-1>r&&e[g+1]!==" "}return!u&&!f?w&&!a&&!s(e)?hR:o===Dp?Cu:gv:n>9&&pR(e)?Cu:a?o===Dp?Cu:gv:f?gR:mR}function d7(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===Dp?'""':"''";if(!e.noCompatMode&&(t7.indexOf(t)!==-1||n7.test(t)))return e.quotingType===Dp?'"'+t+'"':"'"+t+"'";var o=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return a7(e,d)}switch(u7(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case hR:return t;case gv:return"'"+t.replace(/'/g,"''")+"'";case mR:return"|"+b1(t,e.indent)+v1(y1(t,o));case gR:return">"+b1(t,e.indent)+v1(y1(f7(t,a),o));case Cu:return'"'+p7(t)+'"';default:throw new Ns("impossible error: invalid scalar style")}}()}function b1(e,t){var n=pR(e)?String(t):"",r=e[e.length-1]===`
99
- `,s=r&&(e[e.length-2]===`
100
- `||e===`
101
- `),o=s?"+":r?"":"-";return n+o+`
102
- `}function v1(e){return e[e.length-1]===`
103
- `?e.slice(0,-1):e}function f7(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,k1(e.slice(0,d),t)}(),s=e[0]===`
105
- `||e[0]===" ",o,a;a=n.exec(e);){var l=a[1],c=a[2];o=c[0]===" ",r+=l+(!s&&!o&&c!==""?`
106
- `:"")+k1(c,t),s=o}return r}function k1(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,o,a=0,l=0,c="";r=n.exec(e);)l=r.index,l-s>t&&(o=a>s?a:l,c+=`
107
- `+e.slice(s,o),s=o+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 p7(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Mf(e,s),r=xs[n],!r&&Fp(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||s7(n);return t}function h7(e,t,n){var r="",s=e.tag,o,a,l;for(o=0,a=n.length;o<a;o+=1)l=n[o],e.replacer&&(l=e.replacer.call(n,String(o),l)),(Pa(e,t,l,!1,!1)||typeof l>"u"&&Pa(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function S1(e,t,n,r){var s="",o=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)),(Pa(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&Pa(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=mv(e,t)),e.dump&&$p===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=o,e.dump=s||"[]"}function m7(e,t,n){var r="",s=e.tag,o=Object.keys(n),a,l,c,d,p;for(a=0,l=o.length;a<l;a+=1)p="",r!==""&&(p+=", "),e.condenseFlow&&(p+='"'),c=o[a],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),Pa(e,t,c,!1,!1)&&(e.dump.length>1024&&(p+="? "),p+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Pa(e,t,d,!1,!1)&&(p+=e.dump,r+=p));e.tag=s,e.dump="{"+r+"}"}function g7(e,t,n,r){var s="",o=e.tag,a=Object.keys(n),l,c,d,p,u,f;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new Ns("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)f="",(!r||s!=="")&&(f+=mv(e,t)),d=a[l],p=n[d],e.replacer&&(p=e.replacer.call(n,d,p)),Pa(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&$p===e.dump.charCodeAt(0)?f+="?":f+="? "),f+=e.dump,u&&(f+=mv(e,t)),Pa(e,t+1,p,!0,u)&&(e.dump&&$p===e.dump.charCodeAt(0)?f+=":":f+=": ",f+=e.dump,s+=f));e.tag=o,e.dump=s||"{}"}function N1(e,t,n){var r,s,o,a,l,c;for(s=n?e.explicitTypes:e.implicitTypes,o=0,a=s.length;o<a;o+=1)if(l=s[o],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,oR.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(aR.call(l.represent,c))r=l.represent[c](t,c);else throw new Ns("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function Pa(e,t,n,r,s,o,a){e.tag=null,e.dump=n,N1(e,n,!1)||N1(e,n,!0);var l=oR.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var p=l==="[object Object]"||l==="[object Array]",u,f;if(p&&(u=e.duplicates.indexOf(n),f=u!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(s=!1),f&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(p&&f&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(g7(e,t,e.dump,s),f&&(e.dump="&ref_"+u+e.dump)):(m7(e,t,e.dump),f&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?S1(e,t-1,e.dump,s):S1(e,t,e.dump,s),f&&(e.dump="&ref_"+u+e.dump)):(h7(e,t,e.dump),f&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&d7(e,e.dump,t,o,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Ns("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 y7(e,t){var n=[],r=[],s,o;for(yv(e,n,r),s=0,o=r.length;s<o;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(o)}function yv(e,t,n){var r,s,o;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,o=e.length;s<o;s+=1)yv(e[s],t,n);else for(r=Object.keys(e),s=0,o=r.length;s<o;s+=1)yv(e[r[s]],t,n)}function x7(e,t){t=t||{};var n=new o7(t);n.noRefs||y7(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),Pa(n,0,r,!0,!0)?n.dump+`
110
- `:""}var w7=x7,b7={dump:w7};function bk(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 v7=rs,k7=IT,S7=LT,N7=zT,j7=HT,C7=gk,E7=iR.load,_7=iR.loadAll,A7=b7.dump,P7=Ns,I7={binary:UT,float:FT,map:MT,null:OT,pairs:YT,set:GT,timestamp:VT,bool:$T,int:DT,merge:KT,omap:qT,seq:RT,str:TT},T7=bk("safeLoad","load"),R7=bk("safeLoadAll","loadAll"),M7=bk("safeDump","dump"),yR={Type:v7,Schema:k7,FAILSAFE_SCHEMA:S7,JSON_SCHEMA:N7,CORE_SCHEMA:j7,DEFAULT_SCHEMA:C7,load:E7,loadAll:_7,dump:A7,YAMLException:P7,types:I7,safeLoad:T7,safeLoadAll:R7,safeDump:M7};const Rl=["requirement","planning","code","test","normal"],xv={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},L7=["agent","control","provide","condition","jump","condition_jump","start","end"];function O7(e){return L7.includes(e)?e:"agent"}function $7(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function D7(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=yR.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},o=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},c=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=a.viewport&&typeof a.viewport=="object"?a.viewport:null,p=d&&Number.isFinite(Number(d.x))&&Number.isFinite(Number(d.y))&&Number.isFinite(Number(d.zoom))?{x:Number(d.x),y:Number(d.y),zoom:Math.min(Math.max(Number(d.zoom),.1),4)}:void 0,u=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,f=new Set(Object.keys(s));for(const w of o)w!=null&&w.source&&f.add(String(w.source)),w!=null&&w.target&&f.add(String(w.target));const m=Array.from(f).map(w=>{const k=s[w],y=l[w]&&typeof l[w].x=="number"&&typeof l[w].y=="number"?{x:l[w].x,y:l[w].y}:{x:0,y:0},b=c[w]&&typeof c[w].width=="number"&&typeof c[w].height=="number"?{width:c[w].width,height:c[w].height}:null,x=(k==null?void 0:k.definitionId)??w,j=$7(x),E=(k==null?void 0:k.label)!=null?String(k.label):w,N=(k==null?void 0:k.role)!=null?String(k.role).trim():"",T=xv[N]||N,$=Rl.includes(T)?T:"normal",z=(k==null?void 0:k.model)!=null?String(k.model).trim():void 0,K=(k==null?void 0:k.body)!=null?String(k.body):"",B=(k==null?void 0:k.script)!=null?String(k.script):"",L=(k==null?void 0:k.scriptRef)!=null?String(k.scriptRef):"",D=(k==null?void 0:k.implementationRef)!=null?String(k.implementationRef):"",R=(k==null?void 0:k.implementationMode)!=null?String(k.implementationMode):"",M=Array.isArray(k==null?void 0:k.images)?k.images:[];return{id:w,type:O7(j),position:y,...b?{width:b.width,height:b.height}:{},data:{label:E,definitionId:x,schemaType:j,role:$,model:z||void 0,body:K,images:M,...b?{displaySize:b}:{},...B.trim()!==""?{script:B}:{},...L.trim()!==""?{scriptRef:L}:{},...D.trim()!==""?{implementationRef:D}:{},...R.trim()!==""?{implementationMode:R}:{}}}}),g=o.filter(w=>(w==null?void 0:w.source)&&(w==null?void 0:w.target)).map((w,k)=>({id:`e-${w.source}-${w.target}-${k}`,source:String(w.source),target:String(w.target),sourceHandle:w.sourceHandle??void 0,targetHandle:w.targetHandle??void 0,markerEnd:{type:js.ArrowClosed}}));return{nodes:m,edges:g,instances:s,description:u,...p?{viewport:p}:{}}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const o=r.match(/\((\d+):/);s=`
111
-
112
- 💡 提示:通常由 ${o?`第 ${o[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
- YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
-
115
- ✅ 正确写法:
116
- \`\`\`yaml
117
- script: |
118
- node -e "console.log('TODO: scripts/x.mjs')"
119
- \`\`\`
120
- ❌ 错误写法(当前文件):
121
- \`\`\`yaml
122
- script: node -e "console.log('TODO: scripts/x.mjs')"
123
- \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function lh(e,t){var s,o,a,l,c,d,p,u,f,m,g,w,k,y;const n=b=>{const x={type:(b==null?void 0:b.type)??"node",name:(b==null?void 0:b.name)??"",value:(b==null?void 0:b.value)??(b==null?void 0:b.default)??""};return(b==null?void 0:b.required)===!0&&(x.required=!0),(b==null?void 0:b.description)!=null&&String(b.description).trim()&&(x.description=String(b.description)),(b==null?void 0:b.showOnNode)!=null&&(x.showOnNode=!!b.showOnNode),x},r={};for(const b of e){if((s=b==null?void 0:b.data)!=null&&s.isWorkspaceGroup)continue;const x=t[b.id]&&typeof t[b.id]=="object"?{...t[b.id]}:{},j=((o=b.data)==null?void 0:o.definitionId)||b.id,E=((a=b.data)==null?void 0:a.inputs)??[],N=((l=b.data)==null?void 0:l.outputs)??[],T=((c=b.data)==null?void 0:c.role)!=null?String(b.data.role).trim():"",$=x.role!=null?String(x.role).trim():"",z=xv[T]||T,K=xv[$]||$,B=Rl.includes(z)?z:Rl.includes(K)?K:"normal",L=Array.isArray(E)?E.map(n):Array.isArray(x.input)?x.input.map(fe=>n(fe)):[],D=Array.isArray(N)?N.map(n):Array.isArray(x.output)?x.output.map(fe=>n(fe)):[],R=((d=b.data)==null?void 0:d.label)!=null?String(b.data.label):x.label!=null?String(x.label):b.id,M=(p=b.data)==null?void 0:p.body,I=M!=null?String(M):x.body!=null?String(x.body):"";let F=((u=b.data)==null?void 0:u.model)!=null&&String(b.data.model).trim()!==""?String(b.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const P={...x,definitionId:j,label:R,role:B,model:F,input:L,output:D},O=((f=b.data)==null?void 0:f.marketplaceRef)||x.marketplaceRef;O?P.marketplaceRef=String(O):delete P.marketplaceRef;const _=((m=b.data)==null?void 0:m.marketplacePackageId)||x.marketplacePackageId;_?P.marketplacePackageId=String(_):delete P.marketplacePackageId;const Z=((g=b.data)==null?void 0:g.marketplaceVersion)||x.marketplaceVersion;Z?P.marketplaceVersion=String(Z):delete P.marketplaceVersion,j.startsWith("provide_")||I.trim()===""?delete P.body:P.body=I;const ee=Array.isArray((w=b.data)==null?void 0:w.images)?b.data.images:Array.isArray(x.images)?x.images:[];ee.length>0?P.images=ee:delete P.images;const V=(k=b.data)==null?void 0:k.script,ae=V!=null?String(V):x.script!=null?String(x.script):"";ae.trim()===""?delete P.script:P.script=ae;for(const fe of["scriptRef","implementationRef","implementationMode"]){const xe=(y=b.data)==null?void 0:y[fe],Se=xe!=null?String(xe):x[fe]!=null?String(x[fe]):"";Se.trim()===""?delete P[fe]:P[fe]=Se.trim()}delete P.temperature,delete P.maxTokens,delete P.description,r[b.id]=P}return r}function tp(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function F7(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 xR(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const s=new Set(r.map(a=>a.id)),o=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>tp(a)),edges:o.map(a=>tp(a)),instances:lh(r,n||{})}}function wR(e,t,n,r,s={}){var u;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=s.offset||{x:48,y:48},a=new Set((t||[]).map(f=>f.id)),l=new Map;for(const f of e.nodes)l.set(f.id,F7(f.id,a));const c=e.nodes.map(f=>{var g,w;const m=l.get(f.id);return{...tp(f),id:m,selected:!0,dragging:!1,position:{x:Number(((g=f.position)==null?void 0:g.x)||0)+o.x,y:Number(((w=f.position)==null?void 0:w.y)||0)+o.y}}}),d=(e.edges||[]).filter(f=>l.has(f.source)&&l.has(f.target)).map((f,m)=>{const g=l.get(f.source),w=l.get(f.target);return{...tp(f),id:`e-${g}-${w}-${Date.now()}-${m}`,source:g,target:w,selected:!1}}),p={...r||{}};for(const[f,m]of l.entries()){const g=(u=e.instances)==null?void 0:u[f];g&&(p[m]={...tp(g),label:g.label!=null?String(g.label):m})}return{nodes:[...(t||[]).map(f=>({...f,selected:!1})),...c],edges:[...(n||[]).map(f=>({...f,selected:!1})),...d],instances:p,pastedNodeIds:c.map(f=>f.id)}}function j1(e,t,n,r){var p,u,f,m;const s=lh(e,n),o=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const w=g.position??{x:0,y:0};a[g.id]={x:w.x,y:w.y};const k=Number(((u=(p=g.data)==null?void 0:p.displaySize)==null?void 0:u.width)||g.width||0),y=Number(((m=(f=g.data)==null?void 0:f.displaySize)==null?void 0:m.height)||g.height||0);k>0&&y>0&&(l[g.id]={width:Math.round(k),height:Math.round(y)})}const c={nodePositions:a};Object.keys(l).length>0&&(c.nodeSizes=l),r!=null&&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:o,ui:c};return yR.dump(d,{lineWidth:-1})}function z7(e){var s,o;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((o=e.data)==null?void 0:o.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],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 H7(e,t,n){var c,d,p;const r=new Set(e.map(u=>u.id)),s={};for(const u of e)s[u.id]=z7(u);const o=new Map,a=new Map;for(const u of t)u.target&&r.has(u.target)&&(o.has(u.target)||o.set(u.target,new Set),u.targetHandle&&o.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 f=((c=u.data)==null?void 0:c.definitionId)!=null?String(u.data.definitionId):"",m=s[u.id]||{inputNames:[],outputNames:[]},g=m.inputNames.length,w=m.outputNames.length;if(!(f==="control_start"||f.startsWith("provide_"))&&g>0)for(let b=0;b<g;b++){const x=`input-${b}`;if(!((d=o.get(u.id))==null?void 0:d.has(x))){const E=m.inputNames[b]||x;l.push({nodeId:u.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:E,handle:x}),key:`${u.id}-${x}-in`})}}if(!(f==="control_end")&&w>0)for(let b=0;b<w;b++){const x=`output-${b}`;if(!((p=a.get(u.id))==null?void 0:p.has(x))){const E=m.outputNames[b]||x;l.push({nodeId:u.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:E,handle:x}),key:`${u.id}-${x}-out`})}}}return l}const Ug=/\[image\s+(\d+)\]/gi;function Vs(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 B7(e){return`image ${Vs(e).length+1}`}function W7(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function V7(e,t){const n=Vs(e),r=String(t||""),s=new Set;Ug.lastIndex=0;let o;for(;o=Ug.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function K7(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 bR(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 np(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 vR({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=Vs(n);for(const a of r){const l=await K7(a),c=B7(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=W7(s,c)}return{body:s,images:o}}function wv(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),e.description!=null&&(r.description=String(e.description)),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const U7={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function q7(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(U7[e]||[]).includes(s)?r:s}const Y7={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"])},G7={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},X7=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function J7(e,t){if(!X7.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function Q7(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Z7(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function kR(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function eU(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function tU(e){const t=String(e??"").trim();return t?t.includes("${")?t:kR(t):""}function nU(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const r=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),s=r?`${r}/${n}`:`\${flowDir}/${n}`,o=Array.isArray(t.args)?t.args.map(tU).filter(Boolean):[];return[eU(t,n),kR(s),...o].join(" ")}return String(t.command||"").trim()}function C1(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,p;const o=n[s],l=n.find(u=>(u==null?void 0:u.name)&&u.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((d=Y7[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...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&&J7(e,r)?{showOnNode:!0}:{},...(p=G7[e])!=null&&p.has(r.name)?{showOnNode:!1}:{}}})}function SR(e){var s,o;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((o=e==null?void 0:e.data)==null?void 0:o.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=wv(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function zp(e,t,n,r,s){var P,O,_,Z,ee,V,ae,fe,xe,Se,ue,Ee,le,me,we,je,Ye,tt,ze,dt,Ft;const o=((P=e.data)==null?void 0:P.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ue=>Ue.id===o),l=t[e.id];let c=[],d=[],p=((O=e.data)==null?void 0:O.label)??e.id,u,f,m,g,w;const k=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(wv)),Array.isArray(l.output)&&(d=l.output.map(wv)),l.label&&(p=String(l.label)),l.role&&typeof l.role=="string"&&(u=l.role),l.model!=null&&(f=String(l.model).trim()),l.body!=null&&(m=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(w=String(l.script)));const y=u??(typeof((_=e.data)==null?void 0:_.role)=="string"?e.data.role:"普通"),b=f??((Z=e.data)==null?void 0:Z.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=x!==""?x:void 0,E=m??((ee=e.data)==null?void 0:ee.body)??"",N=Array.isArray(g)?g:Array.isArray((V=e.data)==null?void 0:V.images)?e.data.images:[],T=nU(a),$=w!==void 0?w:((ae=e.data)==null?void 0:ae.script)!=null?String(e.data.script):T,z=String(e.id),K=(fe=r==null?void 0:r[s])==null?void 0:fe[z],B=(xe=K==null?void 0:K.label)==null?void 0:xe.label,L=K==null?void 0:K.body,D=K==null?void 0:K.description;k||(c.length===0&&((Se=a==null?void 0:a.inputs)!=null&&Se.length)&&(c=a.inputs.map(Ue=>({...Ue}))),d.length===0&&((ue=a==null?void 0:a.outputs)!=null&&ue.length)&&(d=a.outputs.map(Ue=>({...Ue}))));const R=Z7(a,(a==null?void 0:a.id)??o),M=(l==null?void 0:l.marketplaceRef)||((Ee=e.data)==null?void 0:Ee.marketplaceRef)||Q7(a);if(R==="agent_subAgent"&&!d.some(Ue=>(Ue==null?void 0:Ue.name)==="result")){const Ue=(le=a==null?void 0:a.outputs)==null?void 0:le.find(pt=>(pt==null?void 0:pt.name)==="result");d=[...d,Ue?{...Ue}:{type:"text",name:"result",default:""}]}if((R==="display_markdown"||R==="display_mermaid"||R==="display_ascii"||R==="display_chart"||R==="display_table")&&!d.some(Ue=>(Ue==null?void 0:Ue.name)==="next")){const Ue=(me=a==null?void 0:a.outputs)==null?void 0:me.find(pt=>(pt==null?void 0:pt.name)==="next");d=[...d,Ue?{...Ue}:{type:"node",name:"next",default:""}]}if(R==="workspace_run"){if(!c.some(Ue=>(Ue==null?void 0:Ue.name)==="prev")){const Ue=(we=a==null?void 0:a.inputs)==null?void 0:we.find(pt=>(pt==null?void 0:pt.name)==="prev");c=[Ue?{...Ue}:{type:"node",name:"prev",default:""},...c]}if(!d.some(Ue=>(Ue==null?void 0:Ue.name)==="next")){const Ue=(je=a==null?void 0:a.outputs)==null?void 0:je.find(pt=>(pt==null?void 0:pt.name)==="next");d=[...d,Ue?{...Ue}:{type:"node",name:"next",default:""}]}}c=C1(R,c,a==null?void 0:a.inputs),d=C1(R,d,a==null?void 0:a.outputs),R.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(E).trim()!==""&&(d=d.map((Ue,pt)=>pt===0?{...Ue,default:E,value:E}:Ue));const I=q7(R,B||p,a),F=R==="tool_nodejs"||String($).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:B||p,displayLabel:I,definitionDisplayName:a==null?void 0:a.displayName,definitionId:R,...M?{marketplaceRef:M}:{},...l!=null&&l.marketplacePackageId||(Ye=e.data)!=null&&Ye.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((tt=e.data)==null?void 0:tt.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ze=e.data)!=null&&ze.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((dt=e.data)==null?void 0:dt.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((Ft=e.data)==null?void 0:Ft.schemaType)??e.type??"agent",role:y,model:b,body:L||E,images:N,script:$,inputs:c,outputs:d,description:D||j,originalLabel:p,originalBody:E,...F?{script:$}:{}}}}function NR(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var p,u,f,m;const s=n.get(r.source),o=n.get(r.target),a=((u=(p=s==null?void 0:s.data)==null?void 0:p.outputs)==null?void 0:u.length)??0,l=((m=(f=o==null?void 0:o.data)==null?void 0:f.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&&o&&c>=0&&c<a&&d>=0&&d<l})}function E1(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 _1(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function rp(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=E1(t==null?void 0:t.sourceHandle,"output"),o=E1(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var d,p,u,f;if(c.id===n){const m=_1((d=c.data)==null?void 0:d.outputs,s);if(m!==((p=c.data)==null?void 0:p.outputs))return a=!0,{...c,data:{...c.data,outputs:m}}}if(c.id===r){const m=_1((u=c.data)==null?void 0:u.inputs,o);if(m!==((f=c.data)==null?void 0:f.inputs))return a=!0,{...c,data:{...c.data,inputs:m}}}return c});return a?l:e}const A1=80,rU=220;function sU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function iU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function hm(e,t,n){const r={nodes:Array.isArray(e)?e.map(sU):[],edges:Array.isArray(t)?t.map(iU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function gw(e,t){const n=[...e,t];return n.length>A1?n.slice(n.length-A1):n}function jR({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),d=h.useRef(null),p=h.useRef(null),u=h.useRef(null),f=h.useRef(null),m=h.useRef(!1),g=h.useCallback(()=>a(E=>E+1),[]),w=h.useCallback(()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},[]),k=h.useCallback(()=>{w();const E=p.current,N=u.current;return p.current=null,u.current=null,!E||!N||E.signature===N.signature?(N&&(d.current=N),!1):(l.current=gw(l.current,E),c.current=[],d.current=N,g(),!0)},[g,w]),y=h.useCallback((E=[],N=[],T={})=>{w(),l.current=[],c.current=[],p.current=null,u.current=null,d.current=hm(E,N,T),m.current=!1,g()},[g,w]),b=h.useCallback(E=>{m.current=!0,d.current=E,p.current=null,u.current=null,w(),s==null||s(E.value),g()},[g,w,s]),x=h.useCallback(()=>{k();const E=d.current||hm(e,t,n),N=l.current.pop();return N?(c.current=gw(c.current,E),b(N),!0):(g(),!1)},[g,t,n,k,e,b]),j=h.useCallback(()=>{k();const E=d.current||hm(e,t,n),N=c.current.pop();return N?(l.current=gw(l.current,E),b(N),!0):(g(),!1)},[g,t,n,k,e,b]);return h.useEffect(()=>()=>w(),[w]),h.useEffect(()=>{if(!r)return;const E=hm(e,t,n);if(!d.current){d.current=E;return}if(m.current){m.current=!1,d.current=E;return}E.signature!==d.current.signature&&(p.current||(p.current=d.current),u.current=E,w(),f.current=window.setTimeout(()=>{k()},rU))},[w,t,r,n,k,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:y,undo:x,redo:j,version:o}}function qn(e){switch(qg(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function qg(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 oU(e,t){const n=qg(e),r=qg(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const aU=new Set(["workspaceContext","skillsContext","mcpContext"]);function bv(e){const t=qg(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&aU.has(n)?`${t}+${n}`:t}function CR(e){return bv(e)}function Ml(e,t){if(!e||!t||!oU(e.type,t.type))return!1;const n=bv(e),r=bv(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function lU(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 jd(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=lU(t,n==="source"?"output":"input");return o<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[o]||null}function pa(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function cU(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 uU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function mn(e){e.stopPropagation()}function dU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fU(e,t){const n=`\\[${dU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
- `).replace(/\n{3,}/g,`
125
-
126
- `).trimEnd()}function yw(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function pU(e){const t=String(e||"");let n="",r=0;Ug.lastIndex=0;let s;for(;s=Ug.exec(t);)n+=yw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${yw(s[0])}</span>`,r=s.index+s[0].length;return n+=yw(t.slice(r)),n||" "}function hU(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+o+a+l)}function ER({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var ce,he;const{t:p}=zn(),u=(e==null?void 0:e.inputs)??[],f=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=cU(e),w=(e==null?void 0:e.isRunMode)??!1,k=!!(e!=null&&e.readOnly),y=(e==null?void 0:e.isExecuting)??!1,b=(e==null?void 0:e.isDim)??!1,x=(e==null?void 0:e.nodeStatus)??null,j=(e==null?void 0:e.nodeElapsed)??null,E=(e==null?void 0:e.definitionId)||"",N=E.startsWith("provide_"),T=E==="provide_bool",$=E==="provide_str",z=E==="provide_file",K=E==="provide_password",B=E==="agent_subAgent",L=E==="control_agent_toBool",D=(B||L)&&!w,R=T?uU(f[0]):!1,M=N?String(((ce=f[0])==null?void 0:ce.value)??((he=f[0])==null?void 0:he.default)??(e==null?void 0:e.body)??""):"",I=String((e==null?void 0:e.body)||""),F=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||p("flow:node.fallbackLabel"),P=!N&&!D&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",O=Vs(e==null?void 0:e.images),_=T||$||z||K||D||!!P,Z=h.useRef(!1),ee=h.useRef(!1),V=h.useRef(null),ae=h.useRef(null),fe=h.useRef(null),xe=h.useRef(null),Se=h.useRef(null),[ue,Ee]=h.useState(M),[le,me]=h.useState(!1),[we,je]=h.useState(I),[Ye,tt]=h.useState(!1),[ze,dt]=h.useState({visible:!1,top:0,height:100}),[Ft,Ue]=h.useState(!1),pt=h.useCallback(()=>{const Q=ae.current;if(!Q)return;const ge=Math.max(1,Q.scrollHeight),qe=Math.max(1,Q.clientHeight),Me=ge>qe+1,zt=Me?Math.max(12,qe/ge*100):100,Rn=Math.max(0,100-zt),Hn=Me?Math.min(Rn,Q.scrollTop/Math.max(1,ge-qe)*Rn):0;dt({visible:Me,top:Hn,height:zt})},[]);h.useEffect(()=>{Z.current||Ee(M)},[n,M]),h.useEffect(()=>{ee.current||je(I)},[n,I]),h.useEffect(()=>{const Q=ae.current;if(!Q)return;if(D){Q.style.minHeight="",Q.style.height="",fe.current&&(fe.current.style.minHeight="",fe.current.style.height="");return}const ge=hU(Q,we);Q.style.minHeight=`${ge}px`,Q.style.height="",fe.current&&(fe.current.style.minHeight=`${ge}px`,fe.current.style.height="")},[we,D]),h.useEffect(()=>{if(!D)return;const Q=window.requestAnimationFrame(pt),ge=ae.current;if(!ge||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(Q);const qe=new ResizeObserver(pt);return qe.observe(ge),()=>{window.cancelAnimationFrame(Q),qe.disconnect()}},[we,D,pt]),h.useEffect(()=>{const Q=V.current,ge=e==null?void 0:e.onNodeContentResize;if(!D||!Q||!ge||typeof ResizeObserver>"u")return;let qe=0;const Me=()=>{window.cancelAnimationFrame(qe),qe=window.requestAnimationFrame(()=>ge(n))},zt=new ResizeObserver(Me);return zt.observe(Q),Me(),()=>{window.cancelAnimationFrame(qe),zt.disconnect()}},[e==null?void 0:e.onNodeContentResize,D,n]),h.useEffect(()=>{if(!Ft)return;const Q=window.setTimeout(()=>{const ge=Se.current;if(!ge)return;ge.focus();const qe=ge.value.length;ge.setSelectionRange(qe,qe)},0);return()=>window.clearTimeout(Q)},[Ft]);const _n=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],We=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],sn=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],xt=((e==null?void 0:e.model)??"").trim(),kn=m==="agent"&&!E.startsWith("tool_nodejs"),pe=new Set(_n.map(pa)),_e=new Set(We.map(pa)),Ve=new Set(sn.map(pa)),rt=xt?xt.startsWith("cursor:")||xt.startsWith("opencode:")||xt.startsWith("claude-code:")?xt:Ve.has(xt)?`claude-code:${xt}`:_e.has(xt)?`opencode:${xt}`:pe.has(xt)?`cursor:${xt}`:xt:"",it=xt&&!rt.startsWith("cursor:")&&!rt.startsWith("opencode:")&&!rt.startsWith("claude-code:")&&!pe.has(xt)&&!_e.has(xt)&&!Ve.has(xt),Mt=xt.startsWith("cursor:")?xt.slice(7):xt.startsWith("opencode:")?xt.slice(9):xt.startsWith("claude-code:")?xt.slice(12):xt,wt=Q=>{if(k)return;const ge=Q.target.value;d&&d(n,ge)},gn=Q=>{Q.stopPropagation(),!k&&r&&r(n)},cn=Q=>{Q.stopPropagation(),s&&s()},Jn=Q=>{Q.stopPropagation(),!k&&(o==null||o(n,Q.target.value==="true"?"true":"false"))},on=Q=>{if(Q.stopPropagation(),k)return;const ge=Q.target.value;Ee(ge),Z.current||o==null||o(n,ge)},An=Q=>{Q.stopPropagation(),Z.current=!0},Pn=Q=>{if(Q.stopPropagation(),k)return;Z.current=!1;const ge=Q.currentTarget.value;Ee(ge),o==null||o(n,ge)},mr=()=>{k||o==null||o(n,ue)},Cr=Q=>{if(Q.stopPropagation(),k)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ue);return}const ge=window.prompt("文件路径",ue);ge!=null&&(Ee(ge),o==null||o(n,ge))},gr=Q=>{Q.stopPropagation(),me(ge=>!ge)},Wt=Q=>{if(je(Q),a==null||a(n,Q),l){const ge=V7(O,Q);(ge.length!==O.length||ge.some((qe,Me)=>{var zt;return qe.id!==((zt=O[Me])==null?void 0:zt.id)}))&&l(n,ge)}},Vt=Q=>{if(Q.stopPropagation(),k)return;const ge=Q.target.value;ee.current?je(ge):Wt(ge)},ir=Q=>{Q.stopPropagation(),!k&&(ee.current=!0,tt(!0))},Er=Q=>{if(Q.stopPropagation(),k)return;ee.current=!1,tt(!1);const ge=Q.currentTarget.value;Wt(ge)},dr=()=>{k||(ee.current=!1,tt(!1),Wt(we))},yr=Q=>{Q.stopPropagation(),Q.preventDefault(),!k&&Ue(!0)},_r=()=>{Ue(!1),dr()},Lr=Q=>{Q.stopPropagation(),Q.key==="Escape"&&(Q.preventDefault(),_r())},or=h.useCallback(Q=>{const ge=ae.current;if(!ge)return;const qe=Math.max(0,ge.scrollHeight-ge.clientHeight);ge.scrollTop=Math.min(1,Math.max(0,Q))*qe,pt()},[pt]),xr=h.useCallback((Q,ge=0)=>{const qe=xe.current;if(!qe)return 0;const Me=qe.getBoundingClientRect(),zt=ze.height/100*Me.height,Rn=Math.max(1,Me.height-zt);return(Q-Me.top-ge)/Rn},[ze.height]),Or=h.useCallback(Q=>{var lt,pn;if(!ze.visible)return;Q.preventDefault(),Q.stopPropagation();const ge=xe.current;if(!ge)return;const qe=ge.getBoundingClientRect(),Me=ze.top/100*qe.height,zt=ze.height/100*qe.height,Hn=Q.clientY>=qe.top+Me&&Q.clientY<=qe.top+Me+zt?Q.clientY-qe.top-Me:zt/2;or(xr(Q.clientY,Hn));const wr=Q.pointerId;(pn=(lt=Q.currentTarget).setPointerCapture)==null||pn.call(lt,wr);const Ae=Zt=>{Zt.preventDefault(),or(xr(Zt.clientY,Hn))},Br=()=>{window.removeEventListener("pointermove",Ae),window.removeEventListener("pointerup",Br),window.removeEventListener("pointercancel",Br)};window.addEventListener("pointermove",Ae),window.addEventListener("pointerup",Br),window.addEventListener("pointercancel",Br)},[xr,ze.height,ze.top,ze.visible,or]),ws=async Q=>{if(k)return;const ge=await vR({files:Q,body:we,images:O});ge&&(je(ge.body),a==null||a(n,ge.body),l==null||l(n,ge.images))},ar=(Q,ge)=>{if(Q.stopPropagation(),k)return;const qe=O.filter(zt=>zt.id!==ge.id),Me=fU(we,ge.label);je(Me),a==null||a(n,Me),l==null||l(n,qe)},Ar=Q=>{if(k)return;const ge=bR(Q);ge.length!==0&&(Q.preventDefault(),Q.stopPropagation(),ws(ge).catch(()=>{}))},In=Q=>{if(k)return;const ge=np(Q);ge.length!==0&&(Q.preventDefault(),Q.stopPropagation(),ws(ge).catch(()=>{}))},Tn=()=>{const Q=ae.current,ge=fe.current;!Q||!ge||(ge.scrollTop=Q.scrollTop,ge.scrollLeft=Q.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(x==="success"?" af-flow-node--done":"")+(x==="failed"?" af-flow-node--failed":"")+(x==="running"&&!y?" af-flow-node--running-disk":"")+(b?" af-flow-node--dim":"")+(D?" af-flow-node--inline-body-editor":"")+($?" af-flow-node--provide-text":"")+(K?" af-flow-node--provide-password":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${F}${n?` (${n})`:""}${g?` · ${g}`:""}`,children:F}),!w&&kn&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:mn,onMouseDown:mn,onClick:mn,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:rt,onChange:wt,onPointerDown:mn,onMouseDown:mn,onClick:mn,"aria-label":p("flow:node.model"),title:Mt||p("flow:node.defaultModel"),disabled:k,children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),it&&i.jsx("option",{value:xt,children:xt}),_n.length>0&&i.jsx("optgroup",{label:"Cursor",children:_n.map(Q=>i.jsx("option",{value:`cursor:${pa(Q)}`,children:pa(Q)},`c-${Q}`))}),We.length>0&&i.jsx("optgroup",{label:"OpenCode",children:We.map(Q=>i.jsx("option",{value:`opencode:${pa(Q)}`,children:pa(Q)},`o-${Q}`))}),sn.length>0&&i.jsx("optgroup",{label:"Claude Code",children:sn.map(Q=>i.jsx("option",{value:`claude-code:${pa(Q)}`,children:pa(Q)},`cc-${Q}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),y&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),x==="running"&&!y&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),x==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:j!=null&&String(j).trim()!==""?j:"--"}),x==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!w&&N&&!T&&!$&&!z&&!K&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:cn,"aria-label":p("flow:node.expandProvide"),title:p("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!w&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:k,onClick:gn,"aria-label":p("flow:node.deleteNode"),title:p("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((Q,ge)=>{if(Q.showOnNode===!1)return null;const qe=p("flow:node.inputTooltip",{name:Q.name||`#${ge}`,type:Q.type})+(Q.default!=null&&Q.default!==""?p("flow:node.defaultSuffix",{value:Q.default}):""),Me=Q.name||`#${ge+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:qe,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Me,Q.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${ge}`,className:"af-flow-node__handle",style:{background:qn(Q.type)},title:qe})]},`in-${ge}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[T?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(R?" af-flow-node__bool-select--true":""),value:R?"true":"false",onChange:Jn,onPointerDown:mn,onMouseDown:mn,onClick:mn,"aria-label":"Boolean value",title:R?"true":"false",disabled:k,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):$?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ue,onChange:on,onCompositionStart:An,onCompositionEnd:Pn,onBlur:mr,onPointerDown:mn,onMouseDown:mn,onClick:mn,placeholder:"输入文本",rows:2,readOnly:k}):z?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:mn,onMouseDown:mn,onClick:mn,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ue,onChange:on,onCompositionStart:An,onCompositionEnd:Pn,onBlur:mr,placeholder:"选择或输入文件路径",title:ue||"选择或输入文件路径",readOnly:k}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:k,onClick:Cr,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):K?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:mn,onMouseDown:mn,onClick:mn,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:le?"text":"password",value:ue,onChange:on,onCompositionStart:An,onCompositionEnd:Pn,onBlur:mr,placeholder:"输入密码或密钥",title:le?ue:"密码已隐藏",autoComplete:"off",readOnly:k}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:k,onClick:gr,"aria-label":le?"隐藏密码":"预览密码",title:le?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:le?"visibility_off":"visibility"})})]}):D?i.jsxs("div",{ref:V,className:"af-flow-node__prompt-stack nodrag"+(Ye?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:fe,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:pU(we)+`
127
- `}}),i.jsx("textarea",{ref:ae,className:"af-flow-node__prompt-editor nodrag",value:we,onChange:Vt,onCompositionStart:ir,onCompositionEnd:Er,onBlur:dr,onPaste:Ar,onDrop:In,onScroll:Q=>{Tn(),pt()},onPointerDown:mn,onMouseDown:mn,onClick:mn,onKeyDown:mn,onDragOver:Q=>{np(Q).length>0&&Q.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:k}),!k&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:mn,onMouseDown:mn,onClick:yr,"aria-label":"放大编辑",title:"放大编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsx("div",{ref:xe,className:"af-flow-node__prompt-scrollbar"+(ze.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:Or,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${ze.height}%`,top:`${ze.top}%`}})})]}):null,D&&O.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:O.map((Q,ge)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:Q.name,children:[i.jsx("img",{src:Q.dataUrl,alt:""}),i.jsxs("span",{children:["[",Q.label||`image ${ge+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:k,onClick:qe=>ar(qe,Q),onPointerDown:mn,onMouseDown:mn,"aria-label":`删除 ${Q.label||`image ${ge+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},Q.id||ge))}):null,P?i.jsx("span",{className:"af-flow-node__prompt-preview",title:P,children:P}):null,_?null:i.jsx("span",{className:"af-flow-node__body-title",title:F,children:F})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:f.map((Q,ge)=>{if(Q.showOnNode===!1)return null;const qe=p("flow:node.outputTooltip",{name:Q.name||`#${ge}`,type:Q.type})+(Q.default!=null&&Q.default!==""?p("flow:node.defaultSuffix",{value:Q.default}):""),Me=Q.name||`#${ge+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:qe,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Me,Q.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${ge}`,className:"af-flow-node__handle",style:{background:qn(Q.type)},title:qe})]},`out-${ge}`)})})]}),Ft?Ir.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:mn,onMouseDown:mn,onClick:mn,onWheel:mn,children:i.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[i.jsxs("div",{className:"af-flow-node-full-editor__header",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-flow-node-full-editor__title",children:F}),i.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),i.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:_r,"aria-label":"关闭",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("textarea",{ref:Se,className:"af-flow-node-full-editor__textarea",value:we,onChange:Vt,onCompositionStart:ir,onCompositionEnd:Er,onPaste:Ar,onDrop:In,onKeyDown:Lr,onDragOver:Q=>{np(Q).length>0&&Q.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",readOnly:k})]})}),document.body):null]})}const $c="flowNode";function _R(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 Yg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function mU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function AR({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=zn(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[p,u]=h.useState(!1),[f,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const y=requestAnimationFrame(()=>{var b;return(b=l.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),w=g===n;async function k(y){if(y.preventDefault(),!(!w||p)){u(!0),m("");try{const b=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),x=await b.json().catch(()=>({}));if(!b.ok){m(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(b){m(String((b==null?void 0:b.message)||b))}finally{u(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!w})]}),f?i.jsx("p",{className:"af-err af-new-pipeline-err",children:f}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function P1({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:o=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:p}){const{t:u}=zn(),f=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var x;return(x=m.current)==null?void 0:x.focus()});function b(x){x.key==="Escape"&&p(),x.key==="Enter"&&d()}return window.addEventListener("keydown",b),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",b)}},[e,p,d]),!e)return null;const g=r??u("common:common.confirm","确定"),w=s??u("common:common.cancel","取消"),k=t??u("common:common.confirmTitle","请确认");return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&p()},children:i.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:k}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:p,"aria-label":w,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[i.jsx("p",{className:"af-new-pipeline-lead",children:n}),i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:p,children:w}),a&&c?i.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,i.jsx("button",{type:"button",className:o?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function PR({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:o}){const{t:a}=zn(),l=h.useId(),c=h.useRef(null),[d,p]=h.useState(""),[u,f]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;p(""),g(""),f(!1);const b=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(b)},[e,n]),!e)return null;const w=d.trim(),k=w===n;async function y(b){if(b.preventDefault(),!k||u)return;f(!0),g("");let x=null;try{const j=new AbortController;x=setTimeout(()=>j.abort(),15e3);const E=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:w,flowArchived:s}),signal:j.signal}),N=await E.json().catch(()=>({}));if(!E.ok){g(typeof N.error=="string"?N.error:a("project:deleteModal.deleteFailed"));return}try{for(let T=localStorage.length-1;T>=0;T--){const $=localStorage.key(T);$&&($.startsWith(`af:composer-sessions:${n}:${r}`)||$.startsWith(`af:composer-active-session:${n}:${r}`)||$.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem($)}}catch{}await o()}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{x&&clearTimeout(x),f(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&t()},children:i.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:b=>p(b.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":w.length>0&&!k})]}),m?i.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function gU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Ui({keys:e}){return i.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>i.jsxs("span",{children:[n>0?i.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,i.jsx(gU,{children:t})]},n))})}function IR({open:e,onClose:t}){const{t:n}=zn(),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 o=mU()?"⌘":"Ctrl";return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:i.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body",children:[i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),i.jsx(Ui,{keys:[o,"S"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),i.jsx(Ui,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Ui,{keys:[o,"K"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),i.jsx(Ui,{keys:["A"]})]})]})]}),i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),i.jsx(Ui,{keys:["V"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),i.jsx(Ui,{keys:["H"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),i.jsx(Ui,{keys:["Space"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),i.jsx(Ui,{keys:["F"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),i.jsx(Ui,{keys:[o,"A"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),i.jsx(Ui,{keys:[o,"Z"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),i.jsx(Ui,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function yU(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:o.includes(n)?15:0}function TR({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=zn(),[o,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),p=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var w;return(w=d.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(g)},[e]);const u=h.useMemo(()=>{const g=(r||[]).map(y=>{var b,x,j;return{id:y.id,label:((b=y.data)==null?void 0:b.label)||"",definitionId:((x=y.data)==null?void 0:x.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),w=o.trim(),k=g.map(y=>({e:y,s:yU(y,w)})).filter(y=>y.s>0);return k.sort((y,b)=>b.s-y.s||y.e.id.localeCompare(b.e.id)),k.slice(0,50).map(y=>y.e)},[r,o]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var w;const g=(w=p.current)==null?void 0:w.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const f=g=>{const w=u[g];w&&(n(w.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(w=>Math.min(u.length-1,w+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(w=>Math.max(0,w-1));return}g.key==="Enter"&&(g.preventDefault(),f(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-jump-panel__input-wrap",children:[i.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:g=>{a(g.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:p,className:"af-jump-panel__list",role:"listbox",children:u.map((g,w)=>i.jsxs("li",{"data-idx":w,role:"option","aria-selected":w===l,className:"af-jump-panel__item"+(w===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(w),onMouseDown:k=>{k.preventDefault(),f(w)},children:[i.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&i.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),i.jsxs("div",{className:"af-jump-panel__hint",children:[i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"↑"}),i.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function xU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:o,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=zn(),p=h.useId(),u=h.useRef(null),f=h.useRef(null),[m,g]=h.useState(""),[w,k]=h.useState(""),[y,b]=h.useState(!1),[x,j]=h.useState(!1),[E,N]=h.useState(!1),[T,$]=h.useState(""),[z,K]=h.useState("");if(h.useEffect(()=>{if(!e||!o)return;g(""),k(""),$(""),K(""),b(!0),j(!1),N(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o});(async()=>{try{const P=await fetch(`/api/pipeline-file-content?${I}`),O=await P.json();if(!P.ok)throw new Error(O.error||"HTTP "+P.status);g(O.content||""),k(O.content||"")}catch(P){$(P.message||String(P))}finally{b(!1)}})();const F=requestAnimationFrame(()=>{var P;return(P=u.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(F)},[e,o,n,r,s]),!e)return null;const B=m!==w;async function L(I){if(I.preventDefault(),!x){j(!0),$(""),K("");try{const F=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o}),P=await fetch(`/api/pipeline-file-save?${F}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),O=await P.json();if(!P.ok)throw new Error(O.error||"HTTP "+P.status);k(m),K(d("flow:fileEdit.saved")),l&&l()}catch(F){$(F.message||String(F))}finally{j(!1)}}}async function D(){if(!(!c||E||!m)){N(!0),$("");try{const I=await c(m);typeof I=="string"&&I&&g(I)}catch(I){$(I.message||String(I))}finally{N(!1)}}}function R(){g(w),$(""),K("")}const M=m.length>1e5;return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:i.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:a||o}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-file-edit-body",children:y?i.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):T&&!m?i.jsx("div",{className:"af-file-edit-error",children:T}):i.jsxs(i.Fragment,{children:[M&&i.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),i.jsx("textarea",{ref:f,className:"af-file-edit-textarea",value:m,onChange:I=>g(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(T||z)&&!y&&i.jsx("div",{className:`af-file-edit-status${z?" af-file-edit-status--success":""}`,children:z||T}),i.jsxs("div",{className:"af-file-edit-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:R,disabled:!B||x||E,children:d("flow:fileEdit.reset")}),c&&i.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:D,disabled:E||x||!m,children:d(E?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),i.jsx("button",{type:"button",className:"af-btn-primary",onClick:L,disabled:!B||x||E,children:d(x?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const RR=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),wU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function bU(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 vU(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 I1(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 MR(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(RR.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 LR(e){return{inputNames:I1(e==null?void 0:e.inputs),outputNames:I1(e==null?void 0:e.outputs)}}function kU(e,t,n){const r=LR(t),s=vU(e),o=[];for(const a of s)if(!MR(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function SU(e,t){const n=LR(t),r=/\$\{([^}]*)\}/g,s=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&s.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=MR(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&s.push({kind:"plain",text:e.slice(o)}),s}function NU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function jU(e){return e.map(t=>{const n=NU(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 CU(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of wU)RR.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function EU(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function _U(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;s.style.width=`${o}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),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 mm({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:p}=zn(),u=h.useId(),f=h.useRef(null),m=h.useRef(null),[g,w]=h.useState(0),[k,y]=h.useState(0),[b,x]=h.useState(null),j=h.useMemo(()=>Vs(c),[c]),E=h.useMemo(()=>kU(e,a,p),[e,a,p]),N=E.length>0,T=h.useMemo(()=>SU(e,a),[e,a]),$=h.useMemo(()=>jU(T),[T]),z=h.useMemo(()=>n?null:bU(e,g),[e,g,n]),K=h.useMemo(()=>{if(!z)return[];const I=CU(a,p);return EU(I,z.query)},[z,a,p]);h.useEffect(()=>{y(I=>{const F=Math.max(0,K.length-1);return Math.min(Math.max(0,I),F)})},[K.length]);const B=h.useCallback(()=>{const I=f.current;if(!I||!z||K.length===0){x(null);return}const F=_U(I,g);if(!F){x(null);return}const P=4,O=44,_=13.5*16,Z=Math.min(K.length*O+8,_);let ee=F.bottom+P;ee+Z>window.innerHeight-8&&(ee=Math.max(8,F.top-Z-P));const V=288;let ae=F.left;ae=Math.max(8,Math.min(ae,window.innerWidth-V-8)),x({top:ee,left:ae})},[z,K.length,g]);h.useLayoutEffect(()=>{if(!z||K.length===0){x(null);return}const I=requestAnimationFrame(()=>B());return()=>cancelAnimationFrame(I)},[z,K.length,g,e,B]),h.useEffect(()=>{if(!z||K.length===0)return;const I=()=>B();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[z,K.length,B]);const L=h.useCallback(I=>{if(!z)return;const{atIndex:F}=z,P=e.slice(0,F)+"${"+I+"}"+e.slice(g);t(P);const O=F+I.length+3;queueMicrotask(()=>{const _=f.current;_&&(_.focus(),_.setSelectionRange(O,O)),w(O)})},[z,e,g,t]),D=h.useCallback(()=>{const I=f.current,F=m.current;!I||!F||(F.scrollTop=I.scrollTop,F.scrollLeft=I.scrollLeft,z&&K.length>0&&queueMicrotask(()=>B()))},[z,K.length,B]),R=h.useCallback(I=>{if(!n&&z&&K.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),y(F=>(F+1)%K.length);else if(I.key==="ArrowUp")I.preventDefault(),y(F=>(F-1+K.length)%K.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const F=K[k];F&&L(F.insert)}}},[n,z,K,k,L]),M=h.useCallback(async I=>{if(n||typeof d!="function")return!1;const F=await vR({files:I,body:e,images:j});return F?(t(F.body),d(F.images),queueMicrotask(()=>{const P=f.current;if(!P)return;P.focus();const O=F.body.length;P.setSelectionRange(O,O),w(O)}),!0):!1},[n,j,t,d,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((I,F)=>i.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[i.jsx("img",{src:I.dataUrl,alt:""}),i.jsxs("span",{children:["[",I.label||`image ${F+1}`,"]"]})]},I.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:$+`
128
- `}}),i.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?u:void 0,onChange:I=>{t(I.target.value),w(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onClick:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onKeyUp:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??F.value.length)},onKeyDown:R,onPaste:I=>{const F=bR(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onDragOver:I=>{np(I).length>0&&I.preventDefault()},onDrop:I=>{const F=np(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onScroll:D})]}),z&&K.length>0&&b?Ir.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:K.map((I,F)=>i.jsx("li",{role:"option","aria-selected":F===k,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(F),onClick:()=>L(I.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,N?i.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:E.map(I=>I.message).join(" · ")}):null]})}const OR=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function gm(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function T1({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=zn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((f,m)=>m!==u)),d=(u,f,m)=>{const g=n.map((w,k)=>{if(k!==u)return w;const y={...w,[f]:m};return f==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((u,f)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(f,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(m=>i.jsx("option",{value:m,children:m},m))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(f,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(f,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.description||"",onChange:m=>d(f,"description",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{o||d(f,"required",m.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(f,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(f),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:f}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function $R({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:p,ioSlots:u}){const{t:f}=zn(),[m,g]=h.useState(!1),[w,k]=h.useState(!1),[y,b]=h.useState({status:"idle",message:""}),x=h.useCallback(L=>{t(D=>D&&{...D,...L})},[t]),{cursorList:j,opencodeList:E,claudeCodeList:N,currentNotInLists:T}=h.useMemo(()=>{const L=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],D=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],R=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],M=new Set([...L,...D,...R].map(gm)),I=((e==null?void 0:e.model)??"").trim(),F=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!M.has(F)?I:"";return{cursorList:L,opencodeList:D,claudeCodeList:R,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const $=String(e.script??""),z=n==="tool_nodejs"||$.trim()!=="",K=typeof c=="function"&&!o&&(e==null?void 0:e.newId),B=async()=>{if(K){b({status:"running",message:f("flow:nodeProps.publishRunning")});try{const L=await c(e,n);b({status:"success",message:L!=null&&L.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):f("flow:nodeProps.publishSuccess")})}catch(L){b({status:"error",message:String((L==null?void 0:L.message)||L)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:B,disabled:!K||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?i.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:L=>x({newId:L.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:L=>x({label:L.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Rl.includes(e.role)?e.role:f("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:Rl.map(L=>i.jsx("option",{value:L,children:L},L))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?T||L:""})(),onChange:L=>x({model:L.target.value}),disabled:o,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),T?i.jsxs("option",{value:T,children:[T,f("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map(L=>i.jsx("option",{value:gm(L),children:L},`c-${L}`))}):null,E.length>0?i.jsx("optgroup",{label:"OpenCode",children:E.map(L=>i.jsx("option",{value:gm(L),children:L},`o-${L}`))}):null,N.length>0?i.jsx("optgroup",{label:"Claude Code",children:N.map(L=>i.jsx("option",{value:`claude-code:${gm(L)}`,children:L},`cc-${L}`))}):null]})]}),i.jsx(T1,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!d}),i.jsx(T1,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>x({outputs:L}),disabled:o,requiredReadonly:!d}),z?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(mm,{value:$,onChange:L=>x({script:L}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:L=>x({scriptRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:L=>x({implementationRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:L=>x({implementationMode:L.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":f("flow:nodeProps.expandEdit"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(mm,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),w?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&k(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(mm,{value:$,onChange:L=>x({script:L}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&g(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(mm,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function vk(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 AU(e){const t=vk(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 DR(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function R1({text:e}){const{t}=zn(),n=e||"";return n.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(ah,{children:n})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function M1({o:e}){var r;const{t}=zn(),n=vk(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return i.jsxs("div",{className:"af-run-ctx-media",children:[i.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return i.jsx("pre",{className:"af-run-ctx-pre",children:DR(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(ah,{children:s})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return i.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function L1(e){return AU(e)}function O1(e){var r;if(!e)return null;const t=vk(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"?DR(String(n)):String(n)}function $1({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:i.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const D1=2e4,FR="af:run-node-ctx-width";function Jm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function hl(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):hl(Jm())}function PU(){try{const e=localStorage.getItem(FR);if(e==null)return hl(Jm());const t=parseInt(e,10);return Number.isFinite(t)?hl(t):hl(Jm())}catch{return hl(Jm())}}async function F1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await o.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(l.error||"HTTP "+o.status);return l}function IU(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function TU({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:o}=zn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(PU),p=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,f]=h.useState(!0),[m,g]=h.useState(""),[w,k]=h.useState([]),[y,b]=h.useState(null),[x,j]=h.useState(null),E=h.useRef(null),N=h.useRef(null),T=h.useRef(0),$=h.useRef(0);h.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),O=()=>l(P.matches);return P.addEventListener("change",O),()=>P.removeEventListener("change",O)},[]),h.useEffect(()=>{function P(){d(O=>hl(O))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const z=h.useCallback(()=>{d(P=>{const O=hl(P);try{localStorage.setItem(FR,String(O))}catch{}return O})},[]),K=h.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const O=P.currentTarget;p.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},O.setPointerCapture(P.pointerId)},[a,c]),B=h.useCallback(P=>{const O=p.current;if(!O.active||P.pointerId!==O.pointerId)return;const _=O.startX-P.clientX;d(hl(O.startW+_))},[]),L=h.useCallback(P=>{const O=p.current;if(!(!O.active||P.pointerId!==O.pointerId)){O.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}z()}},[z]),D=h.useCallback(()=>{const P=p.current;P.active&&(P.active=!1,z())},[z]),R=h.useCallback(P=>{const O=Array.isArray(P)?P:[];k(O),b(_=>_&&O.some(Z=>Z.execId===_)?_:O.length>0?O[O.length-1].execId:null)},[]),M=h.useCallback(()=>{if(!e||!t)return;const P=++T.current,O=new AbortController,_=window.setTimeout(()=>O.abort(),D1);(async()=>{try{const Z=await F1(t,e,n,O.signal);if(P!==T.current)return;R(Array.isArray(Z.rounds)?Z.rounds:[])}catch{}finally{window.clearTimeout(_)}})()},[e,t,n,R]);h.useEffect(()=>{if(!e||!t){f(!1),g(""),k([]);return}const P=++$.current;f(!0),g(""),k([]),b(null);const O=new AbortController,_=window.setTimeout(()=>O.abort(),D1);return(async()=>{try{const Z=await F1(t,e,n,O.signal);if(P!==$.current)return;R(Array.isArray(Z.rounds)?Z.rounds:[])}catch(Z){if(P!==$.current)return;const ee=(Z==null?void 0:Z.name)==="AbortError"?"requestTimeout":Z.message||String(Z);g(ee)}finally{window.clearTimeout(_),P===$.current&&f(!1)}})(),()=>{O.abort(),$.current++,T.current++}},[e,t,n,R]),h.useEffect(()=>{r&&M()},[r,M]),h.useEffect(()=>{clearInterval(N.current);const P=w.length>0?w[w.length-1]:null;return(r==="running"&&w.length===0||!!(P&&P.status==="running"))&&e&&t&&(N.current=setInterval(()=>M(),2e3)),()=>clearInterval(N.current)},[w,e,t,n,r,M]),h.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[y]);const I=w.find(P=>P.execId===y),F=a?void 0:{width:`${c}px`};return i.jsxs("aside",{className:"af-run-ctx-panel",style:F,"aria-label":o("flow:runContext.title"),children:[a?null:i.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:K,onPointerMove:B,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:D}),i.jsxs("div",{className:"af-run-ctx-panel__main",children:[i.jsxs("div",{className:"af-run-ctx-head",children:[i.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),m&&i.jsx("div",{className:"af-run-ctx-error",children:IU(o,m)}),!u&&!m&&w.length===0&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),w.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+MU((I==null?void 0:I.status)||""),children:[i.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),i.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const O=P.target.value;b(O==="latest"?"latest":Number(O))},children:[...w].reverse().map(P=>{const O=P.execId==="latest"?o("flow:runContext.latest"):`#${P.execId}`,_=LU(o,P.status),Z=P.finishedAt?` · ${RU(P.finishedAt)}`:"";return i.jsx("option",{value:String(P.execId),children:`${O} · ${_}${Z}`},P.execId)})})]}),I&&i.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[I.inputs&&I.inputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,O)=>i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsx("div",{className:"af-run-ctx-slot-head",children:i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),i.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${O}`))]}),I.prompt!=null&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(R1,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,O)=>{const _=L1(P),Z=O1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:_}):null,i.jsx($1,{text:Z,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${O}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),x&&I&&i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&j(null)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&i.jsx(R1,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((P,O)=>{const _=L1(P),Z=O1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",children:_}):null,i.jsx($1,{text:Z,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${O}`)})]})]})})]})}function RU(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 MU(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 LU(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 OU({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:o,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=zn(),[d,p]=h.useState({}),[u,f]=h.useState(null),[m,g]=h.useState({}),[w,k]=h.useState(!0),[y,b]=h.useState(!1),[x,j]=h.useState(""),[E,N]=h.useState(!1),[T,$]=h.useState(null),z=h.useRef(null),K=h.useRef(!0),B=h.useRef({});h.useMemo(()=>{var _,Z,ee;const O={};for(const V of r){const ae=(ee=(Z=(_=V.data)==null?void 0:_.outputs)==null?void 0:Z[0])==null?void 0:ee.default;ae!=null&&ae!==""&&(O[V.id]=String(ae))}return B.current=O,O},[r]);const L=h.useMemo(()=>{var _;const O={};for(const Z of o){if(!((_=Z.data)!=null&&_.inputs))continue;const ee=Z.data.inputs;for(let V=0;V<ee.length;V++){const ae=ee[V];if(!(ae!=null&&ae.name))continue;const fe=s.find(Se=>Se.target===Z.id&&Se.targetHandle===`input-${V}`);if(!(fe!=null&&fe.source))continue;r.find(Se=>Se.id===fe.source)&&(O[fe.source]=ae.name)}}return O},[o,s,r]);h.useEffect(()=>(K.current=!0,()=>{K.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const O=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&O.set("archived","1"),fetch(`/api/flow/run-config?${O.toString()}`).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{var ee;if(!K.current)return;p(_.presets||{}),f(_.activePreset||null);const Z=_.activePreset&&((ee=_.presets)!=null&&ee[_.activePreset])?_.presets[_.activePreset]:{};g({...B.current,...Z}),k(!1)}).catch(()=>{K.current&&(g(B.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var _;if(!a)return;const O={};for(const[Z,ee]of Object.entries(m)){const V=L[Z];if(!V)continue;const ae=r.find(xe=>xe.id===Z);if(!ae)continue;(((_=ae.data)==null?void 0:_.definitionId)||"").startsWith("provide_file")?O[V]={type:"file",path:ee}:O[V]={type:"str",value:ee}}a(O)},[m,L,r,a]);const D=h.useCallback((O,_)=>{g(Z=>({...Z,[O]:_}))},[]),R=h.useCallback(O=>{O!==u&&(f(O),O&&d[O]?g({...B.current,...d[O]}):g(B.current))},[u,d]),M=h.useCallback(async()=>{if(x.trim()){b(!0);try{const O={...d,[x.trim()]:m},_={flowId:e,flowSource:t,archived:n,presets:O,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).ok&&(p(O),f(x.trim()),j(""),N(!1))}finally{b(!1)}}},[e,t,n,d,m,x]),I=h.useCallback(async()=>{if(u){b(!0);try{const O={...d};delete O[u];const _=Object.keys(O)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:O,activePreset:_})})).ok&&(p(O),f(_),_&&O[_]?g({...B.current,...O[_]}):g(B.current))}finally{b(!1)}}},[e,t,n,d,u]),F=h.useCallback(async()=>{if(u){b(!0);try{const O={...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:O,activePreset:u})})).ok&&p(O)}finally{b(!1)}}},[e,t,n,d,u,m]),P=Object.keys(d);return P.length>0,w?i.jsx("aside",{className:"af-run-config-panel",children:i.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):i.jsxs("aside",{className:"af-run-config-panel",children:[i.jsxs("div",{className:"af-run-config-preset",children:[i.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),i.jsxs("div",{className:"af-run-config-preset-row",children:[i.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:O=>R(O.target.value||null),disabled:y,children:[i.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(O=>i.jsx("option",{value:O,children:O},O))]}),i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>N(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:F,disabled:y,title:c("flow:runConfig.savePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:c("flow:runConfig.deletePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&i.jsxs("div",{className:"af-run-config-save-dialog",children:[i.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:x,onChange:O=>j(O.target.value),disabled:y}),i.jsxs("div",{className:"af-run-config-save-actions",children:[i.jsx("button",{type:"button",className:"af-btn-primary",onClick:M,disabled:y||!x.trim(),children:c(y?"common.saving":"common.save")}),i.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{N(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),i.jsxs("div",{className:"af-run-config-inputs",children:[i.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?i.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):i.jsx("div",{className:"af-run-config-input-list",children:r.map(O=>{var Se,ue;const _=((Se=O.data)==null?void 0:Se.definitionId)||"",Z=_.startsWith("provide_file"),ee=_==="provide_bool",V=((ue=O.data)==null?void 0:ue.label)||O.id,ae=O.id,fe=m[ae]||"",xe=["true","1","yes","on"].includes(String(fe).trim().toLowerCase());return i.jsxs("div",{className:"af-run-config-input-item",children:[i.jsxs("div",{className:"af-run-config-input-head",children:[i.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(Z?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:Z?"description":ee?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-config-input-label",children:V}),ee?null:i.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>$({instanceId:ae,label:V,content:fe}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx("div",{className:"af-run-config-input-id",children:ae}),ee?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(xe?" af-run-config-bool-toggle--true":""),onClick:()=>D(ae,xe?"false":"true"),"aria-pressed":xe,children:xe?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-config-input-field",value:fe,onChange:Ee=>D(ae,Ee.target.value),placeholder:c(Z?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ae)})})]}),T&&Ir.createPortal(i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>$(null),"aria-label":c("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:z,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!z.current||(D(T.instanceId,z.current.value),$(null))},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>$(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const zR={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"]},$U={"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 DU(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function FU(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 zU(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 z1(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(zR))if(r.includes(e))return n;return"other"}function HU({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=$U[e.tag]||"#a8a8a8",o=e.payload,a=o&&typeof o=="object",l=a?typeof o.text=="string"?o.text:"":String(o||""),c=a?o.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(o).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=o[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[o,l,a]),p=h.useCallback(u=>{u.stopPropagation();const f=a?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(f)}catch{}},[o,a]);return i.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[i.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[i.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:FU(e.ts)}),i.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),i.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&i.jsx("button",{type:"button",onClick:p,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&i.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&i.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(o,null,2)}):null]})]})}function BU({open:e,onClose:t,flowId:n}){var $;const[r,s]=h.useState([]),[o,a]=h.useState(!1),[l,c]=h.useState(null),[d,p]=h.useState(null),[u,f]=h.useState(!1),[m,g]=h.useState(!0),[w,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=h.useState(""),x=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const z=m&&n?`?flowId=${encodeURIComponent(n)}`:"",B=await(await fetch(`/api/composer-logs${z}`)).json();s(Array.isArray(B.sessions)?B.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),E=h.useCallback(async z=>{if(!z){p(null);return}f(!0);try{const B=await(await fetch(`/api/composer-logs/${encodeURIComponent(z)}`)).json();p(B)}catch{p(null)}finally{f(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return E(l),x.current=setInterval(()=>E(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,E]);const N=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K=y.trim().toLowerCase();return z.filter(B=>{const L=z1(B.tag,B.payload);return!w[L]&&L!=="other"?!1:K?[B.tag,JSON.stringify(B.payload||"")].join(" ").toLowerCase().includes(K):!0})},[d,w,y]),T=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K={};for(const B of z){const L=z1(B.tag,B.payload);K[L]=(K[L]||0)+1}return K},[d]);return e?i.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[i.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),i.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),i.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:m,onChange:z=>g(z.target.checked),disabled:!n}),"仅显示当前 flow"]}),i.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"}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(z=>{const K=l===z.sessionId;return i.jsxs("div",{onClick:()=>c(z.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:K?"rgba(124,77,255,0.18)":"transparent",borderLeft:K?"3px solid #7c4dff":"3px solid transparent"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:zU(z.mtime)}),i.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:z.flowId||"(no flow)"}),z.promptPreview&&i.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:z.promptPreview}),i.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[DU(z.size)," · ",z.model||"default"]})]},z.sessionId)})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(zR).map(z=>i.jsxs("button",{type:"button",onClick:()=>k(K=>({...K,[z]:!K[z]})),style:{background:w[z]?"rgba(124,77,255,0.25)":"transparent",color:w[z]?"#e8deff":"#6a6a6a",border:`1px solid ${w[z]?"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:[z," ",T[z]!=null?`(${T[z]})`:""]},z)),i.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:z=>b(z.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&N.length===0&&i.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",(($=d.events)==null?void 0:$.length)||0," total)"]}),N.map((z,K)=>i.jsx(HU,{event:z,defaultExpanded:z.tag==="error"},`${z.ts}_${K}`))]})]})]})]}):null}const WU="0.1.83";function H1(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 xw(e,t){return t==="running"?H1(e):e==null||!Number.isFinite(e)||e<=0?"--":H1(e)}const HR=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function VU(e){var b,x,j,E,N,T,$,z,K,B,L;const{setNodes:t}=Hl(),n=J0(),{modelLists:r,onModelChange:s}=h.useContext(HR),o=h.useRef(null),a=!!((b=e.data)!=null&&b.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((E=e.data)!=null&&E.isRunMode)&&!a,d=h.useCallback(D=>{const R=()=>n(D);window.requestAnimationFrame(R),window.setTimeout(R,80)},[n]),p=h.useCallback((D,R)=>{const M=G1(R);M&&(t(I=>I.map(F=>{var _,Z,ee,V,ae,fe;if(F.id!==D)return F;const P=Number(((Z=(_=F.data)==null?void 0:_.displaySize)==null?void 0:Z.width)||F.width||((ee=F.measured)==null?void 0:ee.width)||0),O=Number(((ae=(V=F.data)==null?void 0:V.displaySize)==null?void 0:ae.height)||F.height||((fe=F.measured)==null?void 0:fe.height)||0);return Math.abs(P-M.width)<2&&Math.abs(O-M.height)<2?F:{...F,width:M.width,height:M.height,data:{...F.data,displaySize:M}}})),d(D))},[d,t]),u=h.useCallback(D=>{if(a)return;const R=o.current;if(!R)return;const M=R.getBoundingClientRect();p(D,{width:Math.max(M.width,R.scrollWidth),height:Math.max(M.height,R.scrollHeight)})},[p,a]),f=h.useCallback(D=>{var ae,fe,xe,Se,ue,Ee;if(!c)return;D.preventDefault(),D.stopPropagation();const R=o.current,M=R==null?void 0:R.getBoundingClientRect(),I=Number(((fe=(ae=e.data)==null?void 0:ae.displaySize)==null?void 0:fe.width)||e.width||((xe=e.measured)==null?void 0:xe.width)||(M==null?void 0:M.width)||KR),F=Number(((ue=(Se=e.data)==null?void 0:Se.displaySize)==null?void 0:ue.height)||e.height||((Ee=e.measured)==null?void 0:Ee.height)||(M==null?void 0:M.height)||vv),P=D.clientX,O=D.clientY,_=e.id;let Z=0;const ee=le=>{const me=G1({width:I+le.clientX-P,height:F+le.clientY-O});me&&(window.cancelAnimationFrame(Z),Z=window.requestAnimationFrame(()=>p(_,me)))},V=()=>{window.cancelAnimationFrame(Z),window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(_)};window.addEventListener("pointermove",ee),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[p,(T=(N=e.data)==null?void 0:N.displaySize)==null?void 0:T.height,(z=($=e.data)==null?void 0:$.displaySize)==null?void 0:z.width,e.height,e.id,(K=e.measured)==null?void 0:K.height,(B=e.measured)==null?void 0:B.width,e.width,d,c]),m=h.useCallback(D=>{t(R=>R.filter(M=>M.id!==D))},[t]),g=h.useCallback(()=>{var I,F,P,O,_,Z,ee,V;const D=((I=e.data)==null?void 0:I.definitionId)||"",R=((F=e.data)==null?void 0:F.label)||e.id,M=((_=(O=(P=e.data)==null?void 0:P.outputs)==null?void 0:O[0])==null?void 0:_.value)||((V=(ee=(Z=e.data)==null?void 0:Z.outputs)==null?void 0:ee[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:R,definitionId:D,content:M},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),w=h.useCallback((D,R)=>{t(M=>M.map(I=>{var P;if(I.id!==D)return I;const F=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((O,_)=>_===0?{...O,default:R,value:R}:O):[{type:"bool",name:"value",default:R,value:R}];return{...I,data:{...I.data,body:"",outputs:F}}}))},[t]),k=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,body:R}}:I))},[t]),y=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,images:Vs(R)}}:I))},[t]);return i.jsxs("div",{ref:o,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[i.jsx(ER,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:w,onNodeBodyChange:k,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?i.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((L=e.data)==null?void 0:L.resizeLabel)||"Resize node",role:"separator",onPointerDown:f}):null]})}const KU={[$c]:VU},Lf=["CONTROL","TOOL","PROVIDE","AGENT"],UU=1200,B1="af-flow-node--sync-flash",W1="af-flow-edge--sync-flash";function V1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function K1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function kk(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 qU(e){const t=kk(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function ym(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function BR(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function WR(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function ww(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 U1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function q1(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 YU(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function GU(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 VR(e,t,n,r,s){const o=qU(e),a={id:t,type:$c,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:o,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return zp(a,r,s)}const KR=320,XU=220,JU=1600,vv=104,QU=900;function Y1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function G1(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:Y1(t,XU,JU)||KR,height:Y1(n,vv,QU)||vv}}function ZU(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function X1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),o=s.get(n),a=s.get(r),l=jd(o,e.sourceHandle||"output-0","source"),c=jd(a,e.targetHandle||"input-0","target");return!l||!c?!1:Ml(l,c)}function eq(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=jd(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:CR(a)}:null}function tq(e,t,n){var a;const r=VR(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",o=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<o.length;l+=1){const c=o[l];if(n.handleType==="source"?Ml(n.slot,c):Ml(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function nq(e,t){return t?e.map((n,r)=>{const s=tq(n,e,t);if(!s)return null;const o=kk(n);return{def:n,order:r,category:o,categoryRank:Lf.indexOf(o),slot:s.slot,slotIndex:s.slotIndex,displayLabel:BR(s.hydrated.data||n),description:WR(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const rq=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function sq(e){const t=new Set,n=[];let r;const s=new RegExp(rq.source,"g");for(;(r=s.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function J1(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 ga(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function xm(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const o=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=o.map(ga),d=a.map(ga);return l.map(ga).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function iq(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function bw(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 oq({steps:e}){const{t}=zn();return!e||e.length===0?null:i.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
- `),a=n.status||"pending";return i.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:o,children:[i.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),i.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?i.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?i.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?i.jsx("span",{className:"af-composer-step-chip-model",children:iq(s)}):null]}):null})]},n.index)})})}function aq(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 lq(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",o=t[t.length-1];o&&o.kind===s?o.text+=s==="error"||s==="result"?`
130
- ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function cq(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 uq(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 Q1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:o}=zn(),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]),i.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:o("flow:composer.yourQuestion")}),i.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(Z1,{segments:c.segments,running:!1})},`composer-a-${d}`)),i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(Z1,{segments:t,running:n})})]})}function Z1({segments:e,running:t=!1}){const{t:n}=zn(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),o=aq(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
131
- `),l=e.filter(u=>u.kind!=="error"),c=o?l.filter(u=>u.kind!=="result"):l,d=lq(c),p=!!(d.length>0||a);return i.jsxs(i.Fragment,{children:[d.map((u,f)=>i.jsxs("section",{className:uq(u.kind),children:[i.jsx("div",{className:"af-composer-ai-block-label",children:cq(u.kind,n)}),i.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${f}`)),t&&!p?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),i.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),i.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function dq({fitViewEpoch:e}){const{fitView:t}=Hl(),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 fq({onReady:e}){const t=J0();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function eC(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function tC(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 Qm=1500,nC=500,pq=262144,hq=2e3;function vw(e){return typeof e!="string"?"":e.length<=hq?e:`[log line truncated, ${e.length} chars]`}const mq=Qm;function gq(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const o=JSON.parse(s);return o&&o.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${o.instanceId||""}${o.label?` · ${o.label}`:""} 开始`}:o&&o.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${o.instanceId||""} 完成${o.elapsed?` (${o.elapsed})`:""}`}:o&&o.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${o.instanceId||""} 失败${o.error?`: ${o.error}`:""}`}:o&&o.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${o.uuid||""}`}:{ts:n,type:"info",text:vw(s)}}catch{return{ts:n,type:"info",text:vw(s)}}return{ts:n,type:"log",text:vw(`[${r}] ${s}`)}}function rC(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<mq;r--){const s=n[r];if(!s)continue;const o=gq(s);o&&t.push(o)}return t.reverse(),t}function yq(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const o=e[s],a=t[s];if(!a)return!1;if(o!==a&&(o.status!==a.status||(o.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function xq(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 wq({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:o,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:p,onNodeClick:u,onNodeDoubleClick:f,onEdgeClick:m,onFlowInit:g,onDrop:w,onDragOver:k,hideMinimapAndControls:y,bottomSlot:b}){const{t:x}=zn(),j=!s,E=j||t==="pan"?!0:[1,2],N=j?!1:t==="select",T="af-flow-canvas"+(j?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),$=h.useCallback(()=>{},[]),z=h.useMemo(()=>{const K=new Map(n.map(M=>[M.id,M])),B=new Set(n.filter(M=>M.selected).map(M=>M.id)),L=B.size>0,D=(M,I)=>{const F=/^#([0-9a-f]{6})$/i.exec(M);if(!F)return M;const P=parseInt(F[1],16);return`rgba(${P>>16&255}, ${P>>8&255}, ${P&255}, ${I})`},R="#ff5169";return r.map(M=>{var me,we,je,Ye;const I=K.get(M.source),F=K.get(M.target),P=/^output-(\d+)$/.exec(M.sourceHandle||""),O=/^input-(\d+)$/.exec(M.targetHandle||""),_=I&&P?(we=(me=I.data)==null?void 0:me.outputs)==null?void 0:we[parseInt(P[1],10)]:null,Z=F&&O?(Ye=(je=F.data)==null?void 0:je.inputs)==null?void 0:Ye[parseInt(O[1],10)]:null,ee=_!=null&&_.type?qn(_.type):null,V=Z!=null&&Z.type?qn(Z.type):null,ae=ee&&V&&ee!==V,fe=L&&(B.has(M.source)||B.has(M.target)),xe=M.style||{};if(ae){const tt=M.selected?.95:fe?.85:.78,ze=D(R,tt);return{...M,className:((M.className||"")+" af-flow-edge--type-mismatch"+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...xe,stroke:ze,strokeWidth:fe?2.75:2.5,strokeDasharray:"6 4"},markerEnd:M.markerEnd&&typeof M.markerEnd=="object"?{...M.markerEnd,color:ze}:{type:js.ArrowClosed,color:ze}}}const Se=ee||V;if(!Se)return fe?{...M,className:((M.className||"")+" af-flow-edge--adjacent").trim(),style:{...xe,strokeWidth:2.5}}:M;const ue=fe||M.selected?.7:.38,Ee=D(Se,ue),le=fe?2.5:xe.strokeWidth??2;return{...M,className:((M.className||"")+(fe?" af-flow-edge--adjacent":"")).trim(),style:{...xe,stroke:Ee,strokeWidth:le},markerEnd:M.markerEnd&&typeof M.markerEnd=="object"?{...M.markerEnd,color:Ee}:{type:js.ArrowClosed,color:Ee}}})},[n,r]);return i.jsxs(X0,{className:T,nodes:n,edges:z,onNodesChange:s||$,onEdgesChange:o||$,onConnect:j?void 0:a,onConnectStart:j?void 0:l,onConnectEnd:j?void 0:c,isValidConnection:j?void 0:d,onNodesDelete:j?void 0:p,onNodeClick:u,onNodeDoubleClick:j?void 0:f,onEdgeClick:j?void 0:m,onInit:g,onDrop:j?void 0:w,onDragOver:j?void 0:k,nodeTypes:KU,selectionOnDrag:N,panOnDrag:E,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:[i.jsx(Q0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),i.jsx(Sd,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:i.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:i.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:i.jsx(N4,{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:K=>{var L;const B=(((L=K.data)==null?void 0:L.schemaType)??"agent").toLowerCase();return B==="control"?"rgba(237, 108, 2, 0.85)":B==="provide"?"rgba(0, 228, 117, 0.35)":B==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),i.jsx("div",{className:"af-flow-bottom-unified__center",children:b}),y?null:i.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:i.jsx(d4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&i.jsx(Sd,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:K,color:B})=>i.jsxs("span",{className:"af-pin-legend__item",children:[i.jsx("span",{className:"af-pin-legend__dot",style:{background:B}}),i.jsx("span",{className:"af-pin-legend__label",children:K})]},K))}),i.jsx(dq,{fitViewEpoch:e}),!j&&n.length===0?i.jsxs("div",{className:"af-flow-empty-hint",children:[i.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),i.jsx("p",{className:"af-flow-empty-hint-text",children:x("flow:emptyCanvas.composerHint")}),i.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:x("flow:emptyCanvas.composerSub")}})]}):null]})}function sC(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 bq(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function $s(e){return e==="builtin"||e==="admin"}function Su(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function vq(e){var r,s,o,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const UR="af:run-console-height",sp=230,Sf={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},wm={};function Zm(e){if(!Number.isFinite(e))return sp;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function kq(){try{const e=localStorage.getItem(UR);if(e==null)return sp;const t=parseInt(e,10);return Number.isFinite(t)?Zm(t):sp}catch{return sp}}function Sq(){var qk,Yk;const{t:e,i18n:t}=zn(),{navigate:n,path:r}=Yo(),s=h.useRef(null),o=h.useRef(new Map),a=h.useCallback(v=>{s.current=typeof v=="function"?v:null},[]),[l,c]=h.useState([]),[d,p]=h.useState(""),[u,f]=h.useState(null),[m,g]=h.useState(0),[w,k]=h.useState(""),[y,b]=h.useState(""),[x,j]=h.useState(""),[E,N]=h.useState(""),[T,$]=h.useState(!1),[z,K]=h.useState(""),[B,L]=h.useState(!1),[D,R]=h.useState(""),[M,I]=h.useState(!1),[F,P]=h.useState(!1),[O,_]=h.useState(!1),[Z,ee]=h.useState(null),[V,ae]=h.useState(!1),[fe,xe]=h.useState(!1),Se=h.useRef(!1),[ue,Ee]=h.useState([]),[le,me]=h.useState(""),[we,je]=h.useState("nodes"),Ye=h.useRef(null),[tt,ze]=h.useState([]),[dt,Ft]=h.useState(!1),[Ue,pt]=h.useState(""),[_n,We]=h.useState(!1),[sn,xt]=h.useState({name:"",id:"",description:""}),[kn,pe]=h.useState(!1),[_e,Ve]=h.useState(""),[rt,it]=h.useState(""),Mt=h.useRef(null),[wt,gn]=h.useState([]),[cn,Jn]=h.useState(!1),[on,An]=h.useState(""),[Pn,mr]=h.useState(""),[Cr,gr]=h.useState(null),[Wt,Vt]=h.useState(null),[ir,Er]=h.useState([]),[dr,yr]=h.useState(""),[_r,Lr]=h.useState(!1),or=h.useCallback(v=>{Mt.current&&window.clearTimeout(Mt.current),it(v),Mt.current=window.setTimeout(()=>{it(""),Mt.current=null},3800)},[]),xr=h.useCallback(v=>{const C=String(v||"").trim();if(!C)return;const W=()=>{var Y;return(Y=s.current)==null?void 0:Y.call(s,C)};window.requestAnimationFrame(W),window.setTimeout(W,80)},[]);h.useEffect(()=>()=>{Mt.current&&window.clearTimeout(Mt.current)},[]);const[Or,ws]=h.useState(!1),[ar,Ar]=h.useState({files:[]}),[In,Tn]=h.useState(!1),[ce,he]=h.useState(!0);h.useEffect(()=>{let v=!1;const C=()=>{fetch("/api/flows",{method:"HEAD"}).then(Y=>{v||he(Y.ok)}).catch(()=>{v||he(!1)})};C();const W=window.setInterval(C,5e3);return()=>{v=!0,window.clearInterval(W)}},[]),h.useEffect(()=>{let v=!1;return fetch("/api/dev-info").then(C=>C.json()).then(C=>{v||hi(!!(C!=null&&C.isDev))}).catch(()=>{}),()=>{v=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&($s(u.source)||KA(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]),h.useEffect(()=>{!(u!=null&&u.id)||!$s(u.source)||n(Gf(u,"workspace"))},[n,u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[Q,ge]=h.useState("edit"),[qe,Me]=h.useState([]),zt=h.useRef(0),[Rn,Hn]=h.useState(new Set),[wr,Ae]=h.useState({}),[Br,lt]=h.useState(null),[pn,Zt]=h.useState(0),[br,nt]=h.useState(!1),[os,hi]=h.useState(!1),[Ii,co]=h.useState(!1),[uo,fo]=h.useState(kq),Ti=h.useRef({active:!1,pointerId:-1,startY:0,startH:sp}),[Sn,As]=h.useState(null),[po,Ri]=h.useState(null),[Js,Qr]=h.useState({}),Jo=h.useRef(Js);h.useEffect(()=>{Jo.current=Js},[Js]);const[U,be]=h.useState(!1),[$e,Oe]=h.useState(!1),[st,un]=h.useState({}),[bt,Bn]=h.useState({}),[vr,Mi]=h.useState(null),[Mn,Wl]=h.useState(Sf),[Hd,Bd]=h.useState(!1),[mi,Vl]=h.useState(!1),[La,Kl]=h.useState(""),[Kc,Ul]=h.useState(""),[tn,ql]=h.useState(wm),[Wn,Uc]=h.useState(null),Yl=h.useRef(0),ho=h.useRef(null),qc=h.useRef(null),Qo=h.useRef(!0),Oa=h.useRef(!1),[yn,Gl]=h.useState(null),[$a,Zo]=h.useState(null),[Wd,Wr]=h.useState(!1),[Da,mo]=h.useState(""),[Xl,ea]=h.useState(!1),Qy=h.useRef(null),[Qs,Yc]=h.useState(null),[Vd,gi]=h.useState(!1),[go,Vr]=h.useState(null),[Jl,Kd]=h.useState(!1),[ta,Li]=h.useState(null),na=h.useRef(null),[Zr,ra]=h.useState(""),[sa,ia]=h.useState(0),[Fa,oa]=h.useState(0),[hh,Gc]=h.useState("pan"),[Xc,Oi]=h.useState(!1),[Jc,aa]=h.useState(!1),la=h.useRef(null),yo=h.useRef(null),za=h.useRef(null),[Ha,Ud]=h.useState(0),[Nt,qd]=h.useState(null),[Pe,Ps]=h.useState(""),[_t,mh]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[Is,Yd]=h.useState(""),[$i,Zy]=h.useState(""),[Di,kr]=h.useState([]),[yi,dn]=h.useState([]),[gh,ex]=h.useState(!1),[Qc,yh]=h.useState([]),[Gd,xh]=h.useState(!1),[Ba,tx]=h.useState(()=>new Set),[Ql,Zc]=h.useState(!1),eu=h.useRef(null),Xd=h.useRef(null),[tu,nu]=h.useState({}),xo=h.useCallback(v=>{if(!v)return null;const C=v.id,W=v.source??"user",Y=v.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${C}:${W}${Y?":"+Y:""}`,activeKey:`af:composer-active-session:${C}:${W}${Y?":"+Y:""}`}},[]),wh=h.useCallback(v=>{if(!v)return"";const C=v.id,W=v.source??"user",Y=v.archived?"archived":"";return`af:composer-skills:pipeline:${C}:${W}${Y?":"+Y:""}`},[]),Jd=h.useCallback(v=>{const C=xo(v);if(!C)return{sessions:[],activeSessionId:null};try{const W=localStorage.getItem(C.sessionsKey);if(!W)return{sessions:[],activeSessionId:null};const Y=JSON.parse(W);if(!Array.isArray(Y))return{sessions:[],activeSessionId:null};const G=Y.filter(ie=>ie&&typeof ie.id=="string").map(ie=>({...ie,running:!1,statusLine:ie.running?e("flow:composer.pageRefreshReset"):ie.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(C.activeKey),J&&!G.some(ie=>ie.id===J)&&(J=null)}catch{J=null}return{sessions:G,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[xo]),Zl=h.useCallback((v,C,W)=>{const Y=xo(v);if(Y)try{localStorage.setItem(Y.sessionsKey,JSON.stringify(C)),W?localStorage.setItem(Y.activeKey,W):localStorage.removeItem(Y.activeKey)}catch{}},[xo]),wo=h.useRef(0),ec=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Ts,Qn]=h.useState([]),[Sr,Zs]=h.useState(null),Fi=h.useMemo(()=>wh(u),[wh,u]),[bh,Qd]=h.useState(""),tc=h.useMemo(()=>{if(!u)return null;const v=u.id,C=u.source??"user",W=u.archived?"archived":"";return`${v}:${C}${W?":"+W:""}`},[u]),ru=h.useRef(!1);h.useEffect(()=>{if(!tc){Qn([]),Zs(null),ec.current={sessions:[],activeSessionId:null,flowKey:null};return}const v=ec.current;if(v.flowKey===tc)return;v.flowKey=tc,ru.current&&v.sessions.length>0&&Zl(u,v.sessions,v.activeSessionId);const{sessions:C,activeSessionId:W}=Jd(u);if(C.length===0){const Y=`session-1-${Date.now()}`,G={id:Y,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};v.sessions=[G],v.activeSessionId=Y,Qn([G]),Zs(Y)}else{const Y=C[C.length-1];if(Y&&(!Y.thread||Y.thread.length===0))wo.current=bw(C),v.sessions=C,v.activeSessionId=Y.id,Qn(C),Zs(Y.id);else{const J=bw(C)+1;wo.current=J;const ie=`session-${J}-${Date.now()}`,oe={id:ie,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},ve=[...C,oe];v.sessions=ve,v.activeSessionId=ie,Qn(ve),Zs(ie)}}ru.current=!0},[tc,u,Jd,Zl]);const Zn=h.useMemo(()=>Ts.find(v=>v.id===Sr)||null,[Ts,Sr]),Vn=(Zn==null?void 0:Zn.running)??!1,bo=(Zn==null?void 0:Zn.statusLine)??"",Wa=(Zn==null?void 0:Zn.segments)??[],Va=(Zn==null?void 0:Zn.thread)??[],su=(Zn==null?void 0:Zn.steps)??[];Zn==null||Zn.outputDismissed;const Tt=(Zn==null?void 0:Zn.phaseContext)??null,Rs=h.useRef([]),[nc,rc]=h.useState(!1),vo=h.useRef(null),ca=h.useRef(null);h.useEffect(()=>{const v=ca.current;v&&requestAnimationFrame(()=>{v.scrollTop=v.scrollHeight})},[Va,Wa]);const vt=h.useRef(null),an=h.useRef(!1),Zd=h.useRef(null),vh=h.useCallback(v=>{const C=++wo.current,W=`session-${C}-${Date.now()}`,Y={id:W,label:v||e("flow:composer.conversationLabel",{n:C}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Qn(G=>[...G,Y]),Zs(W),W},[]);h.useEffect(()=>{!u||!ru.current||(ec.current.sessions=Ts,ec.current.activeSessionId=Sr,Zl(u,Ts,Sr))},[Ts,Sr,u,Zl]),h.useEffect(()=>{wo.current=Math.max(wo.current,bw(Ts))},[Ts]);const iu=h.useCallback(v=>{var C;vt.current===v&&((C=vo.current)==null||C.abort()),Qn(W=>{const Y=W.filter(J=>J.id!==v);if(W.some((J,ie)=>J.id===v&&W.findIndex(oe=>oe.id===Sr)===ie)||Sr===v){const J=Y;J.length>0?Zs(J[J.length-1].id):setTimeout(()=>{wo.current=0;const ie=++wo.current,oe=`session-${ie}-${Date.now()}`,ve={id:oe,label:e("flow:composer.conversationLabel",{n:ie}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Qn(Ne=>[...Ne,ve]),Zs(oe)},0)}return Y})},[Sr]),as=h.useCallback(v=>{Qn(C=>{const W=C.findIndex(J=>J.id===Sr);if(W<0)return C;const Y={...C[W]};v(Y);const G=[...C];return G[W]=Y,G})},[Sr]),kh=h.useCallback(v=>{as(C=>{C.running=v})},[as]),xi=h.useCallback(v=>{as(C=>{C.statusLine=v})},[as]),wi=h.useCallback(v=>{as(C=>{typeof v=="function"?C.segments=v(C.segments):C.segments=v})},[as]),Sh=h.useCallback(v=>{as(C=>{typeof v=="function"?C.thread=v(C.thread):C.thread=v})},[as]),Ka=h.useCallback(v=>{as(C=>{typeof v=="function"?C.steps=v(C.steps):C.steps=v})},[as]),ou=h.useCallback(v=>{as(C=>{C.outputDismissed=v})},[as]),zi=h.useCallback(v=>{as(C=>{C.phaseContext=typeof v=="function"?v(C.phaseContext):v})},[as]),Ua=h.useCallback(v=>{Zs(v),Qn(C=>{const W=C.findIndex(G=>G.id===v);if(W<0||!C[W].outputDismissed)return C;const Y=[...C];return Y[W]={...C[W],outputDismissed:!1},Y})},[]);h.useEffect(()=>{Rs.current=Wa},[Wa]);const $r=h.useRef({}),Ms=h.useRef(!1),Dr=h.useRef(null),au=h.useRef(null),ko=h.useRef(null),So=h.useRef(!1),No=h.useRef(0),er=h.useRef(""),[Rt,At,lu]=BI([]),[xn,wn,ef]=WI([]),ls=h.useRef(Rt),jo=h.useRef(xn),tf=h.useRef(null),cu=h.useRef(null),nf=h.useRef(null),ua=h.useRef(null),[es,Hi]=h.useState(null),Nh=h.useCallback(v=>{var C;$r.current=(C=v==null?void 0:v.extra)!=null&&C.instances&&typeof v.extra.instances=="object"?v.extra.instances:{},At(Array.isArray(v==null?void 0:v.nodes)?v.nodes:[]),wn(Array.isArray(v==null?void 0:v.edges)?v.edges:[]),Hi(null)},[wn,At]),jh=h.useMemo(()=>({instances:$r.current}),[xn,Rt]),{resetHistory:qa,undo:Ch,redo:Eh}=jR({nodes:Rt,edges:xn,extra:jh,enabled:!!u&&So.current&&Q==="edit",onRestore:Nh}),ei=h.useMemo(()=>Rt.filter(v=>{var C;return(((C=v.data)==null?void 0:C.definitionId)||"").startsWith("provide_")}),[Rt]),Ya=h.useMemo(()=>{var C;const v={};for(const W of Rt){if(!((C=W.data)!=null&&C.inputs))continue;const Y=W.data.inputs;for(let G=0;G<Y.length;G++){const J=Y[G];if(!(J!=null&&J.name))continue;const ie=xn.find(ve=>ve.target===W.id&&ve.targetHandle===`input-${G}`);if(!(ie!=null&&ie.source))continue;ei.find(ve=>ve.id===ie.source)&&(v[ie.source]=J.name)}}return v},[Rt,xn,ei]),Ga=h.useMemo(()=>{if(Q==="edit"||Rn.size===0)return null;const v=new Set(Rn);for(const C of xn)Rn.has(C.source)&&v.add(C.target),Rn.has(C.target)&&v.add(C.source);return v},[Q,Rn,xn]),_h=h.useMemo(()=>Q==="edit"?Rt:Rt.map(v=>{var C,W;return{...v,draggable:!1,connectable:!1,data:{...v.data,isRunMode:!0,isExecuting:Rn.has(v.id),nodeStatus:((C=wr[v.id])==null?void 0:C.status)??null,nodeElapsed:((W=wr[v.id])==null?void 0:W.elapsed)??null,isDim:Ga?!Ga.has(v.id):!1}}}),[Q,Rt,Rn,wr,Ga]),nx=h.useMemo(()=>Ga?xn.map(v=>{const C=Rn.has(v.source)||Rn.has(v.target),W=v.className?v.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",Y=C?"af-flow-edge--focus":"af-flow-edge--dim";return{...v,className:(W?W+" ":"")+Y}}):xn,[xn,Rn,Ga]);h.useEffect(()=>{if(!u){Bn({}),Mi(null),Wl(Sf),ql(wm),Uc(null),Kl(""),Ul("");return}const v=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&v.set("archived","1"),fetch(`/api/flow/run-config?${v.toString()}`).then(C=>C.json()).then(C=>{Bn(C.presets||{}),Mi(C.activePreset||null)}).catch(()=>{Bn({}),Mi(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const bs=h.useCallback(v=>{Yl.current+=1,Wl(v)},[]),Co=h.useCallback(async(v,C={})=>{if(!v)return;const W=!!C.quiet,Y=!!C.force,G=Yl.current;W||(Bd(!0),Kl(""),Ul(""));const J=new URLSearchParams({flowId:v.id,flowSource:v.source||"user"});v.archived&&J.set("archived","1");try{const ie=await fetch(`/api/flow/schedule?${J.toString()}`),oe=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(oe.error||`HTTP ${ie.status}`);if(!Y&&Yl.current!==G)return;Wl({...Sf,...oe.schedule||{}}),ql(oe.state&&typeof oe.state=="object"?oe.state:wm),Uc(oe.status||null)}catch(ie){if(!Y&&Yl.current!==G)return;Wl(Sf),ql(wm),Uc(null),Kl(String(ie.message||ie))}finally{Bd(!1)}},[]);h.useEffect(()=>{if(!u)return;let v=!1;return(async()=>{await Co(u)})(),()=>{v=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Co]),h.useEffect(()=>{var W,Y,G,J;if(!vr||!bt[vr]||ei.length===0)return;const v=bt[vr],C={};for(const ie of ei){const oe=Ya[ie.id];if(!oe)continue;const ve=((W=ie.data)==null?void 0:W.definitionId)||"",Ne=v[ie.id]??((J=(G=(Y=ie.data)==null?void 0:Y.outputs)==null?void 0:G[0])==null?void 0:J.default)??"";ve.startsWith("provide_file")?C[oe]={type:"file",path:Ne}:C[oe]={type:"str",value:Ne}}Object.keys(C).length>0&&Qr(C)},[vr,bt,ei,Ya]);const rx=h.useCallback(()=>{if(!ta||!na.current)return;const v=na.current.value;At(C=>C.map(W=>{var Y,G;return W.id!==ta.instanceId?W:{...W,data:{...W.data,outputs:((G=(Y=W.data)==null?void 0:Y.outputs)==null?void 0:G.map((J,ie)=>ie===0?{...J,default:v}:J))||[{type:"text",name:"value",default:v}]}}})),Li(null)},[ta,At]),ct=h.useMemo(()=>{const v=Rt.filter(C=>C.selected);return v.length===1?v[0]:null},[Rt]),vs=h.useMemo(()=>u?H7(Rt,xn,e):[],[u,Rt,xn,e]),Bi=h.useMemo(()=>vs.map(v=>v.key).join("|"),[vs]),Ah=h.useMemo(()=>vs.some(v=>String((v==null?void 0:v.level)||"warning").toLowerCase()==="error"),[vs]);h.useLayoutEffect(()=>{ae(vs.length>0&&!Ah)},[Bi,u==null?void 0:u.id,u==null?void 0:u.source,vs.length,Ah]),za.current=ct,h.useEffect(()=>{ls.current=Rt},[Rt]),h.useEffect(()=>{const v=o.current,C=new Map,W=[];for(const ie of Rt){const oe=ZU(ie);C.set(ie.id,oe),v.get(ie.id)!==oe&&W.push(ie.id)}if(o.current=C,W.length===0)return;const Y=()=>W.forEach(ie=>{var oe;return(oe=s.current)==null?void 0:oe.call(s,ie)}),G=window.requestAnimationFrame(Y),J=window.setTimeout(Y,80);return()=>{window.cancelAnimationFrame(G),window.clearTimeout(J)}},[Rt]),h.useEffect(()=>{jo.current=xn},[xn]),h.useEffect(()=>{nf.current=es},[es]),h.useEffect(()=>{if(!es)return;const v=W=>{W.key==="Escape"&&Hi(null)},C=W=>{var Y,G;(G=(Y=W.target)==null?void 0:Y.closest)!=null&&G.call(Y,".af-connect-node-menu")||Hi(null)};return document.addEventListener("keydown",v),document.addEventListener("pointerdown",C),()=>{document.removeEventListener("keydown",v),document.removeEventListener("pointerdown",C)}},[es]),h.useEffect(()=>()=>{ko.current!=null&&(clearTimeout(ko.current),ko.current=null)},[]);const rf=h.useMemo(()=>{var C;if(!ct)return null;const v=(C=ct.data)==null?void 0:C.definitionId;return ue.find(W=>W.id===v)??null},[ct,ue]),sf=h.useMemo(()=>{const v={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const C of ue){const W=kk(C);v[W].push(C)}for(const C of Lf)v[C].sort((W,Y)=>W.id.localeCompare(Y.id));return v},[ue]),uu=h.useMemo(()=>{const v=le.trim().toLowerCase();if(!v)return sf;const C={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const W of Lf)C[W]=sf[W].filter(Y=>GU(Y,v));return C},[sf,le]),sx=h.useMemo(()=>Lf.reduce((v,C)=>v+uu[C].length,0),[uu]),du=h.useMemo(()=>ue.filter(v=>{const C=String(v.id??""),W=String(v.source??"");return C.startsWith("marketplace:")||W==="marketplace"||W==="collection"}),[ue]),of=h.useMemo(()=>{const v=new Set;for(const C of du){const W=String(C.id??"");if(W&&(v.add(W),W.startsWith("marketplace:"))){const Y=W.slice(12),[G]=Y.split("@");G&&v.add(`marketplace:${G}`)}}return v},[du]),sc=h.useCallback(async()=>{p("");try{const v=await fetch("/api/flows");if(!v.ok)throw new Error("HTTP "+v.status);c(await v.json())}catch(v){p(String(v.message||v))}},[]);h.useEffect(()=>{sc()},[sc]),h.useEffect(()=>{if(r!=="/flow")return;const v=new URLSearchParams(window.location.search);v.get("new")==="1"&&!v.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{if(r!=="/flow"||!u)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&Vt("settings")},[r,u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{let v=!1;const C=()=>{fetch("/api/model-lists").then(Y=>Y.json()).then(Y=>{v||mh({cursor:Array.isArray(Y.cursor)?Y.cursor.map(String):[],opencode:Array.isArray(Y.opencode)?Y.opencode.map(String):[],claudeCode:Array.isArray(Y.claudeCode)?Y.claudeCode.map(String):[]})}).catch(()=>{})};C();const W=setTimeout(C,4e3);return()=>{v=!0,clearTimeout(W)}},[]),h.useEffect(()=>{let v=!1;return fetch("/api/skills").then(C=>C.json()).then(C=>{if(v)return;const W=Array.isArray(C.skills)?C.skills.filter(Y=>Y&&typeof Y.key=="string"&&Y.key.trim()).map(Y=>({key:String(Y.key),name:String(Y.name||Y.id||Y.key),description:Y.description?String(Y.description):"",sourceLabel:Y.sourceLabel?String(Y.sourceLabel):""})):[];kr(W),ex(!0)}).catch(()=>{}),()=>{v=!0}},[]),h.useEffect(()=>{let v=!1;return fetch("/api/skill-collections").then(C=>C.json()).then(C=>{v||(yh(jl(C)),xh(!0))}).catch(()=>{}),()=>{v=!0}},[]),h.useEffect(()=>{if(Qd(""),!(!gh||!Gd)){if(!Fi){dn([]);return}dn(XA(Fi,"pipeline",Di,Qc)),Qd(Fi)}},[Qc,Gd,Di,gh,Fi]),h.useEffect(()=>{if(!(bh!==Fi||!Fi))try{localStorage.setItem(Fi,JSON.stringify(yi))}catch{}},[yi,Fi,bh]);const Ph=h.useCallback(async v=>{const C=v.source??"user",W=!!v.archived,Y=new URLSearchParams({flowId:v.id,flowSource:C});W&&Y.set("archived","1");const G=new URLSearchParams({flowId:v.id,flowSource:C});W&&G.set("archived","1"),G.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,ie]=await Promise.all([fetch("/api/flow?"+Y.toString()),fetch("/api/nodes?"+G.toString())]),oe=await J.json();if(!J.ok||oe.error)throw new Error(oe.error||e("flow:nodePropsError.loadFlowFailed"));const ve=await ie.json();if(!ie.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const Ne=Array.isArray(ve)?ve:Array.isArray(ve==null?void 0:ve.nodes)?ve.nodes:[],Ke=!Array.isArray(ve)&&(ve==null?void 0:ve.pipelineTranslations)||{},ye=D7(oe.flowYaml||"");if(ye.error)throw new Error(ye.error);const He={...ye.instances||{}},Ie=ye.nodes.map(Nn=>zp(Nn,He,Ne,Ke,v.id)),jt=NR(ye.edges,Ie);return{flowSource:C,paletteList:Ne,instances:He,flowDescriptionText:ye.description??"",viewport:tC(ye.viewport),nodes:Ie,edges:jt}},[t.language,e]),Ls=h.useCallback(async(v,C={})=>{const W=!!C.preserveComposer,Y=W&&!!C.incrementalSync;So.current=!1,No.current+=1,f(v),b(""),W||(j(""),me(""),Vt(null),k(""),K(""),R(""),ra(""),Sh([]),wi([]),Ka([]),ou(!1),zi(null),Gc("pan")),Y||($r.current={},At([]),wn([])),sC(v);try{const G=await Ph(v);if(Ee(G.paletteList),$r.current=G.instances,k(G.flowDescriptionText),K(v.id||""),Y){const J=ls.current,ie=jo.current;try{const oe=mV(J,ie,G.nodes,G.edges),ve=new Set([...oe.changes.addedNodeIds,...oe.changes.updatedNodeIds]),Ne=new Set([...oe.changes.addedEdgeKeys,...oe.changes.updatedEdgeKeys]),Ke=ve.size>0?oe.nodes.map(He=>ve.has(He.id)?{...He,className:V1(He.className,B1)}:He):oe.nodes,ye=Ne.size>0?oe.edges.map(He=>Ne.has(Lp(He))?{...He,className:V1(He.className,W1)}:He):oe.edges;At(Ke),wn(ye),ko.current!=null&&(clearTimeout(ko.current),ko.current=null),(ve.size>0||Ne.size>0)&&(ko.current=window.setTimeout(()=>{ko.current=null,ve.size>0&&At(He=>He.map(Ie=>{if(!ve.has(Ie.id))return Ie;const jt=K1(Ie.className,B1);return jt===String(Ie.className||"")?Ie:{...Ie,className:jt}})),Ne.size>0&&wn(He=>He.map(Ie=>{if(!Ne.has(Lp(Ie)))return Ie;const jt=K1(Ie.className,W1);return jt===String(Ie.className||"")?Ie:{...Ie,className:jt}}))},UU))}catch{At(G.nodes),wn(G.edges)}}else if(At(G.nodes),wn(G.edges),au.current=G.viewport||null,G.viewport){const J=()=>{var ie;try{(ie=Dr.current)==null||ie.setViewport(G.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else g(J=>J+1);Zh(v.id,G.flowSource),Ud(J=>J+1),qa(G.nodes,G.edges,{instances:G.instances});try{er.current=j1(G.nodes,G.edges,G.instances,{description:G.flowDescriptionText,viewport:au.current})}catch{er.current=""}So.current=!0}catch(G){b(String(G.message||G))}},[Ph,qa,At,wn]),fu=h.useCallback(async()=>{if(!(u!=null&&u.id))return;const v=u.source??"user",C=new URLSearchParams({flowId:u.id,flowSource:v});u.archived&&C.set("archived","1"),C.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const W=await fetch("/api/nodes?"+C.toString()),Y=await W.json();if(!W.ok)throw new Error((Y==null?void 0:Y.error)||e("flow:nodePropsError.loadNodesFailed"));const G=Array.isArray(Y)?Y:Array.isArray(Y==null?void 0:Y.nodes)?Y.nodes:[];Ee(G)},[u,e,t.language]),Xa=h.useCallback(async()=>{Jn(!0),An("");try{const v=await fetch("/api/marketplace/nodes"),C=await v.json().catch(()=>({}));if(!v.ok)throw new Error((C==null?void 0:C.error)||"Failed to load marketplace nodes");gn(Array.isArray(C==null?void 0:C.nodes)?C.nodes:[])}catch(v){An(String(v.message||v)),gn([])}finally{Jn(!1)}},[]),pu=h.useCallback(async()=>{Ft(!0),pt("");try{const v=await fetch("/api/marketplace/flow-snippets"),C=await v.json().catch(()=>({}));if(!v.ok)throw new Error((C==null?void 0:C.error)||"Failed to load flow snippets");ze(Array.isArray(C==null?void 0:C.snippets)?C.snippets:[])}catch(v){pt(String(v.message||v)),ze([])}finally{Ft(!1)}},[]);h.useEffect(()=>{u&&(Xa(),pu())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Xa,pu]);const ix=h.useCallback(async v=>{if(!u||!v)return;const C=v.definitionId||`marketplace:${v.id}${v.version?`@${v.version}`:""}`;if(C){mr(C),An("");try{const W=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:C})}),Y=await W.json().catch(()=>({}));if(!W.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Failed to install marketplace node");await fu()}catch(W){An(String(W.message||W))}finally{mr("")}}},[u,fu]),ox=h.useCallback(async(v,C)=>{const W={packageId:(v==null?void 0:v.newId)||(v==null?void 0:v.id)||(v==null?void 0:v.label),label:(v==null?void 0:v.label)||(v==null?void 0:v.newId)||(v==null?void 0:v.id),version:"1.0.0",definitionId:C,body:(v==null?void 0:v.body)||"",script:(v==null?void 0:v.script)||"",inputs:Array.isArray(v==null?void 0:v.inputs)?v.inputs:[],outputs:Array.isArray(v==null?void 0:v.outputs)?v.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},Y=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),G=await Y.json();if(!Y.ok||(G==null?void 0:G.ok)===!1)throw new Error((G==null?void 0:G.error)||"Publish failed");return await fu(),G},[fu,u]),Ih=h.useCallback(async()=>{var Y;if(!u||Se.current)return;const v=u.id,C=u.source??"user",W=((Y=za.current)==null?void 0:Y.id)??null;Se.current=!0,xe(!0);try{await Ls({id:v,source:C,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),W&&At(G=>G.map(J=>({...J,selected:J.id===W})))}finally{Se.current=!1,xe(!1)}},[u,u==null?void 0:u.archived,Ls,At]);h.useEffect(()=>{if(Ms.current||l.length===0)return;const v=new URLSearchParams(window.location.search),C=v.get("flowId");if(!C)return;const W=v.get("flowSource")??"user",Y=v.get("flowArchived")==="1",G=l.find(J=>J.id===C&&(J.source??"user")===W&&!!J.archived===Y);G&&(Ms.current=!0,Ls(G))},[l,Ls]);const hu=h.useRef(0);h.useEffect(()=>{if(!u)return;const v=u.id,C=u.source??"user",W=!!u.archived;hu.current=0;let Y=!1;const G=async()=>{var oe;if(Y)return;const ie=new URLSearchParams({flowId:v,flowSource:C,v:String(hu.current)});W&&ie.set("archived","1");try{const ve=await fetch("/api/flow-editor-sync-poll?"+ie.toString());if(!ve.ok||Y)return;const Ne=await ve.json();if(Y)return;if(Ne.changed){hu.current=Ne.version;const Ke=((oe=za.current)==null?void 0:oe.id)??null;await Ls({id:v,source:C,archived:W},{preserveComposer:!0,incrementalSync:!0}),await Co({id:v,source:C,archived:W},{quiet:!0,force:!0}),Ke&&At(ye=>ye.map(He=>({...He,selected:He.id===Ke})))}else hu.current=Ne.version}catch{}},J=window.setInterval(G,2e3);return G(),()=>{Y=!0,window.clearInterval(J)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Ls,Co,At]);const ax=h.useMemo(()=>x?x.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":x===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[x]);h.useEffect(()=>{if(!x)return;x===e("flow:status.saved")||x.startsWith(e("flow:status.runInTerminal"));const v=x.startsWith(e("flow:status.runInTerminal"))?5200:2800,C=window.setTimeout(()=>j(""),v);return()=>clearTimeout(C)},[x,e]),h.useEffect(()=>{N("")},[u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{const v=()=>{window.__provideEditContent&&(Li(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",v),()=>window.removeEventListener("provide-expand",v)},[]),h.useEffect(()=>{var oe,ve,Ne,Ke,ye,He,Ie;if(!ct){qd(null);return}const v=$r.current[ct.id]||{},{inputs:C,outputs:W}=SR(ct),Y=String(((oe=ct.data)==null?void 0:oe.definitionId)??ct.id??""),G=((ve=ct.data)==null?void 0:ve.script)!=null?String(ct.data.script):void 0,J=v.script!=null?String(v.script):void 0,ie=Y==="tool_nodejs"||G&&G.trim()!==""||J&&J.trim()!==""?String(G??J??""):"";qd({id:ct.id,newId:ct.id,label:String(((Ne=ct.data)==null?void 0:Ne.label)??ct.id),role:((Ke=ct.data)==null?void 0:Ke.role)??"普通",model:String(((ye=ct.data)==null?void 0:ye.model)??v.model??""),body:String(((He=ct.data)==null?void 0:He.body)??v.body??""),images:Vs(((Ie=ct.data)==null?void 0:Ie.images)??v.images),script:ie,inputs:C,outputs:W})},[ct==null?void 0:ct.id,Ha]),h.useEffect(()=>{u&&(ct||(yo.current=null,Vt(v=>v==="node"?null:v)))},[u,ct==null?void 0:ct.id]);const ic=h.useCallback(()=>{yo.current=null,Vt(v=>v==="settings"||v==="history"?v:"node")},[]),cs=h.useCallback((v,C)=>{v.metaKey||v.ctrlKey||v.shiftKey||Q!=="edit"&&Ri((C==null?void 0:C.id)??null)},[Q]),lx=h.useCallback((v,C)=>{Q==="edit"&&(v.preventDefault(),At(W=>W.map(Y=>({...Y,selected:Y.id===C.id}))),wn(W=>W.map(Y=>({...Y,selected:!1}))),ic())},[ic,Q,wn,At]),Th=h.useCallback((v,C)=>{if(Q!=="edit")return;const W=v.metaKey||v.ctrlKey||v.shiftKey;wn(Y=>Y.map(G=>G.id===C.id?{...G,selected:!G.selected||!W}:W?G:{...G,selected:!1})),W||At(Y=>Y.map(G=>({...G,selected:!1})))},[Q,wn,At]),cx=h.useCallback(v=>X1(v,ls.current),[]),ux=h.useCallback(v=>{if(!X1(v,ls.current)){j("端口类型不匹配,已取消连线");return}Hi(null),At(C=>rp(C,v)),wn(C=>{const W=C.filter(Y=>!(Y.target===v.target&&Y.targetHandle===v.targetHandle));return rd({...v,markerEnd:{type:js.ArrowClosed}},W)})},[wn,At]),Rh=h.useCallback((v,C)=>{cu.current=eq(C,ls.current),Hi(null)},[]),Mh=h.useCallback((v,C)=>{var Ie,jt,Nn,jn;const W=cu.current;if(cu.current=null,!u||!W||C!=null&&C.toNode)return;const Y=nq(ue,W);if(Y.length===0){j(`没有匹配 ${W.slotType} 端口的节点`);return}const G=((jt=(Ie=v==null?void 0:v.changedTouches)==null?void 0:Ie[0])==null?void 0:jt.clientX)??(v==null?void 0:v.clientX),J=((jn=(Nn=v==null?void 0:v.changedTouches)==null?void 0:Nn[0])==null?void 0:jn.clientY)??(v==null?void 0:v.clientY);if(!Number.isFinite(G)||!Number.isFinite(J))return;const ie=Dr.current,oe=document.querySelector(".af-pipeline-flow .react-flow");if(!ie||!oe)return;const ve=oe.getBoundingClientRect(),Ne=320,Ke=Math.min(440,104+Y.length*58),ye=Math.max(12,Math.min(G-ve.left,ve.width-Ne-12)),He=Math.max(12,Math.min(J-ve.top,ve.height-Ke-12));Hi({left:ye,top:He,flowPosition:ie.screenToFlowPosition({x:G,y:J}),draft:W,candidates:Y,query:""})},[ue,u]),S=h.useCallback(v=>{for(const C of v)delete $r.current[C.id]},[]),A=h.useCallback(v=>{Dr.current=v},[]),H=h.useCallback(v=>{At(W=>W.map(Y=>({...Y,selected:Y.id===v}))),wn(W=>W.map(Y=>({...Y,selected:!1}))),ic();const C=()=>{var ve,Ne,Ke;const W=Dr.current;if(!(W!=null&&W.getNode))return;const Y=W.getNode(v);if(!Y)return;const G=(ve=W.getInternalNode)==null?void 0:ve.call(W,v),J=((Ne=G==null?void 0:G.measured)==null?void 0:Ne.width)??(G==null?void 0:G.width)??Y.width??200,ie=((Ke=G==null?void 0:G.measured)==null?void 0:Ke.height)??(G==null?void 0:G.height)??Y.height??88,{zoom:oe}=W.getViewport();W.setCenter(Y.position.x+J/2,Y.position.y+ie/2,{zoom:eC(oe),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(C))},[At,wn,ic]),q=h.useCallback(v=>{At(W=>W.map(Y=>({...Y,selected:Y.id===v}))),wn(W=>W.map(Y=>({...Y,selected:!1})));const C=()=>{var Ne,Ke,ye;const W=Dr.current;if(!(W!=null&&W.getNode))return;const Y=W.getNode(v);if(!Y)return;const G=(Ne=W.getInternalNode)==null?void 0:Ne.call(W,v),J=((Ke=G==null?void 0:G.measured)==null?void 0:Ke.width)??(G==null?void 0:G.width)??Y.width??200,ie=((ye=G==null?void 0:G.measured)==null?void 0:ye.height)??(G==null?void 0:G.height)??Y.height??88,{zoom:oe}=W.getViewport(),ve=eC(oe);W.setCenter(Y.position.x+J/2,Y.position.y+ie/2,{zoom:ve,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(C))},[At,wn]),X=h.useCallback((v,C)=>{const W=`node-${Date.now()}`;return VR(v,W,C,$r.current,ue)},[ue]),re=h.useCallback(v=>{if(!u||!v)return;let C={x:180,y:160};const W=Dr.current,Y=document.querySelector(".af-pipeline-flow .react-flow");if(W&&Y){const G=Y.getBoundingClientRect();C=W.screenToFlowPosition({x:G.left+G.width*.45,y:G.top+G.height*.38})}At(G=>[...G,X(v,C)])},[u,At,X]),se=h.useCallback(v=>{const C=nf.current;if(!u||!C||!(v!=null&&v.def))return;const W=X(v.def,C.flowPosition),Y=C.draft.handleType==="source"?{source:C.draft.nodeId,sourceHandle:C.draft.handleId,target:W.id,targetHandle:`input-${v.slotIndex}`}:{source:W.id,sourceHandle:`output-${v.slotIndex}`,target:C.draft.nodeId,targetHandle:C.draft.handleId};At(G=>rp([...G,W],Y)),wn(G=>{const J=G.filter(ie=>!(ie.target===Y.target&&ie.targetHandle===Y.targetHandle));return rd({...Y,markerEnd:{type:js.ArrowClosed}},J)}),Hi(null)},[u,X,At,wn]),ne=h.useCallback(v=>{v.preventDefault(),v.dataTransfer.dropEffect="move"},[]),te=h.useCallback(v=>{var ie;if(v.preventDefault(),!u)return;const C=Dr.current;if(!C)return;const W=C.screenToFlowPosition({x:v.clientX,y:v.clientY}),Y=v.dataTransfer.getData("application/agentflow-snippet");if(Y){const oe=tt.find(ve=>`${ve.id}@${ve.version}`===Y);oe&&((ie=ua.current)==null||ie.call(ua,oe,W));return}const G=v.dataTransfer.getData("application/agentflow-node");if(!G)return;const J=ue.find(oe=>oe.id===G);J&&At(oe=>[...oe,X(J,W)])},[u,ue,tt,At,X]),de=h.useCallback(async(v,C)=>{if(!u)return;const W=j1(v,C,$r.current,{description:w,viewport:au.current});if(W!==er.current){j(e("flow:status.saving"));try{const Y=bq(u.source),G=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:Y,flowYaml:W,...u.archived?{flowArchived:!0}:{}})}),J=await G.json();if(!G.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(er.current=W,j(e("flow:status.saved")),$s(u.source)&&Y==="workspace"){const ie={id:u.id,source:"workspace",path:void 0};f(ie),sC(ie),Zh(u.id,"workspace")}}catch(Y){j(e("flow:status.saveFailed")+": "+(Y.message||Y))}}},[u,w]);h.useEffect(()=>{if(!u||!So.current||Q!=="edit"||u.archived)return;const v=No.current,C=setTimeout(()=>{v===No.current&&So.current&&de(ls.current,jo.current)},400);return()=>clearTimeout(C)},[Rt,xn,w,Q,u,de]);const ke=h.useCallback(async v=>{if(!u||u.archived)return;const C=u.source??"user";if(!(C!=="user"&&C!=="workspace")&&C!==v){$(!0),N("");try{const W=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:C,toSource:v})}),Y=await W.json().catch(()=>({}));if(!W.ok)throw new Error(typeof Y.error=="string"?Y.error:e("flow:composer.requestFailed"));const G=Y.flowSource==="workspace"||Y.flowSource==="user"?Y.flowSource:v;let J={id:u.id,source:G,archived:u.archived};try{const ie=await fetch("/api/flows");if(ie.ok){const oe=await ie.json(),ve=Array.isArray(oe)?oe.find(Ne=>Ne.id===u.id&&(Ne.source??"user")===G&&!!Ne.archived==!!u.archived):null;ve&&(J=ve)}}catch{}await Ls(J,{preserveComposer:!0}),Zh(u.id,G)}catch(W){N(String(W.message||W))}finally{$(!1)}}},[u,Ls]),De=h.useCallback(async()=>{if(u){Vl(!0),Kl(""),Ul("");try{const v=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:Mn})}),C=await v.json().catch(()=>({}));if(!v.ok||!C.success)throw new Error(C.error||"Failed to save schedule");Wl({...Sf,...C.schedule||{}}),Ul(e("flow:schedule.saved")),await Co(u,{quiet:!0,force:!0})}catch(v){Kl(String(v.message||v))}finally{Vl(!1)}}},[u,Mn,Co,e]),ht=h.useCallback(async()=>{u&&(await de(ls.current,jo.current),!u.archived&&u.source!=="builtin"&&await De())},[u,de,De]),at=h.useCallback(async()=>{if(!u||!z.trim())return;const v=z.trim();if(v===u.id){R("");return}L(!0),R("");try{const C=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:v})}),W=await C.json().catch(()=>({}));if(!C.ok)throw new Error(typeof W.error=="string"?W.error:e("flow:composer.requestFailed"));let Y={id:W.flowId,source:W.flowSource??u.source,archived:u.archived};try{const G=await fetch("/api/flows");if(G.ok){const J=await G.json(),ie=Array.isArray(J)?J.find(oe=>oe.id===W.flowId&&(oe.source??"user")===(W.flowSource??u.source)):null;ie&&(Y=ie)}}catch{}await Ls(Y,{preserveComposer:!0}),Zh(W.flowId,W.flowSource??u.source)}catch(C){R(String(C.message||C))}finally{L(!1)}},[u,z,Ls]),Ut=h.useCallback(v=>{navigator.clipboard.writeText(v).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(()=>{})},[]),hn=h.useCallback(()=>{de(Rt,xn)},[de,Rt,xn]),Kn=h.useCallback(()=>{var C,W;if(!u)return;const v=tC((W=(C=Dr.current)==null?void 0:C.getViewport)==null?void 0:W.call(C));v&&(au.current=v,j("已固定 Pipeline 进入视角"),de(ls.current,jo.current))},[de,u]),Be=h.useCallback((v,C)=>{const W=C.trim()===""||C==="default"?void 0:C.trim(),Y=Rt.map(G=>G.id===v?{...G,data:{...G.data,model:W}}:G);At(Y),de(Y,xn)},[Rt,xn,At,de]),Fe=h.useCallback(()=>{var jt,Nn;if(!Nt||!u||!ct)return!1;const v=ct.id,C=Nt.newId.trim();if(Ps(""),!OR.test(C))return Ps(e("flow:nodePropsError.invalidInstanceId")),!1;if(Rt.some(jn=>jn.id===C&&jn.id!==v))return Ps(e("flow:nodePropsError.duplicateInstanceId")),!1;const W=Nt.role.trim(),Y=Rl.includes(W)?W:"普通",G=Nt.model.trim(),J=jn=>(Array.isArray(jn)?jn:[]).map(Yt=>({type:String((Yt==null?void 0:Yt.type)??"节点").trim()||"节点",name:String((Yt==null?void 0:Yt.name)??""),default:String((Yt==null?void 0:Yt.default)??""),description:String((Yt==null?void 0:Yt.description)??""),required:!!(Yt!=null&&Yt.required),showOnNode:(Yt==null?void 0:Yt.showOnNode)!=null?Yt.showOnNode!==!1:!!(Yt!=null&&Yt.required)||String((Yt==null?void 0:Yt.type)??"节点").trim().toLowerCase()==="node"})),ie=J(Nt.inputs),oe=J(Nt.outputs),ve=String(((jt=ct.data)==null?void 0:jt.definitionId)??C),Ne=ve.startsWith("provide_"),Ke={...ct.data,label:Nt.label.trim()||C,displayLabel:Nt.label.trim()||C,role:Y,model:G===""||G==="default"?void 0:G,body:Ne?"":Nt.body,images:Ne?[]:Vs(Nt.images),inputs:ie,outputs:Ne&&Array.isArray((Nn=ct.data)==null?void 0:Nn.outputs)?ct.data.outputs:oe},ye=String(Nt.script??"").trim();ve==="tool_nodejs"||ye!==""?Ke.script=String(Nt.script??""):delete Ke.script;let He,Ie=xn;if(C!==v){const jn={...$r.current},Yt={...jn[v]||{}};delete jn[v],jn[C]=Yt,$r.current=jn,He=Rt.map(Ct=>Ct.id!==v?Ct:{...Ct,id:C,selected:!0,data:Ke}),Ie=xn.map((Ct,ln)=>({...Ct,source:Ct.source===v?C:Ct.source,target:Ct.target===v?C:Ct.target,id:`e-${Ct.source===v?C:Ct.source}-${Ct.target===v?C:Ct.target}-${ln}`}))}else He=Rt.map(jn=>jn.id===v?{...jn,data:Ke}:jn);return At(He),wn(Ie),xr(C),de(He,Ie),!0},[Nt,u,ct,Rt,xn,At,wn,xr,de]),ot=h.useCallback(()=>{var Nn,jn;if(!Nt||!u||!ct)return!1;const v=ct.id,C=Nt.role.trim(),W=Rl.includes(C)?C:"普通",Y=Nt.model.trim(),G=Yt=>(Array.isArray(Yt)?Yt:[]).map(Ct=>({type:String((Ct==null?void 0:Ct.type)??"节点").trim()||"节点",name:String((Ct==null?void 0:Ct.name)??""),default:String((Ct==null?void 0:Ct.default)??""),description:String((Ct==null?void 0:Ct.description)??""),required:!!(Ct!=null&&Ct.required),showOnNode:(Ct==null?void 0:Ct.showOnNode)!=null?Ct.showOnNode!==!1:!!(Ct!=null&&Ct.required)||String((Ct==null?void 0:Ct.type)??"节点").trim().toLowerCase()==="node"})),J=G(Nt.inputs),ie=G(Nt.outputs),oe=String(((Nn=ct.data)==null?void 0:Nn.definitionId)??v),ve=oe.startsWith("provide_"),Ne=Nt.label.trim()||v,Ke=Y===""||Y==="default"?void 0:Y,ye={...ct.data,label:Ne,displayLabel:Ne,role:W,model:Ke,body:ve?"":Nt.body,images:ve?[]:Vs(Nt.images),inputs:J,outputs:ve&&Array.isArray((jn=ct.data)==null?void 0:jn.outputs)?ct.data.outputs:ie},He=String(Nt.script??"").trim();oe==="tool_nodejs"||He!==""?ye.script=String(Nt.script??""):delete ye.script;const Ie=ct.data||{};return(Ie.label!==ye.label||Ie.role!==ye.role||Ie.model!==ye.model||Ie.body!==ye.body||JSON.stringify(Vs(Ie.images))!==JSON.stringify(ye.images)||(Ie.script??void 0)!==(ye.script??void 0)||JSON.stringify(Ie.inputs||[])!==JSON.stringify(J)||JSON.stringify(Ie.outputs||[])!==JSON.stringify(ie))&&(At(Yt=>Yt.map(Ct=>Ct.id===v?{...Ct,data:ye}:Ct)),xr(v)),!0},[Nt,u,ct,At,xr]),mt=h.useRef(ot);h.useEffect(()=>{mt.current=ot},[ot]),h.useEffect(()=>{if(!Nt||!u||!So.current||Q!=="edit")return;const v=setTimeout(()=>{mt.current()},400);return()=>clearTimeout(v)},[Nt,u,Q]);const qt=h.useCallback(()=>{if(!(!Nt||!ct)){if(Nt.newId.trim()===ct.id){Ps("");return}Fe()}},[Nt,ct,Fe]);h.useEffect(()=>{const v=C=>{var ie,oe,ve;if(Q!=="edit")return;const W=_R(C.target);if((C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="s"){if(Wt==="node"&&ct&&Nt){C.preventDefault(),C.stopPropagation(),Fe()||hn();return}if(W)return;C.preventDefault(),C.stopPropagation(),hn();return}if((C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="k"){C.preventDefault(),C.stopPropagation(),aa(Ne=>!Ne);return}if(Jc)return;if(Xc){if(C.key==="Escape"){C.preventDefault(),Oi(!1);return}if(Yg(C)&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),Oi(!1);return}(C.key==="v"||C.key==="V"||C.key==="h"||C.key==="H")&&!C.metaKey&&!C.ctrlKey&&!C.altKey&&C.preventDefault();return}if(W)return;const Y=C.key.toLowerCase(),G=(C.metaKey||C.ctrlKey)&&!C.shiftKey&&Y==="z",J=(C.metaKey||C.ctrlKey)&&(C.shiftKey&&Y==="z"||Y==="y");if(G||J){C.preventDefault(),C.stopPropagation();const Ne=G?Ch():Eh();j(Ne?G?"Undo canvas change":"Redo canvas change":G?"Nothing to undo":"Nothing to redo");return}if((C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="c"){const Ne=xR(ls.current,jo.current,$r.current);Ne&&(C.preventDefault(),C.stopPropagation(),tf.current=Ne,j(`Copied ${Ne.nodes.length} node${Ne.nodes.length>1?"s":""}`));return}if((C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="v"){const Ne=wR(tf.current,ls.current,jo.current,$r.current);Ne&&(C.preventDefault(),C.stopPropagation(),$r.current=Ne.instances,At(Ne.nodes),wn(Ne.edges),j(`Pasted ${Ne.pastedNodeIds.length} node${Ne.pastedNodeIds.length>1?"s":""}`));return}if((C.key==="a"||C.key==="A")&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),C.stopPropagation(),(ie=Ye.current)==null||ie.focus(),(ve=(oe=Ye.current)==null?void 0:oe.select)==null||ve.call(oe);return}if((C.metaKey||C.ctrlKey)&&C.key.toLowerCase()==="a"){C.preventDefault(),C.stopPropagation(),At(Ne=>Ne.map(Ke=>({...Ke,selected:!0}))),wn(Ne=>Ne.map(Ke=>({...Ke,selected:!1})));return}if(Yg(C)&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),Oi(Ne=>!Ne);return}if((C.key==="v"||C.key==="V")&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),Gc("select");return}if((C.key==="h"||C.key==="H")&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),Gc("pan");return}if((C.key==="f"||C.key==="F")&&!C.metaKey&&!C.ctrlKey&&!C.altKey){C.preventDefault(),Kn();return}};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[hn,Kn,Xc,Jc,Wt,ct,Nt,Fe,Q,Ch,Eh]),h.useEffect(()=>{if(Q!=="running"||Br==null)return;let v=Math.floor((Date.now()-Br)/1e3);const C=setInterval(()=>{const W=Date.now()-Br,Y=Math.floor(W/1e3);Y!==v&&(v=Y,Zt(W))},500);return()=>clearInterval(C)},[Q,Br]),h.useEffect(()=>{const v=qc.current;!v||!v.parentElement||Qo.current&&(Oa.current=!0,v.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Oa.current=!1}))},[qe]),h.useEffect(()=>{const v=qc.current;if(!v)return;const C=v.parentElement;if(!C)return;const W=()=>{if(Oa.current)return;const Y=C.scrollHeight-C.scrollTop-C.clientHeight;Qo.current=Y<40};return C.addEventListener("scroll",W,{passive:!0}),()=>C.removeEventListener("scroll",W)},[br,Q]),h.useEffect(()=>{if(Q==="edit"||!br)return;Qo.current=!0;const v=qc.current;v&&(Oa.current=!0,v.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Oa.current=!1}))},[Q,br]),h.useEffect(()=>{qe.length>Qm+nC&&Me(v=>v.length>Qm+nC?v.slice(-Qm):v)},[qe]);const Ht=h.useCallback(v=>{if(v.button!==0)return;v.preventDefault();const C=v.currentTarget;Ti.current={active:!0,pointerId:v.pointerId,startY:v.clientY,startH:uo},C.setPointerCapture(v.pointerId)},[uo]),Ge=h.useCallback(v=>{const C=Ti.current;if(!C.active||v.pointerId!==C.pointerId)return;const W=C.startY-v.clientY;fo(Zm(C.startH+W))},[]),Bt=h.useCallback(()=>{fo(v=>{const C=Zm(v);try{localStorage.setItem(UR,String(C))}catch{}return C})},[]),us=h.useCallback(v=>{const C=Ti.current;if(!(!C.active||v.pointerId!==C.pointerId)){C.active=!1;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}Bt()}},[Bt]),af=h.useCallback(()=>{const v=Ti.current;v.active&&(v.active=!1,Bt())},[Bt]);h.useEffect(()=>{function v(){fo(C=>Zm(C))}return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]);const ti=h.useCallback(async(v={})=>{if(!u)return;const C=v.runUuid!=null&&String(v.runUuid).trim()?String(v.runUuid).trim():null,W=v.cliInputsOverride??Jo.current,Y=!!v.prepareOnly;if(ge(Y?"ready":"running"),Me(Y?[]:[{ts:new Date().toISOString(),type:"info",text:C?e("flow:run.connectingApiResume",{uuid:C}):e("flow:run.connectingApi")}]),Hn(new Set),Ae({}),nt(!Y),Vt(null),C||As(null),Y)return;if(!C){const J=Date.now();lt(J),Zt(0)}const G=new AbortController;ho.current=G;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",...C?{uuid:C}:{},cliInputs:W}),signal:G.signal});if(!J.ok){const ye=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));Me(He=>[...He,{ts:new Date().toISOString(),type:"error",text:ye.error||e("flow:composer.requestFailed")}]),ge("error");return}if(Me(ye=>[...ye,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){Me(ye=>[...ye,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),ge("error");return}const ie=J.body.getReader(),oe=new TextDecoder;let ve="";const Ne=ye=>{const He=ye.ts||new Date().toISOString();if(ye.type==="event")if(ye.event==="node-start")Hn(Ie=>new Set(Ie).add(ye.instanceId)),Ae(Ie=>({...Ie,[ye.instanceId]:{status:"running",startMs:Date.now()}})),Me(Ie=>[...Ie,{ts:He,type:"node-start",text:ye.label?e("flow:run.nodeStartWithLabel",{instanceId:ye.instanceId,label:ye.label}):e("flow:run.nodeStart",{instanceId:ye.instanceId})}]);else if(ye.event==="node-done"){Hn(jt=>{const Nn=new Set(jt);return Nn.delete(ye.instanceId),Nn});const Ie=ye.elapsed??null;Ae(jt=>({...jt,[ye.instanceId]:{status:"success",elapsed:Ie}})),Me(jt=>[...jt,{ts:He,type:"node-done",text:Ie?e("flow:run.nodeDoneWithElapsed",{instanceId:ye.instanceId,elapsed:Ie}):e("flow:run.nodeDone",{instanceId:ye.instanceId})}])}else if(ye.event==="node-failed")Hn(Ie=>{const jt=new Set(Ie);return jt.delete(ye.instanceId),jt}),Ae(Ie=>({...Ie,[ye.instanceId]:{status:"failed",elapsed:ye.elapsed??null}})),Me(Ie=>[...Ie,{ts:He,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:ye.instanceId})}]);else if(ye.event==="apply-start"){if(ye.uuid&&As(String(ye.uuid)),typeof ye.runStartTime=="number"&&ye.runStartTime>0)lt(ye.runStartTime),Zt(Math.max(0,Date.now()-ye.runStartTime));else if(typeof ye.totalExecutedMs=="number"&&ye.totalExecutedMs>0){const Ie=Date.now()-ye.totalExecutedMs;lt(Ie),Zt(ye.totalExecutedMs)}Me(Ie=>[...Ie,{ts:He,type:"info",text:e("flow:run.pipelineStart",{uuid:ye.uuid||"?"})}])}else ye.event==="apply-done"?Me(Ie=>[...Ie,{ts:He,type:"info",text:ye.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:ye.totalElapsed}):e("flow:run.pipelineDone")}]):ye.event==="apply-paused"?Me(Ie=>[...Ie,{ts:He,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(ye.pendingNodes||[]).join(", ")})}]):Me(Ie=>[...Ie,{ts:He,type:"event",text:`[${ye.event}] ${JSON.stringify(ye)}`}]);else ye.type==="user-check-content"?(Gl({instanceId:ye.instanceId,execId:ye.execId??1,inputPath:ye.inputPath,outputPath:ye.outputPath,content:ye.content||""}),Zo(ye.content||""),Wr(!1),mo(""),ea(!1),Me(Ie=>[...Ie,{ts:He,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:ye.instanceId})}])):ye.type==="user-ask-prompt"?(Yc({instanceId:ye.instanceId,execId:ye.execId??1,question:ye.question||"",options:Array.isArray(ye.options)?ye.options:[]}),gi(!1),Me(Ie=>[...Ie,{ts:He,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:ye.instanceId,defaultValue:`等待用户选择 (${ye.instanceId})`})}])):ye.type==="tool-print-content"?(Vr({instanceId:ye.instanceId,execId:ye.execId??1,content:ye.content||"",createdAt:Date.now()}),Kd(!1)):ye.type==="log"?Me(Ie=>[...Ie,{ts:He,type:"log",text:ye.text!=null?String(ye.text):""}]):ye.type==="error"?Me(Ie=>[...Ie,{ts:He,type:"error",text:ye.message||e("flow:run.unknownError")}]):ye.type==="done"?Me(Ie=>[...Ie,{ts:He,type:"done",text:e("flow:run.executionEnd",{exitCode:ye.exitCode??"?"})}]):Me(Ie=>[...Ie,{ts:He,type:"log",text:JSON.stringify(ye)}])},Ke=ye=>{if(ye.trim())try{Ne(JSON.parse(ye))}catch{Me(He=>[...He,{ts:new Date().toISOString(),type:"log",text:ye}])}};for(;;){const{done:ye,value:He}=await ie.read();ve+=oe.decode(He??new Uint8Array,{stream:!ye});const Ie=ve.split(`
133
- `);ve=Ie.pop()??"";for(const jt of Ie)Ke(jt);if(ye)break}ve.trim()&&Ke(ve),ge("done")}catch(J){J.name==="AbortError"?(Me(ie=>[...ie,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),ge("stopped")):(Me(ie=>[...ie,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),ge("error"))}finally{ho.current=null,Hn(new Set)}},[u]),[mu,bi]=h.useState(!1),Lh=h.useCallback(()=>{bi(!0)},[]),dx=h.useCallback(async()=>{if(bi(!1),ho.current&&(ho.current.abort(),ho.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{}ge("stopped"),Hn(new Set)},[u]),vi=h.useCallback(()=>{ge("edit"),Hn(new Set),Ae({}),Ri(null),As(null)},[]),[gu,Ce]=h.useState(!1),St=h.useCallback(async()=>{if(Ce(!1),ho.current&&(ho.current.abort(),ho.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{}vi()},[u,vi]),gt=h.useCallback(()=>{Ce(!1),n("/projects")},[n]),Pt=h.useCallback(v=>{const C=v.runId!=null&&String(v.runId).trim()?String(v.runId).trim():null,W=v.flowId!=null&&String(v.flowId).trim()?String(v.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;As(C);const Y=v.status||"unknown";let G="stopped";Y==="success"?G="done":Y==="failed"?G="error":Y==="running"?G="running":G="stopped",ge(G);const J=typeof v.at=="number"?v.at:null;if(G==="running"&&J!=null?(lt(J),Zt(Math.max(0,Date.now()-J))):J!=null&&typeof v.endedAt=="number"&&v.endedAt>J?(lt(null),Zt(v.endedAt-J)):(lt(null),Zt(Math.max(0,v.durationMs??0))),Me([]),Hn(new Set),Ae({}),Ri(null),Vt(null),nt(!1),C&&W){const ie=new URLSearchParams({flowId:W,runId:C});fetch(`/api/run-node-statuses?${ie}`).then(oe=>oe.json()).then(oe=>{const ve=oe.statuses&&typeof oe.statuses=="object"?oe.statuses:{},Ne={};for(const[Ke,ye]of Object.entries(ve))ye&&typeof ye=="object"&&typeof ye.status=="string"&&(Ne[Ke]={status:ye.status,...ye.elapsed!=null&&String(ye.elapsed).trim()!==""?{elapsed:String(ye.elapsed)}:{}});Ae(Ne)}).catch(()=>{})}},[u==null?void 0:u.id]);h.useEffect(()=>{if(!(u!=null&&u.id)||Q!=="edit")return;let v=!1;return(async()=>{try{const C=await fetch("/api/pipeline-recent-runs"),W=await C.json();if(v||!C.ok)return;const G=(Array.isArray(W.runs)?W.runs:[]).find(oe=>oe.flowId===u.id&&oe.status==="running");if(!G||v)return;const J=G.runId||null;As(J),ge("running"),nt(!0),lt(G.at||Date.now()),zt.current=0;const ie=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const oe=new URLSearchParams({flowId:u.id,runId:J}),Ne=await(await fetch(`/api/run-node-statuses?${oe}`)).json();if(v)return;const Ke=Ne.statuses&&typeof Ne.statuses=="object"?Ne.statuses:{},ye={},He=new Set;for(const[Ie,jt]of Object.entries(Ke))jt&&typeof jt=="object"&&typeof jt.status=="string"&&(ye[Ie]={status:jt.status,...jt.elapsed!=null&&String(jt.elapsed).trim()!==""?{elapsed:String(jt.elapsed)}:{}},jt.status==="running"&&He.add(Ie));Ae(ye),Hn(He);try{const Ie=new URLSearchParams({flowId:u.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),jt=await fetch(`/api/run-log?${Ie}`);if(jt.ok){const Nn=await jt.json();if(!v){zt.current=Number(Nn.bytes||0);const jn=rC(typeof Nn.text=="string"?Nn.text:"");Me([...jn,...ie]);return}}}catch{}}Me(ie)}catch{}})(),()=>{v=!0}},[u==null?void 0:u.id]),h.useEffect(()=>{if(Q==="edit"||!(u!=null&&u.id)||!Sn)return;let v=!1,C=null;const W=async()=>{try{const Y=new URLSearchParams({flowId:u.id,runId:Sn}),G=await fetch(`/api/run-node-statuses?${Y}`);if(!G.ok)return;const J=await G.json();if(v)return;const ie=J.statuses&&typeof J.statuses=="object"?J.statuses:{},oe={},ve=new Set;for(const[Ne,Ke]of Object.entries(ie))Ke&&typeof Ke=="object"&&typeof Ke.status=="string"&&(oe[Ne]={status:Ke.status,...Ke.elapsed!=null&&String(Ke.elapsed).trim()!==""?{elapsed:String(Ke.elapsed)}:{}},Ke.status==="running"&&ve.add(Ne));Ae(Ne=>yq(Ne,oe)?Ne:oe),Hn(Ne=>xq(Ne,ve)?Ne:ve);try{const Ne=new URLSearchParams({flowId:u.id,runId:Sn,sinceBytes:String(zt.current||0),tailBytes:String(pq)}),Ke=await fetch(`/api/run-log?${Ne}`);if(Ke.ok){const ye=await Ke.json();if(v)return;const He=Number(ye.bytes||0),Ie=typeof ye.text=="string"?ye.text:"";if(Ie){const jt=rC(Ie);jt.length>0&&Me(Nn=>[...Nn,...jt])}zt.current=He}}catch{}try{const Ne=await fetch("/api/pipeline-recent-runs");if(!Ne.ok)return;const Ke=await Ne.json();if(v)return;const He=(Array.isArray(Ke.runs)?Ke.runs:[]).find(Ie=>Ie.flowId===u.id&&Ie.runId===Sn);if(He&&He.status){const Ie=He.status;Ie==="running"?ge(jt=>jt==="running"?jt:"running"):Ie==="success"?ge("done"):Ie==="failed"?ge("error"):(Ie==="stopped"||Ie==="interrupted")&&ge("stopped")}}catch{}}catch{}};return W(),C=window.setInterval(W,2500),()=>{v=!0,C&&window.clearInterval(C)}},[Q,u==null?void 0:u.id,Sn]),h.useEffect(()=>{if(Wt!=="history"||!u)return;let v=!1;return(async()=>{Lr(!0),yr("");try{const C=await fetch("/api/pipeline-recent-runs"),W=await C.json();if(!C.ok)throw new Error(W.error||"HTTP "+C.status);v||Er(Array.isArray(W.runs)?W.runs:[])}catch(C){v||(yr(String(C.message||C)),Er([]))}finally{v||Lr(!1)}})(),()=>{v=!0}},[Wt,u]),h.useEffect(()=>{if(!u){Ar({files:[]});return}let v=!1;return(async()=>{Tn(!0);try{const C=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),W=await fetch(`/api/pipeline-files?${C}`),Y=await W.json();if(!W.ok)throw new Error(Y.error||"HTTP "+W.status);v||Ar({files:Array.isArray(Y.files)?Y.files:[],path:Y.path,error:Y.error})}catch(C){v||Ar({files:[],error:C.message||String(C)})}finally{v||Tn(!1)}})(),()=>{v=!0}},[u]);const Te=h.useMemo(()=>u?ir.filter(v=>v&&v.flowId===u.id).sort((v,C)=>C.at-v.at):[],[ir,u]),ft=h.useMemo(()=>{let v=0,C=0,W=0,Y=0,G=0;for(const J of Te){const ie=J.status||"unknown";ie==="success"?v+=1:ie==="failed"?C+=1:ie==="running"?W+=1:ie==="stopped"?Y+=1:ie==="interrupted"&&(G+=1)}return{success:v,failed:C,running:W,stopped:Y,interrupted:G}},[Te]),Xt=h.useMemo(()=>u?J1(Zr,sa):null,[u,Zr,sa]),Jt=h.useMemo(()=>{if(!Xt||!u)return[];const v=Xt.query.toLowerCase(),C=G=>v?G.some(J=>J&&String(J).toLowerCase().includes(v)):!0,W=Rt.map(G=>{var Ne,Ke;const J=G.id,ie=String(((Ne=G.data)==null?void 0:Ne.label)??J),oe=(Ke=G.data)!=null&&Ke.definitionId?String(G.data.definitionId):"",ve=[ie!==J?ie:"",oe&&oe!==J?oe:""].filter(Boolean);return{id:J,label:ie,defId:oe,subs:ve}}).filter(({id:G,label:J,defId:ie})=>C([G,J,ie])).sort((G,J)=>G.id.localeCompare(J.id)).slice(0,18).map(({id:G,label:J,defId:ie})=>{const oe=[J!==G?J:null,ie||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:G,title:G,subtitle:oe}}),Y=ue.filter(G=>G&&G.id&&C([G.id,G.label,G.description])).sort((G,J)=>G.id.localeCompare(J.id)).slice(0,22).map(G=>({kind:"definition",id:G.id,title:G.id,subtitle:G.label&&G.label!==G.id?String(G.label):String(G.type||"")}));return[...W,...Y]},[Xt,Rt,ue,u]),kt=h.useMemo(()=>{const v=Jt.filter(W=>W.kind==="instance"),C=Jt.filter(W=>W.kind==="definition");return{instances:v,definitions:C}},[Jt]);h.useEffect(()=>{oa(v=>{const C=Math.max(0,Jt.length-1);return Math.min(Math.max(0,v),C)})},[Jt]);const Dt=h.useMemo(()=>sq(Zr),[Zr]),Lt=h.useMemo(()=>Rt.filter(v=>v.selected),[Rt]),nn=h.useMemo(()=>new Set(Lt.map(v=>v.id)),[Lt]),bn=h.useMemo(()=>xn.filter(v=>nn.has(v.source)&&nn.has(v.target)),[xn,nn]),tr=h.useMemo(()=>{const v=le.trim().toLowerCase();return v?tt.filter(C=>[C.id,C.version,C.displayName,C.name,C.description,...Array.isArray(C.tags)?C.tags:[]].filter(Boolean).some(W=>String(W).toLowerCase().includes(v))):tt},[tt,le]),Kr=h.useCallback((v,C)=>{const W=String(v||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",Y=Date.now().toString(36);let G=`${W}-${Y}`,J=2;for(;C.has(G);)G=`${W}-${Y}-${J}`,J+=1;return C.add(G),G},[]),Ur=h.useCallback((v,C)=>{var ln,ks;if(!u||!v)return;const W=v.snippet&&typeof v.snippet=="object"?v.snippet:{},Y=W.instances&&typeof W.instances=="object"?W.instances:{},G=Object.keys(Y);if(G.length===0)return;const J=new Set(ls.current.map(Ze=>Ze.id)),ie={};for(const Ze of G)ie[Ze]=Kr(Ze,J);const oe=(ln=W.ui)!=null&&ln.nodePositions&&typeof W.ui.nodePositions=="object"?W.ui.nodePositions:{},ve=(ks=W.ui)!=null&&ks.nodeSizes&&typeof W.ui.nodeSizes=="object"?W.ui.nodeSizes:{},Ne=G.map(Ze=>{const Cn=oe[Ze];return{id:Ze,x:typeof(Cn==null?void 0:Cn.x)=="number"?Cn.x:0,y:typeof(Cn==null?void 0:Cn.y)=="number"?Cn.y:0}}),Ke=Math.min(...Ne.map(Ze=>Ze.x)),ye=Math.min(...Ne.map(Ze=>Ze.y));let He=C||{x:180,y:160};const Ie=Dr.current,jt=document.querySelector(".af-pipeline-flow .react-flow");if(!C&&Ie&&jt){const Ze=jt.getBoundingClientRect();He=Ie.screenToFlowPosition({x:Ze.left+Ze.width*.48,y:Ze.top+Ze.height*.32})}const Nn={};for(const Ze of G)Nn[ie[Ze]]={...Y[Ze]||{}};$r.current={...$r.current,...Nn};const jn=G.map(Ze=>{const Cn=Y[Ze]||{},_o=Ne.find(cf=>cf.id===Ze)||{x:0,y:0},Wi=ve[Ze]&&typeof ve[Ze].width=="number"&&typeof ve[Ze].height=="number"?{width:ve[Ze].width,height:ve[Ze].height}:null,lc={id:ie[Ze],type:"flowNode",selected:!0,position:{x:He.x+(_o.x-Ke),y:He.y+(_o.y-ye)},...Wi?{width:Wi.width,height:Wi.height}:{},data:{label:Cn.label||ie[Ze],definitionId:Cn.definitionId||Ze,role:Cn.role||"normal",body:Cn.body||"",script:Cn.script||"",...Wi?{displaySize:Wi}:{}}};return zp(lc,$r.current,ue,{},u.id)}),Yt=new Set(G),Ct=(Array.isArray(W.edges)?W.edges:[]).filter(Ze=>Yt.has(Ze==null?void 0:Ze.source)&&Yt.has(Ze==null?void 0:Ze.target)).map((Ze,Cn)=>({id:`e-${ie[Ze.source]}-${ie[Ze.target]}-${Date.now()}-${Cn}`,source:ie[Ze.source],target:ie[Ze.target],sourceHandle:Ze.sourceHandle??void 0,targetHandle:Ze.targetHandle??void 0,markerEnd:{type:js.ArrowClosed}}));At(Ze=>[...Ze.map(Cn=>({...Cn,selected:!1})),...jn]),wn(Ze=>[...Ze.map(Cn=>({...Cn,selected:!1})),...Ct]),j(`已添加流程片段:${v.displayName||v.id}`)},[Kr,ue,u,wn,At]);ua.current=Ur;const Ja=h.useCallback(()=>{var W,Y;if(Lt.length<2){pt("请先在画布上选择至少两个节点。"),je("flows");return}const v=Lt[0],C=Lt.length===2?`${((W=v.data)==null?void 0:W.label)||v.id} 片段`:`${((Y=v.data)==null?void 0:Y.label)||v.id} 等 ${Lt.length} 个节点`;xt({name:C,id:C.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Ve(""),We(!0),je("flows")},[Lt]),da=h.useCallback(async()=>{var J,ie;if(!u||Lt.length<2)return;const v=sn.name.trim();if(!v){Ve("请填写片段名称。");return}const C=lh(Lt,$r.current),W={},Y={};for(const oe of Lt){W[oe.id]={x:((J=oe.position)==null?void 0:J.x)||0,y:((ie=oe.position)==null?void 0:ie.y)||0};const ve=vq(oe);ve&&(Y[oe.id]=ve)}const G=bn.map(oe=>({source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle??null,targetHandle:oe.targetHandle??null}));pe(!0),Ve("");try{const oe=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:sn.id,name:v,displayName:v,version:"1.0.0",description:sn.description,snippet:{instances:C,edges:G,ui:{nodePositions:W,nodeSizes:Y}}})}),ve=await oe.json().catch(()=>({}));if(!oe.ok||(ve==null?void 0:ve.ok)===!1)throw new Error((ve==null?void 0:ve.error)||"Publish failed");We(!1),j(`流程片段已发布:${ve.id||v}`),or(`流程片段已发布:${ve.id||v}`),await pu(),je("flows")}catch(oe){Ve(String(oe.message||oe))}finally{pe(!1)}},[u,Lt,bn,sn,pu,or]),qr=h.useMemo(()=>{const v=[],C=new Set;for(const G of Lt)C.add(G.id),v.push({node:G,kind:"canvas"});const W=new Map(Rt.map(G=>[G.id,G])),Y=new Map(ue.map(G=>[G.id,G]));for(const G of Dt){if(C.has(G))continue;const J=W.get(G);if(J){C.add(G),v.push({node:J,kind:"mention"});continue}const ie=Y.get(G);ie&&(C.add(G),v.push({definition:ie,kind:"definition"}))}return v},[Lt,Dt,Rt,ue]),fr=h.useMemo(()=>{const v=Array.isArray(_t==null?void 0:_t.cursor)?_t.cursor:[],C=Array.isArray(_t==null?void 0:_t.opencode)?_t.opencode:[],W=Array.isArray(_t==null?void 0:_t.claudeCode)?_t.claudeCode:[],Y=C.map(Ne=>`opencode:${ga(Ne)}`),G=W.map(Ne=>`claude-code:${ga(Ne)}`),J=new Set([...v,...C,...W].map(ga).concat(Y).concat(G)),ie=(Is||"").trim(),oe=xm(Is,v,C,W),ve=oe&&!J.has(oe)&&!J.has(ie)?ie:"";return{cursorList:v,opencodeList:C,claudeCodeList:W,currentNotInLists:ve}},[_t,Is]),Qa=h.useMemo(()=>new Set(yi),[yi]),Eo=yi.length,oc=h.useMemo(()=>{const v=new Map(Di.map(J=>[J.key,J])),C=new Set,W=new Set,Y=Qc.map(J=>{const ie=Il(J,Di).map(oe=>v.get(oe)).filter(Boolean);for(const oe of ie)C.add(oe.key),W.add(String(oe.name||oe.id||oe.key||"").trim());return{...J,skills:ie}}).filter(J=>J.skills.length>0),G=Di.filter(J=>{const ie=String(J.name||J.id||J.key||"").trim();return!C.has(J.key)&&!W.has(ie)});return{groups:Y,ungrouped:G}},[Qc,Di]),Za=h.useCallback(()=>{const v=eu.current;if(!v)return;const C=v.getBoundingClientRect(),W=Math.min(400,Math.max(300,window.innerWidth-24)),Y=Math.min(Math.max(12,C.right-W),window.innerWidth-W-12),G=Math.max(140,C.top-22),J=Math.min(360,G);nu({position:"fixed",left:`${Y}px`,top:`${Math.max(12,C.top-J-10)}px`,width:`${W}px`,maxHeight:`${J}px`})},[]);h.useEffect(()=>{const v=Array.isArray(_t==null?void 0:_t.cursor)?_t.cursor:[],C=Array.isArray(_t==null?void 0:_t.opencode)?_t.opencode:[],W=Array.isArray(_t==null?void 0:_t.claudeCode)?_t.claudeCode:[];Yd(Y=>{const G=xm(Y,v,C,W);return G===Y?Y:G})},[_t.cursor,_t.opencode,_t.claudeCode]),h.useEffect(()=>{if(!Ql)return;Za();const v=W=>{var G,J;const Y=W.target;(G=eu.current)!=null&&G.contains(Y)||(J=Xd.current)!=null&&J.contains(Y)||Zc(!1)},C=W=>{W.key==="Escape"&&Zc(!1)};return window.addEventListener("resize",Za),window.addEventListener("scroll",Za,!0),document.addEventListener("pointerdown",v),document.addEventListener("keydown",C),()=>{window.removeEventListener("resize",Za),window.removeEventListener("scroll",Za,!0),document.removeEventListener("pointerdown",v),document.removeEventListener("keydown",C)}},[Ql,Za]);const ac=h.useCallback(async(v,C={})=>{var Ct;if(!u||an.current)return;const W=C.phaseContextSnapshot,Y=(typeof v=="string"?v:Zr).trim();if(!Y)return;const G=Rs.current;an.current=!0,kh(!0),xi(e("flow:composer.connecting")),Vt(ln=>ln!=="composer"?"composer":ln);const J=[...Va];if(G.length>0&&J.push({type:"assistant",segments:[...G]}),Sh([...J,{type:"user",text:Y}]),J.filter(ln=>ln.type==="user").length===0){const ln=Y.replace(/\s+/g," ").slice(0,30)+(Y.length>30?"…":"");Qn(ks=>ks.map(Ze=>Ze.id===Sr?{...Ze,label:ln}:Ze))}const ie=J.map(ln=>ln.type==="user"?{role:"user",text:ln.text}:{role:"assistant",text:(ln.segments||[]).filter(Ze=>Ze.kind==="assistant"||Ze.kind==="result").map(Ze=>Ze.text).join(`
134
- `)}).filter(ln=>ln.text),oe=W??Tt;ra(""),wi([]),Ka([]),ou(!1);const ve=new AbortController;vo.current=ve,vt.current=Sr;let Ne=null;const Ke=Array.isArray(_t==null?void 0:_t.cursor)?_t.cursor:[],ye=Array.isArray(_t==null?void 0:_t.opencode)?_t.opencode:[],He=Array.isArray(_t==null?void 0:_t.claudeCode)?_t.claudeCode:[],Ie=xm(Is,Ke,ye,He),jt=qr.filter(ln=>ln.kind!=="definition"&&ln.node).map(ln=>ln.node.id),Nn=u;let jn=!1,Yt=!1;try{Ne=setTimeout(()=>ve.abort(),12e4);const ln={prompt:Y,model:Ie,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:jt,thread:ie,selectedSkills:yi};oe&&oe.nextPhase&&!oe.isLastPhase&&(ln.phaseContext={phaseIndex:oe.nextPhase.index,phases:oe.phases,userPromptOriginal:oe.userPromptOriginal||Y}),$i&&(ln.phaseRole=$i);const ks=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ln),signal:ve.signal});if(Ne&&(clearTimeout(Ne),Ne=null),!ks.ok){let Wi=ks.statusText||e("flow:composer.requestFailed");try{const lc=await ks.json();lc&&lc.error&&(Wi=String(lc.error))}catch{}xi(Wi),wi([{kind:"error",text:Wi}]);return}const Ze=(Ct=ks.body)==null?void 0:Ct.getReader();if(!Ze){xi(e("flow:composer.cannotReadStream"));return}const Cn=new TextDecoder;let _o="";for(;;){const{done:Wi,value:lc}=await Ze.read();if(Wi)break;for(_o+=Cn.decode(lc,{stream:!0});;){const cf=_o.indexOf(`
135
- `);if(cf<0)break;const Gk=_o.slice(0,cf).trim();if(_o=_o.slice(cf+1),!Gk)continue;let et;try{et=JSON.parse(Gk)}catch{continue}if(et.type==="status"&&typeof et.line=="string"&&xi(et.line),et.type==="natural"&&typeof et.text=="string"&&et.text){const Ln=typeof et.kind=="string"&&et.kind?et.kind:"assistant";wi(En=>[...En,{kind:Ln,text:et.text}])}if(et.type==="error"&&et.message){Yt=!0;const Ln=et.code?` [${et.code}]`:"",En=String(et.message)+Ln;xi(En),wi(Os=>[...Os,{kind:"error",text:En}])}if(et.type==="plan"&&Array.isArray(et.steps)){Ka(et.steps.map(En=>({...En,status:"pending"})));const Ln=et.steps.map((En,Os)=>`${Os+1}. ${En.description||En.type}`).join(`
136
- `);wi(En=>[...En,{kind:"assistant",text:e("flow:composer.taskPlan",{count:et.steps.length,summary:Ln})}])}if(et.type==="step-start"){const Ln=et.index??0,En=et.total??0,Os=et.tier?` [${et.tier}]`:"",fM=et.model?` (${et.model})`:"";xi(e("flow:composer.step",{current:Ln+1,total:En,description:(et.description||"")+Os+fM})),Ka(pM=>pM.map(yu=>yu.index===Ln?{...yu,status:"running",model:et.model,tier:et.tier,nodeRole:et.nodeRole??yu.nodeRole,instanceId:et.instanceId??yu.instanceId,instanceLabel:et.instanceLabel??yu.instanceLabel}:yu))}if(et.type==="step-progress"){const Ln=et.index??0,En=et.total??0;xi(e("flow:composer.step",{current:Ln+1,total:En,description:et.description||""}))}if(et.type==="step-done"){const Ln=et.index??0;Ka(En=>En.map(Os=>Os.index===Ln?{...Os,status:et.success?"done":"error"}:Os))}if(et.type==="phase-plan"&&Array.isArray(et.phases)){zi(En=>({...En||{},phases:et.phases,currentPhase:et.currentPhase??0,phaseTotal:et.phaseTotal??et.phases.length,phaseName:et.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(En==null?void 0:En.userPromptOriginal)||Y}));const Ln=et.phases.map((En,Os)=>`${Os+1}. ${En.label}`).join(" → ");wi(En=>[...En,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:et.phases.length,labels:Ln,current:et.phaseName||""})}])}et.type==="phase-complete"&&(zi(Ln=>{var Os;return{...Ln||{},phases:et.phases||(Ln==null?void 0:Ln.phases)||[],currentPhase:et.phaseIndex??0,phaseTotal:et.phaseTotal??((Os=et.phases)==null?void 0:Os.length)??0,phaseName:et.phaseName||"",isLastPhase:!!et.isLastPhase,nextPhase:et.nextPhase||null,userPromptOriginal:et.userPromptOriginal||(Ln==null?void 0:Ln.userPromptOriginal)||Y}}),!et.isLastPhase&&et.nextPhase&&wi(Ln=>[...Ln,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:et.phaseName||e("flow:composer.nextPhase"),nextPhase:et.nextPhase.label})}])),et.type==="done"&&(jn=!0,xi(Ln=>Ln||e("flow:composer.done")))}}}catch(ln){const ks=ln;if(ks.name==="AbortError"){const Ze=e(Ne?"flow:composer.connectTimeout":"flow:composer.aborted");xi(Ze),wi(Cn=>[...Cn,{kind:"error",text:Ze}])}else{const Ze=ks.code||ks.name||"UNKNOWN",Cn=`${ks.message||String(ln)} [${Ze}]`;xi(Cn),wi(_o=>[..._o,{kind:"error",text:Cn}])}}finally{if(an.current=!1,kh(!1),vo.current=null,vt.current=null,Ne&&clearTimeout(Ne),jn&&Nn){const ln={id:Nn.id,source:Nn.source??"user",archived:Nn.archived};(async()=>(await Ls(ln,{preserveComposer:!0,incrementalSync:!0}),await Co(ln,{quiet:!0,force:!0})))()}}},[u,Zr,Is,_t,qr,Ls,Co,Va,Sr,Tt,$i,yi]);Zd.current=ac;const Wk=h.useCallback(()=>{!Tt||Tt.isLastPhase||(zi(null),ac(e("flow:composer.skipRemainingPhases")))},[Tt,ac]),Vk=h.useCallback(()=>{if(!Tt||Tt.isLastPhase||!Tt.nextPhase)return;const v=String(Tt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");ac(e("flow:composer.continuePhase",{label:v}),{phaseContextSnapshot:Tt})},[Tt,ac]);h.useEffect(()=>{if(!nc)return;const v=C=>{C.key==="Escape"&&rc(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[nc]),h.useEffect(()=>{Q!=="edit"&&rc(!1)},[Q]),h.useLayoutEffect(()=>{const v=la.current;if(!v)return;if(!u){v.style.height="";return}v.style.height="0px";const C=getComputedStyle(v),W=parseFloat(C.lineHeight),Y=(parseFloat(C.paddingTop)||0)+(parseFloat(C.paddingBottom)||0),G=Number.isFinite(W)&&W>0?W:13*1.45,J=Y+G*2,ie=Y+G*10,oe=Math.min(Math.max(v.scrollHeight,J),ie);v.style.height=`${oe}px`},[Zr,u]);const fx=h.useCallback(v=>{const C=Zr,W=sa,Y=J1(C,W);if(!Y)return;const G=C.slice(0,Y.atIndex)+`@${v} `+C.slice(W);ra(G);const J=Y.atIndex+v.length+2;queueMicrotask(()=>{const ie=la.current;ie&&(ie.focus(),ie.setSelectionRange(J,J)),ia(J)})},[Zr,sa]),px=h.useCallback(v=>{ra(C=>{const W=`@${v}`,Y=C.indexOf(W);return Y<0?C:C.slice(0,Y)+C.slice(Y+W.length)})},[]),Kk=h.useCallback(v=>{v.kind==="canvas"?At(C=>C.map(W=>W.id===v.node.id?{...W,selected:!1}:W)):v.kind==="mention"?px(v.node.id):px(v.definition.id)},[At,px]),aM=h.useCallback(()=>{Vt(v=>v==="history"?null:"history")},[]),lM=h.useCallback(()=>{Vt(v=>v==="settings"?null:"settings")},[]),cM=h.useCallback(()=>{Vt(v=>v==="composer"?null:"composer")},[]),lf=h.useCallback(()=>{Vt(v=>(v==="node"&&za.current&&(yo.current=za.current.id),null))},[]),Uk=h.useCallback(()=>{Oi(v=>!v)},[]),uM=()=>{if(!u)return null;const v=mi||u.archived||$s(u.source),C=Wn!=null&&Wn.running?e("flow:schedule.running"):Mn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),W=Wn!=null&&Wn.running?"running":Mn.enabled?"waiting":"disabled",Y=wt.slice(0,12),G=u.archived||$s(u.source);return i.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[i.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[i.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),i.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),i.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),i.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),i.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),i.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),i.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),i.jsxs("main",{className:"af-pipeline-settings-main",children:[i.jsxs("div",{className:"af-pipeline-settings-main-head",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),i.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),i.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:lf,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),i.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),i.jsx("h2",{children:e("flow:settings.basicInfo")})]}),i.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?i.jsxs("div",{className:"af-pipeline-rename-row",children:[i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:z,onChange:J=>{K(J.target.value),R("")},onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),at())},onBlur:()=>{z.trim()&&z.trim()!==u.id&&at()},placeholder:u.id,disabled:B,spellCheck:!1}),i.jsx("span",{className:"af-pipeline-drawer-badge",children:Su(u.source??"user",e)})]}):i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,i.jsx("span",{className:"af-pipeline-drawer-badge",children:Su(u.source??"user",e)}),u.archived?i.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),D?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:D}):null]}),i.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),u.owner||"bigo"]})]})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:w,onChange:J=>k(J.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),i.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),i.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof u.path=="string"&&u.path?i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[i.jsx("span",{className:"af-pipeline-path-text",children:u.path}),i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>Ut(u.path),title:e("flow:settings.copyPath"),children:i.jsx("span",{className:"material-symbols-outlined",children:M?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),i.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>ke("workspace"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>ke("user"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),E?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:E}):null]}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),i.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),i.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),i.jsxs("div",{className:"af-pipeline-market-row",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-pipeline-market-count",children:[wt.length," ",e("flow:settings.marketNodesUnit")]}),i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),i.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Xa,disabled:cn,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(cn?"common:common.loading":"common:common.refresh")]})]}),on?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:on}):null,cn?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Y.length>0?i.jsx("div",{className:"af-pipeline-market-list",children:Y.map(J=>{const ie=J.definitionId||`marketplace:${J.id}${J.version?`@${J.version}`:""}`,oe=of.has(ie)||of.has(`marketplace:${J.id}`),ve=du.find(He=>String(He.id)===ie||String(He.id)===`marketplace:${J.id}`),Ne=Pn===ie,Ke=ym(J.inputs||J.input),ye=ym(J.outputs||J.output);return i.jsxs("div",{className:"af-pipeline-market-item",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:oe?"check_circle":"extension"}),i.jsxs("div",{className:"af-pipeline-market-main",children:[i.jsxs("div",{className:"af-pipeline-market-title-row",children:[i.jsx("strong",{children:J.displayName||J.label||J.id}),i.jsx("span",{children:J.version?`v${J.version}`:ie})]}),i.jsx("p",{className:"af-pipeline-market-purpose",children:J.description||e("flow:settings.marketplaceNoDescription")}),i.jsxs("div",{className:"af-pipeline-market-io",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),i.jsx("div",{className:"af-pipeline-market-chips",children:Ke.length>0?Ke.map(He=>i.jsx("span",{className:"af-pipeline-market-chip",children:He},`in-${ie}-${He}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),i.jsx("div",{className:"af-pipeline-market-chips",children:ye.length>0?ye.map(He=>i.jsx("span",{className:"af-pipeline-market-chip",children:He},`out-${ie}-${He}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),i.jsxs("div",{className:"af-pipeline-market-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>gr(J),children:e("flow:settings.previewNode")}),i.jsx("button",{type:"button",className:oe?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:G||Ne,onClick:()=>{oe&&ve?(re(ve),Vt(null)):ix(J)},children:e(Ne?"flow:settings.installingNode":oe?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},ie)})}):i.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),i.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),i.jsx("h2",{children:e("flow:schedule.title")})]}),Hd?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[i.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[i.jsx("input",{type:"checkbox",checked:!!Mn.enabled,disabled:v,onChange:J=>bs(ie=>({...ie,enabled:J.target.checked}))}),i.jsx("span",{children:e("flow:schedule.enabled")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Mn.cron||"",disabled:v,onChange:J=>bs(ie=>({...ie,cron:J.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Mn.timezone||"",disabled:v,onChange:J=>bs(ie=>({...ie,timezone:J.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),i.jsxs("select",{className:"af-pipeline-flow-select",value:Mn.preset||"",disabled:v,onChange:J=>bs(ie=>({...ie,preset:J.target.value})),children:[i.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(bt).map(J=>i.jsx("option",{value:J,children:J},J))]})]})]}),i.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[i.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${W}`}),i.jsx("span",{children:Mn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(Mn.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),i.jsxs("span",{children:[e("flow:schedule.runtime"),":",C]})]}),i.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[tn.lastTriggeredAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),i.jsx("dd",{children:new Date(tn.lastTriggeredAt).toLocaleString()})]}):null,tn.lastSkippedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),i.jsxs("dd",{children:[new Date(tn.lastSkippedAt).toLocaleString(),tn.lastSkipReason?` · ${tn.lastSkipReason}`:""]})]}):null,tn.lastRunUuid?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastRun")}),i.jsx("dd",{children:tn.lastRunUuid})]}):null,tn.lastExitCode!=null?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastExit")}),i.jsx("dd",{children:String(tn.lastExitCode)})]}):null,tn.lastFinishedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),i.jsx("dd",{children:new Date(tn.lastFinishedAt).toLocaleString()})]}):null]}),Wn!=null&&Wn.lastError||tn.lastError?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Wn==null?void 0:Wn.lastError)||tn.lastError}):null,u.archived||$s(u.source)?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,La?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:La}):null,Kc?i.jsx("p",{className:"af-pipeline-drawer-muted",children:Kc}):null]})]}),i.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[i.jsxs("div",{className:"af-pipeline-settings-section-head",children:[i.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),i.jsx("h2",{children:e("flow:pipeline.metadata")})]}),i.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsxs("dd",{children:[Rt.length," ",e("flow:pipeline.nodesUnit")]})]}),i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),i.jsx("dd",{children:du.length})]}),i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:settings.source")}),i.jsx("dd",{children:Su(u.source??"user",e)})]})]})]})]}),i.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[i.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),i.jsxs("div",{children:[i.jsx("h2",{children:u.id}),i.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${W}`,children:C})]})]}),i.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsx("dd",{children:Rt.length})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.owner")}),i.jsx("dd",{children:u.owner||"bigo"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.source")}),i.jsx("dd",{children:Su(u.source??"user",e)})]})]})]}),i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsx("h2",{children:e("flow:settings.quickActions")}),i.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void ht(),disabled:mi,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(mi?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:lf,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),i.jsxs("section",{className:"af-pipeline-settings-side-card",children:[i.jsx("h2",{children:e("flow:settings.help")}),i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},dM=()=>{const v=Cr;if(!v)return null;const C=v.definitionId||`marketplace:${v.id}${v.version?`@${v.version}`:""}`,W=v.displayName||v.label||v.id,Y=ym(v.inputs||v.input),G=ym(v.outputs||v.output);return Ir.createPortal(i.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:J=>{J.target===J.currentTarget&&gr(null)},children:i.jsxs("div",{className:"af-market-preview-dialog",children:[i.jsxs("div",{className:"af-market-preview-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),i.jsx("h2",{children:W})]}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>gr(null),"aria-label":e("flow:settings.closePreview"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-market-preview-body",children:[i.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:i.jsxs("div",{className:"af-market-preview-node",children:[i.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(Y.length>0?Y:[""]).slice(0,4).map((J,ie)=>i.jsx("span",{title:J},`preview-in-${ie}`))}),i.jsxs("div",{className:"af-market-preview-node-main",children:[i.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("strong",{children:W}),i.jsx("span",{children:C})]}),i.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(G.length>0?G:[""]).slice(0,4).map((J,ie)=>i.jsx("span",{title:J},`preview-out-${ie}`))})]})}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:e("flow:settings.nodeFunction")}),i.jsx("p",{children:v.description||e("flow:settings.marketplaceNoDescription")})]}),i.jsxs("div",{className:"af-market-preview-io-grid",children:[i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:"Inputs"}),i.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:Y.length>0?Y.map(J=>i.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-input-${J}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:"Outputs"}),i.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:G.length>0?G.map(J=>i.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-output-${J}`)):i.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),i.jsxs("section",{className:"af-market-preview-section",children:[i.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),i.jsxs("dl",{className:"af-market-preview-dl",children:[i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.definitionId")}),i.jsx("dd",{children:C})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.version")}),i.jsx("dd",{children:v.version||"-"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.packagePath")}),i.jsx("dd",{children:v.packageDir||"-"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:e("flow:settings.packagedFiles")}),i.jsx("dd",{children:Array.isArray(v.packagedFiles)&&v.packagedFiles.length>0?v.packagedFiles.map(J=>J.to||J).join(", "):"-"})]})]})]})]})]})}),document.body)};return i.jsxs(Fy,{children:[i.jsx(fq,{onReady:a}),i.jsxs(HR.Provider,{value:{modelLists:_t,onModelChange:Be},children:[i.jsxs("div",{className:"af-pipeline-page"+(Q!=="edit"?" af-pipeline-page--run-mode":""),children:[i.jsxs("header",{className:"af-pipeline-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Q==="running"?Ce(!0):Q!=="edit"?vi():n("/projects")},"aria-label":e(Q!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Q!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",WU,"-STABLE"]})]}),i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),i.jsx("button",{type:"button",onClick:()=>n(Gf(u,"workspace")),children:"Workspace"}),i.jsx("button",{type:"button",onClick:()=>n(Gf(u,"display")),children:"Display"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[os&&i.jsx("button",{type:"button",className:"af-icon-btn"+(Ii?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>co(v=>!v),children:i.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Q==="running"&&i.jsxs("div",{className:"af-run-timer",children:[i.jsx("span",{className:"af-run-timer__dot"}),i.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),i.jsx("span",{className:"af-run-timer__value",children:xw(pn,"running")})]}),Q==="stopped"&&i.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[i.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),i.jsx("span",{className:"af-run-timer__value",children:xw(pn,"stopped")})]}),(Q==="done"||Q==="error")&&i.jsxs("div",{className:"af-run-timer"+(Q==="error"?" af-run-timer--error":" af-run-timer--done"),children:[i.jsx("span",{className:"af-run-timer__label",children:Q==="error"?"FAILED":"COMPLETED"}),i.jsx("span",{className:"af-run-timer__value",children:xw(pn,Q)})]}),Q!=="edit"&&i.jsx("button",{type:"button",className:"af-icon-btn"+(br?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>nt(v=>!v),children:i.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Q==="edit"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(Wt==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!u,onClick:aM,children:i.jsx("span",{className:"material-symbols-outlined",children:"history"})}),i.jsx("button",{type:"button",className:"af-icon-btn"+(Wt==="settings"?" af-icon-btn--active":""),onClick:lM,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!u,children:i.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Wt==="composer"?" af-composer-topbar-btn--active":"")+(Vn?" af-composer-topbar-btn--running":""),onClick:cM,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),i.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(Xc?" af-icon-btn--active":""),onClick:Uk,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!u,children:i.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!u||$s(u.source)||u.source!=="user"&&u.source!=="workspace",onClick:()=>_(!0),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),i.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!u||$s(u.source)||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>P(!0),children:"Archive"})]}),Q==="running"?i.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:Lh,title:e("flow:run.pauseRun"),children:[i.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Q==="ready"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void ti(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:vi,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Q==="stopped"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void ti({runUuid:Sn}),title:Sn?e("flow:topbar.resumeTitle",{uuid:Sn}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:vi,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Q==="done"||Q==="error"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void ti(),title:e("flow:topbar.rerunTitle"),children:"Run"}),i.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:vi,children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):i.jsxs("div",{className:"af-run-btn-group",children:[i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!u,onClick:()=>void ti(),children:"Run"}),i.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>be(v=>!v),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":U,children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),U&&u&&i.jsxs("div",{className:"af-run-dropdown-menu",children:[i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var C,W,Y,G,J;be(!1);const v={};for(const ie of ei){const oe=Ya[ie.id];oe&&(v[oe]=((C=Js[oe])==null?void 0:C.value)??((W=Js[oe])==null?void 0:W.path)??((J=(G=(Y=ie.data)==null?void 0:Y.outputs)==null?void 0:G[0])==null?void 0:J.default)??"")}un(v),Oe(!0)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{be(!1),ti({prepareOnly:!0})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),i.jsx("div",{className:"af-run-dropdown-divider"}),i.jsxs("div",{className:"af-run-dropdown-section",children:[i.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{be(!1),ti()},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(bt).map(v=>i.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var Y;be(!1);const C=bt[v]||{},W={};for(const G of ei){const J=Ya[G.id];if(!J)continue;const ie=((Y=G.data)==null?void 0:Y.definitionId)||"",oe=C[G.id]??"";ie.startsWith("provide_file")?W[J]={type:"file",path:oe}:W[J]={type:"str",value:oe}}ti({cliInputsOverride:W})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),v]},v))]})]})]})]})]}),rt?i.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsx("span",{children:rt}),i.jsx("button",{type:"button",onClick:()=>it(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-pipeline-body"+(Q!=="edit"?" af-pipeline-body--run-mode":""),children:[Q==="edit"&&Wt!=="settings"?i.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[i.jsxs("div",{className:`af-palette-workspace${Or?" af-palette-workspace--expanded":""}`,children:[i.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>ws(v=>!v),"aria-expanded":Or,children:[i.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),i.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),i.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Or?"expand_less":"expand_more"})]}),i.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||ar.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),Or&&i.jsx("div",{className:"af-palette-workspace-tree",children:In?i.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):ar.error?i.jsx("div",{className:"af-palette-workspace-empty",children:ar.error}):u?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-palette-workspace-group",children:[i.jsxs("div",{className:"af-palette-workspace-group-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),i.jsx("span",{children:u.id}),i.jsxs("span",{className:"af-palette-workspace-count",children:["(",ar.files.length,")"]})]}),ar.files.length>0?i.jsx("ul",{className:"af-palette-workspace-list",children:ar.files.filter(v=>v.type==="file").map(v=>i.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:v.path,onClick:()=>ee({filePath:v.path,fileName:v.name}),children:[i.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:v.icon}),i.jsx("span",{className:"af-palette-workspace-item-label",children:v.name}),v.size!=null&&i.jsx("span",{className:"af-palette-workspace-item-size",children:v.size<1024?`${v.size}B`:v.size<1024*1024?`${(v.size/1024).toFixed(1)}KB`:`${(v.size/1024/1024).toFixed(1)}MB`})]},v.path))}):ar.files.filter(v=>v.type==="directory").length===0?i.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),ar.files.filter(v=>{var C;return v.type==="directory"&&((C=v.children)==null?void 0:C.length)>0}).map(v=>i.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[i.jsxs("div",{className:"af-palette-workspace-group-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:v.icon}),i.jsxs("span",{children:[v.name,"/"]}),i.jsxs("span",{className:"af-palette-workspace-count",children:["(",v.children.length,")"]})]}),i.jsx("ul",{className:"af-palette-workspace-list",children:v.children.map(C=>i.jsxs("li",{className:`af-palette-workspace-item${C.type==="file"?" af-palette-workspace-item--clickable":""}`,title:C.path,onClick:C.type==="file"?()=>ee({filePath:C.path,fileName:C.name}):void 0,children:[i.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:C.icon}),i.jsx("span",{className:"af-palette-workspace-item-label",children:C.name}),C.type==="file"&&C.size!=null&&i.jsx("span",{className:"af-palette-workspace-item-size",children:C.size<1024?`${C.size}B`:C.size<1024*1024?`${(C.size/1024).toFixed(1)}KB`:`${(C.size/1024/1024).toFixed(1)}MB`})]},C.path))})]},v.path))]}):i.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),i.jsxs("div",{className:"af-node-palette-head",children:[i.jsxs("h2",{className:"af-node-palette-title",children:[i.jsx("span",{children:"Palette"}),i.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),i.jsxs("label",{className:"af-palette-search-wrap",children:[i.jsx("span",{className:"af-visually-hidden",children:we==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),i.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:Ye,type:"search",className:"af-palette-search-input",value:le,onChange:v=>me(v.target.value),placeholder:(we==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":we==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":we==="nodes",className:"af-palette-tab"+(we==="nodes"?" af-palette-tab--active":""),onClick:()=>je("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":we==="flows",className:"af-palette-tab"+(we==="flows"?" af-palette-tab--active":""),onClick:()=>je("flows"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?i.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,i.jsx("div",{className:"af-node-palette-scroll",children:we==="flows"?i.jsxs(i.Fragment,{children:[i.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:i.jsxs("div",{className:"af-flow-snippet-actions",children:[i.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:Ja,disabled:!u||Lt.length<2,title:Lt.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Lt.length," 节点 / ",bn.length," 连线"]})]})}),Ue?i.jsx("p",{className:"af-err af-palette-list-err",children:Ue}):null,dt?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):tr.length>0?i.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[i.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),i.jsx("div",{className:"af-palette-cards",children:tr.map(v=>{const C=`${v.id}@${v.version}`,W=v.displayName||v.name||v.id,Y=v.description||`${v.nodeCount||0} 个节点,${v.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>Ur(v),draggable:!!u,onDragStart:G=>{G.dataTransfer.setData("application/agentflow-snippet",C),G.dataTransfer.effectAllowed="move"},disabled:!u,title:Y,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:W}),i.jsxs("span",{className:"af-palette-card-id",children:[v.id,"@",v.version]})]})]}),Y?i.jsx("span",{className:"af-palette-card-desc",children:Y}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[v.nodeCount||0," nodes"]}),i.jsxs("span",{children:[v.edgeCount||0," edges"]})]})]},C)})})]}):i.jsx("p",{className:"af-palette-empty",children:le.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Lf.filter(v=>uu[v].length>0).map(v=>i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${v}`,children:[i.jsx("h3",{className:"af-palette-cat",children:v}),i.jsx("div",{className:"af-palette-cards",children:uu[v].map(C=>{const W=q1(C.inputs,"input"),Y=q1(C.outputs,"output"),J=C.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":WR(C),ie=BR(C);return i.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>re(C),draggable:!!u,onDragStart:oe=>{oe.dataTransfer.setData("application/agentflow-node",C.id),oe.dataTransfer.effectAllowed="move"},disabled:!u,title:J||C.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:YU(v)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:ie}),ie!==C.id?i.jsx("span",{className:"af-palette-card-id",children:C.id}):null]})]}),J?i.jsx("span",{className:"af-palette-card-desc",children:J}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[W.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[W.shown.map((oe,ve)=>i.jsxs("span",{className:"af-palette-card-port",title:U1("input",oe,ve),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:qn(oe==null?void 0:oe.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:ww(oe,ve)})]},`in-${ve}`)),W.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",W.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[Y.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[Y.shown.map((oe,ve)=>i.jsxs("span",{className:"af-palette-card-port",title:U1("output",oe,ve),children:[i.jsx("span",{className:"af-palette-card-port-name",children:ww(oe,ve)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:qn(oe==null?void 0:oe.type)}})]},`out-${ve}`)),Y.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",Y.hidden]}):null]})]})]})]},C.id)})})]},v)),u&&ue.length===0?i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,u&&ue.length>0&&le.trim()&&sx===0?i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,u?null:i.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),i.jsxs("footer",{className:"af-palette-engine",children:[i.jsxs("div",{className:"af-palette-engine-head",children:[i.jsx("span",{className:"af-palette-engine-dot"+(ce?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),i.jsx("span",{className:"af-palette-engine-label",children:e(ce?"common:engine.online":"common:engine.offline")})]}),x?i.jsx("div",{className:"af-palette-tip"+ax,role:"status","aria-live":"polite",children:x}):null]})]}):Q!=="edit"&&u?i.jsx(OU,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:ei,edges:xn,nodes:Rt,onCliInputsChange:Qr,onBackToEdit:vi}):null,i.jsxs("div",{className:"af-pipeline-main-stack",children:[i.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?i.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,u&&vs.length>0&&!V?i.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[i.jsxs("div",{className:"af-flow-slot-warnings-head",children:[i.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),i.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",disabled:fe,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void Ih(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),i.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>ae(!0),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),i.jsx("ul",{className:"af-flow-slot-warnings-list",children:vs.map(v=>i.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',i.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:v.nodeId}),onClick:C=>{C.preventDefault(),H(v.nodeId)},children:v.nodeId}),'"',v.suffix]},v.key))})]}):null,u&&vs.length>0&&V?i.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:vs.length})}),i.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:Uk,title:e("flow:validation.shortcutHint"),children:[i.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),i.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[i.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>ae(!1),children:e("flow:validation.show")}),i.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:fe,onClick:()=>void Ih(),children:e("common:common.refresh")})]})]}):null,Wt==="settings"&&u&&Q==="edit"?uM():i.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?i.jsxs(i.Fragment,{children:[i.jsx(wq,{fitViewEpoch:m,canvasTool:hh,nodes:_h,edges:nx,onNodesChange:Q!=="edit"?void 0:lu,onEdgesChange:Q!=="edit"?void 0:ef,onConnect:Q!=="edit"?void 0:ux,onConnectStart:Q!=="edit"?void 0:Rh,onConnectEnd:Q!=="edit"?void 0:Mh,isValidConnection:Q!=="edit"?void 0:cx,onNodesDelete:Q!=="edit"?void 0:S,onNodeClick:cs,onNodeDoubleClick:lx,onEdgeClick:Th,onFlowInit:A,onDrop:te,onDragOver:ne,hideMinimapAndControls:!!(u&&Wt),bottomSlot:Q==="edit"?i.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:i.jsxs("div",{className:"af-pipeline-composer-inner",children:[i.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:qr.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):qr.map((v,C)=>{var ve,Ne;if(v.kind==="definition"){const Ke=v.definition,ye=String(Ke.label??Ke.id),He=[Ke.id,Ke.description?String(Ke.description).slice(0,120):""].filter(Boolean).join(" — ");return i.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:He,children:[i.jsx("span",{className:"af-composer-node-chip-label",children:ye}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Kk(v),"aria-label":e("flow:composer.removeFromInput",{id:Ke.id}),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Ke.id}`)}const W=v.node,Y=v.kind,G=String(((ve=W.data)==null?void 0:ve.label)??W.id),J=(Ne=W.data)!=null&&Ne.definitionId?String(W.data.definitionId):"",ie=J&&J!==G?`${G} · ${W.id} · ${J}`:`${G} · ${W.id}`,oe=Y==="canvas"?e("flow:composer.deselectNode",{id:W.id}):e("flow:composer.removeFromInput",{id:W.id});return i.jsxs("div",{className:"af-composer-node-chip"+(Y==="mention"?" af-composer-node-chip--mention":""),title:ie,children:[i.jsx("span",{className:"af-composer-node-chip-label",children:G}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Kk(v),"aria-label":oe,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},W.id)})}),i.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[i.jsxs("div",{className:"af-composer-input-wrap",children:[i.jsx("textarea",{ref:la,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:Zr,rows:2,onChange:v=>{ra(v.target.value),ia(v.target.selectionStart??v.target.value.length)},onSelect:v=>{const C=v.target;C instanceof HTMLTextAreaElement&&ia(C.selectionStart??0)},onKeyDown:v=>{if((v.metaKey||v.ctrlKey)&&v.key==="Enter"){v.preventDefault(),ac();return}if(Xt&&Jt.length>0&&(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")){if(v.key==="ArrowDown")v.preventDefault(),oa(C=>(C+1)%Jt.length);else if(v.key==="ArrowUp")v.preventDefault(),oa(C=>(C-1+Jt.length)%Jt.length);else if(v.key==="Enter"){v.preventDefault();const C=Jt[Fa];C&&fx(C.id)}}},onKeyUp:v=>{const C=v.target;C instanceof HTMLTextAreaElement&&ia(C.selectionStart??C.value.length)},onClick:v=>{const C=v.target;C instanceof HTMLTextAreaElement&&ia(C.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Xt&&u&&Jt.length>0?i.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[kt.instances.length>0?i.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:i.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,kt.instances.map((v,C)=>{const W=C;return i.jsx("li",{role:"option","aria-selected":W===Fa,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(W===Fa?" af-composer-mention-item--active":""),onMouseDown:Y=>Y.preventDefault(),onMouseEnter:()=>oa(W),onClick:()=>fx(v.id),children:[i.jsx("span",{className:"af-composer-mention-id",children:v.title}),v.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:v.subtitle}):null]})},`i-${v.id}`)}),kt.definitions.length>0?i.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:i.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,kt.definitions.map((v,C)=>{const W=kt.instances.length+C;return i.jsx("li",{role:"option","aria-selected":W===Fa,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(W===Fa?" af-composer-mention-item--active":""),onMouseDown:Y=>Y.preventDefault(),onMouseEnter:()=>oa(W),onClick:()=>fx(v.id),children:[i.jsx("span",{className:"af-composer-mention-id",children:v.title}),v.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:v.subtitle}):null]})},`d-${v.id}`)})]}):null]}),i.jsxs("div",{className:"af-composer-toolbar",children:[Ts.length>0&&i.jsx("label",{className:"af-composer-session-field",children:i.jsxs("select",{className:"af-composer-session-select",value:Sr||"",onChange:v=>{v.target.value==="__new__"?vh():Ua(v.target.value)},disabled:Vn,"aria-label":e("flow:composer.switchConversation"),children:[Ts.map(v=>i.jsxs("option",{value:v.id,children:[v.label,v.running?" ⏳":""]},v.id)),i.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:eu,type:"button",className:"af-composer-skills-button"+(Eo>0?" af-composer-skills-button--active":""),disabled:!u||Vn,"aria-haspopup":"listbox","aria-expanded":Ql,onClick:()=>Zc(v=>!v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Eo>0?`Skills ${Eo}`:"Skills"})]}),Ql&&!Vn?Ir.createPortal(i.jsx("div",{ref:Xd,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:tu,children:Di.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[oc.groups.map(v=>{const C=Il(v,Di),W=GA(v,Qa,Di),Y=Ba.has(v.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(Y?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:W==="all",disabled:C.length===0,onChange:G=>{const J=G.target.checked;dn(ie=>J?qA(ie,C):YA(ie,C))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:v.name}),v.builtin?i.jsx("em",{children:"built-in"}):null,W==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":Y?`展开 ${v.name}`:`收起 ${v.name}`,onClick:()=>{tx(G=>{const J=new Set(G);return J.has(v.id)?J.delete(v.id):J.add(v.id),J})},children:[i.jsx("span",{children:v.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Y?"expand_more":"expand_less"})]})]}),Y?null:i.jsx("div",{className:"af-composer-skill-group-items",children:v.skills.map(G=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Qa.has(G.key),onChange:J=>{const ie=J.target.checked;dn(oe=>ie?oe.includes(G.key)?oe:[...oe,G.key]:oe.filter(ve=>ve!==G.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:G.name}),G.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:G.description}):null]})]},`${v.id}:${G.key}`))})]},v.id)}),oc.ungrouped.length>0?i.jsxs("div",{className:"af-composer-skill-group",children:[i.jsxs("div",{className:"af-composer-skill-group-title",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("span",{children:oc.ungrouped.length})]}),oc.ungrouped.map(v=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Qa.has(v.key),onChange:C=>{const W=C.target.checked;dn(Y=>W?Y.includes(v.key)?Y:[...Y,v.key]:Y.filter(G=>G!==v.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:v.name}),v.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:v.description}):null]})]},`ungrouped:${v.key}`))]}):null]})}),document.body):null]}),i.jsxs("label",{className:"af-composer-model-field",children:[i.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),i.jsxs("select",{className:"af-composer-model-select",value:(Is||"").trim()?fr.currentNotInLists?fr.currentNotInLists:xm(Is,fr.cursorList,fr.opencodeList,fr.claudeCodeList):"",onChange:v=>Yd(v.target.value),disabled:!u||Vn,"aria-label":e("flow:composer.modelAriaLabel"),children:[i.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),fr.currentNotInLists?i.jsxs("option",{value:fr.currentNotInLists,children:[fr.currentNotInLists,e("flow:composer.modelNotInList")]}):null,fr.cursorList.length>0?i.jsx("optgroup",{label:"Cursor",children:fr.cursorList.map(v=>i.jsx("option",{value:ga(v),children:v},`composer-c-${v}`))}):null,fr.opencodeList.length>0?i.jsx("optgroup",{label:"OpenCode",children:fr.opencodeList.map(v=>i.jsx("option",{value:`opencode:${ga(v)}`,children:v},`composer-o-${v}`))}):null,fr.claudeCodeList.length>0?i.jsx("optgroup",{label:"Claude Code",children:fr.claudeCodeList.map(v=>i.jsx("option",{value:`claude-code:${ga(v)}`,children:v},`composer-cc-${v}`))}):null]})]}),i.jsx("button",{type:"button",className:"af-composer-send"+(u&&Zr.trim()&&!Vn?" af-composer-send--active":"")+(Vn?" af-composer-send--stop":""),disabled:!u||!Vn&&!Zr.trim(),"aria-label":e(Vn?"flow:composer.stopGeneration":"flow:composer.send"),title:Vn?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var v;if(Vn){(v=vo.current)==null||v.abort();return}ac()},children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Vn?"stop":"arrow_upward"})})]})]}),nc?Ir.createPortal(i.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:v=>{v.target===v.currentTarget&&rc(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[i.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[i.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),i.jsx("div",{className:"af-composer-thread-dialog-status"+(Vn?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:bo||void 0,children:Vn&&!bo?e("flow:composer.executing"):bo||e("flow:composer.ready")})]}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>rc(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),su.length>1&&!(Tt&&Array.isArray(Tt.phases)&&Tt.phases.length>1)?i.jsx("div",{className:"af-composer-steps-track-wrap",children:i.jsx(oq,{steps:su})}):null,Tt&&Array.isArray(Tt.phases)&&Tt.phases.length>1?i.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Tt.phases.map((v,C)=>{const W=v.status||(C<(Tt.currentPhase??0)?"done":C===(Tt.currentPhase??0)?Vn?"running":Tt.nextPhase||Tt.isLastPhase?"done":"running":"pending");return i.jsxs("div",{className:"af-composer-phase-item"+(W==="done"?" af-composer-phase-item--done":"")+(W==="running"?" af-composer-phase-item--running":"")+(W==="pending"?" af-composer-phase-item--pending":""),title:`${v.label}${v.description?":"+v.description:""}`,children:[i.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:W==="done"?i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):i.jsx("span",{children:C+1})}),i.jsx("span",{className:"af-composer-phase-label",children:v.label})]},v.name||C)})}):null,i.jsx("div",{className:"af-composer-thread-dialog-scroll",children:i.jsx(Q1,{thread:Va,liveSegments:Wa,running:Vn})}),Tt&&!Tt.isLastPhase&&Tt.nextPhase&&!Vn?i.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[i.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Tt.nextPhase.label})}),i.jsxs("div",{className:"af-composer-phase-review-buttons",children:[i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Vk,children:e("flow:composer.phaseReviewContinue",{label:Tt.nextPhase.label})}),i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:Wk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),es&&Q==="edit"?(()=>{var Y;const v=String(es.query||"").trim().toLowerCase(),C=v?es.candidates.filter(G=>{var J,ie,oe;return[(J=G.def)==null?void 0:J.id,G.displayLabel,G.description,(ie=G.slot)==null?void 0:ie.name,(oe=G.slot)==null?void 0:oe.type].filter(Boolean).some(ve=>String(ve).toLowerCase().includes(v))}):es.candidates,W=es.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:es.left,top:es.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:qn((Y=es.draft.slot)==null?void 0:Y.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",es.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Hi(null),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:es.query,onChange:G=>Hi(J=>J&&{...J,query:G.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[C.map(G=>{var oe,ve;const J=G.displayLabel||((oe=G.def)==null?void 0:oe.id),ie=ww(G.slot,G.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>se(G),title:G.description||G.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:J}),J!==G.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:G.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:W}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:qn((ve=G.slot)==null?void 0:ve.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ie})]})]},`${G.def.id}-${G.slotIndex}`)}),C.length===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):i.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Q!=="edit"&&br&&i.jsxs("div",{className:"af-run-console",style:{height:uo},children:[i.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:Ht,onPointerMove:Ge,onPointerUp:us,onPointerCancel:us,onLostPointerCapture:af}),i.jsxs("div",{className:"af-run-console__head",children:[i.jsxs("span",{className:"af-run-console__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),i.jsxs("div",{className:"af-run-console__head-right",children:[Q==="running"&&i.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),i.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>nt(!1),"aria-label":e("flow:run.closeLog"),children:i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),i.jsxs("div",{className:"af-run-console__body",children:[qe.map((v,C)=>i.jsxs("div",{className:"af-run-console__line"+(v.type==="error"?" af-run-console__line--error":"")+(v.type==="warn"?" af-run-console__line--warn":"")+(v.type==="node-start"?" af-run-console__line--start":"")+(v.type==="node-done"?" af-run-console__line--done":"")+(v.type==="node-failed"?" af-run-console__line--error":"")+(v.type==="done"?" af-run-console__line--done":""),children:[i.jsxs("span",{className:"af-run-console__ts",children:["[",v.ts?new Date(v.ts).toLocaleTimeString():"--:--:--","]"]}),i.jsx("span",{className:"af-run-console__text",children:v.text!=null?String(v.text):""})]},C)),i.jsx("div",{ref:qc})]})]})]}),Q!=="edit"&&po&&u?i.jsx(TU,{instanceId:po,flowId:u.id,runId:Sn,nodeStatus:((qk=wr[po])==null?void 0:qk.status)??null,onClose:()=>Ri(null)}):null,Wt&&Wt!=="settings"&&u&&Q==="edit"?i.jsx("aside",{className:"af-pipeline-drawer"+(Wt==="node"?" af-pipeline-drawer--wide":"")+(Wt==="composer"?" af-pipeline-drawer--wide":""),"aria-label":Wt==="settings"?e("flow:settings.title"):Wt==="history"?e("flow:history.title"):Wt==="composer"?"AI Composer":e("flow:nodeProps.title"),children:Wt==="composer"?i.jsxs("div",{className:"af-composer-sidebar",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:lf,"aria-label":e("flow:composer.closeSidebar"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ts.length>0&&i.jsxs("div",{className:"af-composer-session-tabs",children:[Ts.map(v=>i.jsxs("button",{type:"button",ref:C=>{C&&v.id===Sr&&C.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",v.id===Sr?"af-composer-session-tab--active":"",v.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Ua(v.id),title:v.label,children:[i.jsx("span",{className:"af-composer-session-label",children:v.label}),i.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:C=>{C.stopPropagation(),iu(v.id)},onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),C.stopPropagation(),iu(v.id))},title:v.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},v.id)),i.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>vh(),title:e("flow:composer.newConversation"),children:i.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),i.jsx("div",{className:"af-composer-sidebar-status"+(Vn?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Vn&&!bo?e("flow:composer.executing"):bo||e("flow:composer.ready")}),Tt&&Array.isArray(Tt.phases)&&Tt.phases.length>1?i.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Tt.phases.map((v,C)=>{const W=v.status||(C<(Tt.currentPhase??0)?"done":C===(Tt.currentPhase??0)?Vn?"running":Tt.isLastPhase&&C===Tt.phases.length-1||Tt.nextPhase?"done":"running":"pending");return i.jsxs("div",{className:"af-composer-phase-item"+(W==="done"?" af-composer-phase-item--done":"")+(W==="running"?" af-composer-phase-item--running":"")+(W==="pending"?" af-composer-phase-item--pending":""),title:`${v.label}${v.description?":"+v.description:""}`,children:[i.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:W==="done"?i.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):i.jsx("span",{children:C+1})}),i.jsx("span",{className:"af-composer-phase-label",children:v.label})]},v.name||C)})}):null,i.jsx("div",{className:"af-composer-sidebar-thread",ref:ca,children:i.jsx(Q1,{thread:Va,liveSegments:Wa,running:Vn})}),Tt&&!Tt.isLastPhase&&Tt.nextPhase&&!Vn?i.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[i.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Tt.nextPhase.label})}),i.jsxs("div",{className:"af-composer-phase-review-buttons",children:[i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Vk,children:e("flow:composer.phaseReviewContinue",{label:Tt.nextPhase.label})}),i.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:Wk,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):Wt==="node"&&ct?Nt?i.jsx($R,{draft:Nt,setDraft:qd,definitionId:String(((Yk=ct.data)==null?void 0:Yk.definitionId)??ct.id),systemPromptReadonly:String((rf==null?void 0:rf.description)??""),modelLists:_t,disabled:!u,onIdBlur:qt,onClose:lf,onPublishToMarketplace:ox,error:Pe,ioSlots:{inputs:Array.isArray(Nt==null?void 0:Nt.inputs)?Nt.inputs:[],outputs:Array.isArray(Nt==null?void 0:Nt.outputs)?Nt.outputs:[]}}):i.jsx("div",{className:"af-pipeline-drawer-body",children:i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:e(Wt==="settings"?"flow:settings.title":"flow:history.title")}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:lf,"aria-label":e("flow:composer.closeSidebar"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-pipeline-drawer-body",children:Wt==="settings"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?i.jsxs("div",{className:"af-pipeline-rename-row",children:[i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:z,onChange:v=>{K(v.target.value),R("")},onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),at())},onBlur:()=>{z.trim()&&z.trim()!==u.id&&at()},placeholder:u.id,disabled:B,spellCheck:!1}),i.jsx("span",{className:"af-pipeline-drawer-badge",children:Su(u.source??"user",e)})]}):i.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,i.jsx("span",{className:"af-pipeline-drawer-badge",children:Su(u.source??"user",e)}),u.archived?i.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),D?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:D}):null]}),typeof u.path=="string"&&u.path?i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),i.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[i.jsx("span",{className:"af-pipeline-path-text",children:u.path}),i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>Ut(u.path),title:e("flow:settings.copyPath"),children:i.jsx("span",{className:"material-symbols-outlined",children:M?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):i.jsxs("div",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),i.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>ke("workspace"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:T,onClick:()=>ke("user"),children:e(T?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),E?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:E}):null]}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:w,onChange:v=>k(v.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),i.jsxs("div",{className:"af-pipeline-meta-card",children:[i.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),Hd?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-new-pipeline-radio",children:[i.jsx("input",{type:"checkbox",checked:!!Mn.enabled,disabled:mi||u.archived||$s(u.source),onChange:v=>bs(C=>({...C,enabled:v.target.checked}))}),i.jsx("span",{children:e("flow:schedule.enabled")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Mn.cron||"",disabled:mi||u.archived||$s(u.source),onChange:v=>bs(C=>({...C,cron:v.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),i.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:Mn.timezone||"",disabled:mi||u.archived||$s(u.source),onChange:v=>bs(C=>({...C,timezone:v.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),i.jsxs("select",{className:"af-pipeline-flow-select",value:Mn.preset||"",disabled:mi||u.archived||$s(u.source),onChange:v=>bs(C=>({...C,preset:v.target.value})),children:[i.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(bt).map(v=>i.jsx("option",{value:v,children:v},v))]})]}),i.jsx("div",{className:"af-pipeline-drawer-readonly",children:i.jsx("span",{children:e("flow:schedule.overlapSkip")})}),Mn.nextRunAt?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(Mn.nextRunAt).toLocaleString()})}):i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),i.jsxs("dl",{className:"af-pipeline-meta-dl",children:[i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.runtime")}),i.jsx("dd",{children:Wn!=null&&Wn.running?e("flow:schedule.running"):Mn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),tn.lastTriggeredAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),i.jsx("dd",{children:new Date(tn.lastTriggeredAt).toLocaleString()})]}):null,tn.lastSkippedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),i.jsxs("dd",{children:[new Date(tn.lastSkippedAt).toLocaleString(),tn.lastSkipReason?` · ${tn.lastSkipReason}`:""]})]}):null,tn.lastRunUuid?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastRun")}),i.jsx("dd",{children:tn.lastRunUuid})]}):null,tn.lastExitCode!=null?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastExit")}),i.jsx("dd",{children:String(tn.lastExitCode)})]}):null,tn.lastFinishedAt?i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),i.jsx("dd",{children:new Date(tn.lastFinishedAt).toLocaleString()})]}):null]}),Wn!=null&&Wn.lastError||tn.lastError?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Wn==null?void 0:Wn.lastError)||tn.lastError}):null,u.archived||$s(u.source)?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,La?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:La}):null,Kc?i.jsx("p",{className:"af-pipeline-drawer-muted",children:Kc}):null,i.jsx("button",{type:"button",className:"af-btn-secondary",disabled:mi||u.archived||$s(u.source),onClick:De,children:e(mi?"flow:schedule.saving":"flow:schedule.save")})]})]}),i.jsxs("div",{className:"af-pipeline-meta-card",children:[i.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),i.jsx("dl",{className:"af-pipeline-meta-dl",children:i.jsxs("div",{className:"af-pipeline-meta-row",children:[i.jsx("dt",{children:e("flow:pipeline.nodeCount")}),i.jsxs("dd",{children:[Rt.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),i.jsx("strong",{children:u.id})]}),_r?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):dr?i.jsx("p",{className:"af-err af-pipeline-drawer-err",children:dr}):Te.length===0?i.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):i.jsxs(i.Fragment,{children:[ft.success+ft.failed+ft.running+ft.stopped+ft.interrupted>0?i.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[ft.success>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:ft.success})}):null,ft.failed>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:ft.failed})}):null,ft.stopped>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:ft.stopped})}):null,ft.interrupted>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:ft.interrupted})}):null,ft.running>0?i.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:ft.running})}):null]}):null,i.jsx("ul",{className:"af-exec-history-list",children:Te.map((v,C)=>{const W=v.status||"unknown",Y=W==="success"?"af-exec-history-card--success":W==="failed"?"af-exec-history-card--failed":W==="stopped"?"af-exec-history-card--stopped":W==="interrupted"?"af-exec-history-card--interrupted":W==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",G=e(W==="success"?"flow:history.success":W==="failed"?"flow:history.failed":W==="stopped"?"flow:history.stopped":W==="interrupted"?"flow:history.interrupted":W==="running"?"flow:history.running":"flow:history.unknown"),J=W==="success"?"check_circle":W==="failed"?"error":W==="stopped"?"stop_circle":W==="interrupted"?"sync_disabled":W==="running"?"progress_activity":"help",ie=v.runId||`${v.at}-${C}`,oe=v.runId!=null&&v.runId.length>=6?e("flow:history.runLabel",{id:v.runId.length>8?v.runId.slice(-8):v.runId}):e("flow:history.runLabel",{id:Te.length-C});return i.jsx("li",{className:"af-exec-history-list-item",children:i.jsxs("button",{type:"button",className:`af-exec-history-card ${Y}`,onClick:()=>Pt(v),title:e("flow:history.enterRunView"),children:[i.jsxs("div",{className:"af-exec-history-card-top",children:[i.jsx("span",{className:"af-exec-history-card-title",children:oe}),i.jsx("span",{className:"af-exec-history-card-time",children:Mb(v.at,e)})]}),i.jsxs("div",{className:"af-exec-history-card-bottom",children:[i.jsxs("span",{className:"af-exec-history-card-status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J}),G]}),i.jsxs("span",{className:"af-exec-history-card-duration",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),f$(v.durationMs,e)]})]})]})},`${u.id}-${ie}`)})})]})]})})]})}):null]}),i.jsx(P1,{open:mu,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:dx,onCancel:()=>bi(!1)}),i.jsx(P1,{open:gu,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:gt,onSecondary:St,onCancel:()=>Ce(!1)}),i.jsx(IR,{open:Xc,onClose:()=>Oi(!1)}),dM(),i.jsx(TR,{open:Jc,onClose:()=>aa(!1),onJump:q,nodes:Rt}),i.jsx(BU,{open:Ii,onClose:()=>co(!1),flowId:(u==null?void 0:u.id)??""}),i.jsx(AR,{open:F,onClose:()=>P(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{P(!1),await sc(),n("/projects?tab=archived")}}),i.jsx(PR,{open:O&&!!(u!=null&&u.id),onClose:()=>_(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),onDeleted:async()=>{_(!1),f(null),At([]),wn([]),zi(null),await sc(),n("/projects")}}),_n&&Ir.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>We(!1),"aria-label":e("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"名称"}),i.jsx("input",{type:"text",value:sn.name,onChange:v=>{const C=v.target.value;xt(W=>({...W,name:C,id:W.id?W.id:C.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"ID"}),i.jsx("input",{type:"text",value:sn.id,onChange:v=>xt(C=>({...C,id:v.target.value})),placeholder:"pr-check-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:sn.description,onChange:v=>xt(C=>({...C,description:v.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Lt.length," 个节点和 ",bn.length," 条内部连线。"]}),_e?i.jsx("div",{className:"af-flow-snippet-error",children:_e}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>We(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:kn||!sn.name.trim(),onClick:()=>void da(),children:kn?"发布中…":"发布"})]})]})}),document.body),i.jsx(xU,{open:!!Z,onClose:()=>ee(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(Z==null?void 0:Z.filePath)??"",fileName:(Z==null?void 0:Z.fileName)??"",onSaved:()=>{Ar(v=>({...v}))}})]}),yn&&Q!=="edit"&&Ir.createPortal(i.jsx("div",{className:"af-user-check-modal-overlay",children:i.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-user-check-modal__head",children:[i.jsxs("span",{className:"af-user-check-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:yn.instanceId})]}),i.jsx("div",{className:"af-user-check-modal__actions",children:Wd?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!yn||!u||!Sn)return;const v=$a||yn.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:Sn,instanceId:yn.instanceId,content:v})})).ok?(Gl(W=>W&&{...W,content:v}),Wr(!1),Me(W=>[...W,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):Me(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Me(C=>[...C,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Zo(yn.content),Wr(!1)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Wr(!0),children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),i.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Gl(null),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),i.jsx("div",{className:"af-user-check-modal__body",children:Wd?i.jsx("textarea",{ref:Qy,className:"af-user-check-modal__textarea",value:$a||yn.content,onChange:v=>Zo(v.target.value)}):i.jsx("div",{className:"af-user-check-modal__preview",children:i.jsx("pre",{children:$a||yn.content})})}),i.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[i.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:Da,onChange:v=>mo(v.target.value),disabled:Xl}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Xl||!Da.trim(),onClick:()=>{!yn||!u||!Sn||!Da.trim()||(ea(!0),Me(v=>[...v,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"ai-edit-user-check-content",runUuid:Sn,instanceId:yn.instanceId,content:$a||yn.content,prompt:Da})}).then(v=>v.json()).then(v=>{ea(!1),v.ok&&v.content?(Zo(v.content),Wr(!0),mo(""),Me(C=>[...C,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):Me(C=>[...C,{ts:new Date().toISOString(),type:"error",text:v.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{ea(!1),Me(v=>[...v,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Xl?i.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):i.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),i.jsxs("div",{className:"af-user-check-modal__foot",children:[i.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),i.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!yn||!u||!Sn)return;const v=$a||yn.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:Sn,instanceId:yn.instanceId,content:v})})).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:Sn,instanceId:yn.instanceId,execId:yn.execId})}),Gl(null),mo(""),ti({runUuid:Sn})):Me(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{Me(C=>[...C,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),Qs&&Q!=="edit"&&Ir.createPortal(i.jsx("div",{className:"af-user-ask-modal-overlay",children:i.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-user-ask-modal__head",children:[i.jsxs("span",{className:"af-user-ask-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:Qs.instanceId})]}),i.jsx("div",{className:"af-user-ask-modal__actions",children:i.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Yc(null),"aria-label":e("flow:userAsk.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),i.jsxs("div",{className:"af-user-ask-modal__body",children:[Qs.question.trim()?i.jsx("div",{className:"af-user-ask-modal__question",children:i.jsx("pre",{children:Qs.question})}):null,Qs.options.length===0?i.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):i.jsx("div",{className:"af-user-ask-modal__options",children:Qs.options.map(v=>i.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:Vd,onClick:async()=>{if(!(!Qs||!u||!Sn)){gi(!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:Sn,instanceId:Qs.instanceId,execId:Qs.execId,branch:v.name,selectedIndex:v.index,selectedLabel:v.label})})).ok?(Yc(null),gi(!1),ti({runUuid:Sn})):(gi(!1),Me(W=>[...W,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{gi(!1),Me(C=>[...C,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[i.jsxs("span",{className:"af-user-ask-option__index",children:["[",v.index,"]"]}),i.jsx("span",{className:"af-user-ask-option__label",children:v.label})]},v.name))})]}),i.jsx("div",{className:"af-user-ask-modal__foot",children:i.jsx("span",{className:"af-user-ask-modal__hint",children:e(Vd?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),go&&Q!=="edit"&&i.jsxs("div",{className:"af-tool-print-toast"+(Jl?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[i.jsxs("div",{className:"af-tool-print-toast__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"print"}),i.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:go.instanceId})}),i.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Kd(v=>!v),"aria-label":e(Jl?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(Jl?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:Jl?"close_fullscreen":"open_in_full"})}),i.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Vr(null),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-tool-print-toast__body",children:i.jsx("div",{className:"af-tool-print-toast__markdown",children:i.jsx(ah,{children:go.content})})})]}),ta&&i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:ta.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Li(null),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:na,className:"af-provide-edit-modal__textarea",defaultValue:ta.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:rx,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Li(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),$e&&i.jsx("div",{className:"af-run-params-overlay",children:i.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-run-params-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),i.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),i.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Oe(!1),"aria-label":e("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-run-params-modal__body",children:ei.length===0?i.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):i.jsx("div",{className:"af-run-params-list",children:ei.map(v=>{var ve,Ne;const C=Ya[v.id];if(!C)return null;const W=((ve=v.data)==null?void 0:ve.definitionId)||"",Y=W.startsWith("provide_file"),G=W==="provide_bool",J=((Ne=v.data)==null?void 0:Ne.label)||v.id,ie=st[C]??"",oe=["true","1","yes","on"].includes(String(ie).trim().toLowerCase());return i.jsxs("div",{className:"af-run-params-item",children:[i.jsxs("div",{className:"af-run-params-item__head",children:[i.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(Y?" af-run-params-item__icon--file":""),children:Y?"description":G?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-params-item__label",children:J}),i.jsx("span",{className:"af-run-params-item__slot",children:C})]}),G?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(oe?" af-run-config-bool-toggle--true":""),onClick:()=>un(Ke=>({...Ke,[C]:oe?"false":"true"})),"aria-pressed":oe,children:oe?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-params-item__input",value:ie,onChange:Ke=>un(ye=>({...ye,[C]:Ke.target.value})),placeholder:e(Y?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},v.id)})})}),i.jsxs("div",{className:"af-run-params-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var C;const v={};for(const W of ei){const Y=Ya[W.id];if(!Y)continue;const G=((C=W.data)==null?void 0:C.definitionId)||"",J=st[Y]??"";G.startsWith("provide_file")?v[Y]={type:"file",path:J}:v[Y]={type:"str",value:J}}Oe(!1),be(!1),ti({cliInputsOverride:v})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),i.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Oe(!1),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const Nq="modulepreload",jq=function(e){return"/"+e},iC={},Cq=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=jq(c),c in iC)return;iC[c]=!0;const d=c.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const u=document.createElement("link");if(u.rel=d?"stylesheet":Nq,d||(u.as="script"),u.crossOrigin="",u.href=c,l&&u.setAttribute("nonce",l),document.head.appendChild(u),d)return new Promise((f,m)=>{u.addEventListener("load",f),u.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},Eq=new Set(["echarts"]),_q=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),Aq=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),Pq=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function _l(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Dc(e,t){if(!_l(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:_l(n[r])&&_l(s)&&(n[r]=Dc(n[r],s));return n}function Ky(e,t){return e==null?e:Array.isArray(e)?e.map(n=>_l(n)?Dc(n,t):n):_l(e)?Dc(e,t):e}function Iq(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 kv(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)=>kv(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||Aq.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);kv(r,`${t}.${n}`)}}}function Tq(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(!_q.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function Rq(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 Mq(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!_l(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return Dc(o,n)}):_l(e)?Dc(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function Lq(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Ky(e,n)}function oC(e,t="rgba(255, 255, 255, 0.62)"){return Ky(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 Oq(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Ky(e,n)}function $q(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:Ky(e,t)}function Dq(e,t,n){const r=Mq(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>_l(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??Pq,textStyle:Dc(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:Rq(e.tooltip),legend:Lq(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?Oq(e.grid,s||o):e.grid,xAxis:oC(e.xAxis),yAxis:oC(e.yAxis),radar:$q(e.radar),series:t}}function Fq(e){const t=Iq(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(!Eq.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");kv(n);const r=Tq(n.option.series),s=n.title==null?"":String(n.title),o=Dq(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function va(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 qR(e){const t=va(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function YR(e){return va(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function zq(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function Hq(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,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?o(d[1],d[2]||d[3]||d[4]||d[1]):o(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 Bq({code:e}){const t=h.useMemo(()=>Hq(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((p,u)=>{l.set(p.id,{x:28+(n?u*(r+o):u%3*(r+o)),y:28+(n?u%3*(s+a):u*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(p=>p.x+r+28)),d=Math.max(220,...Array.from(l.values()).map(p=>p.y+s+28));return i.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid flowchart preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-mermaid-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,u)=>{const f=l.get(p.from),m=l.get(p.to);if(!f||!m)return null;const g=n?`M ${f.x+r} ${f.y+s/2} C ${(f.x+m.x+r)/2} ${f.y+s/2}, ${(f.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${f.x+r/2} ${f.y+s} C ${f.x+r/2} ${f.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:g,markerEnd:"url(#af-md-mermaid-arrow)"},`${p.from}-${p.to}-${u}`)}),t.nodes.map(p=>{const u=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:u.x,y:u.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:u.x+r/2,y:u.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,24)})]},p.id)})]})}function Wq(e){const t=String(e||"").split(/\r?\n/).map(o=>o.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],s=(o,a="")=>{const l=String(o||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const o of t){if(/^sequenceDiagram\b/i.test(o))continue;const a=o.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){s(a[2],a[3]||a[2]);continue}const l=o.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){s(l[1]),s(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=o.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:o})}return{participants:Array.from(n,([o,a])=>({id:o,label:a})),rows:r}}function Vq({code:e}){const t=h.useMemo(()=>Wq(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,o=26,a=44,l=48,c=Math.max(620,s*2+n.length*r),d=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),p=u=>{const f=Math.max(0,n.findIndex(m=>m.id===u));return s+f*r+r/2};return i.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-sequence-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((u,f)=>{const m=s+f*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:m-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:m,y:o+22,textAnchor:"middle",children:u.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:m,y1:o+a,x2:m,y2:d-18})]},u.id)}),t.rows.map((u,f)=>{const m=o+a+f*l+24;if(u.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:m-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:m+4,children:u.text.slice(0,120)})]},`note-${f}`);const g=p(u.from),w=p(u.to),k=(g+w)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:g,y1:m,x2:w,y2:m,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:k,y:m-8,textAnchor:"middle",children:u.text.slice(0,72)})]},`msg-${f}`)})]})}function GR({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return i.jsx("div",{className:"af-md-mermaid-preview",children:n?i.jsx(Vq,{code:t}):i.jsx(Bq,{code:t})})}function Kq(e){const t=String(e||"").replace(/\r\n/g,`
137
- `).split(`
138
- `),n=[];let r=[],s=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&c){o();const d=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)d.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:d.join(`
140
- `)});continue}if(!s&&zq(l)){o();const d=[];for(;a<t.length;){const p=t[a]||"";if(d.length>0&&(!p.trim()||/^-{3,}\s*$/.test(p)||/^#{1,6}\s+/.test(p)))break;d.push(p),a++}n.push({type:"mermaid",text:d.join(`
141
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&va(l).length>1&&qR(t[a+1])){o();const d=va(l),p=YR(t[a+1]),u=[];for(a+=2;a<t.length&&t[a].trim()&&va(t[a]).length>1;)u.push(va(t[a])),a++;n.push({type:"table",headers:d,align:p,rows:u});continue}r.push(l),a++}return o(),n}function aC(e,t=""){const n=String(e||"").trim();if(!n||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n)||n.startsWith("/")||n.startsWith("#")||!t||n.startsWith("outputs/"))return n;const r=String(t||"").split("/").filter(Boolean);r.pop();const s=[...r,...n.split("/")].filter(Boolean),o=[];for(const a of s)if(a!=="."){if(a===".."){if(o.length===0)return n;o.pop();continue}o.push(a)}return o.join("/")}function XR(e){const t=String(e||"").replace(/\r\n/g,`
142
- `).split(`
143
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,s+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){s+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){s+=l,o+=1;continue}let p=o;for(;p<r.length&&!/\s|<|>/.test(r[p]);)p+=1;let u=r.slice(o,p),f="";for(;/[.,;:!?)}\]]$/.test(u);)f=u.slice(-1)+f,u=u.slice(0,-1);u?s+=`[${u}](${u})${f}`:s+=r.slice(o,p),o=p}return s}).join(`
144
- `)}function JR(e,t=!1,n=""){const r=s=>{const o=String(s||"").trim();if(!o)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(o)||o.startsWith("#"))return o;const a=aC(o,n);return e?e(a,{kind:"link",download:!0}):a};return{...t?{p:({children:s})=>i.jsx(i.Fragment,{children:s})}:{},code:({inline:s,className:o,children:a})=>{var d;const l=((d=String(o||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",c=String(a||"").replace(/\n$/,"");return!s&&/^(mermaid|mmd)$/i.test(l)?i.jsx(GR,{code:c}):s?i.jsx("code",{className:o,children:a}):i.jsx("code",{className:o,children:a})},img:({src:s,alt:o})=>i.jsx("img",{src:e?e(aC(s,n)):s||"",alt:o||"",loading:"lazy"}),a:({href:s,children:o})=>i.jsx("a",{href:r(s),target:"_blank",rel:"noopener noreferrer",children:o})}}function lC({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(ah,{components:JR(t,!0,n),children:XR(e)})}function Sk({content:e,resolveSrc:t,basePath:n=""}){const r=h.useMemo(()=>Kq(e),[e]),s=h.useMemo(()=>JR(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(GR,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(ah,{components:s,children:XR(o.text)},`md-${a}`):i.jsx("div",{className:"af-work-display-table-wrap",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:o.headers.map((l,c)=>i.jsx("th",{style:{textAlign:o.align[c]||"left"},children:i.jsx(lC,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((d,p)=>i.jsx("td",{style:{textAlign:o.align[p]||"left"},children:i.jsx(lC,{resolveSrc:t,basePath:n,children:l[p]||""})},p))},c))})]})},`table-${a}`))})}function Uq(e,t=","){const n=[];let r=[],s="",o=!1;const a=String(e||"").replace(/\r\n/g,`
145
- `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(o){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?o=!1:s+=c;continue}c==='"'?o=!0:c===t?(r.push(s.trim()),s=""):c===`
146
- `?(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 Po(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 qq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:s.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>s.map(a=>Po(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>Po(o)||`Column ${a+1}`);return{columns:s.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>s.map((a,l)=>Po(o[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,o)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||o),label:String(s.label||s.title||s.name||s.key||`Column ${o+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(o),label:Po(s)||`Column ${o+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,o)=>({key:String(o),label:Po(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>Po(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>Po(s[a])):s&&typeof s=="object"?r.map(o=>Po(s[o.key])):r.map((o,a)=>a===0?Po(s):""))}}function Yq(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=qq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
147
- `).split(`
148
- `).filter(l=>l.trim());if(s.length>=2&&va(s[0]).length>1&&qR(s[1])){const l=va(s[0]),c=YR(s[1]);return{columns:l.map((d,p)=>({key:String(p),label:d,align:c[p]||"left"})),rows:s.slice(2).map(d=>va(d)),error:""}}const o=r.includes(" ")?" ":",",a=Uq(r,o);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 Nk({content:e}){const t=h.useMemo(()=>Yq(e),[e]);return t.error||t.columns.length===0?i.jsxs("div",{className:"af-work-display-table-empty",children:[i.jsx("strong",{children:"Table data error"}),i.jsx("span",{children:t.error||"No columns found"})]}):i.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:t.columns.map((n,r)=>i.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),i.jsx("tbody",{children:t.rows.map((n,r)=>i.jsx("tr",{children:t.columns.map((s,o)=>i.jsx("td",{style:{textAlign:s.align||"left"},children:Po(n[o])},`${s.key}-${o}`))},r))})]})})}function jk({content:e}){const t=h.useRef(null),n=h.useMemo(()=>Fq(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 o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),Cq(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{o||!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),o||s({loading:!1,error:""}))}).catch(d=>{o||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,p;o=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const Gq="af:workspace-graph:v2",cC="agentflow.workspace.sidebarCollapsed",Eu=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],Xq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),Jq={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:""}]},Qq={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Zq={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}]},eY={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}]},tY=new Set(["png","jpg","jpeg","gif","webp","svg"]),QR=320,ZR=180,e2=960,Gg=96,t2=900,bm=52,Fc=240,zc=160,Sv="display-ref:",Hp="0 9 * * *",nY="Asia/Shanghai",rY="0.1.83";function sY(){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 Ro(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 Xg(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 tY.has(n)}function Jg(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=Ro(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function iY(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 oY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${cC}:${t}`:cC}function aY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function lY(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function cY(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 uY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!cY(e)}function dY(e){const t=String(e||"").trim();if(!t)return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function fY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function mc(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function pY(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(s)?`(+${mc(r)} / 总 ${mc(s)})`:"";return`${t+1}. ${n}${o}`}function n2(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function _u(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function hY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function mY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function gY(e,t){var s;const n=String(((s=t==null?void 0:t.args)==null?void 0:s.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function yY(e){var o,a,l;const t=n2(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=_u(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=mY(t),d=hY(t),p=_u(t.startedAtMs,c==null?void 0:c.startedAtMs),u=_u(t.completedAtMs,c==null?void 0:c.completedAtMs),f=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},m=Number.isFinite(p)&&Number.isFinite(u)?Math.max(0,u-p):_u(f.executionTime,f.localExecutionTimeMs),g=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||f.command||"").trim(),w=g?g.split(`
149
- `).find(Boolean)||g:"";return{kind:"tool",label:gY(d,c),durationMs:Number.isFinite(m)?m:null,at:s,detail:w?w.slice(0,90):""}}if(n==="result"){const c=_u(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:s,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:s,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:s,detail:""}:null}function uC(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(k=>typeof k=="string"?{text:k}:k).filter(k=>k&&String(k.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(k=>(k==null?void 0:k.kind)==="total"&&Number.isFinite(Number(k.durationMs))),l=[...s].reverse().find(k=>Number.isFinite(Number(k.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,d=_u(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=s.filter(k=>k.kind==="model").reduce((k,y)=>k+(Number(y.stepMs)||0),0),u=o.filter(k=>(k==null?void 0:k.kind)==="tool"),f=u.reduce((k,y)=>k+(Number(y.durationMs)||0),0),m=o.filter(k=>(k==null?void 0:k.kind)==="network").length,g=[...s.filter(k=>Number(k.stepMs)>=1e3).map(k=>({label:k.text,durationMs:Number(k.stepMs),detail:"Activity 间隔"})),...u.filter(k=>Number(k.durationMs)>=1e3).map(k=>({label:k.label,durationMs:Number(k.durationMs),detail:k.detail||"工具实际执行"}))].sort((k,y)=>y.durationMs-k.durationMs).slice(0,6),w=["耗时概览"];return Number.isFinite(d)&&w.push(`- 当前总耗时:${mc(d)}`),p>0&&w.push(`- 模型相关间隔:约 ${mc(p)}(按 Activity 间隔估算)`),u.length>0&&w.push(`- 工具实际执行:${mc(f)}(${u.length} 次完成事件)`),m>0&&w.push(`- 网络/会话恢复事件:${m} 次`),g.length>0&&(w.push(""),w.push("慢步骤"),g.forEach((k,y)=>{const b=k.detail?` · ${k.detail}`:"";w.push(`${y+1}. ${k.label}:${mc(k.durationMs)}${b}`)})),s.length>0&&(w.push(""),w.push("最近 Activity"),s.slice(-10).forEach((k,y)=>{w.push(pY(k,y))})),u.length>0&&(w.push(""),w.push("最近工具完成"),u.slice(-8).forEach((k,y)=>{const b=Number.isFinite(Number(k.durationMs))?` ${mc(k.durationMs)}`:"",x=k.detail?` · ${k.detail}`:"";w.push(`${y+1}. ${k.label}${b}${x}`)})),w.join(`
150
- `)}function dC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=n2(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function r2(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 s2(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Ck(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function i2(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function xY(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function wY(e){const t=String(e??"").trim();return t?t.includes("${")?t:i2(t):""}function o2(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const s=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),o=s?`${s}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(wY).filter(Boolean):[];return[xY(t,n),i2(o),...a].join(" ")}return String(t.command||"").trim()}function Of(e){const t=String(Ck(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function fC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Qg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function $f(e){return Qg(e)}function Nv(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function vm(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 pC(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function hC(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 kw(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),o=jd(s.get(n),e.sourceHandle||"output-0","source"),a=jd(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&Ml(o,a))}function bY(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=jd(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:CR(a)}:null}function vY(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let o=0;o<s.length;o+=1){const a=s[o];if(!(t.handleType==="source"?Ml(t.slot,a):Ml(a,t.slot)))continue;const c=Of(n);return{def:n,order:r,category:c,categoryRank:Eu.indexOf(c),slot:a,slotIndex:o,displayLabel:$f(n),description:Nv(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function kY(e,t,n){var o,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const d of e||[]){if(!d||d.id===n.nodeId)continue;const p=Array.isArray(s?(o=d.data)==null?void 0:o.inputs:(a=d.data)==null?void 0:a.outputs)?s?d.data.inputs:d.data.outputs:[];for(let u=0;u<p.length;u+=1){const f=p[u];if((f==null?void 0:f.showOnNode)===!1||!(s?Ml(n.slot,f):Ml(f,n.slot)))continue;const g=s?{source:n.nodeId,sourceHandle:n.handleId,target:d.id,targetHandle:`input-${u}`}:{source:d.id,sourceHandle:`output-${u}`,target:n.nodeId,targetHandle:n.handleId},w=(t||[]).some(k=>k.target===g.target&&k.targetHandle===g.targetHandle);r.push({node:d,nodeId:d.id,nodeLabel:((l=d.data)==null?void 0:l.label)||d.id,definitionId:((c=d.data)==null?void 0:c.definitionId)||"",slot:f,slotIndex:u,handleId:s?g.targetHandle:g.sourceHandle,connection:g,occupied:w})}}return r.sort((d,p)=>{var w,k,y,b,x,j,E,N;const u=Number(((k=(w=d.node)==null?void 0:w.position)==null?void 0:k.y)||0),f=Number(((b=(y=p.node)==null?void 0:y.position)==null?void 0:b.y)||0),m=Number(((j=(x=d.node)==null?void 0:x.position)==null?void 0:j.x)||0),g=Number(((N=(E=p.node)==null?void 0:E.position)==null?void 0:N.x)||0);return u-f||m-g||d.slotIndex-p.slotIndex||String(d.nodeId).localeCompare(String(p.nodeId))})}function qu(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 SY(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const o=`${n}_${s}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function NY(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function jY(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Hp;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:Hp}function ml(e,t=0,n=0,r=59){const s=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(s).padStart(2,"0")}function Ek(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${ml(t[1],9,0,23)}:${ml(t[2],0,0,59)}`:"09:00"}function Df(e,t,n,r,s){const o=Ek(t),[a,l]=o.split(":").map(d=>Number.parseInt(d,10)),c=String(e||"daily");if(c==="weekly"){const d=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${d}`}if(c==="monthly"){const d=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${d} * *`}return c==="custom"?String(s||"").trim()||Hp:`${l} ${a} * * *`}function CY(e){const n=String(e||Hp).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,o,a,l]=n,c=Number.parseInt(r,10),d=Number.parseInt(s,10),p=Number.isFinite(c)&&Number.isFinite(d)&&r===String(c)&&s===String(d),u=p?`${ml(d,9,0,23)}:${ml(c,0,0,59)}`:"09:00";return p&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:u,weekday:1,monthDay:1}:p&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:u,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:p&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:u,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:u,weekday:1,monthDay:1}}function _k(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=jY(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=CY(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Ek(t.time||a.time||"09:00"),d=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),p=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),u=Df(l,c,d,p,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:d,monthDay:p,cron:u,timezone:nY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function EY(e){const t=_k(JSON.stringify(e||{}));return JSON.stringify(t)}function _Y(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function AY(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function mC(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function Sw(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:mC(n.nextRunAt),lastAt:mC(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function ip(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Zg(e){return e>0?`Group ${e+1}`:"Group"}function PY(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!s||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:s,title:String((n==null?void 0:n.title)||Zg(r)).trim()||Zg(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Fc,Math.round(l)),height:Math.max(zc,Math.round(c))}}).filter(Boolean)}function IY(e){var n;return PY((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:$c,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function jv(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(Fc,Math.round(t)),height:Math.max(zc,Math.round(n))}}function km(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:NY(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function a2(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function TY(e){var s,o,a,l;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[a2(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(l=(a=t==null?void 0:t.runningRunNodeIds)==null?void 0:a.has)!=null&&l.call(a,e==null?void 0:e.id)?"running-run":""].join("::")}function Nw(e,t){var m,g;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=c2(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(m=e==null?void 0:e.ui)!=null&&m.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(g=e==null?void 0:e.ui)!=null&&g.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const w of s)w!=null&&w.source&&l.add(String(w.source)),w!=null&&w.target&&l.add(String(w.target));const d=Array.from(l).map(w=>{const k=r[w]||{},y=k.definitionId||w,b=t.find(B=>B.id===y),x=Ck(b)||y,j=t.find(B=>B.id===x)||b,E=k.marketplaceRef||s2(b),N=o2(b),T=o[w]&&typeof o[w].x=="number"&&typeof o[w].y=="number"?o[w]:{x:320+l.size*20,y:180+l.size*12},$=!!$n(x),z=a[w]&&typeof a[w].width=="number"&&typeof a[w].height=="number"?{width:a[w].width,height:a[w].height}:null,K=od(z,{display:$});return{id:w,type:$c,position:T,...K?{width:K.width,height:K.height}:{},data:{label:k.label||Qg(b)||Qg(j)||w,definitionId:x,...E?{marketplaceRef:E}:{},...b!=null&&b.packageId?{marketplacePackageId:b.packageId}:{},...b!=null&&b.version?{marketplaceVersion:b.version}:{},schemaType:r2(x,j||b),role:k.role||"normal",model:k.model||void 0,body:k.body||"",script:k.script||N||"",scriptRef:k.scriptRef||"",implementationRef:k.implementationRef||"",implementationMode:k.implementationMode||"",displayReloadKey:k.displayReloadKey||"",...K?{nodeSize:K}:{},...$&&K?{displaySize:K}:{}}}}).map(w=>zp(w,r,t)),p=IY(e),u=s.filter(w=>(w==null?void 0:w.source)&&(w==null?void 0:w.target)).filter(w=>!p.some(k=>k.id===String(w.source)||k.id===String(w.target))).map((w,k)=>({id:w.id||`we-${w.source}-${w.target}-${k}`,source:String(w.source),target:String(w.target),sourceHandle:w.sourceHandle??void 0,targetHandle:w.targetHandle??void 0,markerEnd:{type:js.ArrowClosed}})),f=[...p,...d];return{nodes:f,edges:NR(u,f),instances:r}}function gC(e){return`${Sv}${e}`}function jw(e){const t=String(e||"");return t.startsWith(Sv)?t.slice(Sv.length):t}function l2(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 Cv(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var f;return $n((f=u==null?void 0:u.data)==null?void 0:f.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const u of r){const f=String(u||"").trim();!f||o.has(f)||!n.has(f)||(o.add(f),s.push(f))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,f)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+f*36,y:120+f*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const f=od(d[u],{display:!0});f&&(c[u]=f)});const p=l2(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...p?{viewport:p}:{}}}function RY(e,t=[]){return Cv(e,t)}function MY(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function LY(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 yC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function od(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:yC(n,ZR,e2)||QR,height:yC(r,Gg,t2)||Gg}}function Au(e){var s,o,a,l,c,d,p,u,f,m,g;const t=!!$n((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((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=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:u.height)||((m=(f=e==null?void 0:e.data)==null?void 0:f.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 od({width:n,height:r},{display:t})}function Sm(e,t,n){var p,u,f,m,g,w,k,y,b,x,j,E,N;const r=(e||[]).filter(T=>!ip(T)),s=(e||[]).filter(ip),o=c2(lh(r,n||{})),a=t.map(T=>({source:T.source,target:T.target,sourceHandle:T.sourceHandle??null,targetHandle:T.targetHandle??null})).filter(T=>!s.some($=>$.id===T.source||$.id===T.target)),l={},c={},d=[];for(const T of r){l[T.id]={x:((p=T.position)==null?void 0:p.x)||0,y:((u=T.position)==null?void 0:u.y)||0};const $=Au(T);$&&(c[T.id]=$)}for(const T of s){const $=Number(((m=(f=T.data)==null?void 0:f.nodeSize)==null?void 0:m.width)||T.width||((g=T.measured)==null?void 0:g.width)||0),z=Number(((k=(w=T.data)==null?void 0:w.nodeSize)==null?void 0:k.height)||T.height||((y=T.measured)==null?void 0:y.height)||0);d.push({id:T.id,title:String(((b=T.data)==null?void 0:b.title)||((x=T.data)==null?void 0:x.label)||"Group"),color:String(((j=T.data)==null?void 0:j.color)||"purple"),x:Number(((E=T.position)==null?void 0:E.x)||0),y:Number(((N=T.position)==null?void 0:N.y)||0),width:Math.max(Fc,Math.round($||Fc)),height:Math.max(zc,Math.round(z||zc))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:d}}}function c2(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!$n(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 $n(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 Cc(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=$n(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),o=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&o(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&o(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&o(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Cd(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 OY(e){let t=String(e||"").replace(/\r\n/g,`
151
- `).trim();return t.includes(`
152
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
153
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
154
- $2`)),t}function Na(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=OY(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
155
- `).filter(f=>/^\s+/.test(f)||!f.trim()).map(f=>f.replace(/^\s{2}/,"")).join(`
156
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const d=t.replace(n[0],"").trim();if(d)return d}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function Ed(e,t){const n=Ro(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 Ev(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 $Y(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=s.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},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(`
157
- `)}).filter(Boolean).join(`
158
-
159
- `)}function Ld(e){let t=Na(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function DY(e){const t=Ld(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function bc(e,t){return e==="html"?DY(t):""}function u2(e,t=""){const n=Ld(e);if(!n.trim())return"";const s=`<base target="_self"><script>
160
- (() => {
161
- const frameId = ${JSON.stringify(String(t||""))};
162
- const postSize = () => {
163
- const doc = document.documentElement;
164
- const body = document.body;
165
- const height = Math.ceil(Math.max(
166
- doc ? doc.scrollHeight : 0,
167
- doc ? doc.offsetHeight : 0,
168
- doc ? doc.clientHeight : 0,
169
- body ? body.scrollHeight : 0,
170
- body ? body.offsetHeight : 0,
171
- body ? body.clientHeight : 0,
172
- window.innerHeight || 0
173
- ));
174
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
175
- };
176
- document.addEventListener("click", (event) => {
177
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
178
- if (!link) return;
179
- const rawHref = String(link.getAttribute("href") || "").trim();
180
- if (!rawHref || rawHref.startsWith("#")) return;
181
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
182
- event.preventDefault();
183
- window.location.href = link.href;
184
- }, true);
185
- window.addEventListener("load", postSize);
186
- window.addEventListener("resize", postSize);
187
- requestAnimationFrame(postSize);
188
- setTimeout(postSize, 60);
189
- setTimeout(postSize, 300);
190
- if (typeof ResizeObserver !== "undefined") {
191
- const resizeObserver = new ResizeObserver(postSize);
192
- resizeObserver.observe(document.documentElement);
193
- if (document.body) resizeObserver.observe(document.body);
194
- }
195
- if (typeof MutationObserver !== "undefined") {
196
- const mutationObserver = new MutationObserver(postSize);
197
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
198
- }
199
- })();
200
- <\/script>`;return/<script\b[^>]*>\s*\(\(\)\s*=>\s*\{\s*document\.addEventListener\("click"/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function FY(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 zY(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function HY(e,t){const n=URL.createObjectURL(e);try{zY(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function d2(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 BY(e){const t=d2(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>"}
201
- ${t.documentElement.outerHTML}`:""}function Cw(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 WY(e,t,n,r={}){var k;const s=(k=e==null?void 0:e.getBoundingClientRect)==null?void 0:k.call(e),o=d2(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,d=(r==null?void 0:r.displayBody)||null,p=(r==null?void 0:r.scroller)||null,u=(r==null?void 0:r.displaySize)||null,f={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:Cw(c),displayBody:Cw(d),scroller:Cw(p)},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((p==null?void 0:p.clientWidth)||0),Number((p==null?void 0:p.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(y=>Math.ceil(y)).filter(y=>y>0),g=Math.max(1,...m.length?m:[960]),w=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:w,debug:f}}async function VY({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const d=WY(r,s,o,{...l||{},displaySize:c}),p=BY(r),u=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:p||t,sourceFilePath:n||"",width:d.width,height:d.height,filename:a})});if(!u.ok){const m=await u.json().catch(()=>({}));throw new Error(m.error||"截图失败")}const f=await u.blob();HY(f,a)}function KY(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 f2(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function UY(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,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?o(d[1],d[2]||d[3]||d[4]||d[1]):o(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 p2({code:e}){const t=h.useMemo(()=>UY(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((p,u)=>{l.set(p.id,{x:24+(n?u*(r+o):u%3*(r+o)),y:24+(n?u%3*(s+a):u*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(p=>p.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(p=>p.y+s+24));return i.jsx("div",{className:"af-work-node__mermaid-preview",children:i.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,u)=>{const f=l.get(p.from),m=l.get(p.to);if(!f||!m)return null;const g=n?`M ${f.x+r} ${f.y+s/2} C ${(f.x+m.x+r)/2} ${f.y+s/2}, ${(f.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${f.x+r/2} ${f.y+s} C ${f.x+r/2} ${f.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${p.from}-${p.to}-${u}`)}),t.nodes.map(p=>{const u=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:u.x,y:u.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:u.x+r/2,y:u.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,22)})]},p.id)})]})})}function qi({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const p=n.current;if(!p)return;const u=Math.max(1,p.scrollHeight),f=Math.max(1,p.clientHeight),m=u>f+1,g=m?Math.max(12,f/u*100):100,w=Math.max(0,100-g),k=m?Math.min(w,p.scrollTop/Math.max(1,u-f)*w):0;o({visible:m,top:k,height:g})},[]);h.useEffect(()=>{const p=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const f=new ResizeObserver(a);f.observe(u);for(const m of Array.from(u.children))f.observe(m);return()=>{cancelAnimationFrame(p),f.disconnect()}},[t,a]);const l=h.useCallback(p=>{const u=n.current;if(!u)return;const f=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,p))*f,a()},[a]),c=h.useCallback((p,u=0)=>{const f=r.current;if(!f)return 0;const m=f.getBoundingClientRect(),g=s.height/100*m.height,w=Math.max(1,m.height-g);return(p-m.top-u)/w},[s.height]),d=h.useCallback(p=>{var j,E;if(!s.visible)return;p.preventDefault(),p.stopPropagation();const u=r.current;if(!u)return;const f=u.getBoundingClientRect(),m=s.top/100*f.height,g=s.height/100*f.height,k=p.clientY>=f.top+m&&p.clientY<=f.top+m+g?p.clientY-f.top-m:g/2;l(c(p.clientY,k));const y=p.pointerId;(E=(j=p.currentTarget).setPointerCapture)==null||E.call(j,y);const b=N=>{N.preventDefault(),l(c(N.clientY,k))},x=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",b),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[i.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function h2({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=$n(e==null?void 0:e.definitionId),o=Cc(e),a=s==="image"?o:Na(o),l=s==="image"?"":Cd(a,s),[c,d]=h.useState(""),[p,u]=h.useState(""),[f,m]=h.useState(!1);h.useEffect(()=>{let j=!1;return l?(m(!0),u(""),d(""),Ed(t,l).then(E=>{j||d(E)}).catch(E=>{j||u(String(E.message||E))}).finally(()=>{j||m(!1)}),()=>{j=!0}):(d(""),u(""),m(!1),()=>{j=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const g=l?c:a,w=s==="html"?Ld(g):Na(g),k=h.useRef(""),[y,b]=h.useState(0);if(k.current||(k.current=`html-display-${Math.random().toString(36).slice(2,10)}`),h.useEffect(()=>{if(s!=="html"){b(0);return}const j=k.current,E=N=>{const T=n.current;if(!T||N.source!==T.contentWindow)return;const $=N.data&&typeof N.data=="object"?N.data:null;if(!$||$.source!=="agentflow-html-display-size"||$.frameId!==j)return;const z=Math.ceil(Number($.height||0));!Number.isFinite(z)||z<=0||b(Math.min(2e5,Math.max(220,z)))};return b(0),window.addEventListener("message",E),()=>window.removeEventListener("message",E)},[w,n,r,s]),!s)return null;const x=bc(s,w);if(f)return i.jsxs(qi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(p)return i.jsx(qi,{className:"af-work-display-empty",children:p});if(x)return i.jsx(qi,{className:"af-work-display-empty",children:x});if(!w.trim())return i.jsx(qi,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return i.jsx(qi,{className:"af-work-display-body af-work-display-body--html",children:i.jsx("iframe",{ref:n,className:"af-work-display-html-frame",style:y>0?{height:`${y}px`}:void 0,title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals",srcDoc:u2(w,k.current)},r)});if(s==="image"){const j=Jg(w,t);return i.jsx(qi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:j,alt:KY(e),loading:"lazy"})})}return s==="markdown"?i.jsx(qi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(Sk,{content:w,basePath:l,resolveSrc:(j,E)=>Jg(j,t,E)})}):s==="chart"?i.jsx(qi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(jk,{content:w})}):s==="table"?i.jsx(qi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(Nk,{content:w})}):s==="mermaid"?i.jsxs(qi,{className:"af-work-display-body",children:[i.jsx(p2,{code:w}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:w})]}):i.jsx(qi,{className:"af-work-display-body af-work-display-body--ascii",children:i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:w})})}function qY({node:e,onClose:t}){var o,a,l;const n=h.useRef(null),r=$n((o=e==null?void 0:e.data)==null?void 0:o.definitionId),s=((a=e==null?void 0:e.data)==null?void 0:a.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览");return h.useEffect(()=>{const c=d=>{d.key==="Escape"&&(t==null||t())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t]),e?Ir.createPortal(i.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:i.jsxs("div",{className:"af-display-preview-shell",children:[i.jsxs("div",{className:"af-display-preview-head",children:[i.jsxs("div",{className:"af-display-preview-title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f2(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsx("button",{type:"button",className:"af-display-preview-close",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsx("div",{className:"af-display-preview-content",children:i.jsx(h2,{data:e.data,flowParams:(l=e.data)==null?void 0:l.flowParams,htmlFrameRef:n})})]})}),document.body):null}function YY({node:e}){var f,m,g,w,k,y,b,x,j,E,N;const t=$n((f=e==null?void 0:e.data)==null?void 0:f.definitionId),n=Cc(e==null?void 0:e.data),r=t==="image"?n:Na(n),s=t==="image"?"":Cd(r,t),[o,a]=h.useState(""),[l,c]=h.useState(!1);h.useEffect(()=>{var $;let T=!1;return s?(c(!0),a(""),Ed((($=e==null?void 0:e.data)==null?void 0:$.flowParams)||{},s).then(z=>{T||a(z)}).catch(()=>{T||a("")}).finally(()=>{T||c(!1)}),()=>{T=!0}):(a(""),c(!1),()=>{T=!0})},[s,(g=(m=e==null?void 0:e.data)==null?void 0:m.flowParams)==null?void 0:g.flowId,(k=(w=e==null?void 0:e.data)==null?void 0:w.flowParams)==null?void 0:k.flowSource,(b=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:b.archived,(x=e==null?void 0:e.data)==null?void 0:x.displayReloadKey]);const d=s?o:r,p=t==="html"?Ld(d):Na(d),u=bc(t,p);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):u?i.jsx("div",{className:"af-display-picker-preview__empty",children:u}):p.trim()?t==="html"?i.jsx("iframe",{title:((j=e==null?void 0:e.data)==null?void 0:j.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals",srcDoc:u2(p)}):t==="image"?i.jsx("img",{src:Jg(p,(E=e==null?void 0:e.data)==null?void 0:E.flowParams),alt:((N=e==null?void 0:e.data)==null?void 0:N.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(Sk,{content:p,basePath:s,resolveSrc:(T,$)=>{var z;return Jg(T,(z=e==null?void 0:e.data)==null?void 0:z.flowParams,$)}})}):t==="chart"?i.jsx(jk,{content:p}):t==="table"?i.jsx(Nk,{content:p}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(p2,{code:p}),i.jsx("pre",{children:p})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:p}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function GY({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=h.useRef(null),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(!1),[d,p]=h.useState({visible:!1,top:0,height:100}),u=h.useCallback(()=>{const y=s.current;if(!y)return;const b=Math.max(1,y.scrollHeight),x=Math.max(1,y.clientHeight),j=b>x+1,E=j?Math.max(12,x/b*100):100,N=Math.max(0,100-E),T=j?Math.min(N,y.scrollTop/Math.max(1,b-x)*N):0;p({visible:j,top:T,height:E})},[]);h.useEffect(()=>{const y=requestAnimationFrame(u),b=s.current;if(!b||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(y);const x=new ResizeObserver(u);return x.observe(b),()=>{cancelAnimationFrame(y),x.disconnect()}},[u,e]);const f=h.useCallback(y=>{const b=s.current;if(!b)return;const x=Math.max(0,b.scrollHeight-b.clientHeight);b.scrollTop=Math.min(1,Math.max(0,y))*x,u()},[u]),m=h.useCallback((y,b=0)=>{const x=a.current;if(!x)return 0;const j=x.getBoundingClientRect(),E=d.height/100*j.height,N=Math.max(1,j.height-E);return(y-j.top-b)/N},[d.height]),g=h.useCallback(y=>{if(!d.visible)return;y.preventDefault(),y.stopPropagation();const b=a.current;if(!b)return;const x=b.getBoundingClientRect(),j=d.top/100*x.height,E=d.height/100*x.height,T=y.clientY>=x.top+j&&y.clientY<=x.top+j+E?y.clientY-x.top-j:E/2;f(m(y.clientY,T));const $=K=>{K.preventDefault(),f(m(K.clientY,T))},z=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)};window.addEventListener("pointermove",$),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z)},[m,f,d.height,d.top,d.visible]),w=h.useCallback(y=>{const b=String(e||""),x=s.current,j=Number((x==null?void 0:x.selectionStart)??b.length),E=Number((x==null?void 0:x.selectionEnd)??j),N=b.slice(0,j),T=b.slice(E),$=N&&!N.endsWith(`
202
- `)?`
203
- `:"",z=T&&!T.startsWith(`
204
- `)?`
205
- `:"",K=`${N}${$}${y}${z}${T}`;t==null||t(K),window.requestAnimationFrame(()=>{var L,D;const B=N.length+$.length+y.length;(L=s.current)==null||L.focus(),(D=s.current)==null||D.setSelectionRange(B,B)})},[t,e]),k=h.useCallback(async y=>{if(!r&&!(!y||l)){c(!0);try{const b=await(n==null?void 0:n(y)),x=String(b||"").trim();if(x){const j=String(y.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";w(`![${j}](${x})`)}}finally{c(!1)}}},[w,n,r,l]);return i.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:y=>y.stopPropagation(),onDragOver:y=>{var x;Array.from(((x=y.dataTransfer)==null?void 0:x.items)||[]).some(j=>String((j==null?void 0:j.type)||"").startsWith("image/"))&&(y.preventDefault(),y.dataTransfer.dropEffect="copy")},onDrop:y=>{var x;const b=Array.from(((x=y.dataTransfer)==null?void 0:x.files)||[]).find(Xg);b&&(y.preventDefault(),k(b))},children:[i.jsxs("div",{className:"af-work-display-editor__toolbar",children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var y;return(y=o.current)==null?void 0:y.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),i.jsx("input",{ref:o,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:y=>{var x;const b=(x=y.target.files)==null?void 0:x[0];y.target.value="",b&&k(b)}})]}),i.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:y=>t==null?void 0:t(y.target.value),onScroll:u,onKeyDown:y=>{y.key==="Escape"&&y.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),i.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(d.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:g,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${d.height}%`,top:`${d.top}%`}})})]})}function XY({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=h.useState(a),d=h.useRef(!1),p=String(s.candidateContent||""),u=!!s.running,f=!!(t!=null&&t.readOnly),m=String(s.error||"");return h.useEffect(()=>{d.current||c(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-work-node-chat__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"继续微调"}),i.jsx("span",{children:(t==null?void 0:t.label)||e})]}),i.jsx("button",{type:"button",onClick:()=>{var g;return(g=t==null?void 0:t.onCloseNodeChat)==null?void 0:g.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||u||m||p.trim()?i.jsxs("div",{className:"af-work-node-chat__messages",children:[o.slice(-4).map((g,w)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${g.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:g.role==="assistant"?"AI":"你"}),i.jsx("p",{children:g.text})]},`${g.at||w}-${w}`)),u?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,m?i.jsx("div",{className:"af-work-node-chat__error",children:m}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:u||f,"aria-label":"添加上下文",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),i.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:u||f,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:g=>{var k;d.current=!1;const w=g.currentTarget.value;c(w),(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,w)},onChange:g=>{var k;const w=g.target.value;c(w),d.current||(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,w)},onKeyDown:g=>{var w,k;g.isComposing||(w=g.nativeEvent)!=null&&w.isComposing||g.keyCode===229||(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),(k=t==null?void 0:t.onSendNodeChat)==null||k.call(t,e,l))}}),i.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:u||f||!l.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onSendNodeChat)==null?void 0:g.call(t,e,l)},"aria-label":"发送",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),i.jsxs("div",{className:"af-work-node-chat__actions",children:[i.jsx("button",{type:"button",disabled:u||f||!p.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"replace")},children:"替换当前内容"}),i.jsx("button",{type:"button",disabled:u||f||!p.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"append")},children:"追加"})]})]}):i.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:g=>{var w;g.stopPropagation(),(w=t==null?void 0:t.onToggleNodeChat)==null||w.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function JY(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function QY(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function xC(e,t){const n=$n(t==null?void 0:t.definitionId)||"markdown";return`outputs/${QY((t==null?void 0:t.label)||e||n)}.${JY(n)}`}function ZY({id:e,data:t,selected:n,deleteNode:r}){var Se,ue,Ee;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((le,me)=>({slot:le,idx:me})).sort((le,me)=>{var ze,dt,Ft,Ue;const we=String(((ze=le.slot)==null?void 0:ze.name)||"").trim(),je=String(((dt=me.slot)==null?void 0:dt.name)||"").trim();if(we==="next"&&je!=="next")return-1;if(je==="next"&&we!=="next")return 1;const Ye=String(((Ft=le.slot)==null?void 0:Ft.type)||"").trim(),tt=String(((Ue=me.slot)==null?void 0:Ue.type)||"").trim();return Ye==="node"&&tt!=="node"?-1:tt==="node"&&Ye!=="node"?1:le.idx-me.idx}),l=$n(t==null?void 0:t.definitionId),c=h.useRef(null),d=h.useRef(null),[p,u]=h.useState(0),[f,m]=h.useState(!1),[g,w]=h.useState(!1),[k,y]=h.useState(!1),[b,x]=h.useState(""),[j,E]=h.useState(""),[N,T]=h.useState(!1),[$,z]=h.useState(!1),K=h.useRef(null),B=Cc(t),L=l==="markdown"?Na(B):"",D=l==="markdown"?Cd(L,"markdown"):"",R=l==="markdown"?D?j:L:"",M=!!(t!=null&&t.readOnly),I=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{let le=!1;return l!=="markdown"||!D?(E(""),T(!1),()=>{le=!0}):(T(!0),Ed((t==null?void 0:t.flowParams)||{},D).then(me=>{le||E(me)}).catch(me=>{var we;le||(E(""),(we=t==null?void 0:t.onStatus)==null||we.call(t,String(me.message||me)))}).finally(()=>{le||T(!1)}),()=>{le=!0})},[l,D,(Se=t==null?void 0:t.flowParams)==null?void 0:Se.flowId,(ue=t==null?void 0:t.flowParams)==null?void 0:ue.flowSource,(Ee=t==null?void 0:t.flowParams)==null?void 0:Ee.archived,t==null?void 0:t.displayReloadKey]),h.useEffect(()=>{if(!g)return;const le=()=>w(!1);return window.addEventListener("pointerup",le,!0),window.addEventListener("pointercancel",le,!0),window.addEventListener("mouseup",le,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("pointerup",le,!0),window.removeEventListener("pointercancel",le,!0),window.removeEventListener("mouseup",le,!0),window.removeEventListener("blur",le)}},[g]),h.useEffect(()=>{k||x(String(R||""))},[R,k]);const F=(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"),P=String((t==null?void 0:t.sourceNodeId)||e),O=(t==null?void 0:t.sharingDisplayNodeId)===P,_=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,Z=h.useCallback(async()=>{var pt,_n,We,sn,xt,kn,pe,_e,Ve,rt;if(l!=="html"||f)return;const le=Cc(t),me=Cd(le,l);let we=le;if(me)try{we=await Ed((t==null?void 0:t.flowParams)||{},me)}catch(it){m(!1),console.warn("Failed to read HTML display file before saving image.",it);return}const je=Ld(we);if(!je.trim())return;const Ye=bc(l,je);if(Ye){console.warn(Ye);return}const tt=(_n=(pt=d.current)==null?void 0:pt.getBoundingClientRect)==null?void 0:_n.call(pt),ze=(sn=(We=c.current)==null?void 0:We.querySelector)==null?void 0:sn.call(We,".af-work-display-body"),dt=(kn=(xt=c.current)==null?void 0:xt.querySelector)==null?void 0:kn.call(xt,".af-visible-scroll-frame__scroller"),Ft=Math.round(Math.max(Number((tt==null?void 0:tt.width)||0),Number((_==null?void 0:_.width)||0),Number(((pe=c.current)==null?void 0:pe.clientWidth)||0),Number((ze==null?void 0:ze.clientWidth)||0),Number((dt==null?void 0:dt.clientWidth)||0),Math.max(320,Number((_==null?void 0:_.width)||960)-2))),Ue=Math.round(Math.max(Number((tt==null?void 0:tt.height)||0),Number((_==null?void 0:_.height)||0),Number(((_e=c.current)==null?void 0:_e.clientHeight)||0),Number((ze==null?void 0:ze.clientHeight)||0),Number((dt==null?void 0:dt.clientHeight)||0),Math.max(180,Number((_==null?void 0:_.height)||640)-46)));m(!0);try{await VY({flowParams:(t==null?void 0:t.flowParams)||{},content:je,sourceFilePath:me,iframe:d.current,width:Ft,height:Ue,filename:FY((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:ze,scroller:dt},displaySize:_}),(Ve=t==null?void 0:t.onStatus)==null||Ve.call(t,"已导出 HTML 展示截图")}catch(it){const Mt=String((it==null?void 0:it.message)||it||"截图失败");(rt=t==null?void 0:t.onStatus)==null||rt.call(t,`HTML 截图失败:${Mt}`),console.warn("Failed to save HTML display as PNG.",it)}finally{m(!1)}},[t,_==null?void 0:_.height,_==null?void 0:_.width,e,l,f]),ee=h.useCallback(le=>{var me;M||!le||l!=="image"||(me=t==null?void 0:t.onUploadImageToDisplayNode)==null||me.call(t,e,le)},[t,e,l,M]),V=h.useCallback(le=>{var me,we;(me=le==null?void 0:le.stopPropagation)==null||me.call(le),!M&&((we=t==null?void 0:t.onSetDisplayNodeContent)==null||we.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),y(!1)))},[t,e,l,M]),ae=h.useCallback(le=>{var je,Ye;M||l!=="image"||!(Array.from(((je=le.dataTransfer)==null?void 0:je.files)||[]).some(Xg)||Array.from(((Ye=le.dataTransfer)==null?void 0:Ye.items)||[]).some(tt=>String((tt==null?void 0:tt.type)||"").startsWith("image/")))||(le.preventDefault(),le.stopPropagation(),le.dataTransfer.dropEffect="copy",z(!0))},[l,M]),fe=h.useCallback(le=>{l==="image"&&(le.currentTarget.contains(le.relatedTarget)||z(!1))},[l]),xe=h.useCallback(le=>{var we;if(l!=="image")return;const me=Array.from(((we=le.dataTransfer)==null?void 0:we.files)||[]).find(Xg);me&&(le.preventDefault(),le.stopPropagation(),z(!1),ee(me))},[l,ee]);return i.jsxs("div",{className:"af-work-display-card"+(_?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(g?" af-work-display-card--resizing":"")+($?" af-work-display-card--image-drop":"")+(I?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:_?{width:_.width,height:_.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:ae,onDragLeave:fe,onDrop:xe,children:[i.jsx(Z0,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>w(!0),onResizeEnd:()=>w(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((le,me)=>{if(le.showOnNode===!1)return null;const we=`${4.15+me*1.75}rem`,je=le.name||`#${me+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:we},children:je}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${me}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:we,background:qn(le.type)},title:`${je} · ${le.type}`})]},`in-${me}`)}),a.map(({slot:le,idx:me},we)=>{if(le.showOnNode===!1)return null;const je=`${4.15+we*1.75}rem`,Ye=le.name||`#${me+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:je},children:Ye}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${me}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:je,background:qn(le.type)},title:`${Ye} · ${le.type}`})]},`out-${me}`)}),i.jsxs("div",{className:"af-work-display-card__head",children:[i.jsxs("div",{className:"af-work-display-card__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:f2(l)}),i.jsx("strong",{children:F}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:le=>le.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var le,me,we,je;try{(je=(we=(me=(le=d.current)==null?void 0:le.contentWindow)==null?void 0:me.history)==null?void 0:we.back)==null||je.call(we)}catch{}},"aria-label":"后退",title:"后退",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var le,me,we,je;try{(je=(we=(me=(le=d.current)==null?void 0:le.contentWindow)==null?void 0:me.history)==null?void 0:we.forward)==null||je.call(we)}catch{}},"aria-label":"前进",title:"前进",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>u(le=>le+1),"aria-label":"刷新",title:"刷新",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:f,onClick:Z,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:f?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?k?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:le=>le.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:M||N,onClick:async()=>{var le,me,we;if(D){try{const je=await Ev((t==null?void 0:t.flowParams)||{},D,b);E(b),(le=t==null?void 0:t.onSetDisplayNodeContent)==null||le.call(t,e,je,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${je}`}),y(!1)}catch(je){(me=t==null?void 0:t.onStatus)==null||me.call(t,String(je.message||je))}return}(we=t==null?void 0:t.onSetDisplayNodeContent)==null||we.call(t,e,b,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),y(!1)},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"done"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String(R||"")),y(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M||N,onClick:le=>{le.stopPropagation(),x(String(R||"")),y(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:K,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:le=>{var we;const me=(we=le.target.files)==null?void 0:we[0];le.target.value="",me&&ee(me)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:le=>{var me;le.stopPropagation(),(me=K.current)==null||me.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:le=>{var me;le.stopPropagation(),(me=t==null?void 0:t.onOpenDisplayPreview)==null||me.call(t,P)},"aria-label":"全屏预览",title:"全屏预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:O,onClick:le=>{var me;le.stopPropagation(),(me=t==null?void 0:t.onShareDisplayNode)==null||me.call(t,P)},"aria-label":"分享展示",title:"分享展示(30 天有效)",children:i.jsx("span",{className:"material-symbols-outlined",children:O?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:V,"aria-label":"清空内容",title:"清空内容",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:()=>{var le;return(le=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:le.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"save"})}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:M,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&k?i.jsx(GY,{value:b,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:M}):i.jsx(h2,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:d,htmlFrameVersion:p}),i.jsx(XY,{nodeId:e,data:t})]})}function eG({id:e,data:t,selected:n,deleteNode:r}){var d,p,u;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((p=(d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d.has)==null?void 0:p.call(d,e))||((u=t==null?void 0:t.runningRunNodeIds)==null?void 0:u[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.nodeStatus)==="stopped",c=!!(t!=null&&t.readOnly);return i.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(l?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((f,m)=>{if(f.showOnNode===!1)return null;const g=`${2.25+m*1.75}rem`,w=f.name||`#${m+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:g},children:w}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${m}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:g,background:qn(f.type)},title:`${w} · ${f.type}`})]},`in-${m}`)}),o.map((f,m)=>{if(f.showOnNode===!1)return null;const g=`${2.25+m*1.75}rem`,w=f.name||`#${m+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:g},children:w}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${m}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:g,background:qn(f.type)},title:`${w} · ${f.type}`})]},`out-${m}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:c,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:c,onClick:f=>{var m,g;f.stopPropagation(),a?(m=t==null?void 0:t.onStopWorkspaceNode)==null||m.call(t,e):(g=t==null?void 0:t.onRunWorkspaceNode)==null||g.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),i.jsx("span",{children:a?"Stop":"Run line"})]})]})}function tG({id:e,data:t,selected:n,deleteNode:r}){var x,j,E;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=_k((t==null?void 0:t.body)||""),l=(t==null?void 0:t.scheduledRunState)||{},c=((j=(x=t==null?void 0:t.runningRunNodeIds)==null?void 0:x.has)==null?void 0:j.call(x,e))||((E=t==null?void 0:t.runningRunNodeIds)==null?void 0:E[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",d=(t==null?void 0:t.nodeStatus)==="stopped",p=!!(t!=null&&t.readOnly),u=N=>{var T;(T=t==null?void 0:t.onChangeScheduledRunConfig)==null||T.call(t,e,{...a,...N})},f=N=>{u({scheduleType:N,cron:Df(N,a.time,a.weekday,a.monthDay,a.cron)})},m=N=>{u({time:N,cron:Df(a.scheduleType,N,a.weekday,a.monthDay,a.cron)})},[g,w]=Ek(a.time).split(":"),k=(N,T)=>{m(`${ml(N,9,0,23)}:${ml(T,0,0,59)}`)},y=N=>{u({weekday:N,cron:Df(a.scheduleType,a.time,N,a.monthDay,a.cron)})},b=N=>{u({monthDay:N,cron:Df(a.scheduleType,a.time,a.weekday,N,a.cron)})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(c?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((N,T)=>{if(N.showOnNode===!1)return null;const $=`${2.25+T*1.75}rem`,z=N.name||`#${T+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:$},children:z}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${T}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:$,background:qn(N.type)},title:`${z} · ${N.type}`})]},`in-${T}`)}),o.map((N,T)=>{if(N.showOnNode===!1)return null;const $=`${2.25+T*1.75}rem`,z=N.name||`#${T+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:$},children:z}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${T}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:$,background:qn(N.type)},title:`${z} · ${N.type}`})]},`out-${T}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:p,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[i.jsxs("label",{className:"af-work-schedule-card__toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,disabled:p,onChange:N=>u({enabled:N.target.checked})}),i.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:a.scheduleType,disabled:p,onChange:N=>f(N.target.value),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"}),i.jsx("option",{value:"monthly",children:"每月"}),i.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{className:"af-work-schedule-time-selects",children:[i.jsx("select",{value:g,disabled:p,"aria-label":"小时",onChange:N=>k(N.target.value,w),children:Array.from({length:24},(N,T)=>ml(T,0,0,23)).map(N=>i.jsxs("option",{value:N,children:[N," 时"]},N))}),i.jsx("select",{value:w,disabled:p,"aria-label":"分钟",onChange:N=>k(g,N.target.value),children:Array.from({length:12},(N,T)=>ml(T*5,0,0,59)).map(N=>i.jsxs("option",{value:N,children:[N," 分"]},N))})]})]}):null,a.scheduleType==="weekly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"星期"}),i.jsxs("select",{value:a.weekday,disabled:p,onChange:N=>y(N.target.value),children:[i.jsx("option",{value:1,children:"周一"}),i.jsx("option",{value:2,children:"周二"}),i.jsx("option",{value:3,children:"周三"}),i.jsx("option",{value:4,children:"周四"}),i.jsx("option",{value:5,children:"周五"}),i.jsx("option",{value:6,children:"周六"}),i.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"日期"}),i.jsx("select",{value:a.monthDay,disabled:p,onChange:N=>b(N.target.value),children:Array.from({length:31},(N,T)=>T+1).map(N=>i.jsxs("option",{value:N,children:[N," 日"]},N))})]}):null,a.scheduleType==="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"Cron"}),i.jsx("input",{type:"text",value:a.cron,disabled:p,spellCheck:!1,placeholder:Hp,onChange:N=>u({cron:N.target.value})})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[AY(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",_Y(l.nextAt)]}),i.jsx("span",{children:c?"running":l.lastStatus||"idle"})]}),l.lastError?i.jsx("div",{className:"af-work-schedule-card__error",children:l.lastError}):null,i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(c?" af-work-run-card__button--stop":""),disabled:p,onClick:N=>{var T,$;N.stopPropagation(),c?(T=t==null?void 0:t.onStopWorkspaceNode)==null||T.call(t,e):($=t==null?void 0:t.onRunWorkspaceNode)==null||$.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:c?"stop_circle":"play_arrow"}),i.jsx("span",{children:c?"停止":"立即运行"})]})]})]})}function nG({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Hl(),o=!!(t!=null&&t.readOnly),a=jv(t==null?void 0:t.nodeSize)||{width:Fc,height:zc},l=h.useCallback(c=>{var d,p;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(p=(d=c.target)==null?void 0:d.closest)!=null&&p.call(d,".af-work-group-node__resize, .af-work-group-node__delete")||s(u=>y2(u,e))},[e,s]);return i.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:i.jsx(Z0,{className:"af-work-group-node__resize nodrag",minWidth:Fc,minHeight:zc,position:"bottom-right",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsxs("div",{className:"af-work-group-node__title nodrag",children:[i.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),i.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:o,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function rG(e){var g,w,k,y,b,x,j,E,N,T,$,z,K,B,L;const{setEdges:t,setNodes:n}=Hl(),r=(g=e.data)==null?void 0:g.onSyncNodePropDraft,s=!!((w=e.data)!=null&&w.readOnly),[o,a]=h.useState(!1),l=(k=e.data)!=null&&k.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=h.useCallback(D=>{s||(n(R=>R.filter(M=>M.id!==D)),t(R=>R.filter(M=>M.source!==D&&M.target!==D)))},[s,t,n]),d=h.useCallback(D=>{var R,M;D.button!==0||D.metaKey||D.ctrlKey||D.shiftKey||(M=(R=D.target)==null?void 0:R.closest)!=null&&M.call(R,".react-flow__handle, .af-work-display-resize")||(n(I=>y2(I,e.id)),t(I=>oG(I)))},[e.id,t,n]),p=h.useCallback((D,R)=>{s||(n(M=>M.map(I=>I.id===D?{...I,data:{...I.data,model:R}}:I)),r==null||r(D,{model:R}))},[s,n,r]),u=h.useCallback((D,R)=>{s||(n(M=>M.map(I=>{var P;if(I.id!==D)return I;const F=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((O,_)=>_===0?{...O,default:R,value:R}:O):[{type:"bool",name:"value",default:R,value:R}];return{...I,data:{...I.data,body:"",outputs:F}}})),r==null||r(D,M=>({body:"",outputs:Array.isArray(M==null?void 0:M.outputs)&&M.outputs.length?M.outputs.map((F,P)=>P===0?{...F,default:R,value:R}:F):[{type:"bool",name:"value",default:R,value:R}]})))},[s,n,r]),f=h.useCallback((D,R)=>{s||(n(M=>M.map(I=>I.id===D?{...I,data:{...I.data,body:R}}:I)),r==null||r(D,{body:R}))},[s,n,r]),m=h.useCallback((D,R)=>{if(s)return;const M=Vs(R);n(I=>I.map(F=>F.id===D?{...F,data:{...F.data,images:M}}:F)),r==null||r(D,{images:M})},[s,n,r]);return(y=e.data)!=null&&y.isWorkspaceGroup?i.jsx(nG,{...e,deleteNode:c}):$n((b=e.data)==null?void 0:b.definitionId)?i.jsx(ZY,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(eG,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:c}):((j=e.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"?i.jsx(tG,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:c}):((E=e.data)==null?void 0:E.definitionId)==="control_load_skills"?i.jsx(wG,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:c,skills:(N=e.data)==null?void 0:N.skills,skillCollections:(T=e.data)==null?void 0:T.skillCollections,onChangeSkillKeys:($=e.data)==null?void 0:$.onChangeLoadSkillKeys}):((z=e.data)==null?void 0:z.definitionId)==="control_load_mcp"?i.jsx(bG,{...e,data:{...e.data,onSelectNodePointerDown:d},deleteNode:c,servers:(K=e.data)==null?void 0:K.mcpServers,onChangeMcpNames:(B=e.data)==null?void 0:B.onChangeLoadMcpNames}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:d,children:[s?null:i.jsx(Z0,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:ZR,minHeight:Gg,maxWidth:e2,maxHeight:t2,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(ER,{...e,deleteNode:c,modelLists:(L=e.data)==null?void 0:L.modelLists,onModelChange:p,onProvideValueChange:u,onNodeBodyChange:f,onNodeImagesChange:m})]})}const sG={[$c]:rG};function Ak(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Ak(n.children,t);return t}function m2(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const s=Array.isArray(r.children)?m2(r.children,n):null;if(s)return s}return null}function iG(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function g2(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&g2(n.children,t));return t}function Nm(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 y2(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?s:e}function oG(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function aG(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function lG(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(o,a,l)=>{const c=r[a],d=l?`${l}/${c}`:c,p=a===r.length-1;let u=!1;const f=(Array.isArray(o)?o:[]).map(m=>m.name!==c?m:(u=!0,p?{...m,type:"file",name:c,path:d,icon:qu(c),size:n}:{...m,type:"directory",name:c,path:d,icon:qu(c,!0),children:s(m.children||[],a+1,d)}));return u||f.push(p?{type:"file",name:c,path:d,icon:qu(c),size:n}:{type:"directory",name:c,path:d,icon:qu(c,!0),children:s([],a+1,d)}),aG(f)};return s(e||[],0,"")}function cG(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"":t<1024?`${t} B`:t<1024*1024?`${Math.round(t/102.4)/10} KB`:`${Math.round(t/1024/102.4)/10} MB`}function x2({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(l=>{var u;const c=l.type==="directory",d=c&&(r==null?void 0:r.has(l.path)),p=n===l.path;return i.jsxs("li",{children:[i.jsx("div",{className:"af-work-file-row",children:i.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+l.type+(p?" af-work-file--selected":""),draggable:!c,onDragStart:f=>{c||a==null||a(f,l)},onClick:()=>{o==null||o(l),c&&(s==null||s(l.path))},onDoubleClick:()=>{c||t(l)},title:l.path,children:[c?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:d?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:l.icon||qu(l.name,c)}),i.jsx("span",{children:l.name})]})}),c&&!d&&((u=l.children)!=null&&u.length)?i.jsx(x2,{items:l.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a}):null]},l.path)})})}function uG({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=h.useMemo(()=>Ak(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(d=>l?`${d.path} ${d.name}`.toLowerCase().includes(l):!0);return i.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:o,children:i.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:d=>d.stopPropagation(),children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"选择文件"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:o,"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[i.jsx("input",{value:t,onChange:d=>n(d.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(""),children:[i.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),i.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(d=>i.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(d),children:[i.jsx("span",{className:"material-symbols-outlined",children:d.icon||qu(d.name)}),i.jsxs("span",{className:"af-work-file-picker-modal__main",children:[i.jsx("strong",{children:d.name}),i.jsx("small",{children:d.path})]}),d.size?i.jsx("em",{children:cG(d.size)}):null]},d.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function dG({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return i.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,o)=>{const a=s.kind==="run-log"||s.kind==="run-summary"||s.kind==="activity"||s.kind==="prompt"||s.kind==="raw"||s.kind==="thinking"||s.kind==="result"||s.kind==="assistant"?"reply":s.role==="user"?"user-msg":s.error?"error":"reply",l=s.kind==="run-summary"?"Steps":s.kind==="run-log"?"Run":s.kind==="activity"?"Activity":s.kind==="prompt"?"Prompt":s.kind==="raw"?"Raw Trace":s.kind==="thinking"?"Thinking":s.kind==="result"?"Result":s.kind==="assistant"?"Response":s.role==="user"?"You":s.error?"Error":"Reply";return i.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[i.jsx("div",{className:"af-composer-ai-block-label",children:l}),i.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${o}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function ey(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 fG(e){const t=ey((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 ey((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function pG(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function hG(e){const t=ey((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 ey((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function mG(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function wC(e){var r,s,o,a,l,c,d,p,u;if(!e)return null;const{inputs:t,outputs:n}=SR(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((s=e.data)==null?void 0:s.role)??"normal"),model:String(((o=e.data)==null?void 0:o.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:Vs((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((d=e.data)==null?void 0:d.scriptRef)??""),implementationRef:String(((p=e.data)==null?void 0:p.implementationRef)??""),implementationMode:String(((u=e.data)==null?void 0:u.implementationMode)??""),inputs:t,outputs:n}}function bC(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 gG(e,t,n){var p,u;const r=String(((p=e==null?void 0:e.data)==null?void 0:p.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=Rl.includes(o)?o:"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?[]:Vs(t==null?void 0:t.images),inputs:bC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((u=e.data)==null?void 0:u.outputs)?e.data.outputs:bC(t==null?void 0:t.outputs)},d=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||d!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const f of["scriptRef","implementationRef","implementationMode"]){const m=String((t==null?void 0:t[f])??"").trim();m?c[f]=m:delete c[f]}return c}function vC({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:o=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=o?l:a;if(o){if(!OR.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(w=>w.id===c&&w.id!==a))return{ok:!1,error:"Duplicate instance id"}}const d=gG(r,s,c),p=r.data||{};if(!(c!==a||p.label!==d.label||p.role!==d.role||p.model!==d.model||p.body!==d.body||JSON.stringify(Vs(p.images))!==JSON.stringify(d.images)||(p.script??void 0)!==(d.script??void 0)||(p.scriptRef??void 0)!==(d.scriptRef??void 0)||(p.implementationRef??void 0)!==(d.implementationRef??void 0)||(p.implementationMode??void 0)!==(d.implementationMode??void 0)||JSON.stringify(p.inputs||[])!==JSON.stringify(d.inputs||[])||JSON.stringify(p.outputs||[])!==JSON.stringify(d.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const f=e.map(w=>w.id===a?{...w,id:c,selected:!0,data:d}:w);let m=t,g=n;if(c!==a){g={...n||{}};const w={...g[a]||{}};delete g[a],g[c]=w,m=t.map((k,y)=>({...k,source:k.source===a?c:k.source,target:k.target===a?c:k.target,id:`we-${k.source===a?c:k.source}-${k.target===a?c:k.target}-${y}`}))}return{ok:!0,changed:!0,nextId:c,nodes:f,edges:m,instances:g}}function yG(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function xG(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","inputs","outputs"])yG(e[s],t[s])&&(r[s]=n[s]);return r}function wG({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],d=Array.isArray(s)?s:[],p=Array.isArray(o)?o:[],[u,f]=h.useState(!1),[m,g]=h.useState(""),[w,k]=h.useState(()=>new Set),y=h.useRef(null),b=h.useRef(null),[x,j]=h.useState({visible:!1,top:0,height:100}),E=h.useMemo(()=>new Set(fG(t)),[t]),N=h.useMemo(()=>new Map(d.map(M=>[M.key,M])),[d]),T=h.useMemo(()=>{const M=new Set,I=p.map(P=>{const O=Il(P,d).map(_=>N.get(_)).filter(Boolean);for(const _ of O)M.add(_.key);return{...P,skills:O}}).filter(P=>P.skills.length>0),F=d.filter(P=>!M.has(P.key));return{collectionGroups:I,ungrouped:F}},[N,p,d]);h.useEffect(()=>{k(M=>{let I=!1;const F=new Set(M);for(const P of T.collectionGroups)F.has(P.id)||(F.add(P.id),I=!0);return I?F:M})},[T.collectionGroups]);const $=h.useMemo(()=>{const M=m.trim().toLowerCase();if(!M)return T;const I=P=>[P==null?void 0:P.key,P==null?void 0:P.name,P==null?void 0:P.description].map(_=>String(_||"").toLowerCase()).join(" ").includes(M);return{collectionGroups:T.collectionGroups.map(P=>{const _=[P==null?void 0:P.id,P==null?void 0:P.name,P==null?void 0:P.description].map(Z=>String(Z||"").toLowerCase()).join(" ").includes(M)?P.skills:P.skills.filter(I);return{...P,skills:_}}).filter(P=>P.skills.length>0),ungrouped:T.ungrouped.filter(I)}},[T,m]),z=h.useCallback((M,I)=>{const F=new Set(E);for(const P of M)I?F.add(P):F.delete(P);a==null||a(e,Array.from(F))},[e,E,a]),K=h.useCallback(M=>{k(I=>{const F=new Set(I);return F.has(M)?F.delete(M):F.add(M),F})},[]),B=h.useCallback(()=>{const M=y.current;if(!M)return;const I=Math.max(1,M.scrollHeight),F=Math.max(1,M.clientHeight),P=I>F+1,O=P?Math.max(12,F/I*100):100,_=Math.max(0,100-O),Z=P?Math.min(_,M.scrollTop/Math.max(1,I-F)*_):0;j({visible:P,top:Z,height:O})},[]);h.useEffect(()=>{if(!u)return;const M=requestAnimationFrame(B);return()=>cancelAnimationFrame(M)},[w,$,E.size,u,B]);const L=h.useCallback(M=>{const I=y.current;if(!I)return;const F=Math.max(0,I.scrollHeight-I.clientHeight);I.scrollTop=Math.min(1,Math.max(0,M))*F,B()},[B]),D=h.useCallback((M,I=0)=>{const F=b.current;if(!F)return 0;const P=F.getBoundingClientRect(),O=x.height/100*P.height,_=Math.max(1,P.height-O);return(M-P.top-I)/_},[x.height]),R=h.useCallback(M=>{var fe,xe;if(!x.visible)return;M.preventDefault(),M.stopPropagation();const I=b.current;if(!I)return;const F=I.getBoundingClientRect(),P=x.top/100*F.height,O=x.height/100*F.height,Z=M.clientY>=F.top+P&&M.clientY<=F.top+P+O?M.clientY-F.top-P:O/2;L(D(M.clientY,Z));const ee=M.pointerId;(xe=(fe=M.currentTarget).setPointerCapture)==null||xe.call(fe,ee);const V=Se=>{Se.preventDefault(),L(D(Se.clientY,Z))},ae=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",ae),window.removeEventListener("pointercancel",ae)};window.addEventListener("pointermove",V),window.addEventListener("pointerup",ae),window.addEventListener("pointercancel",ae)},[D,L,x.height,x.top,x.visible]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((M,I)=>{if(M.showOnNode===!1)return null;const F=`${2.6+I*1.7}rem`,P=M.name||`#${I+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:F},children:P}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${I}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:F,background:qn(M.type)},title:`${P} · ${M.type}`})]},`in-${I}`)}),c.map((M,I)=>{if(M.showOnNode===!1)return null;const F=`${2.6+I*1.7}rem`,P=M.name||`#${I+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:F},children:P}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${I}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:F,background:qn(M.type)},title:`${P} · ${M.type}`})]},`out-${I}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:M=>{var I;M.stopPropagation(),u||(I=t==null?void 0:t.onRefreshSkills)==null||I.call(t),f(F=>!F)},children:[i.jsx("span",{children:E.size>0?`${E.size} skills selected`:"选择 Skills"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:m,onChange:M=>g(M.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?i.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:B,children:[$.collectionGroups.map(M=>{const I=M.skills.map(_=>_.key),F=I.filter(_=>E.has(_)).length,P=I.length>0&&F===I.length,O=w.has(M.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(O?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:P,onChange:_=>z(I,_.target.checked),"aria-label":`选择 ${M.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>K(M.id),"aria-expanded":!O,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:M.name}),M.description?i.jsx("em",{children:M.description}):null]})}),i.jsxs("small",{children:[F,"/",I.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>K(M.id),"aria-label":O?`展开 ${M.name}`:`收起 ${M.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:O?"chevron_right":"expand_more"})})]}),O?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:M.skills.map(_=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:E.has(_.key),onChange:Z=>z([_.key],Z.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:_.name}),_.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:_.description}):null]})]},`${M.id}:${_.key}`))})]},M.id)}),$.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:$.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:$.ungrouped.map(M=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:E.has(M.key),onChange:I=>z([M.key],I.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:M.name}),M.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:M.description}):null]})]},`ungrouped:${M.key}`))})]}):null,$.collectionGroups.length===0&&$.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),i.jsx("div",{ref:b,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:R,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function bG({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,d]=h.useState(!1),[p,u]=h.useState(""),f=h.useMemo(()=>new Set(hG(t)),[t]),m=h.useMemo(()=>(Array.isArray(s)?s:[]).map(k=>({name:String((k==null?void 0:k.name)||""),description:String((k==null?void 0:k.description)||""),detail:String((k==null?void 0:k.url)||[k==null?void 0:k.command,...Array.isArray(k==null?void 0:k.args)?k.args:[]].filter(Boolean).join(" ")||""),type:String((k==null?void 0:k.type)||"")})).filter(k=>k.name),[s]),g=h.useMemo(()=>{const k=p.trim().toLowerCase();return k?m.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(k)):m},[p,m]),w=h.useCallback((k,y)=>{const b=new Set(f);for(const x of k)y?b.add(x):b.delete(x);o==null||o(e,Array.from(b))},[e,f,o]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((k,y)=>{if(k.showOnNode===!1)return null;const b=`${2.6+y*1.7}rem`,x=k.name||`#${y+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:b},children:x}),i.jsx(gs,{type:"target",position:Qe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:b,background:qn(k.type)},title:`${x} · ${k.type}`})]},`in-${y}`)}),l.map((k,y)=>{if(k.showOnNode===!1)return null;const b=`${2.6+y*1.7}rem`,x=k.name||`#${y+1}`;return i.jsxs(h.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:b},children:x}),i.jsx(gs,{type:"source",position:Qe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:b,background:qn(k.type)},title:`${x} · ${k.type}`})]},`out-${y}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"hub"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:k=>{var y;k.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(b=>!b)},children:[i.jsx("span",{children:f.size>0?`${f.size} MCP selected`:"选择 MCP"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:k=>k.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:p,onChange:k=>u(k.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),p?i.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{className:"af-work-load-skills-menu",children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"MCP Servers"}),i.jsx("small",{children:g.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(k=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:f.has(k.name),onChange:y=>w([k.name],y.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:k.name}),k.description||k.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:k.description||k.detail}):null]})]},k.name))})]}),g.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function vG(){var Rh,Mh;const{t:e,i18n:t}=zn(),{navigate:n}=Yo(),r=Hl(),s=J0(),o=h.useMemo(sY,[]),[a,l]=h.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[c,d]=h.useState(!1),[p,u]=h.useState(!1),[f,m]=BI([]),[g,w,k]=WI([]),y=h.useRef([]),b=h.useRef([]),[x,j]=h.useState(()=>Cv(null,[])),E=h.useRef(x),[N,T]=h.useState(null),$=h.useRef(null),[z,K]=h.useState([]),B=h.useRef(new Map),L=h.useRef(new Map),D=h.useRef(null),R=h.useRef(null),M=h.useRef(null),[I,F]=h.useState(null),[P,O]=h.useState({}),_=h.useRef({}),Z=h.useRef(!1),ee=h.useRef(null),[V,ae]=h.useState([]),[fe,xe]=h.useState(""),[Se,ue]=h.useState("nodes"),[Ee,le]=h.useState([]),[me,we]=h.useState(!1),[je,Ye]=h.useState(""),[tt,ze]=h.useState(!1),[dt,Ft]=h.useState({name:"",id:"",description:""}),[Ue,pt]=h.useState(!1),[_n,We]=h.useState(""),[sn,xt]=h.useState(""),kn=h.useRef(null),[pe,_e]=h.useState(!1),[Ve,rt]=h.useState(!1),[it,Mt]=h.useState(""),[wt,gn]=h.useState(null),[cn,Jn]=h.useState({title:"",layout:"gallery",nodeIds:[]}),[on,An]=h.useState(""),[Pn,mr]=h.useState(!1),[Cr,gr]=h.useState(""),[Wt,Vt]=h.useState(!1),[ir,Er]=h.useState(""),[dr,yr]=h.useState(""),[_r,Lr]=h.useState(!1),[or,xr]=h.useState("nodes"),[Or,ws]=h.useState(""),[ar,Ar]=h.useState(0),[In,Tn]=h.useState(""),ce=h.useRef(""),[he,Q]=h.useState(null),ge=h.useRef(null),[qe,Me]=h.useState(""),[zt,Rn]=h.useState([]),[Hn,wr]=h.useState(""),[Ae,Br]=h.useState(!0),[lt,pn]=h.useState(""),[Zt,br]=h.useState(()=>new Set),[nt,os]=h.useState(""),[hi,Ii]=h.useState({nodeId:"",query:""}),[co,uo]=h.useState(!1),fo=h.useRef(null),Ti=h.useRef(null),Sn=h.useRef(""),[As,po]=h.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[Ri,Js]=h.useState(!1),[Qr,Jo]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[U,be]=h.useState(""),[$e,Oe]=h.useState([]),[st,un]=h.useState(!1),[bt,Bn]=h.useState([]),[vr,Mi]=h.useState([]),[Mn,Wl]=h.useState(!1),[Hd,Bd]=h.useState([]),mi=h.useCallback(S=>{kn.current&&window.clearTimeout(kn.current),xt(S),kn.current=window.setTimeout(()=>{xt(""),kn.current=null},3800)},[]),Vl=h.useCallback(S=>{const A=String(S||"").trim();if(!A)return;const H=()=>s(A);window.requestAnimationFrame(H),window.setTimeout(H,80)},[s]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(As)))}catch{}},[As]);const La=h.useCallback(S=>{const A=fo.current;if(!A)return;const H=A.getBoundingClientRect(),q=16,X=150,re=230,se=H.top+q,ne=H.bottom-q,te=Math.max(X,ne-se-re),de=Math.min(Math.max(S-se,X),te);po(de)},[]),Kl=h.useCallback(S=>{S.preventDefault(),S.stopPropagation(),Js(!0),La(S.clientY);const A=q=>{q.preventDefault(),La(q.clientY)},H=()=>{Js(!1),window.removeEventListener("pointermove",A,!0),window.removeEventListener("pointerup",H,!0),window.removeEventListener("pointercancel",H,!0)};window.addEventListener("pointermove",A,!0),window.addEventListener("pointerup",H,!0),window.addEventListener("pointercancel",H,!0)},[La]);h.useEffect(()=>()=>{kn.current&&window.clearTimeout(kn.current)},[]);const[Kc,Ul]=h.useState(()=>new Set),[tn,ql]=h.useState(!1),Wn=h.useRef(null),Uc=h.useRef(null),Yl=h.useRef(null),[ho,qc]=h.useState({}),[Qo,Oa]=h.useState(""),[yn,Gl]=h.useState(!1),[$a,Zo]=h.useState([]),[Wd,Wr]=h.useState([]),[Da,mo]=h.useState("workspace"),[Xl,ea]=h.useState(!1),[Qy,Qs]=h.useState(!0),[Yc,Vd]=h.useState(""),[gi,go]=h.useState({}),[Vr,Jl]=h.useState(null),[Kd,ta]=h.useState(!1),Li=h.useMemo(()=>Kd?oY(Vr):"",[Kd,Vr]),[na,Zr]=h.useState(!0);h.useEffect(()=>{Li&&Zr(aY(Li))},[Li]),h.useEffect(()=>{if(Li)try{window.localStorage.setItem(Li,na?"true":"false")}catch{}},[na,Li]);const[ra,sa]=h.useState(!1),[ia,Fa]=h.useState(!1),[oa,hh]=h.useState("pan"),[Gc,Xc]=h.useState({}),Oi=h.useRef({}),[Jc,aa]=h.useState({}),la=h.useRef(new Map),yo=h.useRef(new Set),[za,Ha]=h.useState(()=>new Set),[Ud,Nt]=h.useState({}),[qd,Pe]=h.useState(""),Ps=h.useMemo(()=>iY(o),[o]),[_t,mh]=h.useState(""),Is=o.flowSource||"user",Yd=h.useMemo(()=>new Set(Object.values(Gc||{}).map(S=>String((S==null?void 0:S.runNodeId)||"").trim()).filter(Boolean)),[Gc]),$i=h.useCallback(S=>{const A=Oi.current||{},H=typeof S=="function"?S(A):S,q=H&&typeof H=="object"&&!Array.isArray(H)?H:{};return Oi.current=q,Xc(q),q},[]),Zy=!!(o.flowId&&!o.archived&&(Is==="user"||Is==="workspace")),Di=h.useMemo(()=>{if(!o.flowId)return"/flow?panel=settings";const S=Gf({id:o.flowId,source:Is,archived:!!o.archived},"pipeline"),[A,H=""]=S.split("?"),q=new URLSearchParams(H);return q.set("panel","settings"),`${A}?${q.toString()}`},[o.archived,o.flowId,Is]);h.useEffect(()=>{o.flowId&&KA(o.flowId,o.flowSource||"user","workspace",!!o.archived)},[o]),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(()=>{Zo([]),Wr([]),mo("workspace"),Qs(!0)},[o]);const kr=h.useCallback(async()=>{const S=Ro(o),A=await fetch(`/api/workspace/files?${S.toString()}`),H=await A.json();if(!A.ok)throw new Error(H.error||"读取 workspace 失败");const q=H.files||[];Rn(q),br(new Set(g2(q))),wr(H.root||"")},[o]),yi=h.useCallback(async()=>{we(!0),Ye("");try{const S=await fetch("/api/marketplace/flow-snippets"),A=await S.json().catch(()=>({}));if(!S.ok)throw new Error(A.error||"读取流程片段失败");le(Array.isArray(A.snippets)?A.snippets:[])}catch(S){Ye(String(S.message||S)),le([])}finally{we(!1)}},[]),dn=h.useCallback(async(S=f,A=g)=>{var re;if(!Z.current)return;if(!Ae)throw Pe("Readonly workspace"),new Error("Readonly workspace");const H=Sm(S,A,_.current);H.ui={...H.ui||{},...$.current?{viewport:$.current}:{},displayPage:RY(E.current,S)};const q=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,graph:H})}),X=await q.json();if(!q.ok)throw new Error(X.error||"保存 workspace graph 失败");_.current=((re=X.graph)==null?void 0:re.instances)||H.instances,O(_.current),aa(Sw(X.workspaceSchedules||[])),Pe("Workspace graph saved")},[g,o,f,Ae]),gh=h.useCallback(S=>{var H;const A=(H=S==null?void 0:S.extra)!=null&&H.instances&&typeof S.extra.instances=="object"?S.extra.instances:{};_.current=A,O(A),m(Array.isArray(S==null?void 0:S.nodes)?S.nodes:[]),w(Array.isArray(S==null?void 0:S.edges)?S.edges:[]),Tn(""),F(null)},[w,m]),ex=h.useMemo(()=>({instances:P}),[P]),Qc=jR({nodes:f,edges:g,extra:ex,enabled:Z.current,onRestore:gh}),{resetHistory:yh,undo:Gd,redo:xh}=Qc,Ba=h.useCallback(async()=>{var ht,at;Z.current=!1;const S=Ro(o),A=Ro(o);A.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[H,q]=await Promise.all([fetch(`/api/nodes?${A.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),kr()]),X=await H.json(),re=await q.json();if(!H.ok)throw new Error(X.error||"读取节点定义失败");if(!q.ok)throw new Error(re.error||"读取 workspace graph 失败");const se=[...(Array.isArray(X)?X:X.nodes||[]).filter(Ut=>!Xq.has(Ut.id)),Zq,eY,Jq,Qq];ae(se);const ne=re.graph||JSON.parse(localStorage.getItem(Gq)||"null")||{},te=Nw(ne,se),de=Cv((ht=ne==null?void 0:ne.ui)==null?void 0:ht.displayPage,te.nodes),ke=l2((at=ne==null?void 0:ne.ui)==null?void 0:at.viewport);_.current=te.instances,O(te.instances),m(te.nodes),w(te.edges),aa(Sw(re.workspaceSchedules||[])),j(de),E.current=de,T(ke),$.current=ke,K([]),yh(te.nodes,te.edges,{instances:te.instances});const De=re.writable!==!1;Br(De),Pe(De?"Workspace ready":"Readonly workspace"),Z.current=!0},[o,t.language,kr,yh,w,m]),tx=h.useCallback(async(S,A)=>{const H={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:A,body:(S==null?void 0:S.body)||"",script:(S==null?void 0:S.script)||"",scriptRef:(S==null?void 0:S.scriptRef)||"",implementationRef:(S==null?void 0:S.implementationRef)||"",implementationMode:(S==null?void 0:S.implementationMode)||"",inputs:Array.isArray(S==null?void 0:S.inputs)?S.inputs:[],outputs:Array.isArray(S==null?void 0:S.outputs)?S.outputs:[],flowId:o.flowId,flowSource:o.flowSource||"user",archived:!!o.archived},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),X=await q.json().catch(()=>({}));if(!q.ok||(X==null?void 0:X.ok)===!1)throw new Error((X==null?void 0:X.error)||"Publish failed");return await Ba(),Pe(`Published node ${X.definitionId||X.id||H.packageId}`),X},[o,Ba]),Ql=h.useCallback((S="workspace")=>{ea(!0),Q(null),mo(S||"workspace")},[]),Zc=h.useCallback(async(S="")=>{const A=String(S||"").trim(),H=Oi.current||{},q=Object.entries(H).find(([de,ke])=>de===A||String((ke==null?void 0:ke.runNodeId)||"")===A)||Object.entries(H)[0]||null,X=(q==null?void 0:q[0])||"",re=(q==null?void 0:q[1])||null,se=String((re==null?void 0:re.runNodeId)||A||"").trim(),ne=new Set([se,...Array.isArray(re==null?void 0:re.plannedNodeIds)?re.plannedNodeIds:[]].map(de=>String(de||"").trim()).filter(Boolean));X&&yo.current.add(X);const te=X?la.current.get(X):null;te&&(te.abort(),la.current.delete(X)),X&&$i(de=>{const ke={...de};return delete ke[X],ke}),Ha(de=>{const ke=new Set(de);for(const De of ne)ke.delete(De);return ke}),Nt(de=>{var De;const ke={...de};for(const ht of ne)ht&&(!ke[ht]||((De=ke[ht])==null?void 0:De.status)==="running")&&(ke[ht]={status:"stopped"});return ke}),Pe(se?`Workspace run stopped: ${se}`:"Workspace run stopped"),Wr(de=>de.map(ke=>(X?ke.id===X:!se||ke.runNodeId===se)&&ke.status==="running"?{...ke,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(ke.messages)?ke.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:ke));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,runId:X,runNodeId:se})})}catch{}},[o,$i]),eu=h.useCallback(async()=>{if(o.flowId)try{const S=Ro(o),A=await fetch(`/api/workspace/run/status?${S.toString()}`),H=await A.json().catch(()=>({}));if(!A.ok||!H.running)return;const q=Array.isArray(H.runs)&&H.runs.length?H.runs:[{runId:`run-restored-${H.startedAt||Date.now()}`,runNodeId:H.runNodeId||"",startedAt:H.startedAt||Date.now(),plannedNodeIds:[]}],X={},re=[];for(const se of q){const ne=String((se==null?void 0:se.runNodeId)||"").trim(),te=String((se==null?void 0:se.runId)||`run-restored-${(se==null?void 0:se.startedAt)||Date.now()}-${ne}`).trim();te&&(X[te]={id:te,runNodeId:ne,plannedNodeIds:Array.isArray(se==null?void 0:se.plannedNodeIds)?se.plannedNodeIds:[],startedAt:(se==null?void 0:se.startedAt)||Date.now()},ne&&re.push(ne))}if(!Object.keys(X).length)return;$i(se=>({...se,...X})),Ha(se=>{const ne=new Set(se);for(const te of re)ne.add(te);return ne}),Nt(se=>{const ne={...se};for(const te of re)ne[te]={status:"running"};return ne}),Pe(re.length?`Workspace run still running: ${re.join(", ")}`:"Workspace run still running"),Wr(se=>{const ne=[...se];for(const[te,de]of Object.entries(X)){if(ne.some(De=>De.id===te||De.status==="running"&&De.runNodeId===de.runNodeId))continue;const ke=String(de.runNodeId||"");ne.push({id:te,label:ke?`Run ${ke}`:"Workspace Run",runNodeId:ke,status:"running",startedAt:de.startedAt||Date.now(),steps:ke?[{id:ke,label:ke,status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:"Workspace run is still running in the background.",at:Date.now()}]})}return[...ne.slice(-8)]})}catch{}},[o,$i]),Xd=h.useCallback(async S=>{if(!Ae){Pe("Readonly workspace");return}if(!S)return;if(Object.values(Oi.current||{}).find(Be=>String((Be==null?void 0:Be.runNodeId)||"")===String(S||""))){Pe(`Workspace run already running: ${S}`);return}let H=f,q=g,X=_.current;const re=ge.current;if(re!=null&&re.id){const Be=H.find(ot=>ot.id===re.id),Fe=vC({nodes:H,edges:q,instances:X,selectedNode:Be,draft:re,allowRename:!1});if(Fe!=null&&Fe.error){Me(Fe.error),Pe(Fe.error);return}Fe!=null&&Fe.ok&&Fe.changed&&(H=Fe.nodes,q=Fe.edges,X=Fe.instances,_.current=X,O(X),m(H),w(q),Vl(Fe.nextId||re.id))}const se=Sm(H,q,X),ne=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,te=`Run ${S}`;let de=[S];try{const Be=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,graph:se,runNodeId:S})}),Fe=await Be.json().catch(()=>({}));if(!Be.ok||(Fe==null?void 0:Fe.ok)===!1)throw new Error(Fe.error||"Workspace run plan failed");de=Array.isArray(Fe.plannedNodeIds)&&Fe.plannedNodeIds.length?Fe.plannedNodeIds.map(mt=>String(mt||"").trim()).filter(Boolean):[S],de=Array.from(new Set([S,...de].filter(Boolean)));const ot=Fe.conflict||null;if(ot!=null&&ot.runNodeId||ot!=null&&ot.runId){const mt=Array.isArray(ot.conflictNodeIds)&&ot.conflictNodeIds.length?`: ${ot.conflictNodeIds.join(", ")}`:"";Pe(`Run ${S} conflicts with running ${ot.runNodeId||ot.runId}${mt}`);return}}catch(Be){Pe(String(Be.message||Be));return}const ke=new Set(de),De=Object.values(Oi.current||{}).find(Be=>(Array.isArray(Be==null?void 0:Be.plannedNodeIds)?Be.plannedNodeIds:[]).some(Fe=>ke.has(String(Fe||"").trim())));if(De){const Be=(Array.isArray(De.plannedNodeIds)?De.plannedNodeIds:[]).map(Fe=>String(Fe||"").trim()).filter(Fe=>Fe&&ke.has(Fe));Pe(`Run ${S} conflicts with running ${De.runNodeId||"workspace run"}${Be.length?`: ${Be.join(", ")}`:""}`);return}const ht=new AbortController;la.current.set(ne,ht),yo.current.delete(ne),$i(Be=>({...Be,[ne]:{id:ne,runNodeId:S,plannedNodeIds:de,startedAt:Date.now()}})),Ha(Be=>new Set([...Be,S])),Nt(Be=>({...Be,[S]:{status:"running"}})),Pe(`Running ${S}...`),mo(ne),Wr(Be=>[...Be.slice(-7),{id:ne,label:te,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let at=S;const Ut=()=>yo.current.has(ne),hn=Be=>{const Fe=new Set((Be||[]).map(ot=>String(ot||"").trim()).filter(Boolean));Fe.size||Fe.add(String(S||"")),Ha(ot=>{const mt=new Set(ot);for(const qt of Fe)mt.delete(qt);return mt})},Kn=(Be,Fe)=>{const ot=new Set((Be||[]).map(mt=>String(mt||"").trim()).filter(Boolean));ot.size||ot.add(String(S||"")),Nt(mt=>{var Ht;const qt={...mt};for(const Ge of ot)Ge&&(!qt[Ge]||((Ht=qt[Ge])==null?void 0:Ht.status)==="running")&&(qt[Ge]={status:Fe});return qt})};try{await dn(H,q);const Be=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:ht.signal,body:JSON.stringify({...o,graph:se,runNodeId:S,runSessionId:ne,model:U,selectedSkills:bt,stream:!0})});if(!Be.ok){const Ce=await Be.json().catch(()=>({}));throw new Error(Ce.error||"Workspace run failed")}if(!Be.body)throw new Error("Workspace run stream unavailable");const Fe=Be.body.getReader(),ot=new TextDecoder;let mt="",qt=[],Ht=[];const Ge=(Ce,St)=>{var ft,Xt;const gt=f.find(Jt=>Jt.id===Ce),Pt=String(((ft=gt==null?void 0:gt.data)==null?void 0:ft.label)||Ce||"").trim(),Te=String(St||((Xt=gt==null?void 0:gt.data)==null?void 0:Xt.definitionId)||"").trim();return Te&&Te!==Pt?`${Pt} (${Te})`:Pt},Bt=(Ce,St,gt)=>{const Pt=String(Ce||"").trim();Pt&&Wr(Te=>Te.map(ft=>{if(ft.id!==ne)return ft;const Jt=[...Array.isArray(ft.steps)?ft.steps:[]],kt=Jt.findIndex(Ur=>Ur.id===Pt),Dt={id:Pt,label:Ge(Pt,St),status:gt};kt>=0?Jt[kt]={...Jt[kt],...Dt}:Jt.push(Dt);const Lt=Jt.map((Ur,Ja)=>{const da=Ur.status==="done"?"[done]":Ur.status==="failed"?"[failed]":"[running]";return`${Ja+1}. ${da} ${Ur.label}`}).join(`
206
- `),nn=Array.isArray(ft.messages)?ft.messages:[],bn=nn.findIndex(Ur=>Ur.kind==="run-summary"),tr={role:"assistant",kind:"run-summary",text:Lt||"准备运行...",at:Date.now()},Kr=[...nn];return bn>=0?Kr[bn]=tr:Kr.unshift(tr),{...ft,steps:Jt,messages:Kr.slice(-160)}}))},us=Ce=>{const St=String(Ce||"").trim();if(!St)return;const gt=at;at=St,Ha(Pt=>{const Te=new Set(Pt);return gt&&gt!==St&&gt!==S&&Te.delete(gt),S&&Te.add(S),Te.add(St),Te}),Nt(Pt=>{var Te;return{...Pt,...gt&&gt!==St&&gt!==S&&((Te=Pt[gt])==null?void 0:Te.status)==="running"?{[gt]:{status:"success"}}:{},...S?{[S]:{status:"running"}}:{},[St]:{status:"running"}}})},af=Ce=>{const St=String(Ce||"").trim();St&&(Ha(gt=>{const Pt=new Set(gt);return Pt.delete(St),Pt}),Nt(gt=>({...gt,[St]:{status:"success"}})))},ti=(Ce,St)=>{const gt=String(St||"");if(!gt.trim())return;const Pt=["assistant","thinking","result","error","prompt"].includes(Ce)?Ce:"assistant";Wr(Te=>Te.map(ft=>{if(ft.id!==ne)return ft;let Xt=Array.isArray(ft.messages)?ft.messages:[];if(Pt==="result"){const Dt=[...Xt].reverse().find(Lt=>Lt.kind==="assistant");if(String((Dt==null?void 0:Dt.text)||"").trim()===gt.trim())return ft}if(Pt==="assistant"){const Dt=Xt.findIndex(Lt=>Lt.kind==="result"&&String(Lt.text||"").trim()===gt.trim());Dt>=0&&(Xt=Xt.filter((Lt,nn)=>nn!==Dt))}const Jt=[...Xt],kt=Jt[Jt.length-1];return kt&&kt.kind===Pt&&!kt.error?Jt[Jt.length-1]={...kt,text:`${kt.text||""}${kt.text?`
207
- `:""}${gt}`}:Jt.push({role:"assistant",kind:Pt,text:gt,...Pt==="error"?{error:!0}:{},at:Date.now()}),{...ft,messages:Jt.slice(-160)}}))},mu=Ce=>{const St=String(Ce||"");St.trim()&&Wr(gt=>gt.map(Pt=>{var Jt;if(Pt.id!==ne)return Pt;const Te=Array.isArray(Pt.messages)?Pt.messages:[],ft=Te.findIndex(kt=>kt.kind==="thinking"),Xt=[...Te];if(ft>=0){const kt=String(((Jt=Xt[ft])==null?void 0:Jt.text)||"");Xt[ft]={...Xt[ft],text:`${kt}${kt&&!kt.endsWith(`
208
- `),""}${St}`,at:Date.now()}}else{const kt=Xt.findIndex(Dt=>Dt.kind==="activity");Xt.splice(kt>=0?kt+1:Xt.length,0,{role:"assistant",kind:"thinking",text:St,at:Date.now()})}return{...Pt,messages:Xt.slice(-160)}}))},bi=(Ce,St=null)=>{const gt=dY(Ce);gt&&Wr(Pt=>Pt.map(Te=>{if(Te.id!==ne)return Te;const ft=Number(St==null?void 0:St.ts)||Date.now(),Xt=Number(Te.startedAt)||ft,Jt=Number(Te.lastActivityAt)||Xt,kt=Math.max(0,ft-Jt),Dt=Number.isFinite(Number(St==null?void 0:St.runElapsedMs))?Math.max(0,Number(St.runElapsedMs)):Math.max(0,ft-Xt),Lt=Array.isArray(Te.activities)?Te.activities:[],nn=Lt[Lt.length-1],tr=(typeof nn=="string"?nn:String((nn==null?void 0:nn.text)||""))===gt?Lt:[...Lt,{text:gt,kind:fY(gt),stepMs:kt,totalMs:Dt,at:ft}].slice(-30),Kr=Array.isArray(Te.timingEntries)?Te.timingEntries:[],Ur=Array.isArray(Te.messages)?Te.messages:[],Ja=Ur.findIndex(fr=>fr.kind==="activity"),da={role:"assistant",kind:"activity",text:uC(tr,Kr,Xt,ft),at:Date.now()},qr=[...Ur];if(Ja>=0)qr[Ja]=da;else{const fr=qr.findIndex(Qa=>Qa.kind==="run-summary");qr.splice(fr>=0?fr+1:0,0,da)}return{...Te,activities:tr,lastActivityAt:ft,messages:qr.slice(-160)}}))},Lh=Ce=>{const St=String((Ce==null?void 0:Ce.source)||"runner"),gt=String((Ce==null?void 0:Ce.stream)||""),Pt=String((Ce==null?void 0:Ce.eventType)||"event"),Te=String((Ce==null?void 0:Ce.text)||"").trim();if(!Te)return;const ft=`[${St}${gt?`:${gt}`:""}] ${Pt}
209
- ${Te}`,Xt=yY(Ce);Wr(Jt=>Jt.map(kt=>{if(kt.id!==ne)return kt;const Lt=[...Array.isArray(kt.rawTrace)?kt.rawTrace:[],ft].slice(-80),nn=Array.isArray(kt.timingEntries)?kt.timingEntries:[],bn=Xt?[...nn,Xt].slice(-80):nn,tr=Array.isArray(kt.activities)?kt.activities:[],Kr=Number(kt.startedAt)||Number(Ce==null?void 0:Ce.ts)||Date.now(),Ur=Number(Xt==null?void 0:Xt.at)||Number(Ce==null?void 0:Ce.ts)||Date.now(),Ja=Array.isArray(kt.messages)?kt.messages:[],da={role:"assistant",kind:"raw",text:Lt.join(`
210
-
211
- ---
212
-
213
- `),at:Date.now()},qr=[...Ja],fr=qr.findIndex(Eo=>Eo.kind==="activity");if(Xt){const Eo={role:"assistant",kind:"activity",text:uC(tr,bn,Kr,Ur),at:Date.now()};if(fr>=0)qr[fr]=Eo;else{const oc=qr.findIndex(Za=>Za.kind==="run-summary");qr.splice(oc>=0?oc+1:0,0,Eo)}}const Qa=qr.findIndex(Eo=>Eo.kind==="raw");return Qa>=0?qr[Qa]=da:qr.push(da),{...kt,rawTrace:Lt,timingEntries:bn,messages:qr.slice(-160)}}))},dx=Ce=>{Wr(St=>St.map(gt=>gt.id===ne?{...gt,status:Ce,endedAt:Date.now()}:gt))},vi=Ce=>{const St=new Set,gt=String((Ce==null?void 0:Ce.nodeId)||"").trim();gt&&St.add(gt);for(const Pt of Array.isArray(Ce==null?void 0:Ce.displayNodeIds)?Ce.displayNodeIds:[]){const Te=String(Pt||"").trim();Te&&St.add(Te)}for(const Pt of Array.isArray(Ce==null?void 0:Ce.touchedNodeIds)?Ce.touchedNodeIds:[]){const Te=String(Pt||"").trim();Te&&St.add(Te)}if(St.size===0)for(const Pt of Array.isArray(Ce==null?void 0:Ce.order)?Ce.order:[]){const Te=String(Pt||"").trim();Te&&St.add(Te)}return St},gu=(Ce,St=null)=>{const gt=Nw(Ce||se,V),Pt=new Map(gt.nodes.map(kt=>[kt.id,kt])),Te=gt.instances||{},ft=St instanceof Set?St:null,Xt=(kt,Dt)=>{const Lt={...kt||Dt};Array.isArray(Dt==null?void 0:Dt.output)&&(Lt.output=Dt.output);for(const nn of["scriptRef","implementationRef","implementationMode"])(Dt==null?void 0:Dt[nn])!=null&&String(Dt[nn]).trim()!==""&&(Lt[nn]=Dt[nn]);return Lt},Jt=(kt,Dt)=>{const Lt={...kt||{}};Array.isArray(Dt==null?void 0:Dt.outputs)&&(Lt.outputs=Dt.outputs);for(const nn of["scriptRef","implementationRef","implementationMode"])(Dt==null?void 0:Dt[nn])!=null&&String(Dt[nn]).trim()!==""&&(Lt[nn]=Dt[nn]);return Lt};m(kt=>{const Dt=new Set(kt.map(bn=>bn.id)),nn={...Sm(kt,b.current,_.current).instances||{}};for(const[bn,tr]of Object.entries(Te)){if(ft&&!ft.has(bn)||!Dt.has(bn))continue;const Kr=nn[bn];$n((tr==null?void 0:tr.definitionId)||(Kr==null?void 0:Kr.definitionId))?nn[bn]=tr:Array.isArray(tr==null?void 0:tr.output)&&(nn[bn]=Xt(Kr,tr))}return _.current=nn,O(nn),kt.map(bn=>{var Kr,Ur;if(ft&&!ft.has(bn.id))return bn;const tr=Pt.get(bn.id);return tr?$n(((Kr=tr.data)==null?void 0:Kr.definitionId)||((Ur=bn.data)==null?void 0:Ur.definitionId))?{...bn,data:{...bn.data,...tr.data}}:{...bn,data:Jt(bn.data,tr.data)}:bn})})};for(;;){const{value:Ce,done:St}=await Fe.read();if(St)break;mt+=ot.decode(Ce,{stream:!0});const gt=mt.split(`
214
- `);mt=gt.pop()||"";for(const Pt of gt){if(!Pt.trim())continue;const Te=JSON.parse(Pt);if(Te.type==="error")throw new Error(Te.error||"Workspace run failed");if(Te.type==="stopped"){yo.current.add(ne),qt=Array.isArray(Te.order)?Te.order:qt,bi("运行停止",Te);continue}if(Te.type==="node-start"&&(Pe(`Running ${Te.nodeId}...`),us(Te.nodeId),Bt(Te.nodeId,Te.definitionId,"running")),Te.type==="node-done"&&(af(Te.nodeId),Bt(Te.nodeId,Te.definitionId,"done")),Te.type==="status"&&bi(Te.line||Te.message||"",Te),Te.type==="paused"&&(Ht=Array.isArray(Te.nodeIds)?Te.nodeIds:[],bi("运行暂停",Te)),Te.type==="natural"&&(Te.kind==="thinking"?mu(Te.text||""):ti(Te.kind,Te.text||"")),Te.type==="raw"){const ft=dC(Te);ft&&mu(ft),Lh(Te)}Te.type==="graph"&&Te.graph&&gu(Te.graph,vi(Te)),Te.type==="done"&&(Te.graph&&gu(Te.graph,vi(Te)),qt=Array.isArray(Te.order)?Te.order:[],Ht=Array.isArray(Te.pauseNodeIds)?Te.pauseNodeIds:Ht,bi(Ht.length?"运行暂停":"运行完成",Te))}}if(mt.trim()){const Ce=JSON.parse(mt);if(Ce.type==="error")throw new Error(Ce.error||"Workspace run failed");if(Ce.type==="stopped"&&(yo.current.add(ne),bi("运行停止",Ce)),Ce.type==="node-start"&&(Pe(`Running ${Ce.nodeId}...`),us(Ce.nodeId),Bt(Ce.nodeId,Ce.definitionId,"running")),Ce.type==="node-done"&&(af(Ce.nodeId),Bt(Ce.nodeId,Ce.definitionId,"done")),Ce.type==="status"&&bi(Ce.line||Ce.message||"",Ce),Ce.type==="paused"&&(Ht=Array.isArray(Ce.nodeIds)?Ce.nodeIds:[],bi("运行暂停",Ce)),Ce.type==="natural"&&(Ce.kind==="thinking"?mu(Ce.text||""):ti(Ce.kind,Ce.text||"")),Ce.type==="raw"){const St=dC(Ce);St&&mu(St),Lh(Ce)}Ce.type==="graph"&&Ce.graph&&gu(Ce.graph,vi(Ce)),Ce.type==="done"&&(Ce.graph&&gu(Ce.graph,vi(Ce)),qt=Array.isArray(Ce.order)?Ce.order:[],Ht=Array.isArray(Ce.pauseNodeIds)?Ce.pauseNodeIds:Ht,bi(Ht.length?"运行暂停":"运行完成",Ce))}Ut()&&(hn(de),Kn(de,"stopped")),Pe(Ut()?`Workspace run stopped: ${S}`:Ht.length?`Workspace run paused at ${Ht.join(", ")}`:`Workspace run done: ${qt.length?qt.join(" -> "):S}`),Ut()||Kn(de,Ht.length?"paused":"success"),dx(Ut()?"stopped":Ht.length?"paused":"done"),Ut()||await kr()}catch(Be){if(Ut()||(Be==null?void 0:Be.name)==="AbortError"){hn(de),Kn(de,"stopped"),Pe(`Workspace run stopped: ${S}`),Wr(Fe=>Fe.map(ot=>ot.id===ne?{...ot,status:"stopped",endedAt:Date.now()}:ot));return}hn(de),Kn([S,at].filter(Boolean),"failed"),Pe(String(Be.message||Be)),Wr(Fe=>Fe.map(ot=>ot.id===ne?{...ot,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(ot.messages)?ot.messages:[],{role:"assistant",error:!0,text:String(Be.message||Be),at:Date.now()}].slice(-160)}:ot))}finally{la.current.get(ne)===ht&&la.current.delete(ne),$i(Be=>{const Fe={...Be};return delete Fe[ne],Fe}),yo.current.delete(ne),hn(de)}},[U,g,o,kr,f,V,Vl,dn,bt,w,m,$i,Ae]),tu=h.useCallback(async()=>{try{const A=await(await fetch("/api/skills")).json().catch(()=>({})),H=Array.isArray(A.skills)?A.skills.map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];Oe(H),un(!0)}catch{un(!0)}},[]),nu=h.useCallback(async()=>{try{const A=await(await fetch("/api/mcps")).json().catch(()=>({})),H=Array.isArray(A.servers)?A.servers.map(q=>({name:String((q==null?void 0:q.name)||""),type:String((q==null?void 0:q.type)||""),url:String((q==null?void 0:q.url)||""),command:String((q==null?void 0:q.command)||""),args:Array.isArray(q==null?void 0:q.args)?q.args.map(String):[],description:String((q==null?void 0:q.description)||"")})).filter(q=>q.name):[];Bd(H)}catch{Bd([])}},[]);h.useEffect(()=>{Ba().catch(S=>Pe(String(S.message||S))),yi(),fetch("/api/model-lists").then(S=>S.json()).then(S=>Jo({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(()=>{}),tu(),nu(),eu(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{Mi(jl(S)),Wl(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>{Jl(S.user||null),ta(!0)}).catch(()=>{Jl(null),ta(!0)})},[Ba,yi,nu,tu,eu,Ps]),h.useEffect(()=>{if(mh(""),!(!st||!Mn)){if(!Ps){Bn([]);return}Bn(XA(Ps,"workspace",$e,vr)),mh(Ps)}},[vr,Mn,$e,st,Ps]),h.useEffect(()=>{if(!(_t!==Ps||!Ps))try{localStorage.setItem(Ps,JSON.stringify(bt))}catch{}},[bt,Ps,_t]),h.useEffect(()=>{_.current=P},[P]),h.useEffect(()=>{y.current=f},[f]),h.useEffect(()=>{const S=B.current,A=new Map,H=[];for(const se of f){const ne=a2(se);A.set(se.id,ne),S.get(se.id)!==ne&&H.push(se.id)}if(B.current=A,H.length===0)return;const q=()=>H.forEach(se=>s(se)),X=window.requestAnimationFrame(q),re=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(X),window.clearTimeout(re)}},[f,s]),h.useEffect(()=>{b.current=g},[g]),h.useEffect(()=>{E.current=x},[x]),h.useEffect(()=>{$.current=N},[N]),h.useEffect(()=>{ge.current=he},[he]),h.useEffect(()=>{ce.current=In},[In]),h.useEffect(()=>{M.current=I},[I]),h.useEffect(()=>{if(!I)return;const S=H=>{H.key==="Escape"&&F(null)},A=H=>{var q,X;(X=(q=H.target)==null?void 0:q.closest)!=null&&X.call(q,".af-connect-node-menu")||F(null)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",A),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",A)}},[I]),h.useEffect(()=>{if(Z.current&&Ae)return ee.current&&window.clearTimeout(ee.current),ee.current=window.setTimeout(()=>{dn().catch(S=>Pe(String(S.message||S)))},650),()=>{ee.current&&window.clearTimeout(ee.current)}},[f,g,x,dn,Ae]);const xo=h.useMemo(()=>f.filter(S=>{var A;return((A=S==null?void 0:S.data)==null?void 0:A.definitionId)==="workspace_scheduled_run"}).map(S=>{var A;return{id:S.id,config:_k(((A=S.data)==null?void 0:A.body)||"")}}),[f]),wh=h.useMemo(()=>xo.map(S=>`${S.id}:${S.config.enabled?"1":"0"}:${S.config.cron}:${S.config.timezone}`).join("|"),[xo]);h.useEffect(()=>{if(!Z.current||a!=="workspace"||!o.flowId){aa({});return}if(!xo.length){aa({});return}let S=!1;const A=async()=>{try{const q=Ro(o),X=await fetch(`/api/workspace/schedules?${q.toString()}`),re=await X.json().catch(()=>({}));if(!X.ok)throw new Error(re.error||"读取 Workspace 定时状态失败");S||aa(Sw(re.schedules||[]))}catch{S||aa(q=>{var re;const X={};for(const se of xo)X[se.id]={...q[se.id]||{},lastStatus:((re=q[se.id])==null?void 0:re.lastStatus)||"unknown"};return X})}};A();const H=window.setInterval(A,5e3);return()=>{S=!0,window.clearInterval(H)}},[o,xo,wh,a]);const Jd=h.useCallback((S,A)=>{if(!Ae){Pe("Readonly workspace");return}const H=pG(A),q=te=>Array.isArray(te)?te.map(de=>(de==null?void 0:de.name)!=="skillKeys"&&(de==null?void 0:de.name)!=="skillsContext"&&(de==null?void 0:de.type)!=="text"?de:{...de,default:H,value:H}):[],X=f.map(te=>{var de;return te.id!==S?te:{...te,data:{...te.data,body:H,inputs:q((de=te.data)==null?void 0:de.inputs)}}}),re=_.current||{},se=re[S]&&typeof re[S]=="object"?re[S]:{},ne={...re,[S]:{...se,body:H,input:q(se.input)}};_.current=ne,m(X),O(ne),Q(te=>!te||te.id!==S?te:{...te,body:H,inputs:q(te.inputs)}),dn(X,g).catch(te=>Pe(String(te.message||te)))},[g,f,dn,m,Ae]),Zl=h.useCallback((S,A)=>{if(!Ae){Pe("Readonly workspace");return}const H=mG(A),q=te=>Array.isArray(te)?te.map(de=>(de==null?void 0:de.name)!=="serverNames"&&(de==null?void 0:de.name)!=="mcpContext"&&(de==null?void 0:de.type)!=="text"?de:{...de,default:H,value:H}):[],X=f.map(te=>{var de;return te.id!==S?te:{...te,data:{...te.data,body:H,inputs:q((de=te.data)==null?void 0:de.inputs)}}}),re=_.current||{},se=re[S]&&typeof re[S]=="object"?re[S]:{},ne={...re,[S]:{...se,body:H,input:q(se.input)}};_.current=ne,m(X),O(ne),Q(te=>!te||te.id!==S?te:{...te,body:H,inputs:q(te.inputs)}),dn(X,g).catch(te=>Pe(String(te.message||te)))},[g,f,dn,m,Ae]),wo=h.useCallback((S,A)=>{if(!Ae){Pe("Readonly workspace");return}const H=EY(A),q=f.map(ne=>ne.id===S?{...ne,data:{...ne.data,body:H}}:ne),X=_.current||{},re=X[S]&&typeof X[S]=="object"?X[S]:{},se={...X,[S]:{...re,body:H}};_.current=se,m(q),O(se),Q(ne=>(ne==null?void 0:ne.id)===S?{...ne,body:H}:ne),dn(q,g).catch(ne=>Pe(String(ne.message||ne)))},[g,f,dn,m,Ae]),ec=h.useCallback(S=>{const A=String(S||"").trim();A&&(Vd(H=>H===A?"":A),go(H=>({...H,[A]:H[A]||{sessionId:`nodechat_${Date.now()}_${A.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Ts=h.useCallback((S,A)=>{const H=String(S||"").trim();H&&go(q=>({...q,[H]:{...q[H]||{sessionId:`nodechat_${Date.now()}_${H.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(A||""),error:""}}))},[]),Qn=h.useCallback((S,A,H="replace",q={})=>{var Fe,ot;if(!Ae){Pe("Readonly workspace");return}const X=String(S||"").trim();if(!X)return;const re=y.current.find(mt=>mt.id===X),se=$n((Fe=re==null?void 0:re.data)==null?void 0:Fe.definitionId),ne=Na(A),te=se==="html"?Ld(ne):String(ne||""),de=re?Cc(re.data):"",ke=H==="append"&&String(de||"").trim()?`${String(de).replace(/\s+$/g,"")}
215
-
216
- ${te.trim()}`:te,De=se==="image"?"src":"content",ht=q!=null&&q.reloadDisplay?Date.now():(ot=re==null?void 0:re.data)==null?void 0:ot.displayReloadKey,at=mt=>{let qt=!1;return(Array.isArray(mt)?mt:[]).map(Ge=>{const Bt=String((Ge==null?void 0:Ge.name)||""),us=String((Ge==null?void 0:Ge.type)||"");return Bt===De||Bt==="filePath"||us==="text"?qt?{...Ge,default:"",value:""}:(qt=!0,{...Ge,default:ke,value:ke}):Ge})},Ut=y.current.map(mt=>{var qt,Ht;return mt.id!==X?mt:{...mt,data:{...mt.data,body:ke,...ht?{displayReloadKey:ht}:{},inputs:at((qt=mt.data)==null?void 0:qt.inputs),outputs:at((Ht=mt.data)==null?void 0:Ht.outputs)}}}),hn=_.current||{},Kn=hn[X]&&typeof hn[X]=="object"?hn[X]:{},Be={...hn,[X]:{...Kn,body:ke,input:at(Kn.input),output:at(Kn.output)}};_.current=Be,m(Ut),O(Be),Q(mt=>(mt==null?void 0:mt.id)===X?{...mt,body:ke}:mt),(q==null?void 0:q.logChat)!==!1&&go(mt=>{var qt;return{...mt,[X]:{...mt[X]||{},candidateContent:"",messages:[...(qt=mt[X])!=null&&qt.messages&&Array.isArray(mt[X].messages)?mt[X].messages:[],{role:"assistant",text:H==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),dn(Ut,b.current).catch(mt=>Pe(String(mt.message||mt))),Pe(String((q==null?void 0:q.statusMessage)||"")||(H==="append"?"已追加节点内容":"已替换节点内容"))},[dn,m,Ae]),Sr=h.useCallback(async(S,A="")=>{if(!Ae)return Pe("Readonly workspace"),"";if(!S)return"";try{const H=new FormData;H.set("file",S),H.set("dir",String(A||"")),o.flowId&&H.set("flowId",o.flowId),o.flowSource&&H.set("flowSource",o.flowSource),o.archived&&H.set("archived","1");const q=await fetch("/api/workspace/upload",{method:"POST",body:H}),X=await q.json().catch(()=>({}));if(!q.ok)throw new Error(X.error||"上传文件失败");const re=String(X.path||"").trim();if(!re)throw new Error("上传文件失败:未返回路径");return await kr(),br(se=>{const ne=new Set(se);for(const te of Nm(re))ne.delete(te);return ne}),Pe(`已上传 ${re}`),re}catch(H){return Pe(String(H.message||H)),""}},[o,kr,Ae]),Zs=h.useCallback(async S=>Xg(S)?Sr(S,"img"):(Pe("请选择图片文件"),""),[Sr]),Fi=h.useCallback((S="")=>{var A;if(!Ae){Pe("Readonly workspace");return}Sn.current=String(S||""),(A=Ti.current)==null||A.click()},[Ae]),bh=h.useCallback(async S=>{const A=Array.from(S.target.files||[]);if(S.target.value="",!A.length)return;const H=Sn.current||"";uo(!0);try{let q="";for(const X of A){const re=await Sr(X,H);re&&(q=re)}A.length>1&&Pe(`已上传 ${A.length} 个文件${q?`,最后一个:${q}`:""}`)}catch(q){Pe(String(q.message||q))}finally{uo(!1)}},[Sr]),Qd=h.useCallback(async(S,A)=>{const H=String(S||"").trim();if(!H)return;const q=await Zs(A);q&&Qn(H,q,"replace",{logChat:!1,statusMessage:`已上传图片 ${q}`})},[Qn,Zs]),tc=h.useCallback((S,A="replace")=>{var X;const H=String(S||"").trim(),q=String(((X=gi[H])==null?void 0:X.candidateContent)||"").trim();!H||!q||Qn(H,q,A)},[gi,Qn]),ru=h.useCallback(async(S,A=void 0)=>{var Ut,hn,Kn;if(!Ae){Pe("Readonly workspace");return}const H=String(S||"").trim();if(!H)return;const q=gi[H]||{},X=String(A!==void 0?A:q.draft||"").trim();if(!X||q.running)return;const re=y.current.find(Be=>Be.id===H);if(!re)return;const se=$n((Ut=re.data)==null?void 0:Ut.definitionId)||"markdown",ne=Cc(re.data);let te=Cd(ne,se),de=Na(ne);if(te)try{de=await Ed(o,te)}catch(Be){Pe(String(Be.message||Be))}else if(se!=="image"&&String(de||"").trim()){const Be=bc(se,de);if(Be){Pe(`${Be} 未进入微调。`);return}try{const Fe=await Ev(o,xC(H,re.data),de);await kr(),Qn(H,Fe,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Fe}`}),te=Fe,de=""}catch(Fe){Pe(String(Fe.message||Fe));return}}const ke=$Y(H,y.current,b.current),De={role:"user",text:X,at:Date.now()},ht=Array.isArray(q.messages)?q.messages:[],at=q.sessionId||`nodechat_${Date.now()}_${H.replace(/[^a-z0-9_-]+/gi,"_")}`;go(Be=>({...Be,[H]:{...q,sessionId:at,messages:[...ht,De],draft:"",running:!0,error:""}}));try{const Be=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,sessionId:at,node:{id:H,label:((hn=re.data)==null?void 0:hn.label)||H,definitionId:((Kn=re.data)==null?void 0:Kn.definitionId)||""},nodeKind:se,currentContent:te?"":de,sourceContext:ke,targetFilePath:te,messages:ht,message:X,model:U})}),Fe=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(Fe.error||"节点微调失败");const ot=String(Fe.candidateContent||Fe.reply||"").trim(),mt=!!Fe.directFileEdit,qt=String(Fe.artifactPath||te||"").trim();if(mt&&qt){const Ht=bc(se,ot);if(Ht)throw new Error(`${Ht} 文件已由 agent 修改,请检查 ${qt}。`);await kr(),Qn(H,qt,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${qt}`})}else if(ot){const Ht=bc(se,ot);if(Ht)throw new Error(`${Ht} 已取消写入,避免覆盖当前展示文件。`);if(te){const Ge=await Ev(o,te,ot);await kr(),Qn(H,Ge,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ge}`})}else Qn(H,ot,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}go(Ht=>{var Ge;return{...Ht,[H]:{...Ht[H]||{},sessionId:String(Fe.sessionId||at),running:!1,candidateContent:"",messages:[...(Ge=Ht[H])!=null&&Ge.messages&&Array.isArray(Ht[H].messages)?Ht[H].messages:[...ht,De],{role:"assistant",text:ot||mt?qt?`已更新文件 ${qt}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(Be){const Fe=String(Be.message||Be);go(ot=>({...ot,[H]:{...ot[H]||{},running:!1,error:Fe}})),Pe(Fe)}},[U,o,kr,gi,Qn,Ae]),Zn=h.useCallback(async(S,A)=>{if(!Ae){Pe("Readonly workspace");return}const H=$n(A==null?void 0:A.definitionId)||"markdown",q=Cc(A),X=Cd(q,H);let re=Na(q);if(X)try{re=await Ed(o,X)}catch(de){Pe(String(de.message||de));return}if(!String(re||"").trim()){Pe("展示节点没有可保存内容");return}const se=bc(H,re);if(se){Pe(`${se} 未保存文件。`);return}const ne=xC(S,A),te=window.prompt("保存到 workspace 相对路径",ne);if(te)try{const de=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:te,content:re})}),ke=await de.json().catch(()=>({}));if(!de.ok)throw new Error(ke.error||"保存文件失败");const De=ke.path||te,ht=Ro(o);ht.set("path",De);const at=await fetch(`/api/workspace/file?${ht.toString()}`);if(!at.ok){const Ut=await at.json().catch(()=>({}));throw new Error(Ut.error||`保存后读取失败:${De}`)}await kr(),Rn(Ut=>lG(Ut,De,String(re||"").length)),br(Ut=>{const hn=new Set(Ut);for(const Kn of Nm(De))hn.delete(Kn);return hn}),Qn(S,De,"replace",{logChat:!1,statusMessage:`已保存并引用 ${De}`}),Pe(`已保存 ${De}`)}catch(de){Pe(String(de.message||de))}},[o,kr,Qn,Ae]),Vn=h.useCallback(async S=>{var X,re,se,ne;const A=String(S||"").trim();if(!A||on)return;const H=y.current.find(te=>te.id===A);if(!H||!$n((X=H==null?void 0:H.data)==null?void 0:X.definitionId)){Pe("展示节点不可用");return}An(A),Mt("");const q=window.open("","_blank");try{await dn(y.current,b.current);const te=String(((re=H.data)==null?void 0:re.label)||((se=H.data)==null?void 0:se.displayName)||A).trim()||"AgentFlow Display",de=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:te,layout:"single",nodeIds:[A]})}),ke=await de.json().catch(()=>({}));if(!de.ok||ke.ok===!1)throw new Error(ke.error||"生成展示链接失败");const De=new URL(ke.url||`/display/${((ne=ke.share)==null?void 0:ne.id)||""}`,window.location.origin).href;gn({...ke,absoluteUrl:De}),gr(""),Pe("已生成 30 天有效的展示链接"),q?q.location.href=De:window.location.assign(De)}catch(te){q&&q.close();const de=String(te.message||te);Mt(de),Pe(de)}finally{An("")}},[o,dn,on]),bo=h.useCallback((S,A)=>{const H=String(S||"");H&&Q(q=>{if(!q||q.id!==H)return q;const X=typeof A=="function"?A(q):A;return!X||typeof X!="object"?q:{...q,...X}})},[]),Wa=h.useCallback((S,A)=>{const H=String(S||"");!H||!Ae||(m(q=>q.map(X=>{var se;if(X.id!==H)return X;const re=Array.isArray((se=X.data)==null?void 0:se.outputs)&&X.data.outputs.length?X.data.outputs.map((ne,te)=>te===0?{...ne,default:A,value:A}:ne):[{type:"file",name:"value",default:A,value:A}];return{...X,data:{...X.data,body:"",outputs:re}}})),bo(H,q=>({body:"",outputs:Array.isArray(q==null?void 0:q.outputs)&&q.outputs.length?q.outputs.map((re,se)=>se===0?{...re,default:A,value:A}:re):[{type:"file",name:"value",default:A,value:A}]})),Pe(`已选择文件 ${A}`))},[m,bo,Ae]),Va=h.useCallback(S=>{Ii({nodeId:String(S||""),query:""})},[]),su=h.useCallback(()=>{Ii({nodeId:"",query:""})},[]),Tt=h.useCallback(S=>{const A=String((S==null?void 0:S.path)||"").trim();!A||!hi.nodeId||(Wa(hi.nodeId,A),su())},[su,hi.nodeId,Wa]),Rs=h.useMemo(()=>f.map(S=>{var A,H;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:Qr,showBodyPreview:!0,isExecuting:za.has(S.id),nodeStatus:((A=Ud[S.id])==null?void 0:A.status)??null,nodeElapsed:((H=Ud[S.id])==null?void 0:H.elapsed)??null,flowParams:o,readOnly:!Ae,onRunWorkspaceNode:Xd,onStopWorkspaceNode:Zc,runningRunNodeIds:Yd,scheduledRunState:Jc[S.id]||null,onChangeScheduledRunConfig:wo,skills:$e,skillCollections:vr,onChangeLoadSkillKeys:Jd,onRefreshSkills:tu,mcpServers:Hd,onChangeLoadMcpNames:Zl,onRefreshMcps:nu,onSaveDisplayNodeToFile:Zn,onShareDisplayNode:Vn,onOpenDisplayPreview:yr,sharingDisplayNodeId:on,onUploadWorkspaceImage:Zs,onUploadImageToDisplayNode:Qd,onOpenProvideFilePicker:Va,onStatus:Pe,nodeChatActive:Yc===S.id,nodeChat:gi[S.id]||null,onSetDisplayNodeContent:Qn,onToggleNodeChat:ec,onCloseNodeChat:()=>Vd(""),onUpdateNodeChatDraft:Ts,onSendNodeChat:ru,onApplyNodeChatCandidate:tc,onSyncNodePropDraft:bo}}}),[Yc,tc,Zl,Jd,wo,o,Hd,Qr,gi,f,Va,nu,tu,Xd,Yd,Zn,Jc,ru,Qn,Vn,on,vr,$e,Zc,bo,ec,Ts,Qd,Zs,za,Ud,Ae]),nc=h.useMemo(()=>new Map(Rs.map(S=>[S.id,S])),[Rs]),rc=dr?nc.get(dr):null,vo=h.useMemo(()=>{const S=new Set(z);return x.nodeIds.map((A,H)=>{var ne;const q=nc.get(A);if(!q||!$n((ne=q.data)==null?void 0:ne.definitionId))return null;const X=Au(q)||{width:520,height:320},re=od(x.nodeSizes[A]||X,{display:!0})||X,se=x.nodePositions[A]||{x:180+H*36,y:120+H*28};return{...q,id:gC(A),position:se,selected:S.has(A),width:re.width,height:re.height,data:{...q.data,sourceNodeId:A,displayPageMode:!0,readOnly:!0,selected:S.has(A),displaySize:re,nodeSize:re}}}).filter(Boolean)},[x,nc,z]),ca=h.useMemo(()=>Rs.filter(S=>{var A;return $n((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}),[Rs]),vt=a==="display";h.useEffect(()=>{if(!vt||!x.viewport)return;const S=x.viewport,A=()=>{try{r.setViewport(S,{duration:0})}catch{}},H=window.requestAnimationFrame(()=>window.requestAnimationFrame(A));return()=>window.cancelAnimationFrame(H)},[x.viewport,vt,r]),h.useEffect(()=>{if(vt||!N)return;const S=N,A=()=>{try{r.setViewport(S,{duration:0})}catch{}},H=window.requestAnimationFrame(()=>window.requestAnimationFrame(A));return()=>window.cancelAnimationFrame(H)},[vt,r,N]),h.useEffect(()=>{const S=L.current,A=new Map,H=[];for(const se of[...Rs,...vo]){const ne=TY(se);A.set(se.id,ne),S.get(se.id)!==ne&&H.push(se.id)}if(L.current=A,H.length===0)return;const q=()=>H.forEach(se=>s(se)),X=window.requestAnimationFrame(q),re=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(X),window.clearTimeout(re)}},[vo,Rs,s]);const an=h.useMemo(()=>f.find(S=>S.id===In)||null,[f,In]),Zd=h.useRef({id:"",draft:null}),vh=h.useMemo(()=>{const S=wC(an);return S?JSON.stringify(S):""},[an]);h.useEffect(()=>{if(!an){Zd.current={id:"",draft:null},Q(null),Me("");return}const S=wC(an),A=Zd.current;Zd.current={id:an.id,draft:S},Q(H=>!H||H.id!==an.id||A.id!==an.id||!A.draft?S:xG(H,A.draft,S)),Me("")},[an==null?void 0:an.id,vh]);const iu=h.useCallback((S=!1)=>{if(!he||!an)return!1;if(!Ae)return Me("Readonly workspace"),Pe("Readonly workspace"),!1;Me("");const A=vC({nodes:f,edges:g,instances:_.current,selectedNode:an,draft:he,allowRename:S});return A!=null&&A.error?(Me(A.error),!1):(!(A!=null&&A.ok)||!A.changed||(_.current=A.instances,O(A.instances),m(A.nodes),w(A.edges),A.nextId!==an.id&&Tn(A.nextId),Vl(A.nextId)),!0)},[g,he,f,an,w,m,Vl,Ae]);h.useEffect(()=>{if(!Ae||!he||!an)return;const S=window.setTimeout(()=>{iu(!1)},350);return()=>window.clearTimeout(S)},[he==null?void 0:he.label,he==null?void 0:he.role,he==null?void 0:he.model,he==null?void 0:he.body,JSON.stringify((he==null?void 0:he.images)||[]),he==null?void 0:he.script,he==null?void 0:he.scriptRef,he==null?void 0:he.implementationRef,he==null?void 0:he.implementationMode,JSON.stringify((he==null?void 0:he.inputs)||[]),JSON.stringify((he==null?void 0:he.outputs)||[]),iu,an==null?void 0:an.id,Ae]);const as=h.useMemo(()=>{const S=new Map(Rs.map(A=>[A.id,A]));return g.map(A=>{var de,ke,De,ht;const H=S.get(A.source),q=S.get(A.target),X=/^output-(\d+)$/.exec(A.sourceHandle||""),re=/^input-(\d+)$/.exec(A.targetHandle||""),se=H&&X?(ke=(de=H.data)==null?void 0:de.outputs)==null?void 0:ke[parseInt(X[1],10)]:null,ne=q&&re?(ht=(De=q.data)==null?void 0:De.inputs)==null?void 0:ht[parseInt(re[1],10)]:null,te=se!=null&&se.type?qn(se.type):ne!=null&&ne.type?qn(ne.type):"";return te?{...A,style:{...A.style||{},stroke:te,strokeWidth:2},markerEnd:{type:js.ArrowClosed,color:te}}:A})},[g,Rs]),kh=vt?vo:Rs,xi=vt?[]:as,wi=h.useMemo(()=>vt?vo.map(S=>({...S,id:jw(S.id)})):Rs,[vo,Rs,vt]),Sh=h.useCallback(S=>{const A=String(S||"").trim();if(!A)return;const H=vt?gC(A):A;vt?K([A]):(m(X=>X.map(re=>({...re,selected:re.id===H}))),w(X=>X.map(re=>({...re,selected:!1}))),Tn(H));const q=()=>{var de,ke,De;const X=r.getNode(H);if(!X)return;const re=(de=r.getInternalNode)==null?void 0:de.call(r,H),se=((ke=re==null?void 0:re.measured)==null?void 0:ke.width)??(re==null?void 0:re.width)??X.width??260,ne=((De=re==null?void 0:re.measured)==null?void 0:De.height)??(re==null?void 0:re.height)??X.height??120,{zoom:te}=r.getViewport();r.setCenter(X.position.x+se/2,X.position.y+ne/2,{zoom:MY(te),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(q))},[vt,r,w,m]),Ka=h.useCallback(()=>{const S=r.getViewport(),A={x:Number(S.x)||0,y:Number(S.y)||0,zoom:Math.min(Math.max(Number(S.zoom)||1,.1),4)};if(vt){const H={...E.current,viewport:A};E.current=H,j(H),Pe("已固定 Display 进入视角")}else $.current=A,T(A),Pe("已固定 Workspace 进入视角");dn(y.current,b.current).catch(H=>Pe(String(H.message||H)))},[vt,r,dn]),ou=h.useMemo(()=>{const S=fe.trim().toLowerCase(),A={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const H of V)S&&![H.id,H.label,H.displayName,H.description].some(q=>String(q||"").toLowerCase().includes(S))||A[Of(H)].push(H);for(const H of Eu)A[H].sort((q,X)=>q.id.localeCompare(X.id));return A},[V,fe]),zi=h.useMemo(()=>{const S=Or.trim().toLowerCase();return V.filter(A=>!S||[A.id,A.label,A.displayName,A.description].some(H=>String(H||"").toLowerCase().includes(S))).sort((A,H)=>{const q=Eu.indexOf(Of(A)),X=Eu.indexOf(Of(H));return q!==X?q-X:$f(A).localeCompare($f(H))}).slice(0,30)},[V,Or]),Ua=h.useMemo(()=>{const S=Or.trim().toLowerCase();return Ee.filter(A=>!S||[A.id,A.version,A.displayName,A.name,A.description,...Array.isArray(A.tags)?A.tags:[]].some(H=>String(H||"").toLowerCase().includes(S))).sort((A,H)=>String(A.displayName||A.name||A.id).localeCompare(String(H.displayName||H.name||H.id))).slice(0,30)},[Ee,Or]);h.useEffect(()=>{Ar(0)},[Or,_r,or]),h.useEffect(()=>{if(!_r)return;const S=window.setTimeout(()=>{var A;return(A=Yl.current)==null?void 0:A.focus()},0);return()=>window.clearTimeout(S)},[_r]);const $r=h.useMemo(()=>{const S=lt.trim().toLowerCase();return S?Ak(zt).filter(A=>A.path.toLowerCase().includes(S)):zt},[lt,zt]),Ms=h.useMemo(()=>m2(zt,nt),[zt,nt]),Dr=(Ms==null?void 0:Ms.type)==="directory"?Ms.path:iG((Ms==null?void 0:Ms.path)||""),au=h.useCallback(S=>{var A,H;(H=(A=S.target)==null?void 0:A.closest)!=null&&H.call(A,".af-work-file")||os("")},[]),ko=[...(Qr.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(Qr.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(Qr.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],So=h.useMemo(()=>new Set(bt),[bt]),No=h.useMemo(()=>{const S=new Map($e.map(re=>[re.key,re])),A=new Set,H=new Set,q=vr.map(re=>{const se=Il(re,$e).map(ne=>S.get(ne)).filter(Boolean);for(const ne of se)A.add(ne.key),H.add(String(ne.name||ne.id||ne.key||"").trim());return{...re,skills:se}}).filter(re=>re.skills.length>0),X=$e.filter(re=>{const se=String(re.name||re.id||re.key||"").trim();return!A.has(re.key)&&!H.has(se)});return{groups:q,ungrouped:X}},[vr,$e]);h.useEffect(()=>{Ul(S=>{let A=!1;const H=new Set(S);for(const q of No.groups)H.has(q.id)||(H.add(q.id),A=!0);return A?H:S})},[No.groups]);const er=h.useMemo(()=>{const S=f.filter(A=>A.selected);return S.length>0?S:In?f.filter(A=>A.id===In):[]},[f,In]),Rt=h.useMemo(()=>er.map(S=>S.id),[er]),At=h.useCallback(()=>{if(vt)return;if(!Ae){Pe("Readonly workspace");return}const S=(y.current||[]).filter(ne=>(ne==null?void 0:ne.selected)&&!ip(ne));if(S.length<2){Pe("选择至少两个节点后按 G 创建 Group");return}const A=S.reduce((ne,te)=>{var at,Ut,hn,Kn,Be,Fe,ot,mt,qt,Ht,Ge,Bt;const de=Number(((at=te.position)==null?void 0:at.x)||0),ke=Number(((Ut=te.position)==null?void 0:Ut.y)||0),De=Number(((hn=te.measured)==null?void 0:hn.width)||te.width||((Be=(Kn=te.data)==null?void 0:Kn.nodeSize)==null?void 0:Be.width)||((ot=(Fe=te.data)==null?void 0:Fe.displaySize)==null?void 0:ot.width)||QR),ht=Number(((mt=te.measured)==null?void 0:mt.height)||te.height||((Ht=(qt=te.data)==null?void 0:qt.nodeSize)==null?void 0:Ht.height)||((Bt=(Ge=te.data)==null?void 0:Ge.displaySize)==null?void 0:Bt.height)||Gg);return{minX:Math.min(ne.minX,de),minY:Math.min(ne.minY,ke),maxX:Math.max(ne.maxX,de+De),maxY:Math.max(ne.maxY,ke+ht)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(A.minX)||!Number.isFinite(A.minY))return;const H=new Set((y.current||[]).map(ne=>ne.id));let q=1,X=`group_${q}`;for(;H.has(X);)q+=1,X=`group_${q}`;const re=jv({width:A.maxX-A.minX+bm*2,height:A.maxY-A.minY+bm*2})||{width:Fc,height:zc},se={id:X,type:$c,position:{x:A.minX-bm,y:A.minY-bm},width:re.width,height:re.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Zg(q-1),title:Zg(q-1),color:"purple",nodeSize:re}};m(ne=>[se,...ne.map(te=>({...te,selected:!1}))]),w(ne=>ne.map(te=>({...te,selected:!1}))),Tn(""),Pe(`Created group for ${S.length} nodes`)},[vt,w,m,Ae]),lu=h.useMemo(()=>f.filter(S=>{var A;return $n((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}),[f]),xn=h.useMemo(()=>er.filter(S=>{var A;return $n((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}).map(S=>S.id),[er]),wn=h.useMemo(()=>{const S=String((Vr==null?void 0:Vr.username)||(Vr==null?void 0:Vr.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[Vr]),ef=h.useMemo(()=>new Set(Rt),[Rt]),ls=h.useMemo(()=>g.filter(S=>ef.has(S.source)&&ef.has(S.target)),[g,ef]),jo=h.useCallback(S=>{const A=S==="display"?"display":"workspace";l(A),Tn(""),K([]),F(null),Lr(!1),Vt(!1);const H=Ro(o);A==="display"&&H.set("view","display");const q=`/workspace${H.toString()?`?${H.toString()}`:""}`;window.history.pushState({},"",q)},[o]),tf=h.useCallback(S=>{var q;const A=String(S||"").trim();if(!A)return;const H=y.current.find(X=>X.id===A);if(!H||!$n((q=H.data)==null?void 0:q.definitionId)){Pe("展示节点不可用");return}j(X=>{if(X.nodeIds.includes(A))return X;const re=X.nodeIds.length,se=Au(H);return{nodeIds:[...X.nodeIds,A],nodePositions:{...X.nodePositions,[A]:{x:180+re*36,y:120+re*28}},nodeSizes:{...X.nodeSizes,...se?{[A]:se}:{}}}}),K([A])},[]),cu=h.useCallback(S=>{const A=String(S||"").trim();A&&(j(H=>{const q=H.nodeIds.filter(se=>se!==A),X={...H.nodePositions},re={...H.nodeSizes};return delete X[A],delete re[A],{nodeIds:q,nodePositions:X,nodeSizes:re}}),K(H=>H.filter(q=>q!==A)))},[]),nf=h.useCallback(S=>{const A=String(S||"").trim();A&&(E.current.nodeIds.includes(A)?cu(A):tf(A))},[tf,cu]),ua=h.useMemo(()=>{const S=ir.trim().toLowerCase();return S?ca.filter(A=>{var H,q;return[A.id,(H=A.data)==null?void 0:H.label,(q=A.data)==null?void 0:q.definitionId].filter(Boolean).some(X=>String(X).toLowerCase().includes(S))}):ca},[ca,ir]),es=h.useMemo(()=>{const S=ua.length,A=S<=1?1:S<=4?2:3,H=Array.from({length:A},()=>({height:0,nodes:[]}));for(const q of ua){const X=Au(q)||{width:420,height:260},re=Math.max(1,Number(X.width)||420),se=Math.max(1,Number(X.height)||260),ne=Math.min(26,Math.max(5.5,se/re*16))+3.2;let te=H[0];for(const de of H)de.height<te.height&&(te=de);te.nodes.push(q),te.height+=ne}return H.map(q=>q.nodes)},[ua]),Hi=h.useCallback(S=>{var re,se;const A=x.nodeIds.includes(S.id),H=Au(S)||{width:420,height:260},q=Math.max(1,Math.round(Number(H.width)||420)),X=Math.max(1,Math.round(Number(H.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(A?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${q} / ${X}`},onClick:()=>nf(S.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:A,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(YY,{node:S})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((re=S.data)==null?void 0:re.label)||S.id}),i.jsxs("small",{children:[$n((se=S.data)==null?void 0:se.definitionId)," · ",S.id]})]})]},S.id)},[x.nodeIds,nf]),Nh=h.useMemo(()=>{const S=fe.trim().toLowerCase();return S?Ee.filter(A=>[A.id,A.version,A.displayName,A.name,A.description,...Array.isArray(A.tags)?A.tags:[]].filter(Boolean).some(H=>String(H).toLowerCase().includes(S))):Ee},[Ee,fe]),jh=h.useCallback((S,A)=>{const H=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let q=`${H}_${Date.now().toString(36)}`,X=2;for(;A.has(q);)q=`${H}_${Date.now().toString(36)}_${X}`,X+=1;return A.add(q),q},[]),qa=h.useCallback((S,A)=>{var qt,Ht;if(!Ae){Pe("Readonly workspace");return}const H=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},q=H.instances&&typeof H.instances=="object"?H.instances:{},X=Object.keys(q);if(X.length===0)return;const re=new Set(y.current.map(Ge=>Ge.id)),se={};for(const Ge of X)se[Ge]=jh(Ge,re);const ne=(qt=H.ui)!=null&&qt.nodePositions&&typeof H.ui.nodePositions=="object"?H.ui.nodePositions:{},te=(Ht=H.ui)!=null&&Ht.nodeSizes&&typeof H.ui.nodeSizes=="object"?H.ui.nodeSizes:{},de=X.map(Ge=>{const Bt=ne[Ge];return{id:Ge,x:typeof(Bt==null?void 0:Bt.x)=="number"?Bt.x:0,y:typeof(Bt==null?void 0:Bt.y)=="number"?Bt.y:0}}),ke=Math.min(...de.map(Ge=>Ge.x)),De=Math.min(...de.map(Ge=>Ge.y));let ht=A||{x:360+y.current.length*24,y:180+y.current.length*18};if(!A){const Ge=document.querySelector(".af-workspace-canvas .react-flow");if(Ge){const Bt=Ge.getBoundingClientRect();ht=r.screenToFlowPosition({x:Bt.left+Bt.width*.48,y:Bt.top+Bt.height*.32})}}const at={},Ut={},hn={};for(const Ge of de){const Bt=se[Ge.id];at[Bt]={...q[Ge.id]||{}},Ut[Bt]={x:ht.x+(Ge.x-ke),y:ht.y+(Ge.y-De)};const us=te[Ge.id];typeof(us==null?void 0:us.width)=="number"&&typeof(us==null?void 0:us.height)=="number"&&(hn[Bt]={width:us.width,height:us.height})}const Kn=new Set(X),Be=(Array.isArray(H.edges)?H.edges:[]).filter(Ge=>Kn.has(Ge==null?void 0:Ge.source)&&Kn.has(Ge==null?void 0:Ge.target)).map(Ge=>({source:se[Ge.source],target:se[Ge.target],sourceHandle:Ge.sourceHandle??null,targetHandle:Ge.targetHandle??null})),Fe=Nw({instances:at,edges:Be,ui:{nodePositions:Ut,nodeSizes:hn}},V),ot=Fe.nodes.map(Ge=>Ge.id),mt=Fe.nodes.map(Ge=>({...Ge,selected:!0}));_.current={..._.current,...Fe.instances},O(_.current),m(Ge=>[...Ge.map(Bt=>({...Bt,selected:!1})),...mt]),w(Ge=>[...Ge.map(Bt=>({...Bt,selected:!1})),...Fe.edges.map(Bt=>({...Bt,selected:!1}))]),Tn(""),K([]),Pe(`已添加流程片段:${S.displayName||S.id}(已选中 ${ot.length} 个节点)`)},[jh,V,r,w,m,Ae]),Ch=h.useCallback(()=>{var H,q;if(er.length<2){Ye("请先在 workspace 画布上选择至少两个节点。"),ue("flows");return}const S=er[0],A=er.length===2?`${((H=S.data)==null?void 0:H.label)||S.id} 片段`:`${((q=S.data)==null?void 0:q.label)||S.id} 等 ${er.length} 个节点`;Ft({name:A,id:A.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),We(""),ze(!0),ue("flows")},[er]),Eh=h.useCallback(async()=>{var X,re;if(er.length<2)return;const S=dt.name.trim();if(!S){We("请填写片段名称。");return}const A={},H={};for(const se of er){A[se.id]={x:((X=se.position)==null?void 0:X.x)||0,y:((re=se.position)==null?void 0:re.y)||0};const ne=Au(se);ne&&(H[se.id]=ne)}const q=ls.map(se=>({source:se.source,target:se.target,sourceHandle:se.sourceHandle??null,targetHandle:se.targetHandle??null}));pt(!0),We("");try{const se=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:dt.id,name:S,displayName:S,version:"1.0.0",description:dt.description,snippet:{instances:lh(er,_.current),edges:q,ui:{nodePositions:A,nodeSizes:H}}})}),ne=await se.json().catch(()=>({}));if(!se.ok||ne.ok===!1)throw new Error(ne.error||"发布流程片段失败");ze(!1),Pe(`流程片段已发布:${ne.id||S}`),mi(`流程片段已发布:${ne.id||S}`),await yi(),ue("flows")}catch(se){We(String(se.message||se))}finally{pt(!1)}},[yi,dt,ls,er,mi]);h.useCallback(()=>{if(lu.length===0){Pe("当前 workspace 没有 display 节点");return}const S=xn.length>0?xn:lu.map(H=>H.id),A=o.flowId?`${o.flowId} 展示页`:"AgentFlow Display";Jn({title:A,layout:"gallery",nodeIds:S}),Mt(""),gn(null),_e(!0)},[o.flowId,xn,lu]);const ei=h.useCallback(S=>{Jn(A=>{const H=Array.isArray(A.nodeIds)?A.nodeIds:[];return H.includes(S)?{...A,nodeIds:H.filter(q=>q!==S)}:{...A,nodeIds:[...H,S]}})},[]),Ya=h.useCallback(async()=>{var H;const S=cn.title.trim(),A=Array.isArray(cn.nodeIds)?cn.nodeIds:[];if(A.length===0){Mt("请选择至少一个 display 节点。");return}rt(!0),Mt(""),gn(null);try{await dn(f,g);const q=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:S,layout:cn.layout,nodeIds:A})}),X=await q.json().catch(()=>({}));if(!q.ok||X.ok===!1)throw new Error(X.error||"发布展示页失败");const re=new URL(X.url||`/display/${((H=X.share)==null?void 0:H.id)||""}`,window.location.origin).href;gn({...X,absoluteUrl:re}),Pe("展示页已生成")}catch(q){Mt(String(q.message||q))}finally{rt(!1)}},[cn,g,o,f,dn]),Ga=h.useCallback(async()=>{var A;const S=Array.isArray(x.nodeIds)?x.nodeIds:[];if(S.length===0){Mt("请先添加至少一个展示节点。"),Pe("请先添加至少一个展示节点"),Vt(!0);return}rt(!0),Mt("");try{await dn(f,g);const H=o.flowId?`${o.flowId} 展示页`:"AgentFlow Display",q=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,title:H,layout:"canvas",nodeIds:S})}),X=await q.json().catch(()=>({}));if(!q.ok||X.ok===!1)throw new Error(X.error||"生成展示链接失败");const re=new URL(X.url||`/display/${((A=X.share)==null?void 0:A.id)||""}`,window.location.origin).href;gn({...X,absoluteUrl:re}),mr(!0),Pe("展示链接已生成")}catch(H){const q=String(H.message||H);Mt(q),Pe(q)}finally{rt(!1)}},[x.nodeIds,g,o,f,dn]),_h=h.useCallback(async()=>{const S=wt==null?void 0:wt.absoluteUrl;if(!S)return;const A=await LY(S);gr(A?"copied":"failed"),window.setTimeout(()=>gr(""),1600)},[wt==null?void 0:wt.absoluteUrl]),nx=h.useCallback(S=>{m(A=>A.map(H=>H.id===S?{...H,selected:!1}:H)),Tn(A=>A===S?"":A)},[m]),bs=h.useCallback(()=>{const S=Wn.current;if(!S)return;const A=S.getBoundingClientRect(),H=Math.min(420,Math.max(320,A.width+160)),q=12,X=Math.max(180,A.top-q*2),re=Math.min(560,X);qc({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-H-12,A.left)),top:Math.max(q,A.top-re-q),width:H,maxHeight:re,zIndex:1e4})},[]);h.useEffect(()=>{if(!tn)return;bs();const S=H=>{var X,re;const q=H.target;(X=Wn.current)!=null&&X.contains(q)||(re=Uc.current)!=null&&re.contains(q)||ql(!1)},A=H=>{H.key==="Escape"&&ql(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",A),window.addEventListener("resize",bs),window.addEventListener("scroll",bs,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",A),window.removeEventListener("resize",bs),window.removeEventListener("scroll",bs,!0)}},[tn,bs]);const Co=h.useCallback(S=>{var q,X,re;if(a==="display"){const se=[];let ne=!1;j(te=>{var De,ht;const de={...te.nodePositions},ke={...te.nodeSizes};for(const at of S||[]){const Ut=jw(at==null?void 0:at.id);if(!(!Ut||!te.nodeIds.includes(Ut))){if(at.type==="select"){at.selected&&se.push(Ut);continue}if(at.type==="position"&&at.position){de[Ut]={x:at.position.x,y:at.position.y},ne=!0;continue}if(at.type==="dimensions"&&((De=at.dimensions)!=null&&De.width)&&((ht=at.dimensions)!=null&&ht.height)){const hn=od({width:Math.round(Number(at.dimensions.width)),height:Math.round(Number(at.dimensions.height))},{display:!0});hn&&(ke[Ut]=hn,ne=!0)}}}return ne?{...te,nodePositions:de,nodeSizes:ke}:te}),(S||[]).some(te=>(te==null?void 0:te.type)==="select")&&K(se);return}if(!Ae){const se=(S||[]).filter(ne=>(ne==null?void 0:ne.type)==="select");se.length>0&&m(ne=>Og(se,ne));return}const A=new Map;for(const se of S||[])if((se==null?void 0:se.type)==="dimensions"&&((q=se.dimensions)!=null&&q.width)&&((X=se.dimensions)!=null&&X.height)){const ne=f.find(ht=>ht.id===se.id),te=ip(ne),de=!!$n((re=ne==null?void 0:ne.data)==null?void 0:re.definitionId),ke={width:Math.round(Number(se.dimensions.width)),height:Math.round(Number(se.dimensions.height))},De=te?jv(ke):od(ke,{display:de});De&&A.set(se.id,De)}const H=Array.from(A.keys());if(m(se=>Og(S,se).map(ne=>{var de;const te=A.get(ne.id);return te?ip(ne)?{...ne,width:te.width,height:te.height,data:{...ne.data,nodeSize:te}}:$n((de=ne.data)==null?void 0:de.definitionId)?{...ne,width:te.width,height:te.height,data:{...ne.data,nodeSize:te,displaySize:te}}:{...ne,width:te.width,height:te.height,data:{...ne.data,nodeSize:te}}:ne})),H.length>0){const se=()=>H.forEach(ne=>s(ne));window.requestAnimationFrame(se),window.setTimeout(se,80)}},[f,m,s,a,Ae]),rx=h.useCallback(S=>{if(a!=="display"){if(!Ae){const A=(S||[]).filter(H=>(H==null?void 0:H.type)==="select");A.length>0&&w(H=>Y0(A,H));return}k(S)}},[k,w,a,Ae]),ct=h.useCallback(()=>{const S=document.querySelector(".af-workspace-canvas .react-flow");if(S){const A=S.getBoundingClientRect();return r.screenToFlowPosition({x:A.left+A.width*.48,y:A.top+A.height*.32})}return{x:360+f.length*36,y:180+f.length*28}},[f.length,r]),vs=h.useCallback(()=>{var S,A,H;if(an){const q=Number(((S=an.measured)==null?void 0:S.width)||an.width||260);return{x:Number(((A=an.position)==null?void 0:A.x)||0)+q+140,y:Number(((H=an.position)==null?void 0:H.y)||0)}}return ct()},[ct,an]),Bi=h.useCallback((S,A={})=>{if(!Ae)return Pe("Readonly workspace"),null;if(!S)return null;const H=Ck(S)||S.id,q=s2(S),X=o2(S),re=A.id||SY(H,f),se=km(S.inputs),ne=km(S.outputs),te={definitionId:H,...q?{marketplaceRef:q}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:A.label||Qg(S),role:"normal",body:A.body||"",...A.script||X?{script:A.script||X}:{},...A.scriptRef?{scriptRef:A.scriptRef}:{},...A.implementationRef?{implementationRef:A.implementationRef}:{},...A.implementationMode?{implementationMode:A.implementationMode}:{},input:A.inputs||se,output:A.outputs||ne},de={id:re,type:$c,position:A.position||ct(),data:{label:te.label,definitionId:H,...q?{marketplaceRef:q}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:r2(H,S),role:"normal",body:te.body,...te.script?{script:te.script}:{},...te.scriptRef?{scriptRef:te.scriptRef}:{},...te.implementationRef?{implementationRef:te.implementationRef}:{},...te.implementationMode?{implementationMode:te.implementationMode}:{},inputs:te.input,outputs:te.output}},ke={...zp(de,{..._.current,[re]:te},V),selected:!0};return m(De=>[...De.map(ht=>({...ht,selected:!1})),ke]),A.openProperties&&Tn(re),re},[ct,f,V,m,Ae]),Ah=h.useCallback(S=>kw(S,y.current),[]),rf=h.useCallback(S=>{if(!Ae){Pe("Readonly workspace");return}if(!kw(S,y.current)){Pe("端口类型不匹配,已取消连线");return}F(null),m(A=>rp(A,S)),w(A=>{const H=A.filter(q=>!(q.target===S.target&&q.targetHandle===S.targetHandle));return rd({...S,markerEnd:{type:js.ArrowClosed}},H)})},[w,m,Ae]),sf=h.useCallback((S,A)=>{if(!Ae)return;const H=bY(A,y.current);R.current=H?{...H,preferExisting:!!(S!=null&&S.shiftKey)}:null,F(null)},[Ae]),uu=h.useCallback((S,A)=>{var Kn,Be,Fe,ot;if(!Ae)return;const H=R.current;if(R.current=null,!H||A!=null&&A.toNode)return;const q=vY(V,H),X=kY(y.current,b.current,H);if(q.length===0&&X.length===0){Pe(`没有匹配 ${H.slotType} 端口的节点`);return}const se=!!(S!=null&&S.shiftKey||H.preferExisting)?X.length>0?"existing":"create":q.length>0?"create":"existing",ne=((Be=(Kn=S==null?void 0:S.changedTouches)==null?void 0:Kn[0])==null?void 0:Be.clientX)??(S==null?void 0:S.clientX),te=((ot=(Fe=S==null?void 0:S.changedTouches)==null?void 0:Fe[0])==null?void 0:ot.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(ne)||!Number.isFinite(te))return;const de=document.querySelector(".af-workspace-canvas .react-flow");if(!de)return;const ke=de.getBoundingClientRect(),De=320,ht=Math.max(q.length,X.length),at=Math.min(480,150+ht*58),Ut=Math.max(12,Math.min(ne-ke.left,ke.width-De-12)),hn=Math.max(12,Math.min(te-ke.top,ke.height-at-12));F({left:Ut,top:hn,flowPosition:r.screenToFlowPosition({x:ne,y:te}),draft:H,candidates:q,existingCandidates:X,mode:se,query:""})},[V,r,Ae]),sx=h.useCallback(S=>{if(!Ae){Pe("Readonly workspace"),F(null);return}const A=M.current;if(!A||!(S!=null&&S.def))return;const H=Bi(S.def,{position:A.flowPosition});if(!H)return;const q=A.draft.handleType==="source"?{source:A.draft.nodeId,sourceHandle:A.draft.handleId,target:H,targetHandle:`input-${S.slotIndex}`}:{source:H,sourceHandle:`output-${S.slotIndex}`,target:A.draft.nodeId,targetHandle:A.draft.handleId};m(X=>rp(X,q)),w(X=>{const re=X.filter(se=>!(se.target===q.target&&se.targetHandle===q.targetHandle));return rd({...q,markerEnd:{type:js.ArrowClosed}},re)}),F(null)},[Bi,w,Ae]),du=h.useCallback(S=>{if(!Ae){Pe("Readonly workspace"),F(null);return}const A=S==null?void 0:S.connection;if(!A||!kw(A,y.current)){Pe("端口类型不匹配,已取消连线"),F(null);return}m(H=>rp(H,A)),w(H=>{const q=H.filter(X=>!(X.target===A.target&&X.targetHandle===A.targetHandle));return rd({...A,markerEnd:{type:js.ArrowClosed}},q)}),F(null)},[w,m,Ae]),of=h.useCallback(S=>{S&&(Bi(S,{position:vs()}),Lr(!1),ws(""))},[Bi,vs]),sc=h.useCallback(S=>{S&&(qa(S,vs()),Lr(!1),ws(""))},[qa,vs]);h.useEffect(()=>{const S=A=>{var de;if(A.defaultPrevented)return;const H=_R(A.target)||lY(A.target);if((A.metaKey||A.ctrlKey)&&A.key.toLowerCase()==="s"){A.preventDefault(),dn().catch(ke=>Pe(String(ke.message||ke)));return}if((A.metaKey||A.ctrlKey)&&A.key.toLowerCase()==="k"){A.preventDefault(),A.stopPropagation(),Fa(ke=>!ke);return}if(ia)return;if(ra){(A.key==="Escape"||Yg(A))&&(A.preventDefault(),sa(!1));return}const q=A.key.toLowerCase(),X=(A.metaKey||A.ctrlKey)&&q==="c",re=(A.metaKey||A.ctrlKey)&&q==="v",se=H&&X&&uY(A.target);if(H&&!se)return;const ne=(A.metaKey||A.ctrlKey)&&!A.shiftKey&&q==="z",te=(A.metaKey||A.ctrlKey)&&(A.shiftKey&&q==="z"||q==="y");if(ne||te){if(vt){A.preventDefault(),A.stopPropagation(),Pe("展示页布局会自动保存");return}if(!Ae){A.preventDefault(),Pe("Readonly workspace");return}A.preventDefault(),A.stopPropagation();const ke=ne?Gd():xh();Pe(ke?ne?"Undo canvas change":"Redo canvas change":ne?"Nothing to undo":"Nothing to redo");return}if(X){if(vt)return;const ke=ce.current,De=(y.current||[]).some(at=>at==null?void 0:at.selected)?y.current:(y.current||[]).map(at=>ke&&at.id===ke?{...at,selected:!0}:at),ht=xR(De,b.current,_.current);ht&&(A.preventDefault(),A.stopPropagation(),D.current=ht,se&&typeof((de=A.target)==null?void 0:de.blur)=="function"&&A.target.blur(),Pe(`Copied ${ht.nodes.length} node${ht.nodes.length>1?"s":""}`));return}if(re){if(vt){A.preventDefault(),A.stopPropagation();return}if(!Ae){A.preventDefault(),Pe("Readonly workspace");return}const ke=wR(D.current,y.current,b.current,_.current);ke&&(A.preventDefault(),A.stopPropagation(),_.current=ke.instances,O(ke.instances),m(ke.nodes),w(ke.edges),Pe(`Pasted ${ke.pastedNodeIds.length} node${ke.pastedNodeIds.length>1?"s":""}`));return}if(Yg(A)&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),sa(!0);return}if(q==="g"&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),At();return}if(A.key==="a"||A.key==="A"){if(A.metaKey||A.ctrlKey){A.preventDefault(),vt?K(E.current.nodeIds):(m(ke=>ke.map(De=>({...De,selected:!0}))),w(ke=>ke.map(De=>({...De,selected:!1}))));return}if(A.altKey)return;if(vt){A.preventDefault(),Vt(!0);return}if(!Ae){A.preventDefault(),Pe("Readonly workspace");return}A.preventDefault(),Lr(!0);return}if((A.key==="v"||A.key==="V")&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),hh("select");return}if((A.key==="h"||A.key==="H")&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),hh("pan");return}(A.key==="f"||A.key==="F")&&!A.metaKey&&!A.ctrlKey&&!A.altKey&&(A.preventDefault(),Ka())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[At,vt,ia,Ka,xh,dn,ra,w,m,Gd,Ae]);const Ph=h.useCallback(S=>{br(A=>{const H=new Set(A);return H.has(S)?H.delete(S):H.add(S),H})},[]),Ls=h.useCallback((S,A)=>{S.dataTransfer.effectAllowed="copy",S.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:A.path,name:A.name,type:A.type})),S.dataTransfer.setData("text/plain",A.path)},[]),fu=h.useCallback((S,A)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",A.id),S.dataTransfer.setData("text/plain",A.id)},[]),Xa=h.useCallback(async(S,A)=>{const H=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),q=H.split(".").pop(),X=q==="html"?"display_html":q==="csv"||q==="tsv"||q==="json"&&/\b(table|data|rows|report)\b/i.test(H)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(q)?"display_image":"display_markdown",re=V.find(De=>De.id===X);if(!re){Pe("展示节点不可用");return}const se=X==="display_image";let ne=String(S.path||"");if(!se){const De=Ro(o);De.set("path",S.path);const ht=await fetch(`/api/workspace/file?${De.toString()}`),at=await ht.json();if(!ht.ok)throw new Error(at.error||"读取文件失败");ne=String(at.content||"")}const te=X==="display_image"?"src":"content",de=km(re.inputs).map(De=>De.name===te?{...De,default:ne,value:ne}:De),ke=km(re.outputs).map(De=>De.name===te?{...De,default:ne,value:ne}:De);Bi(re,{label:S.name||"Display",body:ne,inputs:de,outputs:ke,position:A}),Pe(`已创建展示:${S.path}`)},[Bi,o,V]),pu=h.useCallback(S=>{if(!Ae){Pe("Readonly workspace");return}Xa(S,ct()).catch(A=>Pe(String(A.message||A)))},[Xa,ct,Ae]),ix=h.useCallback(S=>{if(!Ae){S.preventDefault(),Pe("Readonly workspace");return}const A=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(A){S.preventDefault();let se;try{se=JSON.parse(A)}catch{return}if(!(se!=null&&se.path))return;const ne=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Xa(se,ne).catch(te=>Pe(String(te.message||te)));return}const H=S.dataTransfer.getData("application/agentflow-snippet");if(H){const se=Ee.find(te=>`${te.id}@${te.version}`===H);if(!se)return;S.preventDefault();const ne=r.screenToFlowPosition({x:S.clientX,y:S.clientY});qa(se,ne);return}const q=S.dataTransfer.getData("application/agentflow-node");if(!q)return;const X=V.find(se=>se.id===q);if(!X)return;S.preventDefault();const re=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Bi(X,{position:re})},[Xa,Bi,Ee,qa,V,r,Ae]),ox=h.useCallback(S=>{if(!Ae)return;const A=Array.from(S.dataTransfer.types||[]);!A.includes("application/x-agentflow-workspace-file")&&!A.includes("application/agentflow-node")&&!A.includes("application/agentflow-snippet")||(S.preventDefault(),S.dataTransfer.dropEffect=A.includes("application/agentflow-node")||A.includes("application/agentflow-snippet")?"move":"copy")},[Ae]),Ih=h.useCallback(async(S="")=>{if(!Ae){Pe("Readonly workspace");return}const A=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!A)return;const H=S&&!A.includes("/")?`${S}/${A}`:A;try{const q=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:H,content:""})}),X=await q.json();if(!q.ok)throw new Error(X.error||"创建文件失败");await kr(),br(re=>{const se=new Set(re);for(const ne of Nm(X.path||H))se.delete(ne);return se}),Pe(`已创建 ${X.path}`)}catch(q){Pe(String(q.message||q))}},[o,kr,Ae]),hu=h.useCallback(async(S="")=>{if(!Ae){Pe("Readonly workspace");return}const A=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!A)return;const H=S&&!A.includes("/")?`${S}/${A}`:A;try{const q=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:H})}),X=await q.json();if(!q.ok)throw new Error(X.error||"创建文件夹失败");await kr(),br(re=>{const se=new Set(re);for(const ne of Nm(X.path||H))se.delete(ne);return X.path&&se.delete(X.path),se}),Pe(`已创建 ${X.path}`)}catch(q){Pe(String(q.message||q))}},[o,kr,Ae]),ax=h.useCallback(async S=>{if(!Ae){Pe("Readonly workspace");return}if(!(!(S!=null&&S.path)||!window.confirm(`删除 ${S.path}?`)))try{const A=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,path:S.path})}),H=await A.json();if(!A.ok)throw new Error(H.error||"删除失败");Pe(`已删除 ${H.path}`),await kr()}catch(A){Pe(String(A.message||A))}},[o,kr,Ae]),ic=h.useCallback(async()=>{if(!Ae){Pe("Readonly workspace");return}const S=Qo.trim();if(!S||yn)return;const A=Sm(f,g,_.current);Oa(""),Gl(!0),Ql("workspace"),Zo(H=>[...H,{role:"user",text:S,at:Date.now()}]);try{await dn(f,g);const H=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...o,prompt:S,outputKind:"markdown",workspaceGraph:A,allowFlowYaml:!1,model:U,selectedSkills:bt,selectedNodeIds:Rt})}),q=await H.json();if(!H.ok)throw new Error(q.error||"生成失败");const X=String(q.content||"").trim();Zo(re=>[...re,{role:"assistant",text:X,at:Date.now()}]),await Ba(),Pe("AI 生成完成")}catch(H){const q=String(H.message||H);Zo(X=>[...X,{role:"assistant",text:q,error:!0,at:Date.now()}]),Pe(q)}finally{Gl(!1)}},[U,yn,Qo,g,o,Ba,f,Ql,dn,Rt,bt,Ae]),cs=Wd.find(S=>S.id===Da)||null,lx=cs?Array.isArray(cs.messages)?cs.messages:[]:$a,Th=cs?cs.status==="running":yn,cx=cs?cs.status==="running"?`${cs.label} running`:cs.status==="paused"?`${cs.label} paused`:cs.status==="failed"?`${cs.label} failed`:`${cs.label} done`:yn?"Workspace agent running":$a.length>0?"Workspace conversation":"Ready",ux=String(o.flowId||"").trim()||"Workspace";return i.jsxs("div",{className:"af-workspace-page",children:[i.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n("/projects"),"aria-label":"返回",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",title:o.flowId?`${o.flowId} · ${Hn}`:Hn||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:ux}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",rY,"-STABLE"]})]}),i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:a==="workspace"?"af-view-switch__active":"",onClick:()=>jo("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:a==="display"?"af-view-switch__active":"",onClick:()=>jo("display"),children:"Display"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:"af-workspace-save-status",children:qd}),vt?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ve||!(wt!=null&&wt.absoluteUrl)&&x.nodeIds.length===0,onClick:()=>{gr(""),wt!=null&&wt.absoluteUrl?mr(!0):Ga()},title:wt!=null&&wt.absoluteUrl?"查看展示链接":x.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ve?"hourglass_empty":"ios_share"}),Ve?"生成中":wt!=null&&wt.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:ca.length===0,onClick:()=>Vt(!0),title:ca.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>n(Di),"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),children:i.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Zy,onClick:()=>d(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:i.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!Zy,onClick:()=>u(!0),"aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>sa(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Xl?" af-composer-topbar-btn--active":"")+(yn?" af-composer-topbar-btn--running":""),disabled:vt,onClick:()=>ea(S=>!S),children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Ae,onClick:()=>dn().catch(S=>Pe(String(S.message||S))),children:"Save"})]})]}),sn?i.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsx("span",{children:sn}),i.jsx("button",{type:"button",onClick:()=>xt(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!vt&&(Xl||he)?" af-workspace-body--drawer":"")+(!vt&&na?" af-workspace-body--sidebar-collapsed":"")+(vt?" af-workspace-body--display-mode":""),children:[!vt&&na?i.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:i.jsxs("div",{className:"af-workspace-rail__stack",children:[i.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Lr(!0),"aria-label":"添加节点",title:"添加节点",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),i.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>Zr(!1),"aria-label":"展开文件",title:"展开文件",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),i.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),i.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>Zr(!1),"aria-label":"展开侧边栏",title:(Vr==null?void 0:Vr.username)||(Vr==null?void 0:Vr.userId)||"展开侧边栏",children:wn})]})}):null,vt?null:i.jsxs("aside",{ref:fo,className:"af-workspace-sidebar"+(Ri?" af-workspace-sidebar--resizing":""),"aria-hidden":na,style:{"--af-work-files-pane-height":`${Math.round(As)}px`},children:[i.jsxs("section",{className:"af-workspace-files-section",children:[i.jsxs("div",{className:"af-workspace-sidebar-head",children:[i.jsx("h2",{children:"Files"}),i.jsxs("div",{className:"af-workspace-sidebar-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Zr(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ae,onClick:()=>Ih(Dr),"aria-label":"新增文件",title:Dr?`在 ${Dr} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ae,onClick:()=>hu(Dr),"aria-label":"新增文件夹",title:Dr?`在 ${Dr} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ae||co,onClick:()=>Fi(Dr),"aria-label":"上传文件",title:Dr?`上传到 ${Dr}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:co?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ae||!Ms,onClick:()=>ax(Ms),"aria-label":"删除选中项",title:Ms?`删除 ${Ms.path}`:"先选择文件或文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void kr(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:Ti,type:"file",multiple:!0,className:"af-visually-hidden",onChange:bh})]})]}),i.jsx("input",{className:"af-workspace-search",value:lt,onChange:S=>pn(S.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:au,children:i.jsx(x2,{items:$r,onOpen:pu,selectedPath:nt,collapsedDirs:Zt,onToggleDir:Ph,onSelect:S=>os(S.path||""),onFileDragStart:Ls})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Kl,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),i.jsxs("section",{className:"af-workspace-nodes-section",children:[i.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[i.jsxs("h2",{className:"af-node-palette-title",children:[i.jsx("span",{children:"Palette"}),i.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),i.jsxs("label",{className:"af-palette-search-wrap",children:[i.jsx("span",{className:"af-visually-hidden",children:Se==="flows"?"搜索流程片段":"搜索节点"}),i.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",className:"af-palette-search-input",value:fe,onChange:S=>xe(S.target.value),placeholder:Se==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Se==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":Se==="nodes",className:"af-palette-tab"+(Se==="nodes"?" af-palette-tab--active":""),onClick:()=>ue("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":Se==="flows",className:"af-palette-tab"+(Se==="flows"?" af-palette-tab--active":""),onClick:()=>ue("flows"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),i.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:Se==="flows"?i.jsxs(i.Fragment,{children:[i.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:i.jsxs("div",{className:"af-flow-snippet-actions",children:[i.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:Ch,disabled:er.length<2,title:er.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",er.length," 节点 / ",ls.length," 连线"]})]})}),je?i.jsx("p",{className:"af-err af-palette-list-err",children:je}):null,me?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Nh.length>0?i.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[i.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),i.jsx("div",{className:"af-palette-cards",children:Nh.map(S=>{const A=`${S.id}@${S.version}`,H=S.displayName||S.name||S.id,q=S.description||`${S.nodeCount||0} 个节点,${S.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:X=>{X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("application/agentflow-snippet",A),X.dataTransfer.setData("text/plain",A)},onClick:()=>qa(S),title:q,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:H}),i.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),q?i.jsx("span",{className:"af-palette-card-desc",children:q}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[S.nodeCount||0," nodes"]}),i.jsxs("span",{children:[S.edgeCount||0," edges"]})]})]},A)})})]}):i.jsx("p",{className:"af-palette-empty",children:fe.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Eu.map(S=>{var A;return(A=ou[S])!=null&&A.length?i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${S}`,children:[i.jsx("h3",{className:"af-palette-cat",children:S}),i.jsx("div",{className:"af-palette-cards",children:ou[S].map(H=>{const q=hC(H.inputs,"input"),X=hC(H.outputs,"output"),re=Nv(H),se=$f(H);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:ne=>fu(ne,H),onClick:()=>Bi(H),title:re||H.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:fC(S)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:se}),se!==H.id?i.jsx("span",{className:"af-palette-card-id",children:H.id}):null]})]}),re?i.jsx("span",{className:"af-palette-card-desc",children:re}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[q.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[q.shown.map((ne,te)=>i.jsxs("span",{className:"af-palette-card-port",title:pC("input",ne,te),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:qn(ne==null?void 0:ne.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:vm(ne,te)})]},`in-${te}`)),q.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",q.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[X.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[X.shown.map((ne,te)=>i.jsxs("span",{className:"af-palette-card-port",title:pC("output",ne,te),children:[i.jsx("span",{className:"af-palette-card-port-name",children:vm(ne,te)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:qn(ne==null?void 0:ne.type)}})]},`out-${te}`)),X.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",X.hidden]}):null]})]})]})]},H.id)})})]},S):null}),V.length>0&&fe.trim()&&Eu.every(S=>{var A;return!((A=ou[S])!=null&&A.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),i.jsxs("main",{className:"af-workspace-canvas",children:[i.jsx(X0,{className:"af-flow-canvas af-workspace-flow"+(oa==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(vt?" af-workspace-flow--display-mode":""),nodes:kh,edges:xi,nodeTypes:sG,onNodesChange:Co,onEdgesChange:rx,onConnect:vt?void 0:rf,onConnectStart:vt?void 0:sf,onConnectEnd:vt?void 0:uu,isValidConnection:vt?void 0:Ah,onNodeClick:(S,A)=>{var H;if(vt){K([jw(A.id)]);return}if((H=A==null?void 0:A.data)!=null&&H.isWorkspaceGroup){Tn("");return}if(S.detail>=3){ea(!1),m(q=>q.map(X=>({...X,selected:X.id===A.id}))),w(q=>q.map(X=>({...X,selected:!1}))),Tn(A.id);return}In&&Tn(A.id)},onNodeDoubleClick:S=>{S.preventDefault()},onPaneClick:()=>{vt?K([]):Tn("")},onDrop:vt?void 0:ix,onDragOver:vt?void 0:ox,nodesDraggable:vt?!0:Ae,nodesConnectable:vt?!1:Ae,edgesReconnectable:vt?!1:Ae,deleteKeyCode:vt?null:Ae?["Backspace","Delete"]:null,selectionOnDrag:oa==="select",panOnDrag:oa==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(Q0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!vt&&I?(()=>{var ne;const S=String(I.query||"").trim().toLowerCase(),A=I.mode==="create"?"create":"existing",H=Array.isArray(I.candidates)?I.candidates:[],q=Array.isArray(I.existingCandidates)?I.existingCandidates:[],X=S?H.filter(te=>{var de,ke,De;return[(de=te.def)==null?void 0:de.id,te.displayLabel,te.description,(ke=te.slot)==null?void 0:ke.name,(De=te.slot)==null?void 0:De.type].filter(Boolean).some(ht=>String(ht).toLowerCase().includes(S))}):H,re=S?q.filter(te=>{var de,ke;return[te.nodeId,te.nodeLabel,te.definitionId,(de=te.slot)==null?void 0:de.name,(ke=te.slot)==null?void 0:ke.type].filter(Boolean).some(De=>String(De).toLowerCase().includes(S))}):q,se=I.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:I.left,top:I.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:qn((ne=I.draft.slot)==null?void 0:ne.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",I.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>F(null),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[i.jsxs("button",{type:"button",className:A==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:q.length===0,onClick:()=>F(te=>te&&{...te,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:q.length})]}),i.jsxs("button",{type:"button",className:A==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:H.length===0,onClick:()=>F(te=>te&&{...te,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:H.length})]})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:I.query,onChange:te=>F(de=>de&&{...de,query:te.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[A==="create"?X.map(te=>{var De,ht;const de=te.displayLabel||((De=te.def)==null?void 0:De.id),ke=vm(te.slot,te.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>sx(te),title:te.description||te.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:de}),de!==te.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:te.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:se}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:qn((ht=te.slot)==null?void 0:ht.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ke})]})]},`${te.def.id}-${te.slotIndex}`)}):re.map(te=>{var De;const de=te.nodeLabel||te.nodeId,ke=vm(te.slot,te.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>du(te),title:`${te.definitionId||te.nodeId} · ${ke}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:de}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[te.definitionId?`${te.definitionId} · `:"",te.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:se}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:qn((De=te.slot)==null?void 0:De.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:ke}),te.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${te.nodeId}-${te.handleId}`)}),(A==="create"?X.length:re.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!vt&&!Qy?i.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:i.jsxs("div",{className:"af-pipeline-composer-inner",children:[i.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Qs(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),i.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:er.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):er.map(S=>{var X,re;const A=String(((X=S.data)==null?void 0:X.label)??S.id),H=(re=S.data)!=null&&re.definitionId?String(S.data.definitionId):"",q=H&&H!==A?`${A} · ${S.id} · ${H}`:`${A} · ${S.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:q,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:H||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:A}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>nx(S.id),"aria-label":`取消选择 ${S.id}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},S.id)})}),i.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[i.jsx("div",{className:"af-composer-input-wrap",children:i.jsx("textarea",{className:"af-composer-textarea",value:Qo,rows:2,onChange:S=>Oa(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),ic())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Ae})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Wn,type:"button",className:"af-composer-skills-button"+(bt.length>0?" af-composer-skills-button--active":""),disabled:yn||!Ae,"aria-haspopup":"listbox","aria-expanded":tn,onClick:()=>ql(S=>!S),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:bt.length>0?`Skills ${bt.length}`:"Skills"})]}),tn&&!yn?Ir.createPortal(i.jsx("div",{ref:Uc,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:ho,children:$e.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[No.groups.map(S=>{const A=Il(S,$e),H=GA(S,So,$e),q=Kc.has(S.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(q?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:H==="all",disabled:A.length===0,onChange:X=>{const re=X.target.checked;Bn(se=>re?qA(se,A):YA(se,A))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:S.name}),S.builtin?i.jsx("em",{children:"built-in"}):null,H==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":q?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{Ul(X=>{const re=new Set(X);return re.has(S.id)?re.delete(S.id):re.add(S.id),re})},children:[i.jsx("span",{children:S.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:q?"expand_more":"expand_less"})]})]}),q?null:i.jsx("div",{className:"af-composer-skill-group-items",children:S.skills.map(X=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:So.has(X.key),onChange:re=>{const se=re.target.checked;Bn(ne=>se?ne.includes(X.key)?ne:[...ne,X.key]:ne.filter(te=>te!==X.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:X.name}),X.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:X.description}):null]})]},`${S.id}:${X.key}`))})]},S.id)}),No.ungrouped.length>0?i.jsxs("div",{className:"af-composer-skill-group",children:[i.jsxs("div",{className:"af-composer-skill-group-title",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("span",{children:No.ungrouped.length})]}),No.ungrouped.map(S=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:So.has(S.key),onChange:A=>{const H=A.target.checked;Bn(q=>H?q.includes(S.key)?q:[...q,S.key]:q.filter(X=>X!==S.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:S.name}),S.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:S.description}):null]})]},`ungrouped:${S.key}`))]}):null]})}),document.body):null]}),i.jsx("label",{className:"af-composer-model-field",children:i.jsxs("select",{className:"af-composer-model-select",value:U,onChange:S=>be(S.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),ko.map(S=>i.jsx("option",{value:S.value,children:S.label},S.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(Qo.trim()&&!yn?" af-composer-send--active":"")+(yn?" af-composer-send--stop":""),disabled:yn||!Qo.trim()||!Ae,"aria-label":yn?"Running":"Send",onClick:()=>void ic(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:yn?"sync":"arrow_upward"})})]})]})]})}):vt?null:i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Qs(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!vt&&Xl?i.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:i.jsxs("div",{className:"af-composer-sidebar",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>ea(!1),"aria-label":"关闭 AI 对话侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-composer-session-tabs",children:[i.jsx("button",{type:"button",className:"af-composer-session-tab"+(Da==="workspace"?" af-composer-session-tab--active":""),onClick:()=>mo("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Wd.map(S=>i.jsx("button",{type:"button",className:"af-composer-session-tab"+(Da===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>mo(S.id),title:S.runNodeId||S.label,children:i.jsx("span",{className:"af-composer-session-label",children:S.label})},S.id))]}),i.jsx("div",{className:"af-composer-sidebar-status"+(Th?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:cx}),i.jsx("div",{className:"af-composer-sidebar-thread",children:i.jsx(dG,{messages:lx,running:Th,showRunningIndicator:!cs})})]})}):!vt&&he&&an?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx($R,{draft:he,setDraft:Q,definitionId:String(((Rh=an.data)==null?void 0:Rh.definitionId)||an.id),systemPromptReadonly:String(((Mh=an.data)==null?void 0:Mh.description)||""),modelLists:Qr,disabled:!Ae,onIdBlur:()=>iu(!0),onClose:()=>Tn(""),onPublishToMarketplace:tx,error:qe,ioSlots:{inputs:Array.isArray(he==null?void 0:he.inputs)?he.inputs:[],outputs:Array.isArray(he==null?void 0:he.outputs)?he.outputs:[]}})}):null,i.jsx(IR,{open:ra,onClose:()=>sa(!1)}),i.jsx(TR,{open:ia,onClose:()=>Fa(!1),onJump:Sh,nodes:wi}),i.jsx(AR,{open:c,onClose:()=>d(!1),flowId:o.flowId||"",flowSource:Is,onArchived:()=>{d(!1),n("/projects?tab=archived")}}),i.jsx(PR,{open:p&&!!o.flowId,onClose:()=>u(!1),flowId:o.flowId||"",flowSource:Is,flowArchived:!!o.archived,onDeleted:async()=>{u(!1),n("/projects")}}),tt?Ir.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ze(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"名称"}),i.jsx("input",{type:"text",value:dt.name,onChange:S=>{const A=S.target.value;Ft(H=>({...H,name:A,id:H.id?H.id:A.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"ID"}),i.jsx("input",{type:"text",value:dt.id,onChange:S=>Ft(A=>({...A,id:S.target.value})),placeholder:"content-cleanup-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:dt.description,onChange:S=>Ft(A=>({...A,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",er.length," 个节点和 ",ls.length," 条内部连线。"]}),_n?i.jsx("div",{className:"af-flow-snippet-error",children:_n}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>ze(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ue||!dt.name.trim(),onClick:()=>void Eh(),children:Ue?"发布中...":"发布"})]})]})}),document.body):null,rc?i.jsx(qY,{node:rc,onClose:()=>yr("")}):null,pe?Ir.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"发布展示页",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>_e(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{type:"text",value:cn.title,onChange:S=>Jn(A=>({...A,title:S.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:cn.layout,onChange:S=>Jn(A=>({...A,layout:S.target.value})),children:[i.jsx("option",{value:"gallery",children:"Gallery"}),i.jsx("option",{value:"document",children:"Document"}),i.jsx("option",{value:"slides",children:"Slides"})]})]}),i.jsx("div",{className:"af-display-share-node-list",role:"group","aria-label":"选择展示节点",children:lu.map(S=>{var H,q;const A=Array.isArray(cn.nodeIds)&&cn.nodeIds.includes(S.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:A,onChange:()=>ei(S.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((H=S.data)==null?void 0:H.label)||S.id}),i.jsxs("small",{children:[$n((q=S.data)==null?void 0:q.definitionId)," · ",S.id]})]})]},S.id)})}),wt!=null&&wt.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:wt.absoluteUrl,onFocus:S=>S.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(wt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void _h(),children:Cr==="copied"?"已复制":Cr==="failed"?"复制失败":"复制"})]}):null,it?i.jsx("div",{className:"af-flow-snippet-error",children:it}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>_e(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ve||!Array.isArray(cn.nodeIds)||cn.nodeIds.length===0,onClick:()=>void Ya(),children:Ve?"生成中...":"生成链接"})]})]})}),document.body):null,Pn?Ir.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{gr(""),mr(!1)},"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[wt!=null&&wt.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:wt.absoluteUrl,onFocus:S=>S.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(wt.absoluteUrl,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void _h(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Cr==="copied"?"check":"content_copy"}),Cr==="copied"?"已复制":Cr==="failed"?"复制失败":"复制"]})]}):i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),it?i.jsx("div",{className:"af-flow-snippet-error",children:it}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{gr(""),mr(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ve||x.nodeIds.length===0,onClick:()=>void Ga(),children:Ve?"生成中...":wt!=null&&wt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,Wt?Ir.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Vt(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-display-picker-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:ir,onChange:S=>Er(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":es.length||1},children:ua.length>0?es.map((S,A)=>i.jsx("div",{className:"af-display-picker-column",children:S.map(Hi)},`display-picker-column-${A}`)):i.jsx("div",{className:"af-display-picker-empty",children:ca.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>Vt(!1),children:"完成"})})]})}),document.body):null,hi.nodeId?Ir.createPortal(i.jsx(uG,{files:zt,query:hi.query,onQueryChange:S=>Ii(A=>({...A,query:S})),onSelect:Tt,onUpload:Fi,onClose:su}),document.body):null,!vt&&_r?Ir.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Lr(!1),children:i.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:S=>S.stopPropagation(),children:[i.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":or==="nodes",className:"af-workspace-quick-add__tab"+(or==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>xr("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":or==="flows",className:"af-workspace-quick-add__tab"+(or==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>xr("flows"),children:"流程"})]}),i.jsxs("div",{className:"af-workspace-quick-add__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:Yl,value:Or,onChange:S=>ws(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),Lr(!1);else if(S.key==="ArrowDown"){S.preventDefault();const A=or==="flows"?Ua.length:zi.length;Ar(H=>Math.min(Math.max(0,A-1),H+1))}else S.key==="ArrowUp"?(S.preventDefault(),Ar(A=>Math.max(0,A-1))):S.key==="Tab"?(S.preventDefault(),xr(A=>A==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),or==="flows"?sc(Ua[ar]||Ua[0]):of(zi[ar]||zi[0]))},placeholder:or==="flows"?"搜索流程片段...":"搜索节点...","aria-label":or==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:or==="flows"?Ua.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:me?"正在加载流程片段...":je||"没有匹配的流程片段"}):Ua.map((S,A)=>{const H=S.displayName||S.name||S.id,q=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,X=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,re=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(q||{}).length,se=Number.isFinite(Number(S.edgeCount))?Number(S.edgeCount):Array.isArray(X)?X.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(A===ar?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ar(A),onClick:()=>sc(S),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:H}),i.jsxs("span",{className:"af-workspace-quick-add__meta",children:[S.id,S.version?` · v${S.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:S.description||`${re} 节点 / ${se} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):zi.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):zi.map((S,A)=>{const H=Of(S),q=$f(S),X=Nv(S);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(A===ar?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ar(A),onClick:()=>of(S),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:fC(H)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:q}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:S.id}),X?i.jsx("span",{className:"af-workspace-quick-add__desc",children:X}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:H})]},S.id)})})]})}),document.body):null]})]})}function kG(){return i.jsx(Fy,{children:i.jsx(vG,{})})}function SG(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=(e==null?void 0:e.kind)==="image"?"src":"content",r=a=>String((a==null?void 0:a.value)??(a==null?void 0:a.default)??""),s=a=>r(a).trim(),o=t.find(a=>(a==null?void 0:a.name)===n&&s(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&s(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&s(a));return String((e==null?void 0:e.body)||(o?r(o):""))}function NG(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function jG(e){let t=String(e||"").replace(/\r\n/g,`
217
- `).trim();return t.includes(`
218
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
219
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
220
- $2`)),t}function w2(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=jG(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
221
- `).filter(f=>/^\s+/.test(f)||!f.trim()).map(f=>f.replace(/^\s{2}/,"")).join(`
222
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const d=t.replace(n[0],"").trim();if(d)return d}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function Pk(e){let t=w2(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function CG(e){const t=Pk(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function EG(e){const t=Pk(e);if(!t.trim())return"";const n=`<base target="_self"><script>
223
- (() => {
224
- document.addEventListener("click", (event) => {
225
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
226
- if (!link) return;
227
- const rawHref = String(link.getAttribute("href") || "").trim();
228
- if (!rawHref || rawHref.startsWith("#")) return;
229
- if (/^(?:javascript|mailto|tel):/i.test(rawHref)) return;
230
- event.preventDefault();
231
- window.location.href = link.href;
232
- }, true);
233
- })();
234
- <\/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 b2(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=new URLSearchParams;return s.set("id",t),s.set("path",r),n.download&&s.set("download","1"),`/api/display/file/raw?${s.toString()}`}function _G(e,t,n={}){const r=String(e||"").trim();return r?b2(r,t,n):""}function AG({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const p=n.current;if(!p)return;const u=Math.max(1,p.scrollHeight),f=Math.max(1,p.clientHeight),m=u>f+1,g=m?Math.max(12,f/u*100):100,w=Math.max(0,100-g),k=m?Math.min(w,p.scrollTop/Math.max(1,u-f)*w):0;o({visible:m,top:k,height:g})},[]);h.useEffect(()=>{const p=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const f=new ResizeObserver(a);f.observe(u);for(const m of Array.from(u.children))f.observe(m);return()=>{cancelAnimationFrame(p),f.disconnect()}},[t,a]);const l=h.useCallback(p=>{const u=n.current;if(!u)return;const f=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,p))*f,a()},[a]),c=h.useCallback((p,u=0)=>{const f=r.current;if(!f)return 0;const m=f.getBoundingClientRect(),g=s.height/100*m.height,w=Math.max(1,m.height-g);return(p-m.top-u)/w},[s.height]),d=h.useCallback(p=>{if(!s.visible)return;p.preventDefault(),p.stopPropagation();const u=r.current;if(!u)return;const f=u.getBoundingClientRect(),m=s.top/100*f.height,g=s.height/100*f.height,k=p.clientY>=f.top+m&&p.clientY<=f.top+m+g?p.clientY-f.top-m:g/2;l(c(p.clientY,k));const y=x=>{x.preventDefault(),l(c(x.clientY,k))},b=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",b)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[i.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function _v({node:e,shareId:t,style:n,bare:r=!1}){const s=SG(e),o=e.kind==="html"?Pk(s):w2(s),a=e.kind==="html"?CG(o):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return i.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}${r?" af-public-display-node--bare":""}`,style:n,children:[r?null:i.jsx("div",{className:"af-public-display-node__head",children:i.jsxs("div",{className:"af-public-display-node__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:NG(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(AG,{className:l,children:a?i.jsx("div",{className:"af-public-display-empty",children:a}):o.trim()?i.jsxs(i.Fragment,{children:[e.kind==="html"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals",srcDoc:EG(o)}):null,e.kind==="image"?i.jsx("img",{src:b2(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(Sk,{content:o,resolveSrc:(c,d)=>_G(c,t,d)})}):null,e.kind==="chart"?i.jsx(jk,{content:o}):null,e.kind==="table"?i.jsx(Nk,{content:o}):null,e.kind==="mermaid"||e.kind==="ascii"?i.jsx("pre",{children:o}):null]}):i.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function PG({data:e}){return i.jsx(_v,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const IG={publicDisplay:PG};function TG(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 v2(){var l,c,d,p;const{path:e}=Yo(),t=h.useMemo(()=>TG(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let u=!1;async function f(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(m=>({...m,loading:!0,error:""}));try{const m=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),g=await m.json().catch(()=>({}));if(!m.ok)throw new Error(g.error||"展示页不存在");u||r({loading:!1,error:"",share:g.share||null,nodes:Array.isArray(g.nodes)?g.nodes:[]})}catch(m){u||r({loading:!1,error:String((m==null?void 0:m.message)||m),share:null,nodes:[]})}}return f(),()=>{u=!0}},[t]);const s=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((f,m)=>{const g=f.position&&typeof f.position.x=="number"&&typeof f.position.y=="number"?f.position:{x:120+m*40,y:100+m*32},w=f.size&&typeof f.size.width=="number"&&typeof f.size.height=="number"?f.size:{width:520,height:320};return{id:f.id,type:"publicDisplay",position:g,data:{node:f,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(w.width)||520),height:Math.max(1,Number(w.height)||320)}}}),[t,n.nodes]),o=h.useMemo(()=>{var w;const u=(w=n.share)==null?void 0:w.viewport;if(!u||typeof u!="object")return null;const f=Number(u.x),m=Number(u.y),g=Number(u.zoom);return!Number.isFinite(f)||!Number.isFinite(m)||!Number.isFinite(g)?null:{x:f,y:m,zoom:Math.min(Math.max(g,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return i.jsx("main",{className:"af-public-display-page",children:i.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return i.jsx("main",{className:"af-public-display-page",children:i.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),i.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return i.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(f=>i.jsx(_v,{node:f,shareId:t,bare:!0},f.id))})});const u=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return i.jsxs("main",{className:`af-public-display-page ${u}`,children:[i.jsxs("header",{className:"af-public-display-hero",children:[i.jsxs("div",{children:[i.jsx("p",{children:"AgentFlow Display"}),i.jsx("h1",{children:((d=n.share)==null?void 0:d.title)||"AgentFlow Display"})]}),(p=n.share)!=null&&p.expiresAt?i.jsxs("span",{children:["有效期至 ",new Date(n.share.expiresAt).toLocaleString()]}):null]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(f=>i.jsx(_v,{node:f,shareId:t},f.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(Fy,{children:i.jsx(X0,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:IG,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:i.jsx(Q0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const It=e=>typeof e=="string",Nf=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},kC=e=>e==null?"":""+e,RG=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},MG=/###/g,SC=e=>e&&e.indexOf("###")>-1?e.replace(MG,"."):e,NC=e=>!e||It(e),op=(e,t,n)=>{const r=It(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(NC(e))return{};const o=SC(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return NC(e)?{}:{obj:e,k:SC(r[s])}},jC=(e,t,n)=>{const{obj:r,k:s}=op(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let o=t[t.length-1],a=t.slice(0,t.length-1),l=op(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=op(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},LG=(e,t,n,r)=>{const{obj:s,k:o}=op(e,t,Object);s[o]=s[o]||[],s[o].push(n)},ty=(e,t)=>{const{obj:n,k:r}=op(e,t);if(n)return n[r]},OG=(e,t,n)=>{const r=ty(e,n);return r!==void 0?r:ty(t,n)},k2=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?It(e[r])||e[r]instanceof String||It(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):k2(e[r],t[r],n):e[r]=t[r]);return e},Nu=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var $G={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const DG=e=>It(e)?e.replace(/[&<>"'\/]/g,t=>$G[t]):e;class FG{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 zG=[" ",",","?","!",";"],HG=new FG(20),BG=(e,t,n)=>{t=t||"",n=n||"";const r=zG.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=HG.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!s.test(e);if(!o){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(o=!0)}return o},Av=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let o=0;o<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=o;c<r.length;++c)if(c!==o&&(l+=n),l+=r[c],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;o+=c-o+1;break}s=a}return s},ny=e=>e&&e.replace("_","-"),WG={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 ry{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||WG,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:(It(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new ry(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new ry(this.logger,t)}}var Fo=new ry;class Uy{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 CC extends Uy{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):It(r)&&o?l.push(...r.split(o)):l.push(r)));const c=ty(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!It(r)?c:Av(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,s){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),jC(this.data,l,s),o.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(It(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=ty(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?k2(c,r,o):c={...c,...r},jC(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 S2={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,s))}),t}};const EC={};class sy extends Uy{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),RG(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Fo.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!BG(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:It(o)?[o]:o};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(o=d.shift()),t=d.join(s)}return{key:t,namespaces:It(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],d=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(p){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 f=u&&u.res;const m=u&&u.usedKey||a,g=u&&u.exactUsedKey||a,w=Object.prototype.toString.apply(f),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!It(f)&&typeof f!="boolean"&&typeof f!="number";if(b&&f&&x&&k.indexOf(w)<0&&!(It(y)&&Array.isArray(f))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const j=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,f,{...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(o){const j=Array.isArray(f),E=j?[]:{},N=j?g:m;for(const T in f)if(Object.prototype.hasOwnProperty.call(f,T)){const $=`${N}${o}${T}`;E[T]=this.translate($,{...n,joinArrays:!1,ns:l}),E[T]===$&&(E[T]=f[T])}f=E}}else if(b&&It(y)&&Array.isArray(f))f=f.join(y),f&&(f=this.extendTranslation(f,t,n,r));else{let j=!1,E=!1;const N=n.count!==void 0&&!It(n.count),T=sy.hasDefaultValue(n),$=N?this.pluralResolver.getSuffix(d,n.count,n):"",z=n.ordinal&&N?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",K=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),B=K&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${$}`]||n[`defaultValue${z}`]||n.defaultValue;!this.isValidLookup(f)&&T&&(j=!0,f=B),this.isValidLookup(f)||(E=!0,f=a);const D=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:f,R=T&&B!==f&&this.options.updateMissing;if(E||j||R){if(this.logger.log(R?"updateKey":"missingKey",d,c,a,R?B:f),o){const P=this.resolve(a,{...n,keySeparator:!1});P&&P.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let M=[];const I=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&I&&I[0])for(let P=0;P<I.length;P++)M.push(I[P]);else this.options.saveMissingTo==="all"?M=this.languageUtils.toResolveHierarchy(n.lng||this.language):M.push(n.lng||this.language);const F=(P,O,_)=>{const Z=T&&_!==f?_:D;this.options.missingKeyHandler?this.options.missingKeyHandler(P,c,O,Z,R,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(P,c,O,Z,R,n),this.emit("missingKey",P,c,O,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?M.forEach(P=>{const O=this.pluralResolver.getSuffixes(P,n);K&&n[`defaultValue${this.options.pluralSeparator}zero`]&&O.indexOf(`${this.options.pluralSeparator}zero`)<0&&O.push(`${this.options.pluralSeparator}zero`),O.forEach(_=>{F([P],a+_,n[`defaultValue${_}`]||B)})}):F(M,a,B))}f=this.extendTranslation(f,t,n,u,r),E&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${c}:${a}`),(E||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?f:void 0):f=this.options.parseMissingKeyHandler(f))}return s?(u.res=f,u.usedParams=this.getUsedParamsDetails(n),u):f}extendTranslation(t,n,r,s,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=It(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(d){const f=t.match(this.interpolator.nestingRegexp);p=f&&f.length}let u=r.replace&&!It(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 f=t.match(this.interpolator.nestingRegexp),m=f&&f.length;p<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 f=arguments.length,m=new Array(f),g=0;g<f;g++)m[g]=arguments[g];return o&&o[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=It(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=S2.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,o,a,l;return It(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),p=d.key;s=p;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const f=n.count!==void 0&&!It(n.count),m=f&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(It(n.context)||typeof n.context=="number")&&n.context!=="",w=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(k=>{this.isValidLookup(r)||(l=k,!EC[`${w[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(EC[`${w[0]}-${k}`]=!0,this.logger.warn(`key "${s}" for languages "${w.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!!!")),w.forEach(y=>{if(this.isValidLookup(r))return;a=y;const b=[p];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(b,p,y,k,n);else{let j;f&&(j=this.pluralResolver.getSuffix(y,n.count,n));const E=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(b.push(p+j),n.ordinal&&j.indexOf(N)===0&&b.push(p+j.replace(N,this.options.pluralSeparator)),m&&b.push(p+E)),g){const T=`${p}${this.options.contextSeparator}${n.context}`;b.push(T),f&&(b.push(T+j),n.ordinal&&j.indexOf(N)===0&&b.push(T+j.replace(N,this.options.pluralSeparator)),m&&b.push(T+E))}}let x;for(;x=b.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(y,k,x,n))}))})}),{res:r,usedKey:s,exactUsedKey:o,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!It(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const o of n)delete s[o]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Ew=e=>e.charAt(0).toUpperCase()+e.slice(1);class _C{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Fo.create("languageUtils")}getScriptPartFromCode(t){if(t=ny(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=ny(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(It(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]=Ew(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]=Ew(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Ew(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),It(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],o=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return It(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):It(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let VG=[{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}],KG={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 UG=["v1","v2","v3"],qG=["v4"],AC={zero:0,one:1,two:2,few:3,many:4,other:5},YG=()=>{const e={};return VG.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:KG[t.fc]}})}),e};class GG{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Fo.create("pluralResolver"),(!this.options.compatibilityJSON||qG.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=YG(),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=ny(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:s});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[o]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,o)=>AC[s]-AC[o]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const o=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!UG.includes(this.options.compatibilityJSON)}}const PC=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=OG(e,t,n);return!o&&s&&It(n)&&(o=Av(e,n,r),o===void 0&&(o=Av(t,n,r))),o},_w=e=>e.replace(/\$/g,"$$$$");class XG{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Fo.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:o,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:p,unescapePrefix:u,nestingPrefix:f,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:w,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:DG,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Nu(o):a||"{{",this.suffix=l?Nu(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=p?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=f?Nu(f):m||Nu("$t("),this.nestingSuffix=g?Nu(g):w||Nu(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=PC(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),w=g.shift().trim(),k=g.join(this.formatSeparator).trim();return this.format(PC(n,c,w,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:w})};this.resetRegExp();const p=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=>_w(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?_w(this.escape(m)):_w(m)}].forEach(m=>{for(l=0;o=m.regex.exec(t);){const g=o[1].trim();if(a=d(g),a===void 0)if(typeof p=="function"){const k=p(t,o,s);a=It(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(u){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!It(a)&&!this.useRawValueToEscape&&(a=kC(a));const w=m.safeValue(a);if(t=t.replace(o[0],w),u?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=o[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,o,a;const l=(c,d)=>{const p=this.nestingOptionsSeparator;if(c.indexOf(p)<0)return c;const u=c.split(new RegExp(`${p}[ ]*{`));let f=`{${u[1]}`;c=u[0],f=this.interpolate(f,a);const m=f.match(/'/g),g=f.match(/"/g);(m&&m.length%2===0&&!g||g.length%2!==0)&&(f=f.replace(/'/g,'"'));try{a=JSON.parse(f),d&&(a={...d,...a})}catch(w){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,w),`${c}${p}${f}`}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&&!It(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const p=s[1].split(this.formatSeparator).map(u=>u.trim());s[1]=p.shift(),c=p,d=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!It(o))return o;It(o)||(o=kC(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),d&&(o=c.reduce((p,u)=>this.format(p,u,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const JG=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,""),p=l.trim();n[p]||(n[p]=d),d==="false"&&(n[p]=!1),d==="true"&&(n[p]=!0),isNaN(d)||(n[p]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},ju=e=>{const t={};return(n,r,s)=>{let o=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(o={...o,[s.interpolationkey]:void 0});const a=r+JSON.stringify(o);let l=t[a];return l||(l=e(ny(r),s),t[a]=l),l(n)}};class QG{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Fo.create("formatter"),this.options=t,this.formats={number:ju((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:ju((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:ju((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:ju((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:ju((n,r)=>{const s=new Intl.ListFormat(n,{...r});return o=>s.format(o)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=ju(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(c=>c.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,c)=>{const{formatName:d,formatOptions:p}=JG(c);if(this.formats[d]){let u=l;try{const f=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=f.locale||f.lng||s.locale||s.lng||r;u=this.formats[d](l,m,{...p,...s,...f})}catch(f){this.logger.warn(f)}return u}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const ZG=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class eX extends Uy{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=Fo.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const o={},a={},l={},c={};return t.forEach(d=>{let p=!0;n.forEach(u=>{const f=`${d}|${u}`;!r.reload&&this.store.hasResourceBundle(d,u)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?a[f]===void 0&&(a[f]=!0):(this.state[f]=1,p=!1,a[f]===void 0&&(a[f]=!0),o[f]===void 0&&(o[f]=!0),c[u]===void 0&&(c[u]=!0)))}),p||(l[d]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),o=s[0],a=s[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{LG(c.loaded,[o],a),ZG(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const p=c.loaded[d];p.length&&p.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,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:o,callback:a});return}this.readingCalls++;const l=(d,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(d&&p&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(d,p)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(p=>l(null,p)).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();It(t)&&(t=this.languageUtils.toResolveHierarchy(t)),It(n)&&(n=[n]);const o=this.queueLoad(t,n,r,s);if(!o.toLoad.length)return o.pending.length||s(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],o=r[1];this.read(s,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},d=this.backend.create.bind(this.backend);if(d.length<6)try{let p;d.length===5?p=d(t,n,r,s,c):p=d(t,n,r,s),p&&typeof p.then=="function"?p.then(u=>l(null,u)).catch(l):l(null,p)}catch(p){l(p)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const IC=()=>({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]),It(e[1])&&(t.defaultValue=e[1]),It(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}}),TC=e=>(It(e.ns)&&(e.ns=[e.ns]),It(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),It(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),jm=()=>{},tX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Bp extends Uy{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=TC(t),this.services={},this.logger=Fo,this.modules={external:[]},tX(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&&(It(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=IC();this.options={...s,...this.options,...TC(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Fo.init(o(this.modules.logger),this.options):Fo.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:typeof Intl<"u"&&(p=QG);const u=new _C(this.options);this.store=new CC(this.options.resources,this.options);const f=this.services;f.logger=Fo,f.resourceStore=this.store,f.languageUtils=u,f.pluralResolver=new GG(u,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(f.formatter=o(p),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new XG(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new eX(o(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(m){for(var g=arguments.length,w=new Array(g>1?g-1:0),k=1;k<g;k++)w[k-1]=arguments[k];t.emit(m,...w)}),this.modules.languageDetector&&(f.languageDetector=o(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=o(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new sy(this.services,this.options),this.translator.on("*",function(m){for(var g=arguments.length,w=new Array(g>1?g-1:0),k=1;k<g;k++)w[k-1]=arguments[k];t.emit(m,...w)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=jm),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return t.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return t.store[p](...arguments),t}});const c=Nf(),d=()=>{const p=(u,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(f),r(u,f)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jm;const s=It(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&o.indexOf(d)<0&&o.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Nf();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=jm),this.services.backendConnector.reload(t,n,o=>{s.resolve(),r(o)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&S2.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=Nf();this.emit("languageChanging",t);const o=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,d)=>{d?(o(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const d=It(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);d&&(this.language||o(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,p=>{a(p,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let c;if(typeof l!="object"){for(var d=arguments.length,p=new Array(d>2?d-2:0),u=2;u<d;u++)p[u-2]=arguments[u];c=s.options.overloadTranslationOptionHandler([a,l].concat(p))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const f=s.options.keySeparator||".";let m;return c.keyPrefix&&Array.isArray(a)?m=a.map(g=>`${c.keyPrefix}${f}${g}`):m=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a,s.t(m,c)};return It(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,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(o,t)))}loadNamespaces(t,n){const r=Nf();return this.options.ns?(It(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=Nf();It(t)&&(t=[t]);const s=this.options.preload||[],o=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=s.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new _C(IC());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 Bp(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jm;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new Bp(s);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(l=>{o[l]=this[l]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new CC(this.store.data,s),o.services.resourceStore=o.store),o.translator=new sy(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,d=new Array(c>1?c-1:0),p=1;p<c;p++)d[p-1]=arguments[p];o.emit(l,...d)}),o.init(s,n),o.translator.options=s,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const is=Bp.createInstance();is.createInstance=Bp.createInstance;is.createInstance;is.dir;is.init;is.loadResources;is.reloadResources;is.use;is.changeLanguage;is.getFixedT;is.t;is.exists;is.setDefaultNamespace;is.hasLoadedNamespace;is.loadNamespaces;is.loadLanguages;function nX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wp(e){"@babel/helpers - typeof";return Wp=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},Wp(e)}function rX(e,t){if(Wp(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Wp(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function sX(e){var t=rX(e,"string");return Wp(t)=="symbol"?t:t+""}function iX(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,sX(r.key),r)}}function oX(e,t,n){return t&&iX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var N2=[],aX=N2.forEach,lX=N2.slice;function cX(e){return aX.call(lX.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var RC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,uX=function(t,n,r){var s=r||{};s.path=s.path||"/";var o=encodeURIComponent(n),a="".concat(t,"=").concat(o);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!RC.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!RC.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},MC={create:function(t,n,r,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),s&&(o.domain=s),document.cookie=uX(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var o=r[s];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},dX={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=MC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&MC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},fX={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),o=s.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var c=o[a].substring(0,l);c===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},jf=null,LC=function(){if(jf!==null)return jf;try{jf=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{jf=!1}return jf},pX={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&LC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&LC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Cf=null,OC=function(){if(Cf!==null)return Cf;try{Cf=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Cf=!1}return Cf},hX={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&OC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&OC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},mX={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}},gX={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}},yX={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}},xX={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]}},j2=!1;try{document.cookie,j2=!0}catch{}var C2=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];j2||C2.splice(1,1);function wX(){return{order:C2,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var E2=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};nX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return oX(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=cX(r,this.options||{},wX()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(dX),this.addDetector(fX),this.addDetector(pX),this.addDetector(hX),this.addDetector(mX),this.addDetector(gX),this.addDetector(yX),this.addDetector(xX)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(o){if(r.detectors[o]){var a=r.detectors[o].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){s.detectors[o]&&s.detectors[o].cacheUserLanguage(n,s.options)}))}}])}();E2.type="languageDetector";const bX={name:"AgentFlow",tagline:"AI Workflow Orchestration"},vX={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},kX={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"},SX={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},NX={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},jX={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},CX={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},EX={app:bX,nav:vX,common:kX,status:SX,nodeTypes:NX,engine:jX,links:CX},_X="Flow Editor",AX="Nodes",PX="Edges",IX="Properties",TX={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"},RX={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",description:"Description / format",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",pinDescriptionAriaLabel:"{{label}} {{index}} format description",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},MX={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},LX={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},OX={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"},$X={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)"},DX={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},FX={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},zX={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},HX={node:"Node",text:"Text",file:"File",bool:"Boolean"},BX={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"},WX={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"},VX={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},KX={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."},UX={mainNav:"Main Navigation"},qX={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'},YX={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):
235
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
236
- 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}}"},GX={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"},XX={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},JX={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}}"},QX={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"},ZX={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"},eJ={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"},tJ={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"},nJ={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"},rJ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},sJ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},iJ={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"},oJ={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."},aJ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},lJ={save:"Save",cancel:"Cancel"},cJ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},uJ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},dJ={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"},fJ={title:_X,nodes:AX,edges:PX,properties:IX,node:TX,nodeProps:RX,actions:MX,panel:LX,palette:OX,pipeline:$X,status:DX,roles:FX,phases:zX,types:HX,runContext:BX,shortcuts:WX,jumpPalette:VX,emptyCanvas:KX,sidebar:UX,validation:qX,composer:YX,topbar:GX,palette2:XX,run:JX,fileEdit:QX,settings:ZX,schedule:eJ,history:tJ,nodePropsError:nJ,placeholder:rJ,time:sJ,userCheck:iJ,userAsk:oJ,toolPrint:aJ,provideEdit:lJ,runParams:cJ,runPreset:uJ,runConfig:dJ},pJ="Settings",hJ={engine:"Engine Settings",preferences:"Global Preferences"},mJ={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)."},gJ={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..."}},yJ={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."},xJ={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."},wJ={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)"},bJ={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"},vJ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},kJ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},SJ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},NJ={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."},jJ={title:pJ,crumb:hJ,workspace:mJ,cursor:gJ,opencode:yJ,claudeCode:xJ,env:wJ,allowlist:bJ,system:vJ,shortcuts:kJ,language:SJ,onboarding:NJ},CJ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},EJ={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)"},_J={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},AJ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},PJ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},IJ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},TJ={aiLabels:CJ,placeholders:EJ,actions:_J,labels:AJ,tooltips:PJ,rightPanel:IJ},RJ="Projects",MJ="All",LJ="Archived",OJ="Nodes",$J="My Nodes",DJ="My Flows",FJ="Skills",zJ="Active Projects",HJ="Archived Pipelines",BJ="Global Nodes",WJ="Manage node versions published to the current workspace marketplace, {{count}} total.",VJ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",KJ="Global Skills",UJ="Create New Project",qJ="New Pipeline",YJ="SEARCH PIPELINES...",GJ="SEARCH NODES...",XJ="SEARCH FLOW SNIPPETS...",JJ="SEARCH SKILLS...",QJ="Refresh Resources",ZJ="Loading pipelines...",eQ="Loading global resources...",tQ="Filter result: {{count}} items (matching title, description, path and tags)",nQ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",rQ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",sQ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",iQ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",oQ="Executable building blocks for pipeline runtime",aQ="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.",lQ="Published local node packages",cQ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",uQ="Published flow snippets",dQ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",fQ="Operating guides for Composer and agents",pQ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",hQ="No archived projects.",mQ="No active pipelines; archived items are in the Archived tab.",gQ="No global nodes available.",yQ="No marketplace nodes have been published.",xQ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",wQ="No skills available.",bQ="No description.",vQ='No node matches "{{query}}".',kQ='No flow snippet matches "{{query}}".',SQ='No skill matches "{{query}}".',NQ="{{inputs}} in / {{outputs}} out",jQ="Flow Snippet",CQ="{{nodes}} nodes / {{edges}} edges",EQ="Skill",_Q="Node detail",AQ="Flow snippet detail",PQ="Skill detail",IQ="Type",TQ="Source",RQ="Package",MQ="Version",LQ="Path",OQ="Editable",$Q="Read only",DQ="Editable",FQ="Schema",zQ="Inputs",HQ="Outputs",BQ="Runtime",WQ="Node Body",VQ="Files",KQ="Usage",UQ="No runtime manifest.",qQ="No node body or README.",YQ="No previewable files.",GQ="Select a file to preview.",XQ="Binary file preview is not supported.",JQ="Large file; showing the first 256KB only.",QQ="No pipelines using this node were found.",ZQ="Node Management",eZ="Delete Node Version",tZ="Deleting...",nZ="AgentFlow checks all flow references before deleting; installed or used versions are kept.",rZ="Delete {{id}}@{{version}}? This cannot be undone.",sZ="Deleted {{id}}@{{version}}.",iZ="{{count}} flow(s) still use it.",oZ="Flow Snippet Management",aZ="Delete Flow Snippet",lZ="Deleting...",cZ="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",uZ="Delete {{id}}@{{version}}? This cannot be undone.",dZ="Deleted {{id}}@{{version}}.",fZ="No slots",pZ="Purpose",hZ="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",mZ="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.",gZ="Scale",yZ="Flow Preview",xZ="Edges",wZ="Snippet JSON",bZ="{{count}} more edge(s)",vZ="No previewable nodes.",kZ="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",SZ="SKILL.md Preview",NZ="No preview content available.",jZ="Select a resource to inspect details.",CZ="Failed to load pipeline list.",EZ="No pipelines in current workspace.",_Z="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.",AZ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',PZ="Recent Activity",IZ="No recent activity",TZ="No recent activity matching the keyword",RZ="Recent Run",MZ="Recent Open",LZ={builtin:"Built-in",workspace:"Workspace",user:"User"},OZ={flow:"Flow",global:"Global",marketplace:"Marketplace"},$Z={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},DZ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},FZ="Open to edit this pipeline in the node canvas.",zZ={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>"},HZ={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"},BZ={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"},WZ={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"},VZ={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"},KZ={title:RJ,all:MJ,archived:LJ,nodes:OJ,myNodes:$J,myFlows:DJ,skills:FJ,activeProjects:zJ,archivedPipelines:HJ,globalNodes:BJ,myNodesHint:WJ,myFlowsHint:VJ,globalSkills:KJ,createNew:UJ,newPipeline:qJ,searchPipelines:YJ,searchNodes:GJ,searchFlows:XJ,searchSkills:JJ,refreshResources:QJ,loadingPipelines:ZJ,loadingResources:eQ,filterResult:tQ,archivedHint:nQ,activeHint:rQ,nodesHint:sQ,skillsHint:iQ,nodesPurposeTitle:oQ,nodesPurposeDesc:aQ,myNodesPurposeTitle:lQ,myNodesPurposeDesc:cQ,myFlowsPurposeTitle:uQ,myFlowsPurposeDesc:dQ,skillsPurposeTitle:fQ,skillsPurposeDesc:pQ,noArchived:hQ,noActive:mQ,noNodes:gQ,noMyNodes:yQ,noMyFlows:xQ,noSkills:wQ,noDescription:bQ,noNodeMatch:vQ,noFlowSnippetMatch:kQ,noSkillMatch:SQ,nodeSlots:NQ,flowSnippet:jQ,flowSnippetNodes:CQ,skill:EQ,nodeDetail:_Q,flowDetail:AQ,skillDetail:PQ,detailType:IQ,detailSource:TQ,detailPackage:RQ,detailVersion:MQ,detailPath:LQ,detailEditable:OQ,readOnly:$Q,editable:DQ,nodeSchema:FQ,nodeInputs:zQ,nodeOutputs:HQ,nodeRuntime:BQ,nodeBody:WQ,nodeFiles:VQ,nodeUsage:KQ,noRuntimeManifest:UQ,noNodeBody:qQ,noNodeFiles:YQ,selectNodeFile:GQ,binaryFile:XQ,fileTruncated:JQ,noNodeUsage:QQ,myNodeManagement:ZQ,deleteMyNode:eZ,deletingMyNode:tZ,deleteMyNodeHint:nZ,deleteMyNodeConfirm:rZ,deleteMyNodeSuccess:sZ,deleteMyNodeUsedBy:iZ,myFlowManagement:oZ,deleteMyFlow:aZ,deletingMyFlow:lZ,deleteMyFlowHint:cZ,deleteMyFlowConfirm:uZ,deleteMyFlowSuccess:dZ,noSlots:fZ,resourceMeaning:pZ,nodesMeaning:hZ,myFlowsMeaning:mZ,flowSnippetScale:gZ,flowSnippetPreview:yZ,flowSnippetEdges:xZ,flowSnippetJson:wZ,flowSnippetMoreEdges:bZ,noFlowSnippetPreview:vZ,skillsMeaning:kZ,skillPreview:SZ,skillPreviewEmpty:NZ,selectResource:jZ,loadFailed:CZ,noPipelines:EZ,emptyHint:_Z,noMatch:AZ,recentActivity:PZ,noRecentActivity:IZ,noMatchRecent:TZ,recentRun:RZ,recentOpen:MZ,sourceBadge:LZ,resourceSource:OZ,resourceFilter:$Z,nodeDetailTabs:DZ,defaultCardDesc:FZ,hubCard:zZ,newPipelineModal:HZ,importModal:BZ,deleteModal:WZ,archiveModal:VZ},UZ="Back",qZ="Next",YZ="Skip",GZ="Done",XZ="Start Creating",JZ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
237
-
238
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
239
-
240
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},QZ={intro:`Now you're in the flow editor.
241
-
242
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
243
-
244
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
245
-
246
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
247
-
248
- The left node panel allows you to freely drag, delete, and adjust connections.`},ZZ={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"},eee={back:UZ,next:qZ,skip:YZ,done:GZ,startCreate:XZ,projects:JZ,flow:QZ,newPipeline:ZZ},tee={name:"AgentFlow",tagline:"AI 工作流编排"},nee={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},ree={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},see={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},iee={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},oee={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},aee={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},lee={app:tee,nav:nee,common:ree,status:see,nodeTypes:iee,engine:oee,links:aee},cee="流程编辑器",uee="节点",dee="连线",fee="属性",pee={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:"编辑内容"},hee={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",description:"描述 / 格式",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",pinDescriptionAriaLabel:"{{label}} {{index}} 格式描述",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},mee={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},gee={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},yee={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},xee={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},wee={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},bee={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},vee={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},kee={node:"节点",text:"文本",file:"文件",bool:"布尔"},See={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:"等待"},Nee={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},jee={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Cee={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Eee={mainNav:"主导航"},_ee={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Aee={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}} 步):
249
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
250
- 当前:{{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}}"},Pee={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},Iee={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Tee={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}} 的分支"},Ree={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Mee={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:"已复制"},Lee={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:"定时配置已保存"},Oee={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},$ee={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Dee={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Fee={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},zee={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Hee={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Bee={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},Wee={save:"保存",cancel:"取消"},Vee={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},Kee={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},Uee={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},qee={title:cee,nodes:uee,edges:dee,properties:fee,node:pee,nodeProps:hee,actions:mee,panel:gee,palette:yee,pipeline:xee,status:wee,roles:bee,phases:vee,types:kee,runContext:See,shortcuts:Nee,jumpPalette:jee,emptyCanvas:Cee,sidebar:Eee,validation:_ee,composer:Aee,topbar:Pee,palette2:Iee,run:Tee,fileEdit:Ree,settings:Mee,schedule:Lee,history:Oee,nodePropsError:$ee,placeholder:Dee,time:Fee,userCheck:zee,userAsk:Hee,toolPrint:Bee,provideEdit:Wee,runParams:Vee,runPreset:Kee,runConfig:Uee},Yee="设置",Gee={engine:"引擎设置",preferences:"全局首选项"},Xee={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},Jee={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},Qee={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},Zee={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},ete={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},tte={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:"添加"},nte={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},rte={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},ste={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},ite={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},ote={title:Yee,crumb:Gee,workspace:Xee,cursor:Jee,opencode:Qee,claudeCode:Zee,env:ete,allowlist:tte,system:nte,shortcuts:rte,language:ste,onboarding:ite},ate={thinking:"思考",result:"结果",reply:"回复",error:"错误"},lte={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},cte={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},ute={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},dte={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},fte={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},pte={aiLabels:ate,placeholders:lte,actions:cte,labels:ute,tooltips:dte,rightPanel:fte},hte="项目",mte="全部",gte="已归档",yte="Nodes",xte="我的 Nodes",wte="我的流程",bte="Skills",vte="活跃项目",kte="已归档流水线",Ste="全局 Nodes",Nte="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",jte="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Cte="全局 Skills",Ete="创建新项目",_te="新建流水线",Ate="搜索流水线…",Pte="搜索 nodes…",Ite="搜索流程片段…",Tte="搜索 skills…",Rte="刷新资源",Mte="加载流水线列表…",Lte="加载全局资源…",Ote="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",$te="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Dte="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Fte="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",zte="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",Hte="流程运行时的可执行积木",Bte="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",Wte="已发布的本地节点包",Vte="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Kte="已发布的流程片段",Ute="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",qte="Composer/Agent 的操作指南",Yte="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",Gte="暂无归档项目。",Xte="暂无未归档流水线;已归档项在 Archived 标签中查看。",Jte="暂无可用全局 nodes。",Qte="暂无已发布的 marketplace nodes。",Zte="暂无已发布的流程片段。可在画布中选中多个节点后发布。",ene="暂无可用 skills。",tne="暂无描述。",nne="未找到与「{{query}}」匹配的 node。",rne="未找到与「{{query}}」匹配的流程片段。",sne="未找到与「{{query}}」匹配的 skill。",ine="{{inputs}} in / {{outputs}} out",one="流程片段",ane="{{nodes}} 节点 / {{edges}} 连线",lne="Skill",cne="Node 详情",une="流程片段详情",dne="Skill 详情",fne="类型",pne="来源",hne="包",mne="版本",gne="路径",yne="可编辑",xne="只读",wne="可编辑",bne="Schema",vne="输入",kne="输出",Sne="Runtime",Nne="节点内容",jne="Files",Cne="Usage",Ene="暂无 runtime manifest。",_ne="暂无节点正文或 README。",Ane="暂无可预览文件。",Pne="请选择文件查看内容。",Ine="二进制文件暂不支持预览。",Tne="文件较大,仅显示前 256KB。",Rne="暂未发现使用此 node 的流水线。",Mne="节点管理",Lne="删除节点版本",One="删除中…",$ne="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Dne="确定删除 {{id}}@{{version}}?此操作不可撤销。",Fne="已删除 {{id}}@{{version}}。",zne="仍有 {{count}} 个 Flow 使用它。",Hne="流程片段管理",Bne="删除流程片段",Wne="删除中…",Vne="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Kne="确定删除 {{id}}@{{version}}?此操作不可撤销。",Une="已删除 {{id}}@{{version}}。",qne="无槽位",Yne="作用",Gne="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Xne="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Jne="规模",Qne="流程预览",Zne="连线",ere="片段 JSON",tre="还有 {{count}} 条连线",nre="暂无可预览节点。",rre="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",sre="SKILL.md 预览",ire="暂无可预览内容。",ore="请选择一个资源查看详情。",are="未能加载流水线列表。",lre="当前工作区暂无流水线。",cre="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",ure="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",dre="最近打开或最近运行",fre="暂无打开或运行记录",pre="暂无与关键词匹配的最近记录",hre="最近运行",mre="最近打开",gre={builtin:"内置",workspace:"工作区",user:"用户"},yre={flow:"Flow",global:"Global",marketplace:"Marketplace"},xre={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},wre={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},bre="打开以在节点画布中编辑此流水线。",vre={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},kre={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:"关闭"},Sre={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Nre={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},jre={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Cre={title:hte,all:mte,archived:gte,nodes:yte,myNodes:xte,myFlows:wte,skills:bte,activeProjects:vte,archivedPipelines:kte,globalNodes:Ste,myNodesHint:Nte,myFlowsHint:jte,globalSkills:Cte,createNew:Ete,newPipeline:_te,searchPipelines:Ate,searchNodes:Pte,searchFlows:Ite,searchSkills:Tte,refreshResources:Rte,loadingPipelines:Mte,loadingResources:Lte,filterResult:Ote,archivedHint:$te,activeHint:Dte,nodesHint:Fte,skillsHint:zte,nodesPurposeTitle:Hte,nodesPurposeDesc:Bte,myNodesPurposeTitle:Wte,myNodesPurposeDesc:Vte,myFlowsPurposeTitle:Kte,myFlowsPurposeDesc:Ute,skillsPurposeTitle:qte,skillsPurposeDesc:Yte,noArchived:Gte,noActive:Xte,noNodes:Jte,noMyNodes:Qte,noMyFlows:Zte,noSkills:ene,noDescription:tne,noNodeMatch:nne,noFlowSnippetMatch:rne,noSkillMatch:sne,nodeSlots:ine,flowSnippet:one,flowSnippetNodes:ane,skill:lne,nodeDetail:cne,flowDetail:une,skillDetail:dne,detailType:fne,detailSource:pne,detailPackage:hne,detailVersion:mne,detailPath:gne,detailEditable:yne,readOnly:xne,editable:wne,nodeSchema:bne,nodeInputs:vne,nodeOutputs:kne,nodeRuntime:Sne,nodeBody:Nne,nodeFiles:jne,nodeUsage:Cne,noRuntimeManifest:Ene,noNodeBody:_ne,noNodeFiles:Ane,selectNodeFile:Pne,binaryFile:Ine,fileTruncated:Tne,noNodeUsage:Rne,myNodeManagement:Mne,deleteMyNode:Lne,deletingMyNode:One,deleteMyNodeHint:$ne,deleteMyNodeConfirm:Dne,deleteMyNodeSuccess:Fne,deleteMyNodeUsedBy:zne,myFlowManagement:Hne,deleteMyFlow:Bne,deletingMyFlow:Wne,deleteMyFlowHint:Vne,deleteMyFlowConfirm:Kne,deleteMyFlowSuccess:Une,noSlots:qne,resourceMeaning:Yne,nodesMeaning:Gne,myFlowsMeaning:Xne,flowSnippetScale:Jne,flowSnippetPreview:Qne,flowSnippetEdges:Zne,flowSnippetJson:ere,flowSnippetMoreEdges:tre,noFlowSnippetPreview:nre,skillsMeaning:rre,skillPreview:sre,skillPreviewEmpty:ire,selectResource:ore,loadFailed:are,noPipelines:lre,emptyHint:cre,noMatch:ure,recentActivity:dre,noRecentActivity:fre,noMatchRecent:pre,recentRun:hre,recentOpen:mre,sourceBadge:gre,resourceSource:yre,resourceFilter:xre,nodeDetailTabs:wre,defaultCardDesc:bre,hubCard:vre,newPipelineModal:kre,importModal:Sre,deleteModal:Nre,archiveModal:jre},Ere="返回",_re="下一步",Are="跳过",Pre="完成",Ire="开始创建",Tre={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
251
-
252
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
253
-
254
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Rre={intro:`现在进入流程编辑器。
255
-
256
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
257
-
258
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
259
-
260
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
261
-
262
- 左侧节点面板可以自由拖拽、删除和调整连接。`},Mre={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Lre={back:Ere,next:_re,skip:Are,done:Pre,startCreate:Ire,projects:Tre,flow:Rre,newPipeline:Mre},Ore={en:{common:EX,flow:fJ,settings:jJ,composer:TJ,project:KZ,onboarding:eee},zh:{common:lee,flow:qee,settings:ote,composer:pte,project:Cre,onboarding:Lre}};is.use(E2).use(e$).init({resources:Ore,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 $re=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Dre(e){return is.changeLanguage(e)}const Pv="agentflow-settings-opencode-plan-v1";function Aw(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 _2(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Fre(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function pc(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const s=String(r.key??"").trim(),o=String(r.value??""),a=String(r.id??"").trim()||_2(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function $C(e){return pc(e).map(({key:t,value:n})=>({key:t,value:n}))}function DC(){try{return localStorage.getItem(Pv)??""}catch{return""}}function zre(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function FC(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 Hre({authUser:e}){const{t,i18n:n}=zn(["common","settings"]),r=n.language||"zh",[s,o]=h.useState(""),[a,l]=h.useState(""),[c,d]=h.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[p,u]=h.useState(""),[f,m]=h.useState(!1),[g,w]=h.useState(!1),[k,y]=h.useState(""),[b,x]=h.useState([]),[j,E]=h.useState(""),[N,T]=h.useState(!1),[$,z]=h.useState(""),[K,B]=h.useState(""),[L,D]=h.useState(!1),[R,M]=h.useState(()=>new Set),[I,F]=h.useState(""),[P,O]=h.useState([]),[_,Z]=h.useState(!1),[ee,V]=h.useState(""),[ae,fe]=h.useState([]),[xe,Se]=h.useState([]),[ue,Ee]=h.useState(""),[le,me]=h.useState(""),[we,je]=h.useState(!1),[Ye,tt]=h.useState(!1),[ze,dt]=h.useState(""),[Ft,Ue]=h.useState(""),[pt,_n]=h.useState(""),[We,sn]=h.useState(null),[xt,kn]=h.useState(!1),[pe,_e]=h.useState(!1),[Ve,rt]=h.useState(""),it=h.useRef(null),Mt=h.useRef(!1),wt=h.useRef(!1),gn=h.useRef(""),cn=h.useCallback(async()=>{l("");try{const ce=await fetch("/api/ui-context");if(!ce.ok)throw new Error("HTTP "+ce.status);const he=await ce.json();o(typeof he.workspaceRoot=="string"?he.workspaceRoot:"")}catch(ce){l(String(ce.message||ce)),o("")}},[]),Jn=h.useCallback(async()=>{u(""),m(!0);try{const ce=await fetch("/api/model-lists");if(!ce.ok)throw new Error("HTTP "+ce.status);const he=await ce.json();d(Aw(he))}catch(ce){u(String(ce.message||ce))}finally{m(!1)}},[]),on=h.useCallback(async()=>{E("");try{const ce=await fetch("/api/user-env"),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);const Q=pc(Array.isArray(he.env)?he.env:[],"user").map(Me=>({...Me,scope:"user"})),qe=[...e!=null&&e.isAdmin?pc(Array.isArray(he.globalEnv)?he.globalEnv:[],"global").map(Me=>({...Me,scope:"global"})):[],...Q];gn.current=JSON.stringify(qe),x(qe)}catch(ce){x([]),E(String(ce.message||ce))}finally{wt.current=!0}},[e==null?void 0:e.isAdmin]),An=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Z(!0),V("");try{const ce=await fetch("/api/feedback"),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);O(Array.isArray(he.feedback)?he.feedback:[])}catch(ce){V(String(ce.message||ce))}finally{Z(!1)}}},[e==null?void 0:e.isAdmin]),Pn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){je(!0),dt("");try{const ce=await fetch("/api/admin/user-allowlist"),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);const Q=he.allowlist&&typeof he.allowlist=="object"?he.allowlist:{};fe(Array.isArray(Q.fileUsers)?Q.fileUsers.map(String):[]),Se(Array.isArray(Q.envUsers)?Q.envUsers.map(String):[]),Ee(typeof Q.path=="string"?Q.path:"")}catch(ce){dt(String(ce.message||ce))}finally{je(!1)}}},[e==null?void 0:e.isAdmin]),mr=h.useCallback(async ce=>{if(e!=null&&e.isAdmin){tt(!0),dt("");try{const he=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ce})}),Q=await he.json().catch(()=>({}));if(!he.ok)throw new Error(typeof Q.error=="string"?Q.error:"HTTP "+he.status);const ge=Q.allowlist&&typeof Q.allowlist=="object"?Q.allowlist:{};fe(Array.isArray(ge.fileUsers)?ge.fileUsers.map(String):[]),Se(Array.isArray(ge.envUsers)?ge.envUsers.map(String):[]),Ee(typeof ge.path=="string"?ge.path:"")}catch(he){dt(String(he.message||he))}finally{tt(!1)}}},[e==null?void 0:e.isAdmin]),Cr=h.useCallback(async()=>{if(e!=null&&e.isAdmin){kn(!0),rt("");try{const ce=await fetch("/api/admin/storage-config"),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);const Q=he.config&&typeof he.config=="object"?he.config:{};sn(Q),Ue(typeof Q.dataRoot=="string"?Q.dataRoot:""),_n(typeof Q.skillsRoot=="string"?Q.skillsRoot:"")}catch(ce){rt(String(ce.message||ce))}finally{kn(!1)}}},[e==null?void 0:e.isAdmin]),gr=h.useCallback(async()=>{if(e!=null&&e.isAdmin){_e(!0),rt("");try{const ce=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:Ft.trim(),skillsRoot:pt.trim(),migrateLegacySkills:!0})}),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);const Q=he.config&&typeof he.config=="object"?he.config:{};sn(Q),Ue(typeof Q.dataRoot=="string"?Q.dataRoot:""),_n(typeof Q.skillsRoot=="string"?Q.skillsRoot:"")}catch(ce){rt(String(ce.message||ce))}finally{_e(!1)}}},[e==null?void 0:e.isAdmin,Ft,pt]),Wt=h.useCallback(async ce=>{const he=pc(ce),Q=he.filter(qe=>qe.scope!=="global"),ge=he.filter(qe=>qe.scope==="global");T(!0),E("");try{const qe=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:$C(Q),...e!=null&&e.isAdmin?{globalEnv:$C(ge)}:{}})}),Me=await qe.json().catch(()=>({}));if(!qe.ok)throw new Error(typeof Me.error=="string"?Me.error:"HTTP "+qe.status);const zt=pc(Array.isArray(Me.env)?Me.env:[],"user").map(wr=>({...wr,scope:"user"})),Hn=[...e!=null&&e.isAdmin?pc(Array.isArray(Me.globalEnv)?Me.globalEnv:[],"global").map(wr=>({...wr,scope:"global"})):[],...zt];gn.current=JSON.stringify(Hn),x(Hn)}catch(qe){E(String(qe.message||qe))}finally{T(!1)}},[e==null?void 0:e.isAdmin]),Vt=h.useCallback(async()=>{u(""),m(!0);try{const ce=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:I.trim()})}),he=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(typeof he.error=="string"?he.error:"HTTP "+ce.status);d(Aw(he.modelLists))}catch(ce){u(String(ce.message||ce))}finally{m(!1)}},[I]);h.useEffect(()=>{cn(),Jn(),on(),e!=null&&e.isAdmin&&(An(),Pn(),Cr()),(async()=>{try{const ce=await fetch("/api/agentflow-config");if(ce.ok){const he=await ce.json(),Q=typeof he.opencodeProvider=="string"?he.opencodeProvider:"";F(Q),it.current=Q;try{localStorage.setItem(Pv,Q)}catch{}}else{const he=DC();F(he),it.current=he}}catch{const ce=DC();F(ce),it.current=ce}finally{Mt.current=!0}})()},[e==null?void 0:e.isAdmin,cn,An,Jn,Cr,Pn,on]),h.useEffect(()=>{if(!wt.current||JSON.stringify(pc(b))===gn.current)return;const he=setTimeout(()=>{Wt(b)},350);return()=>clearTimeout(he)},[b,Wt]),h.useEffect(()=>{if(!Mt.current)return;const ce=I.trim();if(ce===it.current)return;const he=setTimeout(()=>{(async()=>{w(!0),y("");try{const Q=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ce})}),ge=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Q.status);it.current=ce;try{localStorage.setItem(Pv,ce)}catch{}ge.modelLists&&d(Aw(ge.modelLists))}catch(Q){y(String(Q.message||Q))}finally{w(!1)}})()},450);return()=>clearTimeout(he)},[I]);const ir=c.cursor.length>0,Er=c.opencode.length>0,dr=c.claudeCode.length>0,yr=ae.length>0||xe.length>0,_r=h.useCallback(()=>{var ce;s&&((ce=navigator.clipboard)==null||ce.writeText(s))},[s]),Lr=h.useCallback(()=>{const ce=$.trim(),he=K;if(ce){if(!Fre(ce)){E(t("settings:env.invalidKey"));return}x(Q=>[{id:_2(),key:ce,value:he,scope:e!=null&&e.isAdmin&&L?"global":"user"},...Q]),z(""),B("")}},[e==null?void 0:e.isAdmin,L,$,K,t]),or=h.useCallback(ce=>{x(he=>he.filter(Q=>Q.id!==ce))},[]),xr=h.useCallback((ce,he)=>{x(Q=>Q.map(ge=>ge.id===ce?{...ge,...he}:ge))},[]),Or=h.useCallback(ce=>{M(he=>{const Q=new Set(he);return Q.has(ce)?Q.delete(ce):Q.add(ce),Q})},[]),ws=h.useCallback(()=>{const ce=le.trim();if(!ce)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ce)){dt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(ae.map(Q=>String(Q||"").trim().toLowerCase())).has(ce.toLowerCase())){me("");return}me(""),mr([...ae,ce])},[le,ae,mr]),ar=h.useCallback(ce=>{const he=String(ce||"").trim().toLowerCase();he&&mr(ae.filter(Q=>String(Q||"").trim().toLowerCase()!==he))},[ae,mr]),Ar=h.useCallback(ce=>{const he=ce.target.value;Dre(he)},[]),In=ce=>{const he=FC(ce,r);return he?t("settings:cursor.modelList.fetchedAt",{time:he}):t("settings:cursor.modelList.never")},Tn=ce=>FC(ce,r)||String(ce||"");return i.jsxs("div",{className:"af-settings-page",children:[i.jsx("header",{className:"af-settings-top",children:i.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[i.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),i.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),i.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,p?i.jsx("p",{className:"af-err af-settings-api-hint",children:p}):null,j?i.jsx("p",{className:"af-err af-settings-api-hint",children:j}):null,Ve?i.jsx("p",{className:"af-err af-settings-api-hint",children:Ve}):null]}),i.jsxs("div",{className:"af-settings-layout",children:[i.jsxs("div",{className:"af-settings-bento",children:[i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[i.jsxs("div",{className:"af-set-card-inner",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),i.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),i.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:_r,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:i.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),i.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),i.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),i.jsx("span",{className:"af-set-badge"+(ir?" af-set-badge--ok":" af-set-badge--muted"),children:t(ir?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:ir?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(ir?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:ir?t("settings:cursor.modelList.count",{count:c.cursor.length})+" · "+In(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),ir?i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:c.cursor.join(`
263
- `)}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Vt(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),i.jsx("span",{className:"af-set-badge"+(Er?" af-set-badge--ok":" af-set-badge--err"),children:t(Er?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),i.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),i.jsxs("div",{children:[i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),i.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:I,onChange:ce=>F(ce.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:k}):null]}),Er?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+" · "+In(c.opencodeFetchedAt)}),i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:c.opencode.join(`
264
- `)})]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Vt(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),i.jsx("span",{className:"af-set-badge"+(dr?" af-set-badge--ok":" af-set-badge--err"),children:t(dr?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:dr?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(dr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:dr?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+" · "+In(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),dr?i.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:c.claudeCode.join(`
265
- `)}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Vt(),disabled:f,children:t(f?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),i.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),i.jsx("span",{className:"af-set-env-note",children:N?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),i.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[i.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[i.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?i.jsx("span",{children:t("settings:env.scope")}):null,i.jsx("span",{children:t("settings:env.value")}),i.jsx("span",{})]}),i.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:$,onChange:ce=>z(ce.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:L?"":"is-active",onClick:()=>D(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:L?"is-active":"",onClick:()=>D(!0),children:t("settings:env.global")})]})}):null,i.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:K,onChange:ce=>B(ce.target.value),"aria-label":t("settings:env.newValue")})}),i.jsx("div",{className:"af-set-env-actions",children:i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Lr,disabled:!$.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),b.map(ce=>i.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ce.key,onChange:he=>xr(ce.id,{key:he.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:ce.scope!=="global"?"is-active":"",onClick:()=>xr(ce.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:ce.scope==="global"?"is-active":"",onClick:()=>xr(ce.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,i.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:R.has(ce.id)?"text":"password",value:ce.value,onChange:he=>xr(ce.id,{value:he.target.value}),placeholder:zre(ce.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>Or(ce.id),"aria-label":R.has(ce.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:R.has(ce.id)?"visibility_off":"visibility"})})]}),i.jsx("div",{className:"af-set-env-actions",children:i.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ce.key}),onClick:()=>or(ce.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ce.id))]})]}),e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),i.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),i.jsx("span",{className:"af-set-badge"+(We!=null&&We.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:We!=null&&We.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Cr(),disabled:xt||pe,children:xt?"刷新中...":"刷新"})]}),Ve?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Ve}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:Ft,onChange:ce=>Ue(ce.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(We!=null&&We.envLocked)||pe}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void gr(),"aria-label":"保存 AgentFlow Data Root",disabled:pe||!!(We!=null&&We.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:pe?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(We==null?void 0:We.dataRoot)||Ft||"-"}),We!=null&&We.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:We.configPath})]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",i.jsx("code",{children:"users/"}),"、",i.jsx("code",{children:"pipelines/"}),"、",i.jsx("code",{children:"runBuild/"}),"、",i.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",We!=null&&We.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:pt,onChange:ce=>_n(ce.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(We!=null&&We.skillsEnvLocked)||pe}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void gr(),"aria-label":"保存 AgentFlow Skills Root",disabled:pe||!!(We!=null&&We.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:pe?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(We==null?void 0:We.skillsRoot)||pt||"-"}),We!=null&&We.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:We.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",We!=null&&We.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),i.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),i.jsx("span",{className:"af-set-badge"+(yr?" af-set-badge--ok":" af-set-badge--muted"),children:t(yr?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Pn(),disabled:we,children:t(we?"settings:allowlist.refreshing":"common:common.refresh")})]}),ze?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ze}):null,ue?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:ue})]}):null,i.jsxs("div",{className:"af-allowlist-grid",children:[i.jsxs("div",{className:"af-allowlist-main",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.fileList")}),i.jsx("span",{children:Ye?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:ae.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:ae.length>0?ae.map(ce=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:ce}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>ar(ce),"aria-label":t("settings:allowlist.remove",{username:ce}),disabled:Ye,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ce)):i.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),i.jsxs("div",{className:"af-allowlist-add",children:[i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:le,onChange:ce=>me(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&ws()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:ws,disabled:Ye||!le.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),i.jsxs("div",{className:"af-allowlist-side",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.envList")}),i.jsx("span",{children:t("settings:allowlist.readonly")})]}),i.jsx("div",{className:"af-allowlist-env-list",children:xe.length>0?xe.map(ce=>i.jsx("code",{children:ce},ce)):i.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),i.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void An(),disabled:_,children:_?"刷新中...":"刷新"})]}),ee?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ee}):null,i.jsx("div",{className:"af-feedback-list",children:P.length>0?P.map(ce=>i.jsxs("article",{className:"af-feedback-item",children:[i.jsxs("header",{className:"af-feedback-item__head",children:[i.jsxs("div",{children:[i.jsx("h3",{children:ce.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:ce.username||ce.userId||"unknown"}),i.jsx("span",{children:Tn(ce.createdAt)})]})]}),ce.contact?i.jsx("span",{className:"af-feedback-item__contact",children:ce.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:ce.content}),ce.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:ce.pageUrl}):null]},ce.id)):i.jsx("div",{className:"af-feedback-empty",children:_?"正在加载反馈...":"暂无反馈"})})]}):null]}),i.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[i.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[i.jsxs("div",{className:"af-set-rail-inner",children:[i.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),i.jsxs("div",{className:"af-set-health-line",children:[i.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),i.jsx("span",{className:"af-set-health-label",children:t(!a&&!p?"settings:system.normal":"settings:system.abnormal")})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.cursorModels")}),i.jsx("span",{children:c.cursor.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.opencodeModels")}),i.jsx("span",{children:c.opencode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.claudeCodeModels")}),i.jsx("span",{children:c.claudeCode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]})]}),i.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),i.jsxs("div",{className:"af-set-rail-card",children:[i.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),i.jsxs("div",{className:"af-set-language-selector",children:[i.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Ar,"aria-label":t("settings:language.description"),children:$re.map(ce=>i.jsxs("option",{value:ce.code,children:[ce.flag," ",ce.name]},ce.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function Ds(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Cm(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Pw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function Bre(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Iw(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function Wre(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Vre(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function Kre({authUser:e}){const[t,n]=h.useState(null),[r,s]=h.useState(!1),[o,a]=h.useState(""),l=h.useCallback(async()=>{if(e!=null&&e.isAdmin){s(!0),a("");try{const m=await fetch("/api/admin/usage-dashboard"),g=await m.json().catch(()=>({}));if(!m.ok)throw new Error(typeof g.error=="string"?g.error:"HTTP "+m.status);n(g)}catch(m){n(null),a(String((m==null?void 0:m.message)||m))}finally{s(!1)}}},[e==null?void 0:e.isAdmin]);h.useEffect(()=>{l()},[l]);const c=Array.isArray(t==null?void 0:t.dailyTrend)?t.dailyTrend:[],d=h.useMemo(()=>{const w={top:20,right:24,bottom:42,left:42},k=980-w.left-w.right,y=250-w.top-w.bottom,b=c.length>0?c:[],x=Math.max(1,...b.map(z=>Number(z.runs||0))),j=Math.max(1,...b.flatMap(z=>[Number(z.users||0),Number(z.pipelines||0)])),E=z=>w.left+(b.length<=1?k/2:z*k/(b.length-1)),N=z=>w.top+y-Math.max(0,Number(z||0))/x*y,T=z=>w.top+y-Math.max(0,Number(z||0))/j*y,$=z=>b.map((K,B)=>`${B===0?"M":"L"} ${E(B)} ${T(K[z])}`).join(" ");return{width:980,height:250,margin:w,innerHeight:y,rows:b,x:E,yRuns:N,yLine:T,lineUsers:$("users"),linePipelines:$("pipelines"),barWidth:Math.min(34,Math.max(12,k/Math.max(1,b.length)*.44))}},[c]),p=(t==null?void 0:t.usage)||{},u=(t==null?void 0:t.totals)||{},f=Array.isArray(t==null?void 0:t.recentRuns)?t.recentRuns:[];return e!=null&&e.isAdmin?i.jsxs("main",{className:"af-admin-usage-page",children:[i.jsxs("section",{className:"af-admin-usage-hero",children:[i.jsxs("div",{children:[i.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),i.jsx("h1",{children:"管理看板"}),i.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),i.jsxs("button",{type:"button",onClick:()=>void l(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),r?"刷新中":"刷新"]})]}),o?i.jsx("div",{className:"af-project-admin-usage__error",children:o}):null,i.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[i.jsxs("div",{children:[i.jsx("span",{children:"7日活跃用户率"}),i.jsx("strong",{children:Cm(p.activeUserRate)}),i.jsxs("em",{children:[Ds(p.activeUsers)," / ",Ds(u.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:Cm(p.activePipelineRate)}),i.jsxs("em",{children:[Ds(p.activePipelines)," / ",Ds(u.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Ds(p.runs)}),i.jsxs("em",{children:[Ds(p.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:Cm(p.successRate)}),i.jsxs("em",{children:["失败率 ",Cm(p.failureRate)," · avg ",Pw(p.avgDurationMs)]})]})]}),i.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"每日趋势"}),i.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),i.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[i.jsxs("div",{className:"af-admin-usage-chart__legend",children:[i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),i.jsx("div",{className:"af-admin-usage-chart__canvas",children:i.jsxs("svg",{viewBox:`0 0 ${d.width} ${d.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:d.margin.left,y1:d.margin.top+d.innerHeight,x2:d.width-d.margin.right,y2:d.margin.top+d.innerHeight}),[.25,.5,.75,1].map(m=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:d.margin.left,y1:d.margin.top+d.innerHeight-d.innerHeight*m,x2:d.width-d.margin.right,y2:d.margin.top+d.innerHeight-d.innerHeight*m},m)),d.rows.map((m,g)=>{const w=d.x(g),k=d.yRuns(m.runs),y=d.margin.top+d.innerHeight,b=Math.max(2,y-k);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:w-d.barWidth/2,y:y-b,width:d.barWidth,height:b,rx:"5",children:i.jsx("title",{children:`${m.date}: ${m.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:w,y:y+22,children:Ds(m.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:w,y:y+42,children:Bre(m.date)})]},m.date)}),d.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:d.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:d.linePipelines}),d.rows.map((m,g)=>{const w=d.x(g);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:w,cy:d.yLine(m.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:w,cy:d.yLine(m.pipelines),r:"3.5"})]},`${m.date}-points`)})]}):null]})})]}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"用户"}),i.jsx("th",{children:"流水线"}),i.jsx("th",{children:"运行时间"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"耗时"}),i.jsx("th",{children:"Run ID"})]})}),i.jsx("tbody",{children:f.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):f.map(m=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:m.username||m.userId||"-"}),i.jsx("span",{children:m.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:m.flowId||"-"}),i.jsxs("span",{children:[m.runType==="workspace"?"Workspace Run":"Pipeline"," · ",m.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Iw(m.at)}),m.endedAt?i.jsxs("span",{children:["结束 ",Iw(m.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:Vre(m.status)})})}),i.jsx("td",{children:Pw(m.durationMs)}),i.jsx("td",{children:i.jsx("code",{className:"af-admin-usage-run-id",children:Wre(m.runId)})})]},`${m.userId}:${m.flowSource}:${m.flowId}:${m.runId}:${m.at}`))})]})})]}),i.jsxs("section",{className:"af-project-admin-usage",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"用户使用明细"}),i.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"User"}),i.jsx("th",{children:"Pipeline"}),i.jsx("th",{children:"Runs"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"最近运行"})]})}),i.jsx("tbody",{children:r&&!t?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"正在加载..."})}):((t==null?void 0:t.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"暂无用户数据"})}):((t==null?void 0:t.users)||[]).map(m=>{var g,w,k,y,b,x,j,E,N,T,$;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:m.username||m.userId}),i.jsxs("span",{children:[m.userId,m.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Ds((g=m.pipelines)==null?void 0:g.total)}),i.jsxs("span",{children:[Ds((w=m.pipelines)==null?void 0:w.active)," active / ",Ds((k=m.pipelines)==null?void 0:k.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Ds((y=m.runs)==null?void 0:y.total)}),i.jsxs("span",{children:["avg ",Pw((b=m.runs)==null?void 0:b.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Ds((x=m.runs)==null?void 0:x.success)]}),i.jsxs("em",{children:["失败 ",Ds((j=m.runs)==null?void 0:j.failed)]}),i.jsxs("em",{children:["运行中 ",Ds((E=m.runs)==null?void 0:E.running)]})]})}),i.jsx("td",{children:(N=m.runs)!=null&&N.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((T=m.runs)==null?void 0:T.lastRunFlowId)||"-"}),i.jsxs("span",{children:[(($=m.runs)==null?void 0:$.lastRunStatus)||"unknown"," · ",Iw(m.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})})]},m.userId)})})]})})]})]}):i.jsx("main",{className:"af-admin-usage-page",children:i.jsx("section",{className:"af-project-admin-usage",children:i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"管理看板"}),i.jsx("span",{children:"需要管理员权限。"})]})})})})}function Ure(){const{navigate:e}=Yo(),[t,n]=h.useState(""),[r,s]=h.useState(""),[o,a]=h.useState(!1),[l,c]=h.useState(""),[d,p]=h.useState(!1),u=async f=>{if(f.preventDefault(),!o){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||"提交失败");p(!0),n(""),s("")}catch(m){c(String(m.message||m))}finally{a(!1)}}};return i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?i.jsxs("div",{className:"af-feedback-success",role:"status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("div",{children:[i.jsx("strong",{children:"已提交"}),i.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,i.jsxs("form",{className:"af-feedback-form",onSubmit:u,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:t,onChange:f=>n(f.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"反馈内容"}),i.jsx("textarea",{value:r,onChange:f=>s(f.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),l?i.jsx("p",{className:"af-err af-feedback-error",children:l}):null,i.jsx("div",{className:"af-feedback-actions",children:i.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:o||!t.trim()||!r.trim(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:o?"hourglass_empty":"send"}),o?"提交中...":"提交反馈"]})})]})]})})}function A2(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function zC(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:A2(),key:r,value:String(s??""),private:n.has(r)}))}function HC(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 eg(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(`
266
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:zC(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:zC(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 Tw(){return eg({name:"",raw:{command:""}})}function qre(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const o=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);o.length&&(n.args=o)}const r=HC(e.envRows),s=HC(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(s).length&&(n.headers=s),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean)}}function BC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function WC(e){return e?e.ok?"ok":"error":"unknown"}function VC({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const o=(a,l,c)=>n(t.map(d=>d.id===a?{...d,[l]:c}:d));return i.jsxs("div",{className:"af-mcp-field",children:[i.jsxs("div",{className:"af-mcp-field-head",children:[i.jsx("span",{children:e}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:A2(),key:"",value:"",private:!0}]),children:"添加"})]}),i.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?i.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>i.jsxs("div",{className:"af-mcp-kv-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>o(a.id,"key",l.target.value)}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>o(a.id,"value",l.target.value)}),i.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[i.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>o(a.id,"private",l.target.checked)}),i.jsx("span",{children:"个人"})]}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function Yre(){var L;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,o]=h.useState(Tw),[a,l]=h.useState(""),[c,d]=h.useState(!1),[p,u]=h.useState(!1),[f,m]=h.useState(!1),[g,w]=h.useState({}),[k,y]=h.useState(""),[b,x]=h.useState(""),j=h.useMemo(()=>n.find(D=>D.name===a)||null,[a,n]),E=j&&g[j.name]||null,N=h.useCallback(async()=>{d(!0),y("");try{const D=await fetch("/api/mcps"),R=await D.json().catch(()=>({}));if(!D.ok)throw new Error(R.error||"MCP HTTP "+D.status);const M=Array.isArray(R.servers)?R.servers:[];t(String(R.path||"")),r(M),a&&M.some(I=>I.name===a)&&o(eg(M.find(I=>I.name===a)))}catch(D){y(String(D.message||D))}finally{d(!1)}},[a]);h.useEffect(()=>{N()},[N]);const T=()=>{l(""),o(Tw()),x(""),y("")},$=D=>{l(D.name),o(eg(D)),x(""),y("")},z=async(D="")=>{m(!0),y(""),x("");try{const R=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D?{name:D}:{})}),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(M.error||"检测 MCP 失败");const I=Array.isArray(M.results)?M.results:[];w(F=>{const P={...F};for(const O of I)O!=null&&O.name&&(P[O.name]=O);return P}),x(D?`已检测 ${D}。`:"已检测所有 MCP。")}catch(R){y(String(R.message||R))}finally{m(!1)}},K=async()=>{u(!0),y(""),x("");try{const D=qre(s);if(!D.nextName)throw new Error("请填写 MCP 名称");const R=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(M.error||"保存 MCP 失败");const I=Array.isArray(M.servers)?M.servers:[];r(I),t(String(M.path||e)),l(D.nextName),o(eg(I.find(F=>F.name===D.nextName)||null)),w(F=>{const P={...F};return s.originalName&&s.originalName!==D.nextName&&delete P[s.originalName],delete P[D.nextName],P}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(D){y(String(D.message||D))}finally{u(!1)}},B=async D=>{if(D!=null&&D.name&&window.confirm(`删除 MCP "${D.name}"?`)){u(!0),y(""),x("");try{const R=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D.name})}),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(M.error||"删除 MCP 失败");r(Array.isArray(M.servers)?M.servers:[]),l(""),o(Tw()),w(I=>{const F={...I};return delete F[D.name],F}),x("已删除。")}catch(R){y(String(R.message||R))}finally{u(!1)}}};return i.jsxs("main",{className:"af-settings-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),i.jsxs("div",{className:"af-settings-top-right",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:c||p,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>z(),disabled:f||c||p||n.length===0,children:f?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:T,disabled:p,children:"新增 MCP"})]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),i.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",i.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),i.jsxs("div",{className:"af-mcp-layout",children:[i.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2",children:"Servers"}),i.jsxs("div",{className:"af-mcp-list-head-actions",children:[i.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),i.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:T,disabled:p,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?i.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?i.jsxs("div",{className:"af-mcp-empty",children:[i.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:T,disabled:p,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(D=>i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===D.name?" af-mcp-server-item--active":""),onClick:()=>$(D),children:[i.jsx("span",{className:"material-symbols-outlined",children:D.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:D.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${WC(g[D.name])}`,children:BC(g[D.name])})]}),i.jsx("em",{children:D.url||[D.command,...D.args||[]].filter(Boolean).join(" ")})]})]},D.name))})]}),i.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:j?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),j?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>z(j.name),disabled:f||p,children:f?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>B(j),disabled:p,children:"删除"})]}):null]}),k?i.jsx("p",{className:"af-mcp-error",children:k}):null,b?i.jsx("p",{className:"af-mcp-status",children:b}):null,E?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${WC(E)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:BC(E)}),i.jsxs("span",{children:[E.elapsedMs||0,"ms"]})]}),E.error?i.jsx("p",{children:E.error}):null,(L=E.tools)!=null&&L.length?i.jsx("div",{className:"af-mcp-tools-list",children:E.tools.map(D=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:D.name}),D.description?i.jsx("span",{children:D.description}):null]},D.name))}):null]}):null,i.jsxs("div",{className:"af-mcp-form",children:[i.jsxs("label",{className:"af-set-label",children:["MCP 名称",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:D=>o(R=>({...R,name:D.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:D=>o(R=>({...R,type:D.target.value})),children:[i.jsx("option",{value:"url",children:"URL / HTTP"}),i.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:D=>o(R=>({...R,url:D.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-set-label",children:["Command",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:D=>o(R=>({...R,command:D.target.value})),placeholder:"uvx"})]}),i.jsxs("label",{className:"af-set-label",children:["Args,每行一个",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:D=>o(R=>({...R,argsText:D.target.value})),placeholder:`mcp-server-example
267
- --flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:D=>o(R=>({...R,description:D.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(VC,{title:"Headers",rows:s.headerRows,onChange:D=>o(R=>({...R,headerRows:D})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(VC,{title:"Env",rows:s.envRows,onChange:D=>o(R=>({...R,envRows:D})),placeholderKey:"TOKEN",placeholderValue:"..."}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:D=>o(R=>({...R,extraJson:D.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:T,disabled:p,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:K,disabled:p,children:p?"保存中...":"保存 MCP"})]})]})]})]})})]})}const Gre=[{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"}],Xre=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Jre=[{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"}],Qre=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Em({icon:e,title:t,label:n,tone:r="violet"}){return i.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[i.jsx("span",{className:"material-symbols-outlined",children:e}),i.jsxs("div",{children:[i.jsx("strong",{children:t}),i.jsx("small",{children:n})]})]})}function Zre(){return i.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[i.jsx("div",{className:"likee-scene-grid"}),i.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[i.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),i.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),i.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),i.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),i.jsx("div",{className:"likee-node-pos likee-node-a",children:i.jsx(Em,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(Em,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(Em,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(Em,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),i.jsxs("div",{className:"likee-phone-preview",children:[i.jsxs("div",{className:"likee-phone-top",children:[i.jsx("span",{children:"关注"}),i.jsx("strong",{children:"推荐"}),i.jsx("span",{children:"直播"})]}),i.jsxs("div",{className:"likee-phone-card",children:[i.jsx("div",{className:"likee-gift",children:"AD"}),i.jsx("h4",{children:"广告个性化引导弹框"}),i.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),i.jsx("button",{children:"继续"}),i.jsx("button",{className:"secondary",children:"稍后"})]})]}),i.jsxs("div",{className:"likee-display-panel",children:[i.jsxs("div",{className:"likee-panel-header",children:[i.jsx("span",{children:"DISPLAY"}),i.jsx("strong",{children:"需求资产面板"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"需求"}),i.jsx("strong",{children:"首页广告个性化引导"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"数据"}),i.jsx("strong",{children:"m09 PV Top 1"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"同步"}),i.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function tg({kicker:e,title:t,children:n}){return i.jsxs("div",{className:"likee-section-copy",children:[i.jsx("p",{className:"likee-section-kicker",children:e}),i.jsx("h2",{children:t}),i.jsx("p",{children:n})]})}function ese(){return i.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[i.jsx(tg,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:Jre.map(e=>i.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[i.jsxs("div",{className:"likee-skill-head",children:[i.jsx("div",{className:"likee-skill-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.name}),i.jsx("span",{children:e.namespace})]})]}),i.jsx("div",{className:"likee-skill-mode",children:e.mode}),i.jsx("p",{children:e.usage}),i.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>i.jsx("strong",{children:t},t))})]},e.name))})]})})}function P2(){return i.jsxs("div",{className:"likee-page",children:[i.jsx("div",{className:"likee-top-actions",children:i.jsxs("a",{href:"/projects",className:"likee-home-link",children:[i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),i.jsxs("section",{className:"likee-hero",children:[i.jsx(Zre,{}),i.jsxs("div",{className:"likee-hero-content",children:[i.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),i.jsx("h1",{children:"Likee Agent 工作台"}),i.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),i.jsxs("div",{className:"likee-signal-row",children:[i.jsx("span",{children:"查业务逻辑"}),i.jsx("span",{children:"查 CK / Hive"}),i.jsx("span",{children:"生成原型"}),i.jsx("span",{children:"生成 PRD"}),i.jsx("span",{children:"同步 TAPD / Git"})]}),i.jsxs("div",{className:"likee-hero-actions",children:[i.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),i.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),i.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),i.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),i.jsx("section",{id:"likee-scenarios",className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner",children:[i.jsx(tg,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:Gre.map(e=>i.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[i.jsx("div",{className:"likee-scenario-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.question})]}),i.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>i.jsx("span",{children:t},t))}),i.jsxs("div",{className:"likee-scenario-result",children:[i.jsx("span",{children:"产出"}),i.jsx("strong",{children:e.result})]})]},e.title))})]})}),i.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[i.jsx(tg,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:Xre.map(e=>i.jsxs("article",{className:"likee-usecase-card",children:[i.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>i.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),i.jsxs("div",{className:"likee-usecase-body",children:[i.jsx("div",{className:"likee-usecase-label",children:e.label}),i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.trigger}),i.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>i.jsx("li",{children:t},t))}),i.jsxs("div",{className:"likee-usecase-output",children:[i.jsx("span",{children:"实际产物"}),i.jsx("div",{children:e.outputs.map(t=>i.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),i.jsx(ese,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(tg,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Qre.map(([e,t,n])=>i.jsxs("div",{className:"likee-capability-row",children:[i.jsx("span",{children:e}),i.jsx("strong",{children:t}),i.jsx("p",{children:n})]},e))})]})})]})}function I2(e){return t=>typeof t===e}var tse=I2("function"),nse=e=>e===null,KC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",UC=e=>!rse(e)&&!nse(e)&&(tse(e)||typeof e=="object"),rse=I2("undefined");function sse(e,t,n){return dse(n,e,t)?!0:(fse(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?ise(e,t,n):e instanceof Map&&t instanceof Map?lse(e,t,n):e instanceof Set&&t instanceof Set?use(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?ose(e,t):KC(e)&&KC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?ase(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():cse(e,t,n))}function ch(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!UC(e)||!t||!UC(t)?!1:sse(e,t,n)}function ise(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!ch(e[s],t[s],n))return!1;return!0}function ose(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 ase(e,t,n){return e.message===t.message&&e.name===t.name&&ch(e.cause,t.cause,n)}function lse(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(!ch(r[1],t.get(r[0]),n))return!1;return!0}function cse(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=r.length;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[s]))return!1;for(let s=r.length;s--!==0;){const o=r[s];if(!(o==="_owner"&&e.$$typeof)&&!ch(e[o],t[o],n))return!1}return!0}function use(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 dse(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function fse(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function Ik(e,t){return ch(e,t,new WeakMap)}function Rw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function pse(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function hse(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function mse(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function gse(e,t){const n=mse();h.useEffect(()=>{if(!n)return e()},t)}function T2(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function yse(e,t){const n=h.useRef(t);return Ik(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function xse(e){h.useEffect(()=>{e()},[])}function wse(e=0){const[t,n]=h.useState({height:Rw()?window.innerHeight:0,width:Rw()?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(!Rw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),hse(window,"resize",o),()=>{pse(window,"resize",o)}},[]),t}var bse=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],vse=["bigint","boolean","null","number","string","symbol","undefined"];function uh(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(kse(t))return t}function lo(e){return t=>uh(t)===e}function kse(e){return bse.includes(e)}function Od(e){return t=>typeof t===e}function Sse(e){return vse.includes(e)}var Nse=["innerHTML","ownerDocument","style","attributes","nodeValue"],dh=e=>Array.isArray(e),jse=e=>uh(e)==="AsyncGeneratorFunction",Cse=lo("AsyncFunction"),Ese=Od("bigint"),_se=e=>e===!0||e===!1,Ase=lo("Date"),Pse=lo("Error"),Ll=Od("function"),Ise=lo("GeneratorFunction"),Tse=e=>typeof e=="number"&&Number.isInteger(e),Iv=lo("Map"),R2=e=>Number.isNaN(e),Tk=e=>e===null,M2=lo("Function"),Rse=lo("Promise"),Mse=lo("RegExp"),Tv=lo("Set"),fh=Od("string"),Lse=Od("symbol"),Rk=Od("undefined"),Ose=lo("WeakMap"),$se=lo("WeakSet"),Mk=e=>Tk(e)||Rk(e),L2=e=>!Rk(e),Dse=e=>Od("number")(e)&&!R2(e),Fse=e=>fh(e)&&e.trim().length>0,zse=e=>{if(!fh(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},qy=e=>!Mk(e)&&(Ll(e)||typeof e=="object"),O2=e=>{if(uh(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Hse=e=>Tk(e)||Sse(typeof e),Bse=e=>uh(e)==="URL",$2=e=>!Mk(e)&&Ll(e[Symbol.iterator]),Wse=e=>$2(e)&&Ll(e.next)&&Ll(e.throw),Vse=e=>Ll(e)&&/^class\s/.test(e.toString()),Kse=(e,t)=>!dh(e)||!Ll(t)?!1:e.every(n=>t(n)),Use=e=>qy(e)&&!O2(e)&&e.nodeType===1&&fh(e.nodeName)&&Nse.every(t=>t in e),qse=e=>fh(e)&&e.length===0||dh(e)&&e.length===0||qy(e)&&!Iv(e)&&!Tv(e)&&Object.keys(e).length===0||Tv(e)&&e.size===0||Iv(e)&&e.size===0,Yse=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Gse=(e,t)=>dh(e)?e.indexOf(t)>-1:!1,Xse=(e,t,n)=>{if(!qy(e)||!t)return!1;const r=e[t];return Ll(n)?n(r):L2(r)};function $t(e){if(e===null)return"null";switch(typeof e){case"bigint":return"bigint";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"undefined":return"undefined"}if(dh(e))return"Array";if(M2(e))return"Function";const t=uh(e);return t||"Object"}$t.array=dh;$t.arrayOf=Kse;$t.asyncGeneratorFunction=jse;$t.asyncFunction=Cse;$t.bigint=Ese;$t.boolean=_se;$t.class=Vse;$t.date=Ase;$t.defined=L2;$t.domElement=Use;$t.empty=qse;$t.error=Pse;$t.function=Ll;$t.generator=Wse;$t.generatorFunction=Ise;$t.instanceOf=Yse;$t.integer=Tse;$t.iterable=$2;$t.map=Iv;$t.nan=R2;$t.null=Tk;$t.nullOrUndefined=Mk;$t.nonEmptyString=Fse;$t.number=Dse;$t.numericString=zse;$t.object=qy;$t.oneOf=Gse;$t.plainFunction=M2;$t.plainObject=O2;$t.primitive=Hse;$t.promise=Rse;$t.propertyOf=Xse;$t.regexp=Mse;$t.set=Tv;$t.string=fh;$t.symbol=Lse;$t.undefined=Rk;$t.url=Bse;$t.weakMap=Ose;$t.weakSet=$se;var hs=$t;/* v8 ignore next -- @preserve */var Jse=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Qse=function(e,t){return e+Vp(t)},Vp=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(Qse,""):Jse(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Vp(e.props.children):""};Vp.default=Vp;var Zse=Vp;const Mw=$l(Zse);var D2={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(o){return typeof o=="object"&&o!==null&&!(o instanceof RegExp)&&!(o instanceof Date)}}function r(s){function o(E){return E!=="constructor"&&E!=="prototype"&&E!=="__proto__"}function a(E){let N=0;const T=E.length,$=new Array(T);for(N;N<T;++N)$[N]=y(E[N]);return $}function l(E){const N={};if(f&&Object.getPrototypeOf(E)!==t)return f(E);const T=u(E);let $,z,K;for($=0,z=T.length;$<z;++$)o(K=T[$])&&(N[K]=y(E[K]));return N}function c(E,N){const T=E.length,$=N.length;let z=0;const K=new Array(T+$);for(z;z<T;++z)K[z]=y(E[z]);for(z=0;z<$;++z)K[z+T]=y(N[z]);return K}const d=Object.prototype.propertyIsEnumerable;function p(E){const N=Object.keys(E),T=Object.getOwnPropertySymbols(E);for(let $=0,z=T.length;$<z;++$)d.call(E,T[$])&&N.push(T[$]);return N}const u=s!=null&&s.symbols?p:Object.keys,f=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 w(E){return typeof E!="object"||E===null}const k=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:x,getKeys:u,isMergeableObject:m}):c;function y(E){return m(E)?Array.isArray(E)?a(E):l(E):E}function b(E,N){const T={},$=u(E),z=u(N);let K,B,L;for(K=0,B=$.length;K<B;++K)o(L=$[K])&&z.indexOf(L)===-1&&(T[L]=y(E[L]));for(K=0,B=z.length;K<B;++K)if(o(L=z[K]))if(L in E)$.indexOf(L)!==-1&&(f&&m(N[L])&&Object.getPrototypeOf(N[L])!==t?T[L]=f(N[L]):T[L]=x(E[L],N[L]));else{if(g&&typeof N[L]>"u")continue;T[L]=y(N[L])}return T}function x(E,N){if(g&&typeof N>"u")return y(E);const T=Array.isArray(N),$=Array.isArray(E);return w(N)?N:m(E)?T&&$?k(E,N):T!==$?y(N):b(E,N):y(N)}function j(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return x(arguments[0],arguments[1])}let E;for(let N=0,T=arguments.length;N<T;++N)E=x(E,arguments[N]);return E}return s!=null&&s.all?j:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(D2);var eie=D2.exports;const tie=$l(eie);var nie=new Error("Element already at target scroll position"),rie=new Error("Scroll cancelled"),sie=Math.min,qC=Date.now,iie={left:YC("scrollLeft"),top:YC("scrollTop")};function YC(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=aie);var a=qC(),l=n[e],c=s.ease||oie,d=isNaN(s.duration)?350:+s.duration,p=!1;return l===r?o(nie,n[e]):requestAnimationFrame(f),u;function u(){p=!0}function f(m){if(p)return o(rie,n[e]);var g=qC(),w=sie(1,(g-a)/d),k=c(w);n[e]=k*(r-l)+l,w<1?requestAnimationFrame(f):requestAnimationFrame(function(){o(null,n[e])})}}}function oie(e){return .5*(1-Math.cos(Math.PI*e))}function aie(){}const lie=$l(iie);var F2={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(ap,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})})(F2);var cie=F2.exports;const z2=$l(cie),uie=["top","right","bottom","left"],GC=["start","end"],XC=uie.reduce((e,t)=>e.concat(t,t+"-"+GC[0],t+"-"+GC[1]),[]),_d=Math.min,Ec=Math.max,iy=Math.round,_m=Math.floor,Vo=e=>({x:e,y:e}),die={left:"right",right:"left",bottom:"top",top:"bottom"};function Rv(e,t,n){return Ec(e,_d(t,n))}function $d(e,t){return typeof e=="function"?e(t):e}function Ia(e){return e.split("-")[0]}function Ko(e){return e.split("-")[1]}function H2(e){return e==="x"?"y":"x"}function Lk(e){return e==="y"?"height":"width"}function gl(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ok(e){return H2(gl(e))}function B2(e,t,n){n===void 0&&(n=!1);const r=Ko(e),s=Ok(e),o=Lk(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=ay(a)),[a,ay(a)]}function fie(e){const t=ay(e);return[oy(e),t,oy(t)]}function oy(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const JC=["left","right"],QC=["right","left"],pie=["top","bottom"],hie=["bottom","top"];function mie(e,t,n){switch(e){case"top":case"bottom":return n?t?QC:JC:t?JC:QC;case"left":case"right":return t?pie:hie;default:return[]}}function gie(e,t,n,r){const s=Ko(e);let o=mie(Ia(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(oy)))),o}function ay(e){const t=Ia(e);return die[t]+e.slice(t.length)}function yie(e){return{top:0,right:0,bottom:0,left:0,...e}}function W2(e){return typeof e!="number"?yie(e):{top:e,right:e,bottom:e,left:e}}function ly(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 ZC(e,t,n){let{reference:r,floating:s}=e;const o=gl(t),a=Ok(t),l=Lk(a),c=Ia(t),d=o==="y",p=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,f=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:p,y:r.y-s.height};break;case"bottom":m={x:p,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(Ko(t)){case"start":m[a]-=f*(n&&d?-1:1);break;case"end":m[a]+=f*(n&&d?-1:1);break}return m}async function xie(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:u="floating",altBoundary:f=!1,padding:m=0}=$d(t,e),g=W2(m),k=l[f?u==="floating"?"reference":"floating":u],y=ly(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(k)))==null||n?k:k.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:c})),b=u==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),j=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},E=ly(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:x,strategy:c}):b);return{top:(y.top-E.top+g.top)/j.y,bottom:(E.bottom-y.bottom+g.bottom)/j.y,left:(y.left-E.left+g.left)/j.x,right:(E.right-y.right+g.right)/j.x}}const wie=50,bie=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:xie},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:u}=ZC(d,r,c),f=r,m=0;const g={};for(let w=0;w<o.length;w++){const k=o[w];if(!k)continue;const{name:y,fn:b}=k,{x,y:j,data:E,reset:N}=await b({x:p,y:u,initialPlacement:r,placement:f,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});p=x??p,u=j??u,g[y]={...g[y],...E},N&&m<wie&&(m++,typeof N=="object"&&(N.placement&&(f=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):N.rects),{x:p,y:u}=ZC(d,f,c)),w=-1)}return{x:p,y:u,placement:f,strategy:s,middlewareData:g}},vie=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:p=0}=$d(e,t)||{};if(d==null)return{};const u=W2(p),f={x:n,y:r},m=Ok(s),g=Lk(m),w=await a.getDimensions(d),k=m==="y",y=k?"top":"left",b=k?"bottom":"right",x=k?"clientHeight":"clientWidth",j=o.reference[g]+o.reference[m]-f[m]-o.floating[g],E=f[m]-o.reference[m],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let T=N?N[x]:0;(!T||!await(a.isElement==null?void 0:a.isElement(N)))&&(T=l.floating[x]||o.floating[g]);const $=j/2-E/2,z=T/2-w[g]/2-1,K=_d(u[y],z),B=_d(u[b],z),L=K,D=T-w[g]-B,R=T/2-w[g]/2+$,M=Rv(L,R,D),I=!c.arrow&&Ko(s)!=null&&R!==M&&o.reference[g]/2-(R<L?K:B)-w[g]/2<0,F=I?R<L?R-L:R-D:0;return{[m]:f[m]+F,data:{[m]:M,centerOffset:R-M-F,...I&&{alignmentOffset:F}},reset:I}}});function kie(e,t,n){return(e?[...n.filter(s=>Ko(s)===e),...n.filter(s=>Ko(s)!==e)]:n.filter(s=>Ia(s)===s)).filter(s=>e?Ko(s)===e||(t?oy(s)!==s:!1):!0)}const Sie=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:o,middlewareData:a,placement:l,platform:c,elements:d}=t,{crossAxis:p=!1,alignment:u,allowedPlacements:f=XC,autoAlignment:m=!0,...g}=$d(e,t),w=u!==void 0||f===XC?kie(u||null,m,f):f,k=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,b=w[y];if(b==null)return{};const x=B2(b,o,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==b)return{reset:{placement:w[0]}};const j=[k[Ia(b)],k[x[0]],k[x[1]]],E=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:b,overflows:j}],N=w[y+1];if(N)return{data:{index:y+1,overflows:E},reset:{placement:N}};const T=E.map(K=>{const B=Ko(K.placement);return[K.placement,B&&p?K.overflows.slice(0,2).reduce((L,D)=>L+D,0):K.overflows[0],K.overflows]}).sort((K,B)=>K[1]-B[1]),z=((s=T.filter(K=>K[2].slice(0,Ko(K[0])?2:3).every(B=>B<=0))[0])==null?void 0:s[0])||T[0][0];return z!==l?{data:{index:y+1,overflows:E},reset:{placement:z}}:{}}}},Nie=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:p=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...k}=$d(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Ia(s),b=gl(l),x=Ia(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),E=f||(x||!w?[ay(l)]:fie(l)),N=g!=="none";!f&&N&&E.push(...gie(l,w,g,j));const T=[l,...E],$=await c.detectOverflow(t,k),z=[];let K=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&z.push($[y]),u){const R=B2(s,a,j);z.push($[R[0]],$[R[1]])}if(K=[...K,{placement:s,overflows:z}],!z.every(R=>R<=0)){var B,L;const R=(((B=o.flip)==null?void 0:B.index)||0)+1,M=T[R];if(M&&(!(u==="alignment"?b!==gl(M):!1)||K.every(P=>gl(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:R,overflows:K},reset:{placement:M}};let I=(L=K.filter(F=>F.overflows[0]<=0).sort((F,P)=>F.overflows[1]-P.overflows[1])[0])==null?void 0:L.placement;if(!I)switch(m){case"bestFit":{var D;const F=(D=K.filter(P=>{if(N){const O=gl(P.placement);return O===b||O==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(O=>O>0).reduce((O,_)=>O+_,0)]).sort((P,O)=>P[1]-O[1])[0])==null?void 0:D[0];F&&(I=F);break}case"initialPlacement":I=l;break}if(s!==I)return{reset:{placement:I}}}return{}}}},jie=new Set(["left","top"]);async function Cie(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=Ia(n),l=Ko(n),c=gl(n)==="y",d=jie.has(a)?-1:1,p=o&&c?-1:1,u=$d(t,e);let{mainAxis:f,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*p,y:f*d}:{x:f*d,y:m*p}}const Eie=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:a,middlewareData:l}=t,c=await Cie(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},_ie=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:b,y:x}=y;return{x:b,y:x}}},...d}=$d(e,t),p={x:n,y:r},u=await o.detectOverflow(t,d),f=gl(Ia(s)),m=H2(f);let g=p[m],w=p[f];if(a){const y=m==="y"?"top":"left",b=m==="y"?"bottom":"right",x=g+u[y],j=g-u[b];g=Rv(x,g,j)}if(l){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",x=w+u[y],j=w-u[b];w=Rv(x,w,j)}const k=c.fn({...t,[m]:g,[f]:w});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[m]:a,[f]:l}}}}}};function Yy(){return typeof window<"u"}function Dd(e){return V2(e)?(e.nodeName||"").toLowerCase():"#document"}function ci(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Xo(e){var t;return(t=(V2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function V2(e){return Yy()?e instanceof Node||e instanceof ci(e).Node:!1}function io(e){return Yy()?e instanceof Element||e instanceof ci(e).Element:!1}function Ma(e){return Yy()?e instanceof HTMLElement||e instanceof ci(e).HTMLElement:!1}function eE(e){return!Yy()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ci(e).ShadowRoot}function ph(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=oo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Aie(e){return/^(table|td|th)$/.test(Dd(e))}function Gy(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Pie=/transform|translate|scale|rotate|perspective|filter/,Iie=/paint|layout|strict|content/,cc=e=>!!e&&e!=="none";let Lw;function $k(e){const t=io(e)?oo(e):e;return cc(t.transform)||cc(t.translate)||cc(t.scale)||cc(t.rotate)||cc(t.perspective)||!Dk()&&(cc(t.backdropFilter)||cc(t.filter))||Pie.test(t.willChange||"")||Iie.test(t.contain||"")}function Tie(e){let t=Ol(e);for(;Ma(t)&&!Ad(t);){if($k(t))return t;if(Gy(t))return null;t=Ol(t)}return null}function Dk(){return Lw==null&&(Lw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lw}function Ad(e){return/^(html|body|#document)$/.test(Dd(e))}function oo(e){return ci(e).getComputedStyle(e)}function Xy(e){return io(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ol(e){if(Dd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||eE(e)&&e.host||Xo(e);return eE(t)?t.host:t}function K2(e){const t=Ol(e);return Ad(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ma(t)&&ph(t)?t:K2(t)}function Kp(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=K2(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ci(s);if(o){const l=Mv(a);return t.concat(a,a.visualViewport||[],ph(s)?s:[],l&&n?Kp(l):[])}else return t.concat(s,Kp(s,[],n))}function Mv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function U2(e){const t=oo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ma(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=iy(n)!==o||iy(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Fk(e){return io(e)?e:e.contextElement}function ad(e){const t=Fk(e);if(!Ma(t))return Vo(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=U2(t);let a=(o?iy(n.width):n.width)/r,l=(o?iy(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Rie=Vo(0);function q2(e){const t=ci(e);return!Dk()||!t.visualViewport?Rie:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mie(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ci(e)?!1:t}function Hc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Fk(e);let a=Vo(1);t&&(r?io(r)&&(a=ad(r)):a=ad(e));const l=Mie(o,n,r)?q2(o):Vo(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,p=s.width/a.x,u=s.height/a.y;if(o){const f=ci(o),m=r&&io(r)?ci(r):r;let g=f,w=Mv(g);for(;w&&r&&m!==g;){const k=ad(w),y=w.getBoundingClientRect(),b=oo(w),x=y.left+(w.clientLeft+parseFloat(b.paddingLeft))*k.x,j=y.top+(w.clientTop+parseFloat(b.paddingTop))*k.y;c*=k.x,d*=k.y,p*=k.x,u*=k.y,c+=x,d+=j,g=ci(w),w=Mv(g)}}return ly({width:p,height:u,x:c,y:d})}function Jy(e,t){const n=Xy(e).scrollLeft;return t?t.left+n:Hc(Xo(e)).left+n}function Y2(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Jy(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Lie(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Xo(r),l=t?Gy(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},d=Vo(1);const p=Vo(0),u=Ma(r);if((u||!u&&!o)&&((Dd(r)!=="body"||ph(a))&&(c=Xy(r)),u)){const m=Hc(r);d=ad(r),p.x=m.x+r.clientLeft,p.y=m.y+r.clientTop}const f=a&&!u&&!o?Y2(a,c):Vo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+p.x+f.x,y:n.y*d.y-c.scrollTop*d.y+p.y+f.y}}function Oie(e){return Array.from(e.getClientRects())}function $ie(e){const t=Xo(e),n=Xy(e),r=e.ownerDocument.body,s=Ec(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ec(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Jy(e);const l=-n.scrollTop;return oo(r).direction==="rtl"&&(a+=Ec(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const tE=25;function Die(e,t){const n=ci(e),r=Xo(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const p=Dk();(!p||p&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=Jy(r);if(d<=0){const p=r.ownerDocument,u=p.body,f=getComputedStyle(u),m=p.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-m);g<=tE&&(o-=g)}else d<=tE&&(o+=d);return{width:o,height:a,x:l,y:c}}function Fie(e,t){const n=Hc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ma(e)?ad(e):Vo(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,d=r*o.y;return{width:a,height:l,x:c,y:d}}function nE(e,t,n){let r;if(t==="viewport")r=Die(e,n);else if(t==="document")r=$ie(Xo(e));else if(io(t))r=Fie(t,n);else{const s=q2(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return ly(r)}function G2(e,t){const n=Ol(e);return n===t||!io(n)||Ad(n)?!1:oo(n).position==="fixed"||G2(n,t)}function zie(e,t){const n=t.get(e);if(n)return n;let r=Kp(e,[],!1).filter(l=>io(l)&&Dd(l)!=="body"),s=null;const o=oo(e).position==="fixed";let a=o?Ol(e):e;for(;io(a)&&!Ad(a);){const l=oo(a),c=$k(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ph(a)&&!c&&G2(e,a))?r=r.filter(p=>p!==a):s=l,a=Ol(a)}return t.set(e,r),r}function Hie(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Gy(t)?[]:zie(t,this._c):[].concat(n),r],l=nE(t,a[0],s);let c=l.top,d=l.right,p=l.bottom,u=l.left;for(let f=1;f<a.length;f++){const m=nE(t,a[f],s);c=Ec(m.top,c),d=_d(m.right,d),p=_d(m.bottom,p),u=Ec(m.left,u)}return{width:d-u,height:p-c,x:u,y:c}}function Bie(e){const{width:t,height:n}=U2(e);return{width:t,height:n}}function Wie(e,t,n){const r=Ma(t),s=Xo(t),o=n==="fixed",a=Hc(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Vo(0);function d(){c.x=Jy(s)}if(r||!r&&!o)if((Dd(t)!=="body"||ph(s))&&(l=Xy(t)),r){const m=Hc(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&d();o&&!r&&s&&d();const p=s&&!r&&!o?Y2(s,l):Vo(0),u=a.left+l.scrollLeft-c.x-p.x,f=a.top+l.scrollTop-c.y-p.y;return{x:u,y:f,width:a.width,height:a.height}}function Ow(e){return oo(e).position==="static"}function rE(e,t){if(!Ma(e)||oo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Xo(e)===n&&(n=n.ownerDocument.body),n}function X2(e,t){const n=ci(e);if(Gy(e))return n;if(!Ma(e)){let s=Ol(e);for(;s&&!Ad(s);){if(io(s)&&!Ow(s))return s;s=Ol(s)}return n}let r=rE(e,t);for(;r&&Aie(r)&&Ow(r);)r=rE(r,t);return r&&Ad(r)&&Ow(r)&&!$k(r)?n:r||Tie(e)||n}const Vie=async function(e){const t=this.getOffsetParent||X2,n=this.getDimensions,r=await n(e.floating);return{reference:Wie(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Kie(e){return oo(e).direction==="rtl"}const Uie={convertOffsetParentRelativeRectToViewportRelativeRect:Lie,getDocumentElement:Xo,getClippingRect:Hie,getOffsetParent:X2,getElementRects:Vie,getClientRects:Oie,getDimensions:Bie,getScale:ad,isElement:io,isRTL:Kie};function J2(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qie(e,t){let n=null,r;const s=Xo(e);function o(){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),o();const d=e.getBoundingClientRect(),{left:p,top:u,width:f,height:m}=d;if(l||t(),!f||!m)return;const g=_m(u),w=_m(s.clientWidth-(p+f)),k=_m(s.clientHeight-(u+m)),y=_m(p),x={rootMargin:-g+"px "+-w+"px "+-k+"px "+-y+"px",threshold:Ec(0,_d(1,c))||1};let j=!0;function E(N){const T=N[0].intersectionRatio;if(T!==c){if(!j)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!J2(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(E,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return a(!0),o}function sE(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=Fk(e),p=s||o?[...d?Kp(d):[],...t?Kp(t):[]]:[];p.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const u=d&&l?qie(d,n):null;let f=-1,m=null;a&&(m=new ResizeObserver(y=>{let[b]=y;b&&b.target===d&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),d&&!c&&m.observe(d),t&&m.observe(t));let g,w=c?Hc(e):null;c&&k();function k(){const y=Hc(e);w&&!J2(w,y)&&n(),w=y,g=requestAnimationFrame(k)}return n(),()=>{var y;p.forEach(b=>{s&&b.removeEventListener("scroll",n),o&&b.removeEventListener("resize",n)}),u==null||u(),(y=m)==null||y.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const Yie=Eie,Gie=Sie,Xie=_ie,Jie=Nie,iE=vie,Qie=(e,t,n)=>{const r=new Map,s={platform:Uie,...n},o={...s.platform,_c:r};return bie(e,t,{...s,platform:o})};var Zie=typeof document<"u",eoe=function(){},ng=Zie?h.useLayoutEffect:eoe;function cy(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(!cy(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!cy(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Q2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oE(e,t){const n=Q2(e);return Math.round(t*n)/n}function $w(e){const t=h.useRef(e);return ng(()=>{t.current=e}),t}function aE(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[p,u]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=h.useState(r);cy(f,r)||m(r);const[g,w]=h.useState(null),[k,y]=h.useState(null),b=h.useCallback(P=>{P!==N.current&&(N.current=P,w(P))},[]),x=h.useCallback(P=>{P!==T.current&&(T.current=P,y(P))},[]),j=o||g,E=a||k,N=h.useRef(null),T=h.useRef(null),$=h.useRef(p),z=c!=null,K=$w(c),B=$w(s),L=$w(d),D=h.useCallback(()=>{if(!N.current||!T.current)return;const P={placement:t,strategy:n,middleware:f};B.current&&(P.platform=B.current),Qie(N.current,T.current,P).then(O=>{const _={...O,isPositioned:L.current!==!1};R.current&&!cy($.current,_)&&($.current=_,Ir.flushSync(()=>{u(_)}))})},[f,t,n,B,L]);ng(()=>{d===!1&&$.current.isPositioned&&($.current.isPositioned=!1,u(P=>({...P,isPositioned:!1})))},[d]);const R=h.useRef(!1);ng(()=>(R.current=!0,()=>{R.current=!1}),[]),ng(()=>{if(j&&(N.current=j),E&&(T.current=E),j&&E){if(K.current)return K.current(j,E,D);D()}},[j,E,D,K,z]);const M=h.useMemo(()=>({reference:N,floating:T,setReference:b,setFloating:x}),[b,x]),I=h.useMemo(()=>({reference:j,floating:E}),[j,E]),F=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!I.floating)return P;const O=oE(I.floating,p.x),_=oE(I.floating,p.y);return l?{...P,transform:"translate("+O+"px, "+_+"px)",...Q2(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:_}},[n,l,I.floating,p.x,p.y]);return h.useMemo(()=>({...p,update:D,refs:M,elements:I,floatingStyles:F}),[p,D,M,I,F])}const toe=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?iE({element:r.current,padding:s}).fn(n):{}:r?iE({element:r,padding:s}).fn(n):{}}}},lE=(e,t)=>{const n=Yie(e);return{name:n.name,fn:n.fn,options:[e,t]}},noe=(e,t)=>{const n=Xie(e);return{name:n.name,fn:n.fn,options:[e,t]}},roe=(e,t)=>{const n=Jie(e);return{name:n.name,fn:n.fn,options:[e,t]}},soe=(e,t)=>{const n=Gie(e);return{name:n.name,fn:n.fn,options:[e,t]}},ioe=(e,t)=>{const n=toe(e);return{name:n.name,fn:n.fn,options:[e,t]}},ooe={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},aoe={beaconOptions:{offset:-18}},Z2={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},loe={isFixed:!1,locale:Z2,placement:"bottom"},coe={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Qt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},Yr={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"},Xe={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Lo={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Kt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},uoe="react-joyride-portal";function doe(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function Yu(...e){return tie({all:!0,isMergeableObject:t=>!(!hs.plainObject(t)||h.isValidElement(t))})(...e)}function eM(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function ya(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=Mw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&eM(e.type)==="function")try{o=ya(e.type({}),t)}catch{o=Mw(n)}else o=Mw(n);return o}function Xr(e,t,n,...r){if(!e)return;const s=new Date,o=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}.${String(s.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function foe(e,t){const n=doe(t);return{...e,...n}}function Up(){}function poe(e){return Object.keys(e)}function uy(e,...t){if(!hs.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 cE(e,...t){if(!hs.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 Lv(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(eM(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(hs.string(s)&&s.includes("{current}"))return h.cloneElement(e,{children:r(s)});if(Array.isArray(s))return h.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):Lv(o,t,n))});if(hs.function(e.type)&&!Object.values(e.props).length)try{return Lv(e.type({}),t,n)}catch{return e}return e}function uE(e){return poe(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function zk(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function dE(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 Hk(e){return e?e.getBoundingClientRect():null}function hoe(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((o,a)=>o-a),s=Math.floor(r.length/2);return r.length%2===0?(r[s-1]+r[s])/2:r[s]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function Ci(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 moe(e,t,n){const r=Hk(e),s=Fd(e),o=s?!s.isSameNode(Ks()):!1,a=n??zd(e);let l=0,c=(r==null?void 0:r.top)??0;return o&&a?c=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!o&&!a&&(c+=l),s.isSameNode(Ks())||(c+=Ks().scrollTop)),Math.floor(c-t)}function Fd(e,t){if(!e)return Ks();const n=z2(e);if(n){if(n.isSameNode(Ks()))return t?document:Ks();if(!(n.scrollHeight>n.offsetHeight))return Ks()}return n}function goe(e){const t=e.getBoundingClientRect(),n=Ks(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function yoe(e,t){if(!e)return 0;const n=z2(e)??Ks(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Hk(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(tM(e)||xoe(e))){const p=e.getBoundingClientRect(),u=p.top-((s==null?void 0:s.top)??0),f=u+p.height,m=n.clientHeight,g=m*.2;u>=g&&f<=m-g?c=o:c=u+o}const d=Math.floor(c-t-r);return d<0?0:d}function xoe(e){return e.offsetParent!==document.body}function tM(e){if(!e)return!1;const t=Fd(e);return t?!t.isSameNode(Ks()):!1}function zd(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?zd(e.parentNode,t):!1}function Am(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 fE(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Xe.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Fd(s):Ks(),l=a?!a.isSameNode(Ks()):!1;return(r.isFixed||zd(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Ks(){return document.scrollingElement??document.documentElement}function pE(e,t){const{duration:n,element:r}=t;let s=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=lie.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function woe(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,o,a)=>s+s+o+o+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const nM={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Pm={...nM,borderRadius:4,padding:8};function boe(e,t){const{styles:n}=e,r=Yu(n??{},t.styles??{});let{width:s}=t;zk()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const o={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return Yu({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...nM,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(${woe(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:{...Pm,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Pm,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Pm,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Pm,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...o,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:s},tooltipContainer:{lineHeight:1.4,textAlign:"center"},tooltipTitle:{fontSize:18,margin:0},tooltipContent:{paddingBottom:12,paddingTop:12},tooltipFooter:{alignItems:"center",display:"flex",justifyContent:"flex-end"},tooltipFooterSpacer:{flex:1}},r)}const voe=["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 Bk(e,t){if(!t)return null;const n=Yu(loe,cE(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=Yu(ooe,e.options??{},cE(t,...voe)),s=boe(e,{...n,...r}),o=Yu(aoe,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:Yu(Z2,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:koe(r.spotlightPadding),styles:s}}function koe(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 Soe(e,t,n){const{action:r}=t,s=n&&[Qt.PREV,Qt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function rM(e,t=!1){return hs.plainObject(e)?e.target?!0:(Xr(t,"tour","target is missing from the step"),!1):(Xr(t,"tour","step must be an object"),!1)}function sM(e,t=!1){return hs.array(e)?e.every(n=>rM(n,t)):(Xr(t,"tour","steps must be an array"),!1)}var Noe=class{constructor(e){pr(this,"beaconPosition",null);pr(this,"debug");pr(this,"eventListeners",new Map);pr(this,"listeners",new Set);pr(this,"props");pr(this,"snapshot");pr(this,"state");pr(this,"steps");pr(this,"tooltipPosition",null);pr(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});pr(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);pr(this,"getServerSnapshot",()=>this.snapshot);pr(this,"getSnapshot",()=>this.snapshot);pr(this,"getEventState",()=>uy(this.snapshot,"positioned"));pr(this,"getState",()=>uy(this.snapshot,"positioned"));pr(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Xr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Xe.BEACON_BEFORE||this.state.lifecycle===Xe.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});pr(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});pr(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});pr(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)}});pr(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));pr(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,o=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:o,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!Ik(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=hs.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,hs.number(t)&&Xr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):hs.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&Xr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Qt.INIT,controlled:s,index:o,lifecycle:Xe.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Kt.READY:Kt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Kt.WAITING&&e.size>0?{...e,status:Kt.RUNNING}:e}getStep(e){return Bk(this.props,this.steps[e??this.state.index])}};function joe(e){return new Noe(e)}function hE(e,t){return Math.min(Math.max(e,0),t)}function Coe(e,t,n){const r=h.useRef(t),s=h.useRef(n);return r.current=t,s.current=n,h.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(k=null)=>{const{index:y,status:b}=o();b===Kt.RUNNING&&e.current.updateState({action:Qt.CLOSE,index:y+1,origin:k,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:k=>{const{controlled:y,size:b,status:x}=o();if(y){Xr(r.current,"tour","go() is not supported in controlled mode");return}x===Kt.RUNNING&&e.current.updateState({action:Qt.GO,index:k,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:k<b?x:Kt.FINISHED,waiting:!1})},info:()=>uy(e.current.getSnapshot(),"positioned"),next:k=>{const{index:y,size:b,status:x}=o();x===Kt.RUNNING&&e.current.updateState({action:Qt.NEXT,index:hE(y+1,b),lifecycle:Xe.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:k}=o();k===Kt.RUNNING&&e.current.updateState({action:Qt.UPDATE,lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:k=>{const{index:y,size:b,status:x}=o();x===Kt.RUNNING&&e.current.updateState({action:Qt.PREV,index:hE(y-1,b),lifecycle:Xe.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},reset:(k=!1)=>{const{controlled:y}=o();if(y){Xr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Qt.RESET,index:0,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:k?Kt.RUNNING:Kt.READY,waiting:!1})},skip:k=>{const{status:y}=o();y===Kt.RUNNING&&e.current.updateState({action:Qt.SKIP,lifecycle:Xe.COMPLETE,origin:k,positioned:!1,scrolling:!1,status:Kt.SKIPPED,waiting:!1})},start:k=>{const{index:y,size:b}=o();s.current(),e.current.updateState({action:Qt.START,index:hs.number(k)?k:y,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:b?Kt.RUNNING:Kt.WAITING,waiting:!1},!0)},stop:(k=!1)=>{const{index:y,status:b}=o();[Kt.FINISHED,Kt.SKIPPED].includes(b)||e.current.updateState({action:Qt.STOP,index:y+(k?1:0),lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:Kt.PAUSED,waiting:!1})}}},[e])}const Eoe=new Set(["origin","positioned"]);function _oe(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Xr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const o=n.current;if(n.current=s,!o)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==o[c]&&!Eoe.has(c)&&(a[c]={from:o[c],to:s[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||Xr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Aoe(e,t,n){const r=h.useRef(e),s=h.useRef(t);return r.current=e,s.current=t,h.useCallback((o,a,l)=>{var d;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(d=r.current)==null||d.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function ll(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],o=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(o):s===r&&o!==r},previous:t}}function Poe(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:d,index:p,lifecycle:u,positioned:f,scrolling:m,size:g,status:w}=a,k=T2(l)??null,y=h.useRef(null),b=h.useRef(o),x=h.useRef(a),j=h.useRef(s),E=h.useRef(l),N=h.useRef(k),T=h.useRef(n),$=h.useRef(null),z=h.useRef(null),K=h.useRef(null);b.current=o,x.current=a,j.current=s,E.current=l,N.current=k,T.current=n;const B=()=>{$.current&&(clearInterval($.current),$.current=null),z.current=null,K.current&&(K.current.cancel(),K.current=null)};h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L}=ll(x.current,j.current);(L("action",[Qt.NEXT,Qt.PREV,Qt.SKIP,Qt.CLOSE])||y.current===Qt.CLOSE&&d===Qt.START)&&(y.current=d)},[d]),h.useEffect(()=>{if(!j.current)return()=>{B()};const{hasChanged:L}=ll(x.current,j.current),D=E.current;if(L("index")&&B(),w!==Kt.RUNNING||!D||u!==Xe.INIT)return()=>{B()};const{hasChangedTo:R}=ll(x.current,j.current);R("status",Kt.RUNNING)&&[Kt.IDLE,Kt.READY,Kt.PAUSED].includes(j.current.status)&&r(Yr.TOUR_START,D),c.current.cleanupPositionData();const{debug:M}=b.current;if(D.before&&!K.current){Xr(M,`step:${p}`,"before()",D),K.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(Yr.STEP_BEFORE_HOOK,D,{action:y.current??x.current.action});const I=()=>{K.current=null,c.current.updateState({action:y.current??x.current.action,waiting:!1,lifecycle:Xe.READY})},F=new AbortController,P=D.beforeTimeout;K.current={cancel:()=>F.abort()};const O=P?setTimeout(()=>{F.signal.aborted||(Xr(M,`step:${p}`,"before()","timed out",`${P}ms`),F.abort(),t(D,"before_hook"),r(Yr.ERROR,D,{error:new Error("Step before hook timed out")}),I())},P):null;D.before({...c.current.getState(),action:y.current??c.current.getState().action,step:D}).then(()=>{F.signal.aborted||(O&&clearTimeout(O),I())}).catch(_=>{F.signal.aborted||(O&&clearTimeout(O),t(D,"before_hook"),r(Yr.ERROR,D,{error:_ instanceof Error?_:new Error(String(_))}),I())})}else if(!K.current){$.current&&z.current!==D.target&&B();const I=Ci(D.target);if(I&&Am(I))B(),c.current.updateState({action:y.current??Qt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(D.targetWaitTimeout===0)c.current.updateState({action:y.current??Qt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(!$.current){const{targetWaitTimeout:F}=D,P=Date.now();z.current=D.target,Xr(M,`step:${p}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),$.current=setInterval(()=>{const O=Ci(D.target),_=Date.now()-P,Z=_>=F;(O&&Am(O)||Z)&&(Xr(M,`step:${p}`,"polling",O&&Am(O)?"found":"timed out",`${_}ms`),B(),c.current.updateState({action:y.current??Qt.UPDATE,lifecycle:Xe.READY,waiting:!1}))},100)}}return()=>{B()}},[t,r,p,u,w,c]),h.useEffect(()=>{if(!j.current)return;const{hasChanged:L,hasChangedTo:D,previous:R}=ll(x.current,j.current),M=E.current;if(!M)return;const I=Ci(M.target),F=!!I;if(F&&Am(I)){if(D("lifecycle",Xe.READY)&&R.lifecycle===Xe.INIT&&r(Yr.STEP_BEFORE,M,{action:y.current??x.current.action}),D("lifecycle",Xe.READY)){const P=x.current,O=Soe(M,P,b.current.continuous)?Xe.TOOLTIP:Xe.BEACON,_=Ci(M.scrollTarget??M.spotlightTarget??M.target),Z=fE({isFirstStep:P.index===0,scrollToFirstStep:b.current.scrollToFirstStep,step:M,target:_,targetLifecycle:O}),ee=O===Xe.TOOLTIP?Xe.TOOLTIP_BEFORE:Xe.BEACON_BEFORE;Xr(b.current.debug,`step:${p}`,"scroll",Z?"needed":"skipped"),c.current.updateState({action:Qt.UPDATE,lifecycle:ee,scrolling:Z})}}else if(x.current.status===Kt.RUNNING&&u!==Xe.INIT&&u!==Xe.COMPLETE&&L("lifecycle")){Xr(b.current.debug,`step:${p}`,F?"Target not visible":"Target not mounted",M),t(M,"target_not_found"),r(Yr.TARGET_NOT_FOUND,M);const P=x.current;P.controlled||c.current.updateState({action:Qt.UPDATE,index:P.index+(P.action===Qt.PREV?-1:1),lifecycle:Xe.INIT})}},[t,r,p,u,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L,previous:D}=ll(x.current,j.current),R=E.current,M=N.current;if(R&&L("lifecycle",Xe.TOOLTIP_BEFORE)&&D.lifecycle===Xe.BEACON){const P=Ci(R.scrollTarget??R.spotlightTarget??R.target);if(fE({isFirstStep:x.current.index===0,scrollToFirstStep:b.current.scrollToFirstStep,step:R,target:P,targetLifecycle:Xe.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const I=u===Xe.BEACON_BEFORE||u===Xe.TOOLTIP_BEFORE;if(R&&I&&!m){const P=u===Xe.TOOLTIP_BEFORE?Xe.TOOLTIP:Xe.BEACON;c.current.updateState({action:Qt.UPDATE,lifecycle:P})}R&&L("lifecycle",Xe.BEACON)&&r(Yr.BEACON,R),R&&L("lifecycle",Xe.TOOLTIP)&&r(Yr.TOOLTIP,R);const F=x.current;if((F.status===Kt.RUNNING||F.controlled&&F.status===Kt.PAUSED&&R)&&M&&L("lifecycle",Xe.COMPLETE)&&D.lifecycle===Xe.TOOLTIP&&(r(Yr.STEP_AFTER,M,{action:y.current??Qt.UPDATE,index:D.index??F.index,lifecycle:F.lifecycle}),M.after)){r(Yr.STEP_AFTER_HOOK,M,{action:y.current??Qt.UPDATE,index:D.index??F.index,lifecycle:F.lifecycle});try{M.after({...c.current.getState(),action:y.current??Qt.UPDATE,index:D.index??F.index,lifecycle:F.lifecycle,step:M})}catch{}}},[r,u,f,m,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L,previous:D}=ll(x.current,j.current),R=E.current,M=N.current;g&&!R&&u===Xe.INIT&&c.current.updateState({action:Qt.UPDATE,lifecycle:Xe.COMPLETE,status:Kt.FINISHED}),!x.current.controlled&&w===Kt.RUNNING&&L("lifecycle",Xe.COMPLETE)&&p<g&&c.current.updateState({action:Qt.UPDATE,lifecycle:Xe.INIT}),L("lifecycle",Xe.COMPLETE)&&p>=g&&c.current.updateState({action:Qt.UPDATE,lifecycle:Xe.COMPLETE,status:Kt.FINISHED});const I=R??M??Bk(b.current,b.current.steps[p-1]);if(I&&L("status",[Kt.FINISHED,Kt.SKIPPED])){let F;R?F=p:M?F=D.index??p:F=p-1,r(Yr.TOUR_END,I,{index:F}),x.current.controlled||T.current.reset(),y.current=null}R&&L("action",Qt.STOP)&&(y.current=null,r(Yr.TOUR_STATUS,R)),R&&L("action",Qt.RESET)&&(r(Yr.TOUR_STATUS,R),y.current=null)},[d,r,p,u,g,w,c])}function Ioe({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:d}=n,p=h.useRef(void 0),u=h.useRef(r),f=h.useRef(e);u.current=r,f.current=e,h.useEffect(()=>{const m=p.current;if(p.current=n,!m||n===m)return;const{hasChanged:g}=ll(n,m);if(Ik(m.steps,d)||(sM(d,o)?s.current.setSteps(d):(Xr(o,"tour","Steps are not valid",d),t(Yr.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&f.current.start(c??a):f.current.stop();else if(hs.number(c)&&g("stepIndex")){const w=hs.number(m.stepIndex)&&m.stepIndex<c?Qt.NEXT:Qt.PREV;[Kt.FINISHED,Kt.SKIPPED].includes(u.current.status)||s.current.updateState({action:w,index:c,lifecycle:Xe.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,d,s])}function Toe(e,t){var l,c,d,p;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Xe.BEACON_BEFORE&&(n!=null&&n.placement)){const u=Roe(n);["bottom"].includes(n.placement)||(a+=Math.floor(u-s))}else if(r===Xe.TOOLTIP_BEFORE){const{placement:u}=o;if(u==="top"){const f=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,g=o.offset+o.spotlightPadding.top+m;a-=f+g}else if(u==="left"||u==="right"){const f=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,m=((p=Ci(o.target))==null?void 0:p.getBoundingClientRect().height)??0,g=s+o.spotlightPadding.top+m/2-f/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Roe(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 Moe({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:d,status:p}=r,u=h.useRef(null),f=h.useRef(r),m=h.useRef(t),g=h.useRef(n),w=h.useRef(s);f.current=r,m.current=t,g.current=n,w.current=s,h.useEffect(()=>()=>{var k;(k=u.current)==null||k.call(u)},[]),h.useEffect(()=>{var E;if(!m.current||!w.current)return;const{hasChangedTo:k}=ll(f.current,m.current),y=w.current,{debug:b}=g.current,{scrollDuration:x}=y,j=l===Xe.BEACON_BEFORE||l===Xe.TOOLTIP_BEFORE;if(p===Kt.RUNNING&&j&&d&&k("positioned",!0)){const N=Ci(y.scrollTarget??y.spotlightTarget??y.target),T=o.current.getPositionData("beacon"),$=Fd(N),z=$?!$.isSameNode(Ks()):!1;(E=u.current)==null||E.call(u),(async()=>{if(z&&!zd($)){const F=Ks(),P=goe($),O={initial:F.scrollTop,target:P,element:F,duration:x};e(Yr.SCROLL_START,y,{scroll:O});const{cancel:_,promise:Z}=pE(P,{element:F,duration:x});u.current=_,await Z,e(Yr.SCROLL_END,y,{scroll:O})}const B=Math.floor(yoe(N,y.scrollOffset))||0,L=z?B:Toe(B,{beaconPosition:T,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Xr(b,`step:${a}`,"scroll",z?"custom":"document",`${B} → ${L}`);const D=$,R={initial:D.scrollTop,target:L,element:D,duration:x};e(Yr.SCROLL_START,y,{scroll:R});const{cancel:M,promise:I}=pE(L,{element:D,duration:x});u.current=M,await I,e(Yr.SCROLL_END,y,{scroll:R}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,d,p,o])}function Loe(e){const t=yse(()=>foe(coe,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=h.useRef(joe(t)),d=dI.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[p,u]=h.useState([]),f=h.useCallback((E,N)=>{u(T=>[...T,{reason:N,step:E}])},[]),m=h.useCallback(()=>{u([])},[]);_oe(c,n);const g=Coe(c,n,m),w=Aoe(s,g,c),{index:k,size:y,status:b}=d,x=T2(d),j=h.useMemo(()=>Bk(t,l[k]),[k,t,l]);return xse(()=>{o&&y&&sM(l,n)&&g.start(a??r)}),gse(()=>{o&&y&&b===Kt.IDLE&&c.current.updateState({status:Kt.READY})},[o,y,b]),Ioe({controls:g,emitEvent:w,props:t,state:d,store:c}),Poe({addFailure:f,controls:g,emitEvent:w,previousState:x,props:t,state:d,step:j,store:c}),Moe({emitEvent:w,previousState:x,props:t,state:d,step:j,store:c}),{controls:g,failures:p,mergedProps:t,state:d,step:j,store:c}}function Ooe(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,s=!1;if(e)if(hs.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=uoe,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const $oe={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Doe({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Up;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
268
- @keyframes joyride-loader-spin {
269
- to { transform: rotate(360deg); }
270
- }
271
- `)),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:o,...a}=t.styles.loader;let l;if(n){const c=n;l=yt.createElement(c,{step:t})}else l=yt.createElement("div",{style:{...$oe,height:s,width:o,borderTopColor:t.primaryColor}});return yt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Foe={height:0,isFixed:!1,left:0,top:0,width:0};function Ef(e,t){const n=Ci(e);if(!n)return Foe;const r=Hk(n),s=zd(n),o=moe(n,t.top,s);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:s,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:o,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function zoe(e,t,n){const[r,s]=h.useState(()=>Ef(e,t)),o=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),c=h.useRef(null),d=h.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(u=>{const f=Ef(e,t);return u.top===f.top&&u.left===f.left&&u.width===f.width&&u.height===f.height&&u.isFixed===f.isFixed?u:f})},100)},[e,t]);h.useEffect(()=>{let u=null;const f=g=>{a.current=Fd(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(Ef(e,t))},m=Ci(e);return m?f(m):(u=new MutationObserver(()=>{const g=Ci(e);g&&(u==null||u.disconnect(),u=null,f(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(o.current)}},[e,t,d]),h.useEffect(()=>{l.current&&!n&&s(Ef(e,t)),l.current=n},[n,e,t]);let p=r;return l.current&&!n&&(p=Ef(e,t)),p}function Hoe(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function mE(e,t,n,r,s){if(n<=0||r<=0)return"";const o=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+o} ${t}`;return a+=`H${e+n-o}`,a+=`A${o} ${o} 0 0 1 ${e+n} ${t+o}`,a+=`V${t+r-o}`,a+=`A${o} ${o} 0 0 1 ${e+n-o} ${t+r}`,a+=`H${e+o}`,a+=`A${o} ${o} 0 0 1 ${e} ${t+r-o}`,a+=`V${t+o}`,a+=`A${o} ${o} 0 0 1 ${e+o} ${t}Z`,a}const Boe=[Xe.BEACON_BEFORE,Xe.BEACON];function Woe(e){var I,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:d,spotlightPadding:p,spotlightRadius:u,spotlightTarget:f,styles:m,target:g,waiting:w}=e,k=wse(),y=zoe(f??g,p,d||w),b=h.useRef(null),x=(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE)&&l!=="center",[j,E]=h.useState(!1),N=c?(I=b.current)==null?void 0:I.offsetParent:null,T=(N==null?void 0:N.clientWidth)??k.width,$=(N==null?void 0:N.clientHeight)??hoe()??k.height,z=((F=m.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",K=h.useMemo(()=>{const{backgroundColor:P,mixBlendMode:O,..._}=m.overlay;return{height:$,pointerEvents:"none",..._}},[$,m.overlay]),B=x&&!d&&!w;h.useEffect(()=>{B?requestAnimationFrame(()=>E(!0)):E(!1)},[B]);const L=n&&Boe.includes(s),D=!n&&s!==Xe.TOOLTIP;if(r||!w&&(L||D))return null;let R="";if(B)if(c&&N){const P=Ci(f??g);if(P){const O=dE(P),_=dE(N);R=mE(O.left-_.left-p.left,O.top-_.top-p.top,P.offsetWidth+p.left+p.right,P.offsetHeight+p.top+p.bottom,u)}}else R=mE(y.left,y.top,y.width,y.height,u);const M=Hoe(T,$,R);return yt.createElement("div",{ref:b,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:K},yt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:$,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:T}},yt.createElement("path",{d:M,fill:z,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),R&&yt.createElement("path",{d:R,fill:z,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),R&&Object.keys(m.spotlight).length>0&&yt.createElement("path",{d:R,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function iM(e){const{children:t,element:n}=e;return n?Ir.createPortal(t,n):null}const Voe='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Koe(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return Up;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Voe)],{shiftKey:l}=o;if(!a.length)return;o.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 o=e.querySelector(t);o&&(s=setTimeout(()=>{o.focus({preventScroll:!0})},100))}return()=>{var o;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(o=n.current)==null||o.focus({preventScroll:!0})}},[e,t])}function ka(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 Uoe(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...ka(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...ka(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...ka(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...ka(e,t,n)};default:return null}}function qoe(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...ka(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...ka(e,r,n)};case"left":return{right:-n,top:t.y??0,...ka(e,r,n)};case"right":return{left:-n,top:t.y??0,...ka(e,r,n)};default:return{}}}function Yoe({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!ka(r,n,o))return null;c=yt.createElement("span",{style:{flexShrink:0}},yt.createElement(l,{base:n,placement:r,size:o}))}else{const d=Uoe(r,n,o);if(!d)return null;c=yt.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},yt.createElement("polygon",{fill:"currentColor",points:d.points}))}return yt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...qoe(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function Goe(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:d,step:p,styles:u}=e,f=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return Up;const k=document.createElement("style");k.id="joyride-beacon-animation",a&&k.setAttribute("nonce",a),k.appendChild(document.createTextNode(`
272
- @keyframes joyride-beacon-inner {
273
- 20% {
274
- opacity: 0.9;
275
- }
276
-
277
- 90% {
278
- opacity: 0.7;
279
- }
280
- }
281
-
282
- @keyframes joyride-beacon-outer {
283
- 0% {
284
- transform: scale(1);
285
- }
286
-
287
- 45% {
288
- opacity: 0.7;
289
- transform: scale(0.75);
290
- }
291
-
292
- 100% {
293
- opacity: 0.9;
294
- transform: scale(1);
295
- }
296
- }
297
- `)),document.head.appendChild(k);const y=setTimeout(()=>{hs.domElement(f.current)&&c&&f.current.focus()},0);return()=>{clearTimeout(y);const b=document.getElementById("joyride-beacon-animation");b!=null&&b.parentNode&&b.parentNode.removeChild(b)}},[m,a,c]);const g=ya(o.open);let w;if(t){const k=t;w=yt.createElement(k,{continuous:n,index:r,isLastStep:s,size:d,step:p})}else w=yt.createElement("span",{style:u.beacon},yt.createElement("span",{style:u.beaconOuter}),yt.createElement("span",{style:u.beaconInner}));return yt.createElement("button",{ref:f,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:u.beaconWrapper,title:g,type:"button"},w)}function Xoe({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return yt.createElement("button",{style:o,type:"button",...t},yt.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"},yt.createElement("g",null,yt.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 Joe(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:d,content:p,styles:u,title:f}=l,m={};d.includes("primary")&&(m.primary=yt.createElement("button",{"data-testid":"button-primary",style:u.buttonPrimary,type:"button",...o})),d.includes("skip")&&!s&&(m.skip=yt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:u.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(m.back=yt.createElement("button",{"data-testid":"button-back",style:u.buttonBack,type:"button",...t})),m.close=d.includes("close")&&yt.createElement(Xoe,{"data-testid":"button-close",styles:u.buttonClose,...n});const g=f?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":ya(p),"aria-describedby":"joyride-tooltip-content"};return yt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:u.tooltip,...c,...g},yt.createElement("div",{style:u.tooltipContainer},f&&yt.createElement("h4",{id:"joyride-tooltip-title",style:u.tooltipTitle},f),yt.createElement("div",{id:"joyride-tooltip-content",style:u.tooltipContent},p)),d.some(w=>w==="back"||w==="primary"||w==="skip")&&yt.createElement("div",{style:u.tooltipFooter},yt.createElement("div",{style:u.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function Qoe(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=y=>{y.preventDefault(),n.prev(Lo.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(Lo.BUTTON_CLOSE):n.close(Lo.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(Lo.BUTTON_PRIMARY);return}n.next(Lo.BUTTON_PRIMARY)},p=y=>{y.preventDefault(),n.skip(Lo.BUTTON_SKIP)},u=()=>{const{back:y,close:b,last:x,next:j,nextWithProgress:E,skip:N}=a.locale,T=ya(y),$=ya(b),z=ya(x),K=ya(j),B=ya(N);let L=b,D=$;if(t){if(L=j,D=K,a.showProgress&&!s){const R=ya(E,{step:r+1,steps:o});L=Lv(E,r+1,o),D=R}s&&(L=x,D=z)}return{backProps:{"aria-label":T,children:y,"data-action":"back",onClick:l,role:"button",title:T},closeProps:{"aria-label":$,children:b,"data-action":"close",onClick:c,role:"button",title:$},primaryProps:{"aria-label":D,children:L,"data-action":"primary",onClick:d,role:"button",title:D},skipProps:{"aria-label":B,children:N,"data-action":"skip",onClick:p,role:"button",title:B},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:f,beaconComponent:m,tooltipComponent:g,...w}=a;let k;if(g){const y=g;k=yt.createElement(y,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:w})}else k=yt.createElement(Joe,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:w});return k}function Zoe(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function eae(e,t,n){var r,s;return e?[soe()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[roe({crossAxis:!1,fallbackPlacements:Zoe(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function tae(e){var O,_,Z,ee,V;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:d,shouldScroll:p,size:u,step:f,target:m,updateState:g}=e,w=h.useRef(null),k=h.useRef({}),y=h.useRef({}),b=f.placement==="center",x=f.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})}),[]),E=h.useMemo(()=>tM(m)?Fd(m):void 0,[m]),N=h.useMemo(()=>zd(m),[m]),T=h.useMemo(()=>E?{boundary:E,rootBoundary:"viewport"}:{},[E]),$=b||x?"bottom":f.placement,z=b?"fixed":((O=f.floatingOptions)==null?void 0:O.strategy)??(f.isFixed||N?"fixed":"absolute"),K=h.useMemo(()=>{var ae,fe,xe,Se;return b?[{name:"center",fn:({rects:ue})=>({x:(window.innerWidth-ue.floating.width)/2,y:(window.innerHeight-ue.floating.height)/2})}]:[lE(({placement:ue})=>{var me;let Ee="right";ue.startsWith("top")?Ee="top":ue.startsWith("bottom")?Ee="bottom":ue.startsWith("left")&&(Ee="left");const le=f.spotlightTarget?0:f.spotlightPadding[Ee];return f.offset+le+((me=f.floatingOptions)!=null&&me.hideArrow?0:f.arrowSize)},[f.offset,f.spotlightPadding,f.spotlightTarget,f.arrowSize,(ae=f.floatingOptions)==null?void 0:ae.hideArrow]),...eae(x,f,$),noe({padding:10,...T,...(fe=f.floatingOptions)==null?void 0:fe.shiftOptions}),...(xe=f.floatingOptions)!=null&&xe.hideArrow?[]:[ioe({element:w,padding:f.arrowSpacing},[f.arrowSpacing,f.arrowBase])],...((Se=f.floatingOptions)==null?void 0:Se.middleware)??[]]},[b,f,x,$,T]),B=aE({...b?{elements:{reference:j}}:{},placement:$,strategy:z,middleware:K}),L=aE({strategy:z,placement:f.beaconPlacement??(x||b?"bottom":f.placement),middleware:h.useMemo(()=>{var ae,fe;return[lE(((fe=(ae=f.floatingOptions)==null?void 0:ae.beaconOptions)==null?void 0:fe.offset)??-18)]},[(Z=(_=f.floatingOptions)==null?void 0:_.beaconOptions)==null?void 0:Z.offset]),whileElementsMounted:sE});y.current=B.middlewareData,k.current=L.middlewareData,h.useEffect(()=>{var xe;const{floating:ae,reference:fe}=B.elements;if(!(!fe||!ae||s!==Xe.TOOLTIP))return sE(fe,ae,B.update,(xe=f.floatingOptions)==null?void 0:xe.autoUpdate)},[s,B.update,(ee=f.floatingOptions)==null?void 0:ee.autoUpdate,f.target,B.elements]),h.useEffect(()=>{!b&&m&&B.refs.setReference(m),m&&L.refs.setReference(m)},[L.refs,b,m,B.refs]),h.useEffect(()=>{B.isPositioned&&c("tooltip",{placement:B.placement,x:B.x??0,y:B.y??0,middlewareData:y.current})},[c,B.isPositioned,B.placement,B.x,B.y]),h.useEffect(()=>{L.isPositioned&&c("beacon",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:k.current})},[c,L.isPositioned,L.placement,L.x,L.y]);const D=f.zIndex+100,R=h.useCallback(ae=>{ae.type==="mouseenter"&&f.beaconTrigger!=="hover"||g({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[f.beaconTrigger,g]),M=h.useCallback(ae=>{ae&&(B.refs.setFloating(ae),d(ae))},[B.refs,d]),{arrow:I,floater:F}=f.styles;let P=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const ae=uE({...F,...B.floatingStyles,zIndex:D,opacity:a&&B.isPositioned?1:0,...!a&&{transition:"none"}});P=yt.createElement("div",{ref:M,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:ae},yt.createElement(Qoe,{continuous:t,controls:n,index:r,isLastStep:r+1===u,size:u,step:f}),!b&&!((V=f.floatingOptions)!=null&&V.hideArrow)&&yt.createElement(Yoe,{arrowComponent:f.arrowComponent,arrowRef:w,base:f.arrowBase,placement:B.placement,position:B.middlewareData.arrow,size:f.arrowSize,styles:I}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&(P=yt.createElement("div",{ref:L.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:uE({...L.floatingStyles,zIndex:D})},yt.createElement(Goe,{beaconComponent:f.beaconComponent,continuous:t,index:r,isLastStep:r+1===u,locale:f.locale,nonce:o,onInteract:R,shouldFocus:p,size:u,step:f,styles:f.styles})));return yt.createElement(iM,{element:l},P)}function nae(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:d,step:p,updateState:u}=e,[f,m]=h.useState(null);Koe(p.disableFocusTrap?null:f,"[data-action=primary]");const g=Ci(p.target),w=s===Xe.TOOLTIP;return!rM(p)||!hs.domElement(g)?null:yt.createElement(tae,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:w,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:d,step:p,target:g,updateState:u})}function rae({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,p=Ooe(c),{index:u,lifecycle:f,status:m}=n,g=m===Kt.RUNNING,[w,k]=h.useState(!1),y=h.useRef(null),b=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?b===0?k(!0):y.current=setTimeout(()=>{k(!0)},b):k(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[b,n.waiting]),h.useEffect(()=>{if(!g)return;const E=N=>{!r||f!==Xe.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Lo.KEYBOARD):e.close(Lo.KEYBOARD))};return document.body.addEventListener("keydown",E,{passive:!0}),()=>{document.body.removeEventListener("keydown",E)}},[e,g,f,r]);const x=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Lo.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Lo.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===Qt.START&&!r.skipBeacon&&r.placement!=="center";return yt.createElement(yt.Fragment,null,f!==Xe.INIT&&yt.createElement(nae,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(u!==0||d),step:r,updateState:s.current.updateState}),yt.createElement(iM,{element:p},yt.createElement(yt.Fragment,null,w&&yt.createElement(Doe,{nonce:l,step:r}),!j&&yt.createElement(Woe,{...r,continuous:o,lifecycle:f,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function sae(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=Loe(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>uy(s,"positioned"),[s]),step:o,Tour:zk()?yt.createElement(rae,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function iae(e){const{Tour:t}=sae(e);return t}function oae(e){return zk()?yt.createElement(iae,e):null}function aae(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 lae(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function cae(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Im="af:onboarding";function uae({page:e,hasNodes:t=!1}){const{t:n}=zn(),[r,s]=h.useState(!1),[o,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?aae(n):t?lae(n):cae(n),[e,t,n]);return h.useEffect(()=>{const d=localStorage.getItem(Im),p=d?JSON.parse(d):{};if(p.completed||p[e]){s(!1),a([]);return}localStorage.setItem(Im,JSON.stringify({...p,[e]:!0})),a(c),s(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const d=p=>{var g;const u=p.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 w=localStorage.getItem(Im)||"{}",k=JSON.parse(w);m===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(Im,JSON.stringify(k)),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||o.length===0?null:i.jsx(oae,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function dae(){const{navigate:e,path:t}=Yo(),[n,r]=h.useState([]),[s,o]=h.useState(!1);if(h.useEffect(()=>{let p=!1;const u=async()=>{try{const m=await fetch("/api/pipeline-recent-runs");if(!m.ok)return;const g=await m.json();if(p)return;const w=Array.isArray(g.runs)?g.runs:[];r(w.filter(k=>k&&k.status==="running"))}catch{}};u();const f=window.setInterval(u,3e3);return()=>{p=!0,window.clearInterval(f)}},[]),n.length===0)return null;const a=p=>{const u=new URLSearchParams({flowId:p.flowId,flowSource:p.flowSource||"workspace"});e(`/flow?${u.toString()}`),o(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,c=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return i.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&i.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:n.map(p=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(p.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(p),title:`${p.flowId} · ${p.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:p.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:p.runId.slice(0,12)})]},`${p.flowId}:${p.runId}`))}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):o(p=>!p),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}function oM(e){return e==="/likee-context"||e==="/likee_context"}class fae 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,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function pae({authUser:e}){const{path:t}=Yo();return t==="/projects"||t==="/"?i.jsx(wu,{authUser:e}):t==="/nodes"?i.jsx(wu,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(wu,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(wu,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(wu,{authUser:e,resourceKind:"skills"}):t==="/mcps"?i.jsx(Yre,{}):t==="/flow"?i.jsx(Sq,{}):t==="/workspace"?i.jsx(kG,{}):t.startsWith("/display")?i.jsx(v2,{}):t==="/settings"?i.jsx(Hre,{authUser:e}):t==="/admin/usage"?i.jsx(Kre,{authUser:e}):t==="/feedback"?i.jsx(Ure,{}):oM(t)?i.jsx(P2,{}):i.jsx(wu,{})}function hae({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=h.useState(""),[o,a]=h.useState(""),[l,c]=h.useState(!1),[d,p]=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}),p(g.error?String(g.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(m.message||m))}};h.useEffect(()=>{u()},[]);const f=async m=>{m.preventDefault(),c(!0),p("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),w=await g.json().catch(()=>({}));if(!g.ok)throw new Error(w.error||"登录失败");n({loading:!1,authenticated:!0,user:w.user||null,setupRequired:!1})}catch(g){p(String(g.message||g))}finally{c(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:f,children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{value:r,onChange:m=>s(m.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{type:"password",value:o,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?i.jsx("p",{className:"af-auth-error",children:d}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function mae({authUser:e,onLogout:t}){const{path:n}=Yo(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(uae,{page:r?"flow":"projects"}):null,r?null:i.jsx(a$,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(pae,{authUser:e})}),i.jsx(dae,{})]})}function gae(){return i.jsx(fae,{children:i.jsx(BO,{children:i.jsx(yae,{})})})}function yae(){const{path:e}=Yo();return e.startsWith("/display")?i.jsx(v2,{}):oM(e)?i.jsx(P2,{}):i.jsx(hae,{children:({user:t,onLogout:n})=>i.jsx(mae,{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 gE=document.querySelector('link[rel="icon"]');gE&&(gE.href=TA);Dw.createRoot(document.getElementById("root")).render(i.jsx(yt.StrictMode,{children:i.jsx(gae,{})}));