@fieldwangai/agentflow 0.1.134 → 0.1.135

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,350 +0,0 @@
1
- var l2=Object.defineProperty;var c2=(e,t,n)=>t in e?l2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tn=(e,t,n)=>c2(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 jd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function da(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mE={exports:{}},Om={},gE={exports:{}},Mt={};/**
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 df=Symbol.for("react.element"),u2=Symbol.for("react.portal"),d2=Symbol.for("react.fragment"),f2=Symbol.for("react.strict_mode"),p2=Symbol.for("react.profiler"),h2=Symbol.for("react.provider"),m2=Symbol.for("react.context"),g2=Symbol.for("react.forward_ref"),y2=Symbol.for("react.suspense"),w2=Symbol.for("react.memo"),x2=Symbol.for("react.lazy"),Q0=Symbol.iterator;function b2(e){return e===null||typeof e!="object"?null:(e=Q0&&e[Q0]||e["@@iterator"],typeof e=="function"?e:null)}var yE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},wE=Object.assign,xE={};function qc(e,t,n){this.props=e,this.context=t,this.refs=xE,this.updater=n||yE}qc.prototype.isReactComponent={};qc.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")};qc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function bE(){}bE.prototype=qc.prototype;function Fb(e,t,n){this.props=e,this.context=t,this.refs=xE,this.updater=n||yE}var zb=Fb.prototype=new bE;zb.constructor=Fb;wE(zb,qc.prototype);zb.isPureReactComponent=!0;var Z0=Array.isArray,kE=Object.prototype.hasOwnProperty,Bb={current:null},vE={key:!0,ref:!0,__self:!0,__source:!0};function SE(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)kE.call(t,r)&&!vE.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:df,type:e,key:o,ref:a,props:s,_owner:Bb.current}}function k2(e,t){return{$$typeof:df,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Hb(e){return typeof e=="object"&&e!==null&&e.$$typeof===df}function v2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var ej=/\/+/g;function py(e,t){return typeof e=="object"&&e!==null&&e.key!=null?v2(""+e.key):t.toString(36)}function rh(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 df:case u2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+py(a,0):r,Z0(s)?(n="",e!=null&&(n=e.replace(ej,"$&/")+"/"),rh(s,t,n,"",function(u){return u})):s!=null&&(Hb(s)&&(s=k2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(ej,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",Z0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+py(o,l);a+=rh(o,t,n,c,s)}else if(c=b2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+py(o,l++),a+=rh(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 cp(e,t,n){if(e==null)return e;var r=[],s=0;return rh(e,r,"","",function(o){return t.call(n,o,s++)}),r}function S2(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 Hr={current:null},sh={transition:null},j2={ReactCurrentDispatcher:Hr,ReactCurrentBatchConfig:sh,ReactCurrentOwner:Bb};function jE(){throw Error("act(...) is not supported in production builds of React.")}Mt.Children={map:cp,forEach:function(e,t,n){cp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return cp(e,function(){t++}),t},toArray:function(e){return cp(e,function(t){return t})||[]},only:function(e){if(!Hb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Mt.Component=qc;Mt.Fragment=d2;Mt.Profiler=p2;Mt.PureComponent=Fb;Mt.StrictMode=f2;Mt.Suspense=y2;Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=j2;Mt.act=jE;Mt.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=wE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Bb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)kE.call(t,c)&&!vE.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:df,type:e.type,key:s,ref:o,props:r,_owner:a}};Mt.createContext=function(e){return e={$$typeof:m2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:h2,_context:e},e.Consumer=e};Mt.createElement=SE;Mt.createFactory=function(e){var t=SE.bind(null,e);return t.type=e,t};Mt.createRef=function(){return{current:null}};Mt.forwardRef=function(e){return{$$typeof:g2,render:e}};Mt.isValidElement=Hb;Mt.lazy=function(e){return{$$typeof:x2,_payload:{_status:-1,_result:e},_init:S2}};Mt.memo=function(e,t){return{$$typeof:w2,type:e,compare:t===void 0?null:t}};Mt.startTransition=function(e){var t=sh.transition;sh.transition={};try{e()}finally{sh.transition=t}};Mt.unstable_act=jE;Mt.useCallback=function(e,t){return Hr.current.useCallback(e,t)};Mt.useContext=function(e){return Hr.current.useContext(e)};Mt.useDebugValue=function(){};Mt.useDeferredValue=function(e){return Hr.current.useDeferredValue(e)};Mt.useEffect=function(e,t){return Hr.current.useEffect(e,t)};Mt.useId=function(){return Hr.current.useId()};Mt.useImperativeHandle=function(e,t,n){return Hr.current.useImperativeHandle(e,t,n)};Mt.useInsertionEffect=function(e,t){return Hr.current.useInsertionEffect(e,t)};Mt.useLayoutEffect=function(e,t){return Hr.current.useLayoutEffect(e,t)};Mt.useMemo=function(e,t){return Hr.current.useMemo(e,t)};Mt.useReducer=function(e,t,n){return Hr.current.useReducer(e,t,n)};Mt.useRef=function(e){return Hr.current.useRef(e)};Mt.useState=function(e){return Hr.current.useState(e)};Mt.useSyncExternalStore=function(e,t,n){return Hr.current.useSyncExternalStore(e,t,n)};Mt.useTransition=function(){return Hr.current.useTransition()};Mt.version="18.3.1";gE.exports=Mt;var m=gE.exports;const pt=da(m);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var N2=m,C2=Symbol.for("react.element"),_2=Symbol.for("react.fragment"),E2=Object.prototype.hasOwnProperty,A2=N2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,P2={key:!0,ref:!0,__self:!0,__source:!0};function NE(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)E2.call(t,r)&&!P2.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:C2,type:e,key:o,ref:a,props:s,_owner:A2.current}}Om.Fragment=_2;Om.jsx=NE;Om.jsxs=NE;mE.exports=Om;var i=mE.exports,Ow={},CE={exports:{}},ys={},_E={exports:{}},EE={};/**
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($,W){var E=$.length;$.push(W);e:for(;0<E;){var Q=E-1>>>1,K=$[Q];if(0<s(K,W))$[Q]=W,$[E]=K,E=Q;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var W=$[0],E=$.pop();if(E!==W){$[0]=E;e:for(var Q=0,K=$.length,H=K>>>1;Q<H;){var ee=2*(Q+1)-1,ue=$[ee],G=ee+1,te=$[G];if(0>s(ue,E))G<K&&0>s(te,ue)?($[Q]=te,$[G]=E,Q=G):($[Q]=ue,$[ee]=E,Q=ee);else if(G<K&&0>s(te,E))$[Q]=te,$[G]=E,Q=G;else break e}}return W}function s($,W){var E=$.sortIndex-W.sortIndex;return E!==0?E:$.id-W.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=[],u=[],d=1,f=null,p=3,h=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x($){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=$)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function j($){if(v=!1,x($),!y)if(n(c)!==null)y=!0,z(S);else{var W=n(u);W!==null&&F(j,W.startTime-$)}}function S($,W){y=!1,v&&(v=!1,g(R),R=-1),h=!0;var E=p;try{for(x(W),f=n(c);f!==null&&(!(f.expirationTime>W)||$&&!O());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=f.priorityLevel;var K=Q(f.expirationTime<=W);W=e.unstable_now(),typeof K=="function"?f.callback=K:f===n(c)&&r(c),x(W)}else r(c);f=n(c)}if(f!==null)var H=!0;else{var ee=n(u);ee!==null&&F(j,ee.startTime-W),H=!1}return H}finally{f=null,p=E,h=!1}}var C=!1,P=null,R=-1,B=5,A=-1;function O(){return!(e.unstable_now()-A<B)}function D(){if(P!==null){var $=e.unstable_now();A=$;var W=!0;try{W=P(!0,$)}finally{W?L():(C=!1,P=null)}}else C=!1}var L;if(typeof k=="function")L=function(){k(D)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,V=M.port2;M.port1.onmessage=D,L=function(){V.postMessage(null)}}else L=function(){b(D,0)};function z($){P=$,C||(C=!0,L())}function F($,W){R=b(function(){$(e.unstable_now())},W)}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($){$.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,z(S))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var E=p;p=W;try{return $()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,W){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var E=p;p=$;try{return W()}finally{p=E}},e.unstable_scheduleCallback=function($,W,E){var Q=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Q+E:Q):E=Q,$){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=E+K,$={id:d++,callback:W,priorityLevel:$,startTime:E,expirationTime:K,sortIndex:-1},E>Q?($.sortIndex=E,t(u,$),n(c)===null&&$===n(u)&&(v?(g(R),R=-1):v=!0,F(j,E-Q))):($.sortIndex=K,t(c,$),y||h||(y=!0,z(S))),$},e.unstable_shouldYield=O,e.unstable_wrapCallback=function($){var W=p;return function(){var E=p;p=W;try{return $.apply(this,arguments)}finally{p=E}}}})(EE);_E.exports=EE;var I2=_E.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 R2=m,ms=I2;function Ae(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 AE=new Set,Nd={};function dl(e,t){_c(e,t),_c(e+"Capture",t)}function _c(e,t){for(Nd[e]=t,e=0;e<t.length;e++)AE.add(t[e])}var co=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dw=Object.prototype.hasOwnProperty,T2=/^[: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]*$/,tj={},nj={};function M2(e){return Dw.call(nj,e)?!0:Dw.call(tj,e)?!1:T2.test(e)?nj[e]=!0:(tj[e]=!0,!1)}function $2(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 L2(e,t,n,r){if(t===null||typeof t>"u"||$2(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 Wr(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 br={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){br[e]=new Wr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];br[t]=new Wr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){br[e]=new Wr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){br[e]=new Wr(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){br[e]=new Wr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){br[e]=new Wr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){br[e]=new Wr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){br[e]=new Wr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){br[e]=new Wr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Wb=/[\-:]([a-z])/g;function Vb(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(Wb,Vb);br[t]=new Wr(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(Wb,Vb);br[t]=new Wr(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(Wb,Vb);br[t]=new Wr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){br[e]=new Wr(e,1,!1,e.toLowerCase(),null,!1,!1)});br.xlinkHref=new Wr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){br[e]=new Wr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Kb(e,t,n,r){var s=br.hasOwnProperty(t)?br[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(L2(t,n,s,r)&&(n=null),r||s===null?M2(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 wo=R2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,up=Symbol.for("react.element"),Gl=Symbol.for("react.portal"),Jl=Symbol.for("react.fragment"),qb=Symbol.for("react.strict_mode"),Fw=Symbol.for("react.profiler"),PE=Symbol.for("react.provider"),IE=Symbol.for("react.context"),Ub=Symbol.for("react.forward_ref"),zw=Symbol.for("react.suspense"),Bw=Symbol.for("react.suspense_list"),Yb=Symbol.for("react.memo"),Lo=Symbol.for("react.lazy"),RE=Symbol.for("react.offscreen"),rj=Symbol.iterator;function Eu(e){return e===null||typeof e!="object"?null:(e=rj&&e[rj]||e["@@iterator"],typeof e=="function"?e:null)}var In=Object.assign,hy;function Uu(e){if(hy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);hy=t&&t[1]||""}return`
34
- `+hy+e}var my=!1;function gy(e,t){if(!e||my)return"";my=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
35
- `),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{my=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Uu(e):""}function O2(e){switch(e.tag){case 5:return Uu(e.type);case 16:return Uu("Lazy");case 13:return Uu("Suspense");case 19:return Uu("SuspenseList");case 0:case 2:case 15:return e=gy(e.type,!1),e;case 11:return e=gy(e.type.render,!1),e;case 1:return e=gy(e.type,!0),e;default:return""}}function Hw(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 Jl:return"Fragment";case Gl:return"Portal";case Fw:return"Profiler";case qb:return"StrictMode";case zw:return"Suspense";case Bw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case IE:return(e.displayName||"Context")+".Consumer";case PE:return(e._context.displayName||"Context")+".Provider";case Ub:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yb:return t=e.displayName||null,t!==null?t:Hw(e.type)||"Memo";case Lo:t=e._payload,e=e._init;try{return Hw(e(t))}catch{}}return null}function D2(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 Hw(t);case 8:return t===qb?"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 ra(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function TE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function F2(e){var t=TE(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 dp(e){e._valueTracker||(e._valueTracker=F2(e))}function ME(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=TE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ah(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 Ww(e,t){var n=t.checked;return In({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sj(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ra(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&&Kb(e,"checked",t,!1)}function Vw(e,t){$E(e,t);var n=ra(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")?Kw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Kw(e,t.type,ra(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ij(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 Kw(e,t,n){(t!=="number"||Ah(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Yu=Array.isArray;function pc(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=""+ra(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(Ae(91));return In({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oj(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ae(92));if(Yu(n)){if(1<n.length)throw Error(Ae(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ra(n)}}function LE(e,t){var n=ra(t.value),r=ra(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 aj(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function OE(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 Uw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?OE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var fp,DE=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(fp=fp||document.createElement("div"),fp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=fp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Cd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var id={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},z2=["Webkit","ms","Moz","O"];Object.keys(id).forEach(function(e){z2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),id[t]=id[e]})});function FE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||id.hasOwnProperty(e)&&id[e]?(""+t).trim():t+"px"}function zE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=FE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var B2=In({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Yw(e,t){if(t){if(B2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ae(62))}}function Gw(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 Gb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xw=null,hc=null,mc=null;function lj(e){if(e=hf(e)){if(typeof Xw!="function")throw Error(Ae(280));var t=e.stateNode;t&&(t=Hm(t),Xw(e.stateNode,e.type,t))}}function BE(e){hc?mc?mc.push(e):mc=[e]:hc=e}function HE(){if(hc){var e=hc,t=mc;if(mc=hc=null,lj(e),t)for(e=0;e<t.length;e++)lj(t[e])}}function WE(e,t){return e(t)}function VE(){}var yy=!1;function KE(e,t,n){if(yy)return e(t,n);yy=!0;try{return WE(e,t,n)}finally{yy=!1,(hc!==null||mc!==null)&&(VE(),HE())}}function _d(e,t){var n=e.stateNode;if(n===null)return null;var r=Hm(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(Ae(231,t,typeof n));return n}var Qw=!1;if(co)try{var Au={};Object.defineProperty(Au,"passive",{get:function(){Qw=!0}}),window.addEventListener("test",Au,Au),window.removeEventListener("test",Au,Au)}catch{Qw=!1}function H2(e,t,n,r,s,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var od=!1,Ph=null,Ih=!1,Zw=null,W2={onError:function(e){od=!0,Ph=e}};function V2(e,t,n,r,s,o,a,l,c){od=!1,Ph=null,H2.apply(W2,arguments)}function K2(e,t,n,r,s,o,a,l,c){if(V2.apply(this,arguments),od){if(od){var u=Ph;od=!1,Ph=null}else throw Error(Ae(198));Ih||(Ih=!0,Zw=u)}}function fl(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 qE(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 cj(e){if(fl(e)!==e)throw Error(Ae(188))}function q2(e){var t=e.alternate;if(!t){if(t=fl(e),t===null)throw Error(Ae(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 cj(s),e;if(o===r)return cj(s),t;o=o.sibling}throw Error(Ae(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(Ae(189))}}if(n.alternate!==r)throw Error(Ae(190))}if(n.tag!==3)throw Error(Ae(188));return n.stateNode.current===n?e:t}function UE(e){return e=q2(e),e!==null?YE(e):null}function YE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=YE(e);if(t!==null)return t;e=e.sibling}return null}var GE=ms.unstable_scheduleCallback,uj=ms.unstable_cancelCallback,U2=ms.unstable_shouldYield,Y2=ms.unstable_requestPaint,Dn=ms.unstable_now,G2=ms.unstable_getCurrentPriorityLevel,Jb=ms.unstable_ImmediatePriority,JE=ms.unstable_UserBlockingPriority,Rh=ms.unstable_NormalPriority,J2=ms.unstable_LowPriority,XE=ms.unstable_IdlePriority,Dm=null,Pi=null;function X2(e){if(Pi&&typeof Pi.onCommitFiberRoot=="function")try{Pi.onCommitFiberRoot(Dm,e,void 0,(e.current.flags&128)===128)}catch{}}var oi=Math.clz32?Math.clz32:eO,Q2=Math.log,Z2=Math.LN2;function eO(e){return e>>>=0,e===0?32:31-(Q2(e)/Z2|0)|0}var pp=64,hp=4194304;function Gu(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 Th(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=Gu(l):(o&=a,o!==0&&(r=Gu(o)))}else a=n&~s,a!==0?r=Gu(a):o!==0&&(r=Gu(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-oi(t),s=1<<n,r|=e[n],t&=~s;return r}function tO(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 nO(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-oi(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=tO(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function ex(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function QE(){var e=pp;return pp<<=1,!(pp&4194240)&&(pp=64),e}function wy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ff(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-oi(t),e[t]=n}function rO(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-oi(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Xb(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-oi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var rn=0;function ZE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var eA,Qb,tA,nA,rA,tx=!1,mp=[],Uo=null,Yo=null,Go=null,Ed=new Map,Ad=new Map,Fo=[],sO="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 dj(e,t){switch(e){case"focusin":case"focusout":Uo=null;break;case"dragenter":case"dragleave":Yo=null;break;case"mouseover":case"mouseout":Go=null;break;case"pointerover":case"pointerout":Ed.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ad.delete(t.pointerId)}}function Pu(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=hf(t),t!==null&&Qb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function iO(e,t,n,r,s){switch(t){case"focusin":return Uo=Pu(Uo,e,t,n,r,s),!0;case"dragenter":return Yo=Pu(Yo,e,t,n,r,s),!0;case"mouseover":return Go=Pu(Go,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Ed.set(o,Pu(Ed.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Ad.set(o,Pu(Ad.get(o)||null,e,t,n,r,s)),!0}return!1}function sA(e){var t=La(e.target);if(t!==null){var n=fl(t);if(n!==null){if(t=n.tag,t===13){if(t=qE(n),t!==null){e.blockedOn=t,rA(e.priority,function(){tA(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 ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=nx(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=hf(n),t!==null&&Qb(t),e.blockedOn=n,!1;t.shift()}return!0}function fj(e,t,n){ih(e)&&n.delete(t)}function oO(){tx=!1,Uo!==null&&ih(Uo)&&(Uo=null),Yo!==null&&ih(Yo)&&(Yo=null),Go!==null&&ih(Go)&&(Go=null),Ed.forEach(fj),Ad.forEach(fj)}function Iu(e,t){e.blockedOn===t&&(e.blockedOn=null,tx||(tx=!0,ms.unstable_scheduleCallback(ms.unstable_NormalPriority,oO)))}function Pd(e){function t(s){return Iu(s,e)}if(0<mp.length){Iu(mp[0],e);for(var n=1;n<mp.length;n++){var r=mp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Uo!==null&&Iu(Uo,e),Yo!==null&&Iu(Yo,e),Go!==null&&Iu(Go,e),Ed.forEach(t),Ad.forEach(t),n=0;n<Fo.length;n++)r=Fo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Fo.length&&(n=Fo[0],n.blockedOn===null);)sA(n),n.blockedOn===null&&Fo.shift()}var gc=wo.ReactCurrentBatchConfig,Mh=!0;function aO(e,t,n,r){var s=rn,o=gc.transition;gc.transition=null;try{rn=1,Zb(e,t,n,r)}finally{rn=s,gc.transition=o}}function lO(e,t,n,r){var s=rn,o=gc.transition;gc.transition=null;try{rn=4,Zb(e,t,n,r)}finally{rn=s,gc.transition=o}}function Zb(e,t,n,r){if(Mh){var s=nx(e,t,n,r);if(s===null)Ey(e,t,r,$h,n),dj(e,r);else if(iO(s,e,t,n,r))r.stopPropagation();else if(dj(e,r),t&4&&-1<sO.indexOf(e)){for(;s!==null;){var o=hf(s);if(o!==null&&eA(o),o=nx(e,t,n,r),o===null&&Ey(e,t,r,$h,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else Ey(e,t,r,null,n)}}var $h=null;function nx(e,t,n,r){if($h=null,e=Gb(r),e=La(e),e!==null)if(t=fl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=qE(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 $h=e,null}function iA(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(G2()){case Jb:return 1;case JE:return 4;case Rh:case J2:return 16;case XE:return 536870912;default:return 16}default:return 16}}var Wo=null,ek=null,oh=null;function oA(){if(oh)return oh;var e,t=ek,n=t.length,r,s="value"in Wo?Wo.value:Wo.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 oh=s.slice(e,1<r?1-r:void 0)}function ah(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 gp(){return!0}function pj(){return!1}function ws(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)?gp:pj,this.isPropagationStopped=pj,this}return In(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=gp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=gp)},persist:function(){},isPersistent:gp}),t}var Uc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tk=ws(Uc),pf=In({},Uc,{view:0,detail:0}),cO=ws(pf),xy,by,Ru,Fm=In({},pf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nk,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!==Ru&&(Ru&&e.type==="mousemove"?(xy=e.screenX-Ru.screenX,by=e.screenY-Ru.screenY):by=xy=0,Ru=e),xy)},movementY:function(e){return"movementY"in e?e.movementY:by}}),hj=ws(Fm),uO=In({},Fm,{dataTransfer:0}),dO=ws(uO),fO=In({},pf,{relatedTarget:0}),ky=ws(fO),pO=In({},Uc,{animationName:0,elapsedTime:0,pseudoElement:0}),hO=ws(pO),mO=In({},Uc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),gO=ws(mO),yO=In({},Uc,{data:0}),mj=ws(yO),wO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xO={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"},bO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=bO[e])?!!t[e]:!1}function nk(){return kO}var vO=In({},pf,{key:function(e){if(e.key){var t=wO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ah(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?xO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nk,charCode:function(e){return e.type==="keypress"?ah(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ah(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),SO=ws(vO),jO=In({},Fm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gj=ws(jO),NO=In({},pf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nk}),CO=ws(NO),_O=In({},Uc,{propertyName:0,elapsedTime:0,pseudoElement:0}),EO=ws(_O),AO=In({},Fm,{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}),PO=ws(AO),IO=[9,13,27,32],rk=co&&"CompositionEvent"in window,ad=null;co&&"documentMode"in document&&(ad=document.documentMode);var RO=co&&"TextEvent"in window&&!ad,aA=co&&(!rk||ad&&8<ad&&11>=ad),yj=" ",wj=!1;function lA(e,t){switch(e){case"keyup":return IO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cA(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xl=!1;function TO(e,t){switch(e){case"compositionend":return cA(t);case"keypress":return t.which!==32?null:(wj=!0,yj);case"textInput":return e=t.data,e===yj&&wj?null:e;default:return null}}function MO(e,t){if(Xl)return e==="compositionend"||!rk&&lA(e,t)?(e=oA(),oh=ek=Wo=null,Xl=!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 aA&&t.locale!=="ko"?null:t.data;default:return null}}var $O={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 xj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!$O[e.type]:t==="textarea"}function uA(e,t,n,r){BE(r),t=Lh(t,"onChange"),0<t.length&&(n=new tk("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var ld=null,Id=null;function LO(e){kA(e,0)}function zm(e){var t=ec(e);if(ME(t))return e}function OO(e,t){if(e==="change")return t}var dA=!1;if(co){var vy;if(co){var Sy="oninput"in document;if(!Sy){var bj=document.createElement("div");bj.setAttribute("oninput","return;"),Sy=typeof bj.oninput=="function"}vy=Sy}else vy=!1;dA=vy&&(!document.documentMode||9<document.documentMode)}function kj(){ld&&(ld.detachEvent("onpropertychange",fA),Id=ld=null)}function fA(e){if(e.propertyName==="value"&&zm(Id)){var t=[];uA(t,Id,e,Gb(e)),KE(LO,t)}}function DO(e,t,n){e==="focusin"?(kj(),ld=t,Id=n,ld.attachEvent("onpropertychange",fA)):e==="focusout"&&kj()}function FO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return zm(Id)}function zO(e,t){if(e==="click")return zm(t)}function BO(e,t){if(e==="input"||e==="change")return zm(t)}function HO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ci=typeof Object.is=="function"?Object.is:HO;function Rd(e,t){if(ci(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(!Dw.call(t,s)||!ci(e[s],t[s]))return!1}return!0}function vj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Sj(e,t){var n=vj(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=vj(n)}}function pA(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?pA(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hA(){for(var e=window,t=Ah();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ah(e.document)}return t}function sk(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 WO(e){var t=hA(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&pA(n.ownerDocument.documentElement,n)){if(r!==null&&sk(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=Sj(n,o);var a=Sj(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 VO=co&&"documentMode"in document&&11>=document.documentMode,Ql=null,rx=null,cd=null,sx=!1;function jj(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;sx||Ql==null||Ql!==Ah(r)||(r=Ql,"selectionStart"in r&&sk(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}),cd&&Rd(cd,r)||(cd=r,r=Lh(rx,"onSelect"),0<r.length&&(t=new tk("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Ql)))}function yp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Zl={animationend:yp("Animation","AnimationEnd"),animationiteration:yp("Animation","AnimationIteration"),animationstart:yp("Animation","AnimationStart"),transitionend:yp("Transition","TransitionEnd")},jy={},mA={};co&&(mA=document.createElement("div").style,"AnimationEvent"in window||(delete Zl.animationend.animation,delete Zl.animationiteration.animation,delete Zl.animationstart.animation),"TransitionEvent"in window||delete Zl.transitionend.transition);function Bm(e){if(jy[e])return jy[e];if(!Zl[e])return e;var t=Zl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in mA)return jy[e]=t[n];return e}var gA=Bm("animationend"),yA=Bm("animationiteration"),wA=Bm("animationstart"),xA=Bm("transitionend"),bA=new Map,Nj="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 fa(e,t){bA.set(e,t),dl(t,[e])}for(var Ny=0;Ny<Nj.length;Ny++){var Cy=Nj[Ny],KO=Cy.toLowerCase(),qO=Cy[0].toUpperCase()+Cy.slice(1);fa(KO,"on"+qO)}fa(gA,"onAnimationEnd");fa(yA,"onAnimationIteration");fa(wA,"onAnimationStart");fa("dblclick","onDoubleClick");fa("focusin","onFocus");fa("focusout","onBlur");fa(xA,"onTransitionEnd");_c("onMouseEnter",["mouseout","mouseover"]);_c("onMouseLeave",["mouseout","mouseover"]);_c("onPointerEnter",["pointerout","pointerover"]);_c("onPointerLeave",["pointerout","pointerover"]);dl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));dl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));dl("onBeforeInput",["compositionend","keypress","textInput","paste"]);dl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));dl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));dl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ju="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(" "),UO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ju));function Cj(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,K2(r,t,void 0,e),e.currentTarget=null}function kA(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,u=l.currentTarget;if(l=l.listener,c!==o&&s.isPropagationStopped())break e;Cj(s,l,u),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==o&&s.isPropagationStopped())break e;Cj(s,l,u),o=c}}}if(Ih)throw e=Zw,Ih=!1,Zw=null,e}function mn(e,t){var n=t[cx];n===void 0&&(n=t[cx]=new Set);var r=e+"__bubble";n.has(r)||(vA(t,e,2,!1),n.add(r))}function _y(e,t,n){var r=0;t&&(r|=4),vA(n,e,r,t)}var wp="_reactListening"+Math.random().toString(36).slice(2);function Td(e){if(!e[wp]){e[wp]=!0,AE.forEach(function(n){n!=="selectionchange"&&(UO.has(n)||_y(n,!1,e),_y(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wp]||(t[wp]=!0,_y("selectionchange",!1,t))}}function vA(e,t,n,r){switch(iA(t)){case 1:var s=aO;break;case 4:s=lO;break;default:s=Zb}n=s.bind(null,t,n,e),s=void 0,!Qw||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 Ey(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=La(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}KE(function(){var u=o,d=Gb(n),f=[];e:{var p=bA.get(e);if(p!==void 0){var h=tk,y=e;switch(e){case"keypress":if(ah(n)===0)break e;case"keydown":case"keyup":h=SO;break;case"focusin":y="focus",h=ky;break;case"focusout":y="blur",h=ky;break;case"beforeblur":case"afterblur":h=ky;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=hj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=dO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=CO;break;case gA:case yA:case wA:h=hO;break;case xA:h=EO;break;case"scroll":h=cO;break;case"wheel":h=PO;break;case"copy":case"cut":case"paste":h=gO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=gj}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var k=u,x;k!==null;){x=k;var j=x.stateNode;if(x.tag===5&&j!==null&&(x=j,g!==null&&(j=_d(k,g),j!=null&&v.push(Md(k,j,x)))),b)break;k=k.return}0<v.length&&(p=new h(p,y,null,n,d),f.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==Jw&&(y=n.relatedTarget||n.fromElement)&&(La(y)||y[uo]))break e;if((h||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?La(y):null,y!==null&&(b=fl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=hj,j="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=gj,j="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?p:ec(h),x=y==null?p:ec(y),p=new v(j,k+"leave",h,n,d),p.target=b,p.relatedTarget=x,j=null,La(d)===u&&(v=new v(g,k+"enter",y,n,d),v.target=x,v.relatedTarget=b,j=v),b=j,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=Ol(x))k++;for(x=0,j=g;j;j=Ol(j))x++;for(;0<k-x;)v=Ol(v),k--;for(;0<x-k;)g=Ol(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Ol(v),g=Ol(g)}v=null}else v=null;h!==null&&_j(f,p,h,v,!1),y!==null&&b!==null&&_j(f,b,y,v,!0)}}e:{if(p=u?ec(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var S=OO;else if(xj(p))if(dA)S=BO;else{S=FO;var C=DO}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(S=zO);if(S&&(S=S(e,u))){uA(f,S,n,d);break e}C&&C(e,p,u),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Kw(p,"number",p.value)}switch(C=u?ec(u):window,e){case"focusin":(xj(C)||C.contentEditable==="true")&&(Ql=C,rx=u,cd=null);break;case"focusout":cd=rx=Ql=null;break;case"mousedown":sx=!0;break;case"contextmenu":case"mouseup":case"dragend":sx=!1,jj(f,n,d);break;case"selectionchange":if(VO)break;case"keydown":case"keyup":jj(f,n,d)}var P;if(rk)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else Xl?lA(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(aA&&n.locale!=="ko"&&(Xl||R!=="onCompositionStart"?R==="onCompositionEnd"&&Xl&&(P=oA()):(Wo=d,ek="value"in Wo?Wo.value:Wo.textContent,Xl=!0)),C=Lh(u,R),0<C.length&&(R=new mj(R,e,null,n,d),f.push({event:R,listeners:C}),P?R.data=P:(P=cA(n),P!==null&&(R.data=P)))),(P=RO?TO(e,n):MO(e,n))&&(u=Lh(u,"onBeforeInput"),0<u.length&&(d=new mj("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=P))}kA(f,t)})}function Md(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Lh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=_d(e,n),o!=null&&r.unshift(Md(e,o,s)),o=_d(e,t),o!=null&&r.push(Md(e,o,s))),e=e.return}return r}function Ol(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function _j(e,t,n,r,s){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,s?(c=_d(n,o),c!=null&&a.unshift(Md(n,c,l))):s||(c=_d(n,o),c!=null&&a.push(Md(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var YO=/\r\n?/g,GO=/\u0000|\uFFFD/g;function Ej(e){return(typeof e=="string"?e:""+e).replace(YO,`
38
- `).replace(GO,"")}function xp(e,t,n){if(t=Ej(t),Ej(e)!==t&&n)throw Error(Ae(425))}function Oh(){}var ix=null,ox=null;function ax(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 lx=typeof setTimeout=="function"?setTimeout:void 0,JO=typeof clearTimeout=="function"?clearTimeout:void 0,Aj=typeof Promise=="function"?Promise:void 0,XO=typeof queueMicrotask=="function"?queueMicrotask:typeof Aj<"u"?function(e){return Aj.resolve(null).then(e).catch(QO)}:lx;function QO(e){setTimeout(function(){throw e})}function Ay(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),Pd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Pd(t)}function Jo(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 Pj(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 Yc=Math.random().toString(36).slice(2),ji="__reactFiber$"+Yc,$d="__reactProps$"+Yc,uo="__reactContainer$"+Yc,cx="__reactEvents$"+Yc,ZO="__reactListeners$"+Yc,eD="__reactHandles$"+Yc;function La(e){var t=e[ji];if(t)return t;for(var n=e.parentNode;n;){if(t=n[uo]||n[ji]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Pj(e);e!==null;){if(n=e[ji])return n;e=Pj(e)}return t}e=n,n=e.parentNode}return null}function hf(e){return e=e[ji]||e[uo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ec(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ae(33))}function Hm(e){return e[$d]||null}var ux=[],tc=-1;function pa(e){return{current:e}}function yn(e){0>tc||(e.current=ux[tc],ux[tc]=null,tc--)}function cn(e,t){tc++,ux[tc]=e.current,e.current=t}var sa={},Ir=pa(sa),Zr=pa(!1),Ga=sa;function Ec(e,t){var n=e.type.contextTypes;if(!n)return sa;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 es(e){return e=e.childContextTypes,e!=null}function Dh(){yn(Zr),yn(Ir)}function Ij(e,t,n){if(Ir.current!==sa)throw Error(Ae(168));cn(Ir,t),cn(Zr,n)}function SA(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(Ae(108,D2(e)||"Unknown",s));return In({},n,r)}function Fh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||sa,Ga=Ir.current,cn(Ir,e),cn(Zr,Zr.current),!0}function Rj(e,t,n){var r=e.stateNode;if(!r)throw Error(Ae(169));n?(e=SA(e,t,Ga),r.__reactInternalMemoizedMergedChildContext=e,yn(Zr),yn(Ir),cn(Ir,e)):yn(Zr),cn(Zr,n)}var Qi=null,Wm=!1,Py=!1;function jA(e){Qi===null?Qi=[e]:Qi.push(e)}function tD(e){Wm=!0,jA(e)}function ha(){if(!Py&&Qi!==null){Py=!0;var e=0,t=rn;try{var n=Qi;for(rn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Qi=null,Wm=!1}catch(s){throw Qi!==null&&(Qi=Qi.slice(e+1)),GE(Jb,ha),s}finally{rn=t,Py=!1}}return null}var nc=[],rc=0,zh=null,Bh=0,Ps=[],Is=0,Ja=null,eo=1,to="";function Aa(e,t){nc[rc++]=Bh,nc[rc++]=zh,zh=e,Bh=t}function NA(e,t,n){Ps[Is++]=eo,Ps[Is++]=to,Ps[Is++]=Ja,Ja=e;var r=eo;e=to;var s=32-oi(r)-1;r&=~(1<<s),n+=1;var o=32-oi(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,eo=1<<32-oi(t)+s|n<<s|r,to=o+e}else eo=1<<o|n<<s|r,to=e}function ik(e){e.return!==null&&(Aa(e,1),NA(e,1,0))}function ok(e){for(;e===zh;)zh=nc[--rc],nc[rc]=null,Bh=nc[--rc],nc[rc]=null;for(;e===Ja;)Ja=Ps[--Is],Ps[Is]=null,to=Ps[--Is],Ps[Is]=null,eo=Ps[--Is],Ps[Is]=null}var ps=null,ds=null,xn=!1,ti=null;function CA(e,t){var n=Ms(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 Tj(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,ps=e,ds=Jo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ps=e,ds=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ja!==null?{id:eo,overflow:to}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ms(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ps=e,ds=null,!0):!1;default:return!1}}function dx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function fx(e){if(xn){var t=ds;if(t){var n=t;if(!Tj(e,t)){if(dx(e))throw Error(Ae(418));t=Jo(n.nextSibling);var r=ps;t&&Tj(e,t)?CA(r,n):(e.flags=e.flags&-4097|2,xn=!1,ps=e)}}else{if(dx(e))throw Error(Ae(418));e.flags=e.flags&-4097|2,xn=!1,ps=e}}}function Mj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ps=e}function bp(e){if(e!==ps)return!1;if(!xn)return Mj(e),xn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ax(e.type,e.memoizedProps)),t&&(t=ds)){if(dx(e))throw _A(),Error(Ae(418));for(;t;)CA(e,t),t=Jo(t.nextSibling)}if(Mj(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ae(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ds=Jo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ds=null}}else ds=ps?Jo(e.stateNode.nextSibling):null;return!0}function _A(){for(var e=ds;e;)e=Jo(e.nextSibling)}function Ac(){ds=ps=null,xn=!1}function ak(e){ti===null?ti=[e]:ti.push(e)}var nD=wo.ReactCurrentBatchConfig;function Tu(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ae(309));var r=n.stateNode}if(!r)throw Error(Ae(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(Ae(284));if(!n._owner)throw Error(Ae(290,e))}return e}function kp(e,t){throw e=Object.prototype.toString.call(t),Error(Ae(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function $j(e){var t=e._init;return t(e._payload)}function EA(e){function t(g,k){if(e){var x=g.deletions;x===null?(g.deletions=[k],g.flags|=16):x.push(k)}}function n(g,k){if(!e)return null;for(;k!==null;)t(g,k),k=k.sibling;return null}function r(g,k){for(g=new Map;k!==null;)k.key!==null?g.set(k.key,k):g.set(k.index,k),k=k.sibling;return g}function s(g,k){return g=ea(g,k),g.index=0,g.sibling=null,g}function o(g,k,x){return g.index=x,e?(x=g.alternate,x!==null?(x=x.index,x<k?(g.flags|=2,k):x):(g.flags|=2,k)):(g.flags|=1048576,k)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,k,x,j){return k===null||k.tag!==6?(k=Oy(x,g.mode,j),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,j){var S=x.type;return S===Jl?d(g,k,x.props.children,j,x.key):k!==null&&(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Lo&&$j(S)===k.type)?(j=s(k,x.props),j.ref=Tu(g,k,x),j.return=g,j):(j=hh(x.type,x.key,x.props,null,g.mode,j),j.ref=Tu(g,k,x),j.return=g,j)}function u(g,k,x,j){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=Dy(x,g.mode,j),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function d(g,k,x,j,S){return k===null||k.tag!==7?(k=Wa(x,g.mode,j,S),k.return=g,k):(k=s(k,x),k.return=g,k)}function f(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Oy(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case up:return x=hh(k.type,k.key,k.props,null,g.mode,x),x.ref=Tu(g,null,k),x.return=g,x;case Gl:return k=Dy(k,g.mode,x),k.return=g,k;case Lo:var j=k._init;return f(g,j(k._payload),x)}if(Yu(k)||Eu(k))return k=Wa(k,g.mode,x,null),k.return=g,k;kp(g,k)}return null}function p(g,k,x,j){var S=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:l(g,k,""+x,j);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case up:return x.key===S?c(g,k,x,j):null;case Gl:return x.key===S?u(g,k,x,j):null;case Lo:return S=x._init,p(g,k,S(x._payload),j)}if(Yu(x)||Eu(x))return S!==null?null:d(g,k,x,j,null);kp(g,x)}return null}function h(g,k,x,j,S){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(x)||null,l(k,g,""+j,S);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case up:return g=g.get(j.key===null?x:j.key)||null,c(k,g,j,S);case Gl:return g=g.get(j.key===null?x:j.key)||null,u(k,g,j,S);case Lo:var C=j._init;return h(g,k,x,C(j._payload),S)}if(Yu(j)||Eu(j))return g=g.get(x)||null,d(k,g,j,S,null);kp(k,j)}return null}function y(g,k,x,j){for(var S=null,C=null,P=k,R=k=0,B=null;P!==null&&R<x.length;R++){P.index>R?(B=P,P=null):B=P.sibling;var A=p(g,P,x[R],j);if(A===null){P===null&&(P=B);break}e&&P&&A.alternate===null&&t(g,P),k=o(A,k,R),C===null?S=A:C.sibling=A,C=A,P=B}if(R===x.length)return n(g,P),xn&&Aa(g,R),S;if(P===null){for(;R<x.length;R++)P=f(g,x[R],j),P!==null&&(k=o(P,k,R),C===null?S=P:C.sibling=P,C=P);return xn&&Aa(g,R),S}for(P=r(g,P);R<x.length;R++)B=h(P,g,R,x[R],j),B!==null&&(e&&B.alternate!==null&&P.delete(B.key===null?R:B.key),k=o(B,k,R),C===null?S=B:C.sibling=B,C=B);return e&&P.forEach(function(O){return t(g,O)}),xn&&Aa(g,R),S}function v(g,k,x,j){var S=Eu(x);if(typeof S!="function")throw Error(Ae(150));if(x=S.call(x),x==null)throw Error(Ae(151));for(var C=S=null,P=k,R=k=0,B=null,A=x.next();P!==null&&!A.done;R++,A=x.next()){P.index>R?(B=P,P=null):B=P.sibling;var O=p(g,P,A.value,j);if(O===null){P===null&&(P=B);break}e&&P&&O.alternate===null&&t(g,P),k=o(O,k,R),C===null?S=O:C.sibling=O,C=O,P=B}if(A.done)return n(g,P),xn&&Aa(g,R),S;if(P===null){for(;!A.done;R++,A=x.next())A=f(g,A.value,j),A!==null&&(k=o(A,k,R),C===null?S=A:C.sibling=A,C=A);return xn&&Aa(g,R),S}for(P=r(g,P);!A.done;R++,A=x.next())A=h(P,g,R,A.value,j),A!==null&&(e&&A.alternate!==null&&P.delete(A.key===null?R:A.key),k=o(A,k,R),C===null?S=A:C.sibling=A,C=A);return e&&P.forEach(function(D){return t(g,D)}),xn&&Aa(g,R),S}function b(g,k,x,j){if(typeof x=="object"&&x!==null&&x.type===Jl&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case up:e:{for(var S=x.key,C=k;C!==null;){if(C.key===S){if(S=x.type,S===Jl){if(C.tag===7){n(g,C.sibling),k=s(C,x.props.children),k.return=g,g=k;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Lo&&$j(S)===C.type){n(g,C.sibling),k=s(C,x.props),k.ref=Tu(g,C,x),k.return=g,g=k;break e}n(g,C);break}else t(g,C);C=C.sibling}x.type===Jl?(k=Wa(x.props.children,g.mode,j,x.key),k.return=g,g=k):(j=hh(x.type,x.key,x.props,null,g.mode,j),j.ref=Tu(g,k,x),j.return=g,g=j)}return a(g);case Gl:e:{for(C=x.key;k!==null;){if(k.key===C)if(k.tag===4&&k.stateNode.containerInfo===x.containerInfo&&k.stateNode.implementation===x.implementation){n(g,k.sibling),k=s(k,x.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=Dy(x,g.mode,j),k.return=g,g=k}return a(g);case Lo:return C=x._init,b(g,k,C(x._payload),j)}if(Yu(x))return y(g,k,x,j);if(Eu(x))return v(g,k,x,j);kp(g,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,k!==null&&k.tag===6?(n(g,k.sibling),k=s(k,x),k.return=g,g=k):(n(g,k),k=Oy(x,g.mode,j),k.return=g,g=k),a(g)):n(g,k)}return b}var Pc=EA(!0),AA=EA(!1),Hh=pa(null),Wh=null,sc=null,lk=null;function ck(){lk=sc=Wh=null}function uk(e){var t=Hh.current;yn(Hh),e._currentValue=t}function px(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 yc(e,t){Wh=e,lk=sc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jr=!0),e.firstContext=null)}function Ls(e){var t=e._currentValue;if(lk!==e)if(e={context:e,memoizedValue:t,next:null},sc===null){if(Wh===null)throw Error(Ae(308));sc=e,Wh.dependencies={lanes:0,firstContext:e}}else sc=sc.next=e;return t}var Oa=null;function dk(e){Oa===null?Oa=[e]:Oa.push(e)}function PA(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,dk(t)):(n.next=s.next,s.next=n),t.interleaved=n,fo(e,r)}function fo(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 Oo=!1;function fk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function IA(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 io(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,qt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,fo(e,n)}return s=r.interleaved,s===null?(t.next=t,dk(r)):(t.next=s.next,s.next=t),r.interleaved=t,fo(e,n)}function lh(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,Xb(e,n)}}function Lj(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 Vh(e,t,n,r){var s=e.updateQueue;Oo=!1;var o=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==a&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(o!==null){var f=s.baseState;a=0,d=u=c=null,l=o;do{var p=l.lane,h=l.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(p=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(h,f,p);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,p=typeof y=="function"?y.call(h,f,p):y,p==null)break e;f=In({},f,p);break e;case 2:Oo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=h,c=f):d=d.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,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);Qa|=a,e.lanes=a,e.memoizedState=f}}function Oj(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(Ae(191,s));s.call(r)}}}var mf={},Ii=pa(mf),Ld=pa(mf),Od=pa(mf);function Da(e){if(e===mf)throw Error(Ae(174));return e}function pk(e,t){switch(cn(Od,t),cn(Ld,e),cn(Ii,mf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Uw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Uw(t,e)}yn(Ii),cn(Ii,t)}function Ic(){yn(Ii),yn(Ld),yn(Od)}function RA(e){Da(Od.current);var t=Da(Ii.current),n=Uw(t,e.type);t!==n&&(cn(Ld,e),cn(Ii,n))}function hk(e){Ld.current===e&&(yn(Ii),yn(Ld))}var En=pa(0);function Kh(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 Iy=[];function mk(){for(var e=0;e<Iy.length;e++)Iy[e]._workInProgressVersionPrimary=null;Iy.length=0}var ch=wo.ReactCurrentDispatcher,Ry=wo.ReactCurrentBatchConfig,Xa=0,Pn=null,Zn=null,cr=null,qh=!1,ud=!1,Dd=0,rD=0;function Cr(){throw Error(Ae(321))}function gk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ci(e[n],t[n]))return!1;return!0}function yk(e,t,n,r,s,o){if(Xa=o,Pn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ch.current=e===null||e.memoizedState===null?aD:lD,e=n(r,s),ud){o=0;do{if(ud=!1,Dd=0,25<=o)throw Error(Ae(301));o+=1,cr=Zn=null,t.updateQueue=null,ch.current=cD,e=n(r,s)}while(ud)}if(ch.current=Uh,t=Zn!==null&&Zn.next!==null,Xa=0,cr=Zn=Pn=null,qh=!1,t)throw Error(Ae(300));return e}function wk(){var e=Dd!==0;return Dd=0,e}function bi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cr===null?Pn.memoizedState=cr=e:cr=cr.next=e,cr}function Os(){if(Zn===null){var e=Pn.alternate;e=e!==null?e.memoizedState:null}else e=Zn.next;var t=cr===null?Pn.memoizedState:cr.next;if(t!==null)cr=t,Zn=e;else{if(e===null)throw Error(Ae(310));Zn=e,e={memoizedState:Zn.memoizedState,baseState:Zn.baseState,baseQueue:Zn.baseQueue,queue:Zn.queue,next:null},cr===null?Pn.memoizedState=cr=e:cr=cr.next=e}return cr}function Fd(e,t){return typeof t=="function"?t(e):t}function Ty(e){var t=Os(),n=t.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=e;var r=Zn,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,u=o;do{var d=u.lane;if((Xa&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Pn.lanes|=d,Qa|=d}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,ci(r,t.memoizedState)||(Jr=!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,Pn.lanes|=o,Qa|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function My(e){var t=Os(),n=t.queue;if(n===null)throw Error(Ae(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);ci(o,t.memoizedState)||(Jr=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function TA(){}function MA(e,t){var n=Pn,r=Os(),s=t(),o=!ci(r.memoizedState,s);if(o&&(r.memoizedState=s,Jr=!0),r=r.queue,xk(OA.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||cr!==null&&cr.memoizedState.tag&1){if(n.flags|=2048,zd(9,LA.bind(null,n,r,s,t),void 0,null),fr===null)throw Error(Ae(349));Xa&30||$A(n,t,s)}return s}function $A(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Pn.updateQueue,t===null?(t={lastEffect:null,stores:null},Pn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function LA(e,t,n,r){t.value=n,t.getSnapshot=r,DA(t)&&FA(e)}function OA(e,t,n){return n(function(){DA(t)&&FA(e)})}function DA(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ci(e,n)}catch{return!0}}function FA(e){var t=fo(e,1);t!==null&&ai(t,e,1,-1)}function Dj(e){var t=bi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fd,lastRenderedState:e},t.queue=e,e=e.dispatch=oD.bind(null,Pn,e),[t.memoizedState,e]}function zd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Pn.updateQueue,t===null?(t={lastEffect:null,stores:null},Pn.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 zA(){return Os().memoizedState}function uh(e,t,n,r){var s=bi();Pn.flags|=e,s.memoizedState=zd(1|t,n,void 0,r===void 0?null:r)}function Vm(e,t,n,r){var s=Os();r=r===void 0?null:r;var o=void 0;if(Zn!==null){var a=Zn.memoizedState;if(o=a.destroy,r!==null&&gk(r,a.deps)){s.memoizedState=zd(t,n,o,r);return}}Pn.flags|=e,s.memoizedState=zd(1|t,n,o,r)}function Fj(e,t){return uh(8390656,8,e,t)}function xk(e,t){return Vm(2048,8,e,t)}function BA(e,t){return Vm(4,2,e,t)}function HA(e,t){return Vm(4,4,e,t)}function WA(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 VA(e,t,n){return n=n!=null?n.concat([e]):null,Vm(4,4,WA.bind(null,t,e),n)}function bk(){}function KA(e,t){var n=Os();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&gk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function qA(e,t){var n=Os();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&gk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function UA(e,t,n){return Xa&21?(ci(n,t)||(n=QE(),Pn.lanes|=n,Qa|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jr=!0),e.memoizedState=n)}function sD(e,t){var n=rn;rn=n!==0&&4>n?n:4,e(!0);var r=Ry.transition;Ry.transition={};try{e(!1),t()}finally{rn=n,Ry.transition=r}}function YA(){return Os().memoizedState}function iD(e,t,n){var r=Zo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},GA(e))JA(t,n);else if(n=PA(e,t,n,r),n!==null){var s=Br();ai(n,e,r,s),XA(n,t,r)}}function oD(e,t,n){var r=Zo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(GA(e))JA(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,ci(l,a)){var c=t.interleaved;c===null?(s.next=s,dk(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=PA(e,t,s,r),n!==null&&(s=Br(),ai(n,e,r,s),XA(n,t,r))}}function GA(e){var t=e.alternate;return e===Pn||t!==null&&t===Pn}function JA(e,t){ud=qh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function XA(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xb(e,n)}}var Uh={readContext:Ls,useCallback:Cr,useContext:Cr,useEffect:Cr,useImperativeHandle:Cr,useInsertionEffect:Cr,useLayoutEffect:Cr,useMemo:Cr,useReducer:Cr,useRef:Cr,useState:Cr,useDebugValue:Cr,useDeferredValue:Cr,useTransition:Cr,useMutableSource:Cr,useSyncExternalStore:Cr,useId:Cr,unstable_isNewReconciler:!1},aD={readContext:Ls,useCallback:function(e,t){return bi().memoizedState=[e,t===void 0?null:t],e},useContext:Ls,useEffect:Fj,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,uh(4194308,4,WA.bind(null,t,e),n)},useLayoutEffect:function(e,t){return uh(4194308,4,e,t)},useInsertionEffect:function(e,t){return uh(4,2,e,t)},useMemo:function(e,t){var n=bi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bi();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=iD.bind(null,Pn,e),[r.memoizedState,e]},useRef:function(e){var t=bi();return e={current:e},t.memoizedState=e},useState:Dj,useDebugValue:bk,useDeferredValue:function(e){return bi().memoizedState=e},useTransition:function(){var e=Dj(!1),t=e[0];return e=sD.bind(null,e[1]),bi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Pn,s=bi();if(xn){if(n===void 0)throw Error(Ae(407));n=n()}else{if(n=t(),fr===null)throw Error(Ae(349));Xa&30||$A(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Fj(OA.bind(null,r,o,e),[e]),r.flags|=2048,zd(9,LA.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=bi(),t=fr.identifierPrefix;if(xn){var n=to,r=eo;n=(r&~(1<<32-oi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Dd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=rD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},lD={readContext:Ls,useCallback:KA,useContext:Ls,useEffect:xk,useImperativeHandle:VA,useInsertionEffect:BA,useLayoutEffect:HA,useMemo:qA,useReducer:Ty,useRef:zA,useState:function(){return Ty(Fd)},useDebugValue:bk,useDeferredValue:function(e){var t=Os();return UA(t,Zn.memoizedState,e)},useTransition:function(){var e=Ty(Fd)[0],t=Os().memoizedState;return[e,t]},useMutableSource:TA,useSyncExternalStore:MA,useId:YA,unstable_isNewReconciler:!1},cD={readContext:Ls,useCallback:KA,useContext:Ls,useEffect:xk,useImperativeHandle:VA,useInsertionEffect:BA,useLayoutEffect:HA,useMemo:qA,useReducer:My,useRef:zA,useState:function(){return My(Fd)},useDebugValue:bk,useDeferredValue:function(e){var t=Os();return Zn===null?t.memoizedState=e:UA(t,Zn.memoizedState,e)},useTransition:function(){var e=My(Fd)[0],t=Os().memoizedState;return[e,t]},useMutableSource:TA,useSyncExternalStore:MA,useId:YA,unstable_isNewReconciler:!1};function Qs(e,t){if(e&&e.defaultProps){t=In({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function hx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:In({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Km={isMounted:function(e){return(e=e._reactInternals)?fl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Br(),s=Zo(e),o=io(r,s);o.payload=t,n!=null&&(o.callback=n),t=Xo(e,o,s),t!==null&&(ai(t,e,s,r),lh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Br(),s=Zo(e),o=io(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Xo(e,o,s),t!==null&&(ai(t,e,s,r),lh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Br(),r=Zo(e),s=io(n,r);s.tag=2,t!=null&&(s.callback=t),t=Xo(e,s,r),t!==null&&(ai(t,e,r,n),lh(t,e,r))}};function zj(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?!Rd(n,r)||!Rd(s,o):!0}function QA(e,t,n){var r=!1,s=sa,o=t.contextType;return typeof o=="object"&&o!==null?o=Ls(o):(s=es(t)?Ga:Ir.current,r=t.contextTypes,o=(r=r!=null)?Ec(e,s):sa),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Km,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Bj(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&&Km.enqueueReplaceState(t,t.state,null)}function mx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},fk(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Ls(o):(o=es(t)?Ga:Ir.current,s.context=Ec(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(hx(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&&Km.enqueueReplaceState(s,s.state,null),Vh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Rc(e,t){try{var n="",r=t;do n+=O2(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 $y(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function gx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var uD=typeof WeakMap=="function"?WeakMap:Map;function ZA(e,t,n){n=io(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Gh||(Gh=!0,Cx=r),gx(e,t)},n}function eP(e,t,n){n=io(-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(){gx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){gx(e,t),typeof r!="function"&&(Qo===null?Qo=new Set([this]):Qo.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Hj(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new uD;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=jD.bind(null,e,t,n),t.then(e,e))}function Wj(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 Vj(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=io(-1,1),t.tag=2,Xo(n,t,1))),n.lanes|=1),e)}var dD=wo.ReactCurrentOwner,Jr=!1;function zr(e,t,n,r){t.child=e===null?AA(t,null,n,r):Pc(t,e.child,n,r)}function Kj(e,t,n,r,s){n=n.render;var o=t.ref;return yc(t,s),r=yk(e,t,n,r,o,s),n=wk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,po(e,t,s)):(xn&&n&&ik(t),t.flags|=1,zr(e,t,r,s),t.child)}function qj(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!Ek(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,tP(e,t,o,r,s)):(e=hh(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:Rd,n(a,r)&&e.ref===t.ref)return po(e,t,s)}return t.flags|=1,e=ea(o,r),e.ref=t.ref,e.return=t,t.child=e}function tP(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Rd(o,r)&&e.ref===t.ref)if(Jr=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Jr=!0);else return t.lanes=e.lanes,po(e,t,s)}return yx(e,t,n,r,s)}function nP(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},cn(oc,ls),ls|=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,cn(oc,ls),ls|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,cn(oc,ls),ls|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,cn(oc,ls),ls|=r;return zr(e,t,s,n),t.child}function rP(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function yx(e,t,n,r,s){var o=es(n)?Ga:Ir.current;return o=Ec(t,o),yc(t,s),n=yk(e,t,n,r,o,s),r=wk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,po(e,t,s)):(xn&&r&&ik(t),t.flags|=1,zr(e,t,n,s),t.child)}function Uj(e,t,n,r,s){if(es(n)){var o=!0;Fh(t)}else o=!1;if(yc(t,s),t.stateNode===null)dh(e,t),QA(t,n,r),mx(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=Ls(u):(u=es(n)?Ga:Ir.current,u=Ec(t,u));var d=n.getDerivedStateFromProps,f=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Bj(t,a,r,u),Oo=!1;var p=t.memoizedState;a.state=p,Vh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Zr.current||Oo?(typeof d=="function"&&(hx(t,n,d,r),c=t.memoizedState),(l=Oo||zj(t,n,l,r,p,c,u))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,IA(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Qs(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ls(c):(c=es(n)?Ga:Ir.current,c=Ec(t,c));var h=n.getDerivedStateFromProps;(d=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&Bj(t,a,r,c),Oo=!1,p=t.memoizedState,a.state=p,Vh(t,r,a,s);var y=t.memoizedState;l!==f||p!==y||Zr.current||Oo?(typeof h=="function"&&(hx(t,n,h,r),y=t.memoizedState),(u=Oo||zj(t,n,u,r,p,y,c)||!1)?(d||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return wx(e,t,n,r,o,s)}function wx(e,t,n,r,s,o){rP(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Rj(t,n,!1),po(e,t,o);r=t.stateNode,dD.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Pc(t,e.child,null,o),t.child=Pc(t,null,l,o)):zr(e,t,l,o),t.memoizedState=r.state,s&&Rj(t,n,!0),t.child}function sP(e){var t=e.stateNode;t.pendingContext?Ij(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Ij(e,t.context,!1),pk(e,t.containerInfo)}function Yj(e,t,n,r,s){return Ac(),ak(s),t.flags|=256,zr(e,t,n,r),t.child}var xx={dehydrated:null,treeContext:null,retryLane:0};function bx(e){return{baseLanes:e,cachePool:null,transitions:null}}function iP(e,t,n){var r=t.pendingProps,s=En.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),cn(En,s&1),e===null)return fx(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=Ym(a,r,0,null),e=Wa(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=bx(n),t.memoizedState=xx,e):kk(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return fD(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=ea(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=ea(l,o):(o=Wa(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?bx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=xx,r}return o=e.child,e=o.sibling,r=ea(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 kk(e,t){return t=Ym({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function vp(e,t,n,r){return r!==null&&ak(r),Pc(t,e.child,null,n),e=kk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function fD(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=$y(Error(Ae(422))),vp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Ym({mode:"visible",children:r.children},s,0,null),o=Wa(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Pc(t,e.child,null,a),t.child.memoizedState=bx(a),t.memoizedState=xx,o);if(!(t.mode&1))return vp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ae(419)),r=$y(o,r,void 0),vp(e,t,a,r)}if(l=(a&e.childLanes)!==0,Jr||l){if(r=fr,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,fo(e,s),ai(r,e,s,-1))}return _k(),r=$y(Error(Ae(421))),vp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=ND.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ds=Jo(s.nextSibling),ps=t,xn=!0,ti=null,e!==null&&(Ps[Is++]=eo,Ps[Is++]=to,Ps[Is++]=Ja,eo=e.id,to=e.overflow,Ja=t),t=kk(t,r.children),t.flags|=4096,t)}function Gj(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),px(e.return,t,n)}function Ly(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 oP(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(zr(e,t,r.children,n),r=En.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&&Gj(e,n,t);else if(e.tag===19)Gj(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(cn(En,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&&Kh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Ly(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&&Kh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Ly(t,!0,n,null,o);break;case"together":Ly(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function dh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function po(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Qa|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ae(153));if(t.child!==null){for(e=t.child,n=ea(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ea(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function pD(e,t,n){switch(t.tag){case 3:sP(t),Ac();break;case 5:RA(t);break;case 1:es(t.type)&&Fh(t);break;case 4:pk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;cn(Hh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(cn(En,En.current&1),t.flags|=128,null):n&t.child.childLanes?iP(e,t,n):(cn(En,En.current&1),e=po(e,t,n),e!==null?e.sibling:null);cn(En,En.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return oP(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),cn(En,En.current),r)break;return null;case 22:case 23:return t.lanes=0,nP(e,t,n)}return po(e,t,n)}var aP,kx,lP,cP;aP=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}};kx=function(){};lP=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Da(Ii.current);var o=null;switch(n){case"input":s=Ww(e,s),r=Ww(e,r),o=[];break;case"select":s=In({},s,{value:void 0}),r=In({},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=Oh)}Yw(n,r);var a;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Nd.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(l=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Nd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&mn("scroll",e),o||l===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};cP=function(e,t,n,r){n!==r&&(t.flags|=4)};function Mu(e,t){if(!xn)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 _r(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 hD(e,t,n){var r=t.pendingProps;switch(ok(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _r(t),null;case 1:return es(t.type)&&Dh(),_r(t),null;case 3:return r=t.stateNode,Ic(),yn(Zr),yn(Ir),mk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(bp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ti!==null&&(Ax(ti),ti=null))),kx(e,t),_r(t),null;case 5:hk(t);var s=Da(Od.current);if(n=t.type,e!==null&&t.stateNode!=null)lP(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ae(166));return _r(t),null}if(e=Da(Ii.current),bp(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[ji]=t,r[$d]=o,e=(t.mode&1)!==0,n){case"dialog":mn("cancel",r),mn("close",r);break;case"iframe":case"object":case"embed":mn("load",r);break;case"video":case"audio":for(s=0;s<Ju.length;s++)mn(Ju[s],r);break;case"source":mn("error",r);break;case"img":case"image":case"link":mn("error",r),mn("load",r);break;case"details":mn("toggle",r);break;case"input":sj(r,o),mn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},mn("invalid",r);break;case"textarea":oj(r,o),mn("invalid",r)}Yw(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&&xp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&xp(r.textContent,l,e),s=["children",""+l]):Nd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&mn("scroll",r)}switch(n){case"input":dp(r),ij(r,o,!0);break;case"textarea":dp(r),aj(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Oh)}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=OE(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[ji]=t,e[$d]=r,aP(e,t,!1,!1),t.stateNode=e;e:{switch(a=Gw(n,r),n){case"dialog":mn("cancel",e),mn("close",e),s=r;break;case"iframe":case"object":case"embed":mn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ju.length;s++)mn(Ju[s],e);s=r;break;case"source":mn("error",e),s=r;break;case"img":case"image":case"link":mn("error",e),mn("load",e),s=r;break;case"details":mn("toggle",e),s=r;break;case"input":sj(e,r),s=Ww(e,r),mn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=In({},r,{value:void 0}),mn("invalid",e);break;case"textarea":oj(e,r),s=qw(e,r),mn("invalid",e);break;default:s=r}Yw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?zE(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&DE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Cd(e,c):typeof c=="number"&&Cd(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Nd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&mn("scroll",e):c!=null&&Kb(e,o,c,a))}switch(n){case"input":dp(e),ij(e,r,!1);break;case"textarea":dp(e),aj(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ra(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?pc(e,!!r.multiple,o,!1):r.defaultValue!=null&&pc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Oh)}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 _r(t),null;case 6:if(e&&t.stateNode!=null)cP(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ae(166));if(n=Da(Od.current),Da(Ii.current),bp(t)){if(r=t.stateNode,n=t.memoizedProps,r[ji]=t,(o=r.nodeValue!==n)&&(e=ps,e!==null))switch(e.tag){case 3:xp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&xp(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[ji]=t,t.stateNode=r}return _r(t),null;case 13:if(yn(En),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(xn&&ds!==null&&t.mode&1&&!(t.flags&128))_A(),Ac(),t.flags|=98560,o=!1;else if(o=bp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ae(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ae(317));o[ji]=t}else Ac(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_r(t),o=!1}else ti!==null&&(Ax(ti),ti=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||En.current&1?er===0&&(er=3):_k())),t.updateQueue!==null&&(t.flags|=4),_r(t),null);case 4:return Ic(),kx(e,t),e===null&&Td(t.stateNode.containerInfo),_r(t),null;case 10:return uk(t.type._context),_r(t),null;case 17:return es(t.type)&&Dh(),_r(t),null;case 19:if(yn(En),o=t.memoizedState,o===null)return _r(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Mu(o,!1);else{if(er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Kh(e),a!==null){for(t.flags|=128,Mu(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 cn(En,En.current&1|2),t.child}e=e.sibling}o.tail!==null&&Dn()>Tc&&(t.flags|=128,r=!0,Mu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Kh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Mu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!xn)return _r(t),null}else 2*Dn()-o.renderingStartTime>Tc&&n!==1073741824&&(t.flags|=128,r=!0,Mu(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=Dn(),t.sibling=null,n=En.current,cn(En,r?n&1|2:n&1),t):(_r(t),null);case 22:case 23:return Ck(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ls&1073741824&&(_r(t),t.subtreeFlags&6&&(t.flags|=8192)):_r(t),null;case 24:return null;case 25:return null}throw Error(Ae(156,t.tag))}function mD(e,t){switch(ok(t),t.tag){case 1:return es(t.type)&&Dh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ic(),yn(Zr),yn(Ir),mk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hk(t),null;case 13:if(yn(En),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ae(340));Ac()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return yn(En),null;case 4:return Ic(),null;case 10:return uk(t.type._context),null;case 22:case 23:return Ck(),null;case 24:return null;default:return null}}var Sp=!1,Er=!1,gD=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function ic(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Mn(e,t,r)}else n.current=null}function vx(e,t,n){try{n()}catch(r){Mn(e,t,r)}}var Jj=!1;function yD(e,t){if(ix=Mh,e=hA(),sk(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,u=0,d=0,f=e,p=null;t:for(;;){for(var h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)p=f,f=h;for(;;){if(f===e)break t;if(p===n&&++u===s&&(l=a),p===o&&++d===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(ox={focusedElem:e,selectionRange:n},Mh=!1,Xe=t;Xe!==null;)if(t=Xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Xe=e;else for(;Xe!==null;){t=Xe;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,b=y.memoizedState,g=t.stateNode,k=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:Qs(t.type,v),b);g.__reactInternalSnapshotBeforeUpdate=k}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(Ae(163))}}catch(j){Mn(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return y=Jj,Jj=!1,y}function dd(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&&vx(t,n,o)}s=s.next}while(s!==r)}}function qm(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 Sx(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 uP(e){var t=e.alternate;t!==null&&(e.alternate=null,uP(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ji],delete t[$d],delete t[cx],delete t[ZO],delete t[eD])),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 dP(e){return e.tag===5||e.tag===3||e.tag===4}function Xj(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||dP(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 jx(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=Oh));else if(r!==4&&(e=e.child,e!==null))for(jx(e,t,n),e=e.sibling;e!==null;)jx(e,t,n),e=e.sibling}function Nx(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(Nx(e,t,n),e=e.sibling;e!==null;)Nx(e,t,n),e=e.sibling}var wr=null,Zs=!1;function Po(e,t,n){for(n=n.child;n!==null;)fP(e,t,n),n=n.sibling}function fP(e,t,n){if(Pi&&typeof Pi.onCommitFiberUnmount=="function")try{Pi.onCommitFiberUnmount(Dm,n)}catch{}switch(n.tag){case 5:Er||ic(n,t);case 6:var r=wr,s=Zs;wr=null,Po(e,t,n),wr=r,Zs=s,wr!==null&&(Zs?(e=wr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wr.removeChild(n.stateNode));break;case 18:wr!==null&&(Zs?(e=wr,n=n.stateNode,e.nodeType===8?Ay(e.parentNode,n):e.nodeType===1&&Ay(e,n),Pd(e)):Ay(wr,n.stateNode));break;case 4:r=wr,s=Zs,wr=n.stateNode.containerInfo,Zs=!0,Po(e,t,n),wr=r,Zs=s;break;case 0:case 11:case 14:case 15:if(!Er&&(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)&&vx(n,t,a),s=s.next}while(s!==r)}Po(e,t,n);break;case 1:if(!Er&&(ic(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Mn(n,t,l)}Po(e,t,n);break;case 21:Po(e,t,n);break;case 22:n.mode&1?(Er=(r=Er)||n.memoizedState!==null,Po(e,t,n),Er=r):Po(e,t,n);break;default:Po(e,t,n)}}function Qj(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gD),t.forEach(function(r){var s=CD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Gs(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:wr=l.stateNode,Zs=!1;break e;case 3:wr=l.stateNode.containerInfo,Zs=!0;break e;case 4:wr=l.stateNode.containerInfo,Zs=!0;break e}l=l.return}if(wr===null)throw Error(Ae(160));fP(o,a,s),wr=null,Zs=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Mn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)pP(t,e),t=t.sibling}function pP(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Gs(t,e),yi(e),r&4){try{dd(3,e,e.return),qm(3,e)}catch(v){Mn(e,e.return,v)}try{dd(5,e,e.return)}catch(v){Mn(e,e.return,v)}}break;case 1:Gs(t,e),yi(e),r&512&&n!==null&&ic(n,n.return);break;case 5:if(Gs(t,e),yi(e),r&512&&n!==null&&ic(n,n.return),e.flags&32){var s=e.stateNode;try{Cd(s,"")}catch(v){Mn(e,e.return,v)}}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),Gw(l,a);var u=Gw(l,o);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?zE(s,f):d==="dangerouslySetInnerHTML"?DE(s,f):d==="children"?Cd(s,f):Kb(s,d,f,u)}switch(l){case"input":Vw(s,o);break;case"textarea":LE(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?pc(s,!!o.multiple,h,!1):p!==!!o.multiple&&(o.defaultValue!=null?pc(s,!!o.multiple,o.defaultValue,!0):pc(s,!!o.multiple,o.multiple?[]:"",!1))}s[$d]=o}catch(v){Mn(e,e.return,v)}}break;case 6:if(Gs(t,e),yi(e),r&4){if(e.stateNode===null)throw Error(Ae(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){Mn(e,e.return,v)}}break;case 3:if(Gs(t,e),yi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Pd(t.containerInfo)}catch(v){Mn(e,e.return,v)}break;case 4:Gs(t,e),yi(e);break;case 13:Gs(t,e),yi(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(jk=Dn())),r&4&&Qj(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Er=(u=Er)||d,Gs(t,e),Er=u):Gs(t,e),yi(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(Xe=e,d=e.child;d!==null;){for(f=Xe=d;Xe!==null;){switch(p=Xe,h=p.child,p.tag){case 0:case 11:case 14:case 15:dd(4,p,p.return);break;case 1:ic(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Mn(r,n,v)}}break;case 5:ic(p,p.return);break;case 22:if(p.memoizedState!==null){eN(f);continue}}h!==null?(h.return=p,Xe=h):eN(f)}d=d.sibling}e:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{s=f.stateNode,u?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=FE("display",a))}catch(v){Mn(e,e.return,v)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){Mn(e,e.return,v)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Gs(t,e),yi(e),r&4&&Qj(e);break;case 21:break;default:Gs(t,e),yi(e)}}function yi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(dP(n)){var r=n;break e}n=n.return}throw Error(Ae(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Cd(s,""),r.flags&=-33);var o=Xj(e);Nx(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Xj(e);jx(e,l,a);break;default:throw Error(Ae(161))}}catch(c){Mn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wD(e,t,n){Xe=e,hP(e)}function hP(e,t,n){for(var r=(e.mode&1)!==0;Xe!==null;){var s=Xe,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Sp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Er;l=Sp;var u=Er;if(Sp=a,(Er=c)&&!u)for(Xe=s;Xe!==null;)a=Xe,c=a.child,a.tag===22&&a.memoizedState!==null?tN(s):c!==null?(c.return=a,Xe=c):tN(s);for(;o!==null;)Xe=o,hP(o),o=o.sibling;Xe=s,Sp=l,Er=u}Zj(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Xe=o):Zj(e)}}function Zj(e){for(;Xe!==null;){var t=Xe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Er||qm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Er)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Qs(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Oj(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}Oj(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&Pd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ae(163))}Er||t.flags&512&&Sx(t)}catch(p){Mn(t,t.return,p)}}if(t===e){Xe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function eN(e){for(;Xe!==null;){var t=Xe;if(t===e){Xe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function tN(e){for(;Xe!==null;){var t=Xe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{qm(4,t)}catch(c){Mn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Mn(t,s,c)}}var o=t.return;try{Sx(t)}catch(c){Mn(t,o,c)}break;case 5:var a=t.return;try{Sx(t)}catch(c){Mn(t,a,c)}}}catch(c){Mn(t,t.return,c)}if(t===e){Xe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Xe=l;break}Xe=t.return}}var xD=Math.ceil,Yh=wo.ReactCurrentDispatcher,vk=wo.ReactCurrentOwner,$s=wo.ReactCurrentBatchConfig,qt=0,fr=null,Kn=null,xr=0,ls=0,oc=pa(0),er=0,Bd=null,Qa=0,Um=0,Sk=0,fd=null,Yr=null,jk=0,Tc=1/0,Xi=null,Gh=!1,Cx=null,Qo=null,jp=!1,Vo=null,Jh=0,pd=0,_x=null,fh=-1,ph=0;function Br(){return qt&6?Dn():fh!==-1?fh:fh=Dn()}function Zo(e){return e.mode&1?qt&2&&xr!==0?xr&-xr:nD.transition!==null?(ph===0&&(ph=QE()),ph):(e=rn,e!==0||(e=window.event,e=e===void 0?16:iA(e.type)),e):1}function ai(e,t,n,r){if(50<pd)throw pd=0,_x=null,Error(Ae(185));ff(e,n,r),(!(qt&2)||e!==fr)&&(e===fr&&(!(qt&2)&&(Um|=n),er===4&&zo(e,xr)),ts(e,r),n===1&&qt===0&&!(t.mode&1)&&(Tc=Dn()+500,Wm&&ha()))}function ts(e,t){var n=e.callbackNode;nO(e,t);var r=Th(e,e===fr?xr:0);if(r===0)n!==null&&uj(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&uj(n),t===1)e.tag===0?tD(nN.bind(null,e)):jA(nN.bind(null,e)),XO(function(){!(qt&6)&&ha()}),n=null;else{switch(ZE(r)){case 1:n=Jb;break;case 4:n=JE;break;case 16:n=Rh;break;case 536870912:n=XE;break;default:n=Rh}n=vP(n,mP.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function mP(e,t){if(fh=-1,ph=0,qt&6)throw Error(Ae(327));var n=e.callbackNode;if(wc()&&e.callbackNode!==n)return null;var r=Th(e,e===fr?xr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Xh(e,r);else{t=r;var s=qt;qt|=2;var o=yP();(fr!==e||xr!==t)&&(Xi=null,Tc=Dn()+500,Ha(e,t));do try{vD();break}catch(l){gP(e,l)}while(!0);ck(),Yh.current=o,qt=s,Kn!==null?t=0:(fr=null,xr=0,t=er)}if(t!==0){if(t===2&&(s=ex(e),s!==0&&(r=s,t=Ex(e,s))),t===1)throw n=Bd,Ha(e,0),zo(e,r),ts(e,Dn()),n;if(t===6)zo(e,r);else{if(s=e.current.alternate,!(r&30)&&!bD(s)&&(t=Xh(e,r),t===2&&(o=ex(e),o!==0&&(r=o,t=Ex(e,o))),t===1))throw n=Bd,Ha(e,0),zo(e,r),ts(e,Dn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ae(345));case 2:Pa(e,Yr,Xi);break;case 3:if(zo(e,r),(r&130023424)===r&&(t=jk+500-Dn(),10<t)){if(Th(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Br(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=lx(Pa.bind(null,e,Yr,Xi),t);break}Pa(e,Yr,Xi);break;case 4:if(zo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-oi(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Dn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*xD(r/1960))-r,10<r){e.timeoutHandle=lx(Pa.bind(null,e,Yr,Xi),r);break}Pa(e,Yr,Xi);break;case 5:Pa(e,Yr,Xi);break;default:throw Error(Ae(329))}}}return ts(e,Dn()),e.callbackNode===n?mP.bind(null,e):null}function Ex(e,t){var n=fd;return e.current.memoizedState.isDehydrated&&(Ha(e,t).flags|=256),e=Xh(e,t),e!==2&&(t=Yr,Yr=n,t!==null&&Ax(t)),e}function Ax(e){Yr===null?Yr=e:Yr.push.apply(Yr,e)}function bD(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(!ci(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 zo(e,t){for(t&=~Sk,t&=~Um,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-oi(t),r=1<<n;e[n]=-1,t&=~r}}function nN(e){if(qt&6)throw Error(Ae(327));wc();var t=Th(e,0);if(!(t&1))return ts(e,Dn()),null;var n=Xh(e,t);if(e.tag!==0&&n===2){var r=ex(e);r!==0&&(t=r,n=Ex(e,r))}if(n===1)throw n=Bd,Ha(e,0),zo(e,t),ts(e,Dn()),n;if(n===6)throw Error(Ae(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Pa(e,Yr,Xi),ts(e,Dn()),null}function Nk(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&(Tc=Dn()+500,Wm&&ha())}}function Za(e){Vo!==null&&Vo.tag===0&&!(qt&6)&&wc();var t=qt;qt|=1;var n=$s.transition,r=rn;try{if($s.transition=null,rn=1,e)return e()}finally{rn=r,$s.transition=n,qt=t,!(qt&6)&&ha()}}function Ck(){ls=oc.current,yn(oc)}function Ha(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,JO(n)),Kn!==null)for(n=Kn.return;n!==null;){var r=n;switch(ok(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Dh();break;case 3:Ic(),yn(Zr),yn(Ir),mk();break;case 5:hk(r);break;case 4:Ic();break;case 13:yn(En);break;case 19:yn(En);break;case 10:uk(r.type._context);break;case 22:case 23:Ck()}n=n.return}if(fr=e,Kn=e=ea(e.current,null),xr=ls=t,er=0,Bd=null,Sk=Um=Qa=0,Yr=fd=null,Oa!==null){for(t=0;t<Oa.length;t++)if(n=Oa[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}Oa=null}return e}function gP(e,t){do{var n=Kn;try{if(ck(),ch.current=Uh,qh){for(var r=Pn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}qh=!1}if(Xa=0,cr=Zn=Pn=null,ud=!1,Dd=0,vk.current=null,n===null||n.return===null){er=1,Bd=t,Kn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=xr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var h=Wj(a);if(h!==null){h.flags&=-257,Vj(h,a,l,o,t),h.mode&1&&Hj(o,u,t),t=h,c=u;var y=t.updateQueue;if(y===null){var v=new Set;v.add(c),t.updateQueue=v}else y.add(c);break e}else{if(!(t&1)){Hj(o,u,t),_k();break e}c=Error(Ae(426))}}else if(xn&&l.mode&1){var b=Wj(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Vj(b,a,l,o,t),ak(Rc(c,l));break e}}o=c=Rc(c,l),er!==4&&(er=2),fd===null?fd=[o]:fd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=ZA(o,c,t);Lj(o,g);break e;case 1:l=c;var k=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof k.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Qo===null||!Qo.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var j=eP(o,l,t);Lj(o,j);break e}}o=o.return}while(o!==null)}xP(n)}catch(S){t=S,Kn===n&&n!==null&&(Kn=n=n.return);continue}break}while(!0)}function yP(){var e=Yh.current;return Yh.current=Uh,e===null?Uh:e}function _k(){(er===0||er===3||er===2)&&(er=4),fr===null||!(Qa&268435455)&&!(Um&268435455)||zo(fr,xr)}function Xh(e,t){var n=qt;qt|=2;var r=yP();(fr!==e||xr!==t)&&(Xi=null,Ha(e,t));do try{kD();break}catch(s){gP(e,s)}while(!0);if(ck(),qt=n,Yh.current=r,Kn!==null)throw Error(Ae(261));return fr=null,xr=0,er}function kD(){for(;Kn!==null;)wP(Kn)}function vD(){for(;Kn!==null&&!U2();)wP(Kn)}function wP(e){var t=kP(e.alternate,e,ls);e.memoizedProps=e.pendingProps,t===null?xP(e):Kn=t,vk.current=null}function xP(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=mD(n,t),n!==null){n.flags&=32767,Kn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{er=6,Kn=null;return}}else if(n=hD(n,t,ls),n!==null){Kn=n;return}if(t=t.sibling,t!==null){Kn=t;return}Kn=t=e}while(t!==null);er===0&&(er=5)}function Pa(e,t,n){var r=rn,s=$s.transition;try{$s.transition=null,rn=1,SD(e,t,n,r)}finally{$s.transition=s,rn=r}return null}function SD(e,t,n,r){do wc();while(Vo!==null);if(qt&6)throw Error(Ae(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(Ae(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(rO(e,o),e===fr&&(Kn=fr=null,xr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||jp||(jp=!0,vP(Rh,function(){return wc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=$s.transition,$s.transition=null;var a=rn;rn=1;var l=qt;qt|=4,vk.current=null,yD(e,n),pP(n,e),WO(ox),Mh=!!ix,ox=ix=null,e.current=n,wD(n),Y2(),qt=l,rn=a,$s.transition=o}else e.current=n;if(jp&&(jp=!1,Vo=e,Jh=s),o=e.pendingLanes,o===0&&(Qo=null),X2(n.stateNode),ts(e,Dn()),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(Gh)throw Gh=!1,e=Cx,Cx=null,e;return Jh&1&&e.tag!==0&&wc(),o=e.pendingLanes,o&1?e===_x?pd++:(pd=0,_x=e):pd=0,ha(),null}function wc(){if(Vo!==null){var e=ZE(Jh),t=$s.transition,n=rn;try{if($s.transition=null,rn=16>e?16:e,Vo===null)var r=!1;else{if(e=Vo,Vo=null,Jh=0,qt&6)throw Error(Ae(331));var s=qt;for(qt|=4,Xe=e.current;Xe!==null;){var o=Xe,a=o.child;if(Xe.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Xe=u;Xe!==null;){var d=Xe;switch(d.tag){case 0:case 11:case 15:dd(8,d,o)}var f=d.child;if(f!==null)f.return=d,Xe=f;else for(;Xe!==null;){d=Xe;var p=d.sibling,h=d.return;if(uP(d),d===u){Xe=null;break}if(p!==null){p.return=h,Xe=p;break}Xe=h}}}var y=o.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var b=v.sibling;v.sibling=null,v=b}while(v!==null)}}Xe=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Xe=a;else e:for(;Xe!==null;){if(o=Xe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:dd(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,Xe=g;break e}Xe=o.return}}var k=e.current;for(Xe=k;Xe!==null;){a=Xe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Xe=x;else e:for(a=k;Xe!==null;){if(l=Xe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:qm(9,l)}}catch(S){Mn(l,l.return,S)}if(l===a){Xe=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Xe=j;break e}Xe=l.return}}if(qt=s,ha(),Pi&&typeof Pi.onPostCommitFiberRoot=="function")try{Pi.onPostCommitFiberRoot(Dm,e)}catch{}r=!0}return r}finally{rn=n,$s.transition=t}}return!1}function rN(e,t,n){t=Rc(n,t),t=ZA(e,t,1),e=Xo(e,t,1),t=Br(),e!==null&&(ff(e,1,t),ts(e,t))}function Mn(e,t,n){if(e.tag===3)rN(e,e,n);else for(;t!==null;){if(t.tag===3){rN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Qo===null||!Qo.has(r))){e=Rc(n,e),e=eP(t,e,1),t=Xo(t,e,1),e=Br(),t!==null&&(ff(t,1,e),ts(t,e));break}}t=t.return}}function jD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Br(),e.pingedLanes|=e.suspendedLanes&n,fr===e&&(xr&n)===n&&(er===4||er===3&&(xr&130023424)===xr&&500>Dn()-jk?Ha(e,0):Sk|=n),ts(e,t)}function bP(e,t){t===0&&(e.mode&1?(t=hp,hp<<=1,!(hp&130023424)&&(hp=4194304)):t=1);var n=Br();e=fo(e,t),e!==null&&(ff(e,t,n),ts(e,n))}function ND(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),bP(e,n)}function CD(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(Ae(314))}r!==null&&r.delete(t),bP(e,n)}var kP;kP=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Zr.current)Jr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Jr=!1,pD(e,t,n);Jr=!!(e.flags&131072)}else Jr=!1,xn&&t.flags&1048576&&NA(t,Bh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;dh(e,t),e=t.pendingProps;var s=Ec(t,Ir.current);yc(t,n),s=yk(null,t,r,e,s,n);var o=wk();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,es(r)?(o=!0,Fh(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,fk(t),s.updater=Km,t.stateNode=s,s._reactInternals=t,mx(t,r,e,n),t=wx(null,t,r,!0,o,n)):(t.tag=0,xn&&o&&ik(t),zr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(dh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=ED(r),e=Qs(r,e),s){case 0:t=yx(null,t,r,e,n);break e;case 1:t=Uj(null,t,r,e,n);break e;case 11:t=Kj(null,t,r,e,n);break e;case 14:t=qj(null,t,r,Qs(r.type,e),n);break e}throw Error(Ae(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),yx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),Uj(e,t,r,s,n);case 3:e:{if(sP(t),e===null)throw Error(Ae(387));r=t.pendingProps,o=t.memoizedState,s=o.element,IA(e,t),Vh(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=Rc(Error(Ae(423)),t),t=Yj(e,t,r,n,s);break e}else if(r!==s){s=Rc(Error(Ae(424)),t),t=Yj(e,t,r,n,s);break e}else for(ds=Jo(t.stateNode.containerInfo.firstChild),ps=t,xn=!0,ti=null,n=AA(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ac(),r===s){t=po(e,t,n);break e}zr(e,t,r,n)}t=t.child}return t;case 5:return RA(t),e===null&&fx(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,ax(r,s)?a=null:o!==null&&ax(r,o)&&(t.flags|=32),rP(e,t),zr(e,t,a,n),t.child;case 6:return e===null&&fx(t),null;case 13:return iP(e,t,n);case 4:return pk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Pc(t,null,r,n):zr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),Kj(e,t,r,s,n);case 7:return zr(e,t,t.pendingProps,n),t.child;case 8:return zr(e,t,t.pendingProps.children,n),t.child;case 12:return zr(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,cn(Hh,r._currentValue),r._currentValue=a,o!==null)if(ci(o.value,a)){if(o.children===s.children&&!Zr.current){t=po(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=io(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),px(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(Ae(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),px(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}zr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,yc(t,n),s=Ls(s),r=r(s),t.flags|=1,zr(e,t,r,n),t.child;case 14:return r=t.type,s=Qs(r,t.pendingProps),s=Qs(r.type,s),qj(e,t,r,s,n);case 15:return tP(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),dh(e,t),t.tag=1,es(r)?(e=!0,Fh(t)):e=!1,yc(t,n),QA(t,r,s),mx(t,r,s,n),wx(null,t,r,!0,e,n);case 19:return oP(e,t,n);case 22:return nP(e,t,n)}throw Error(Ae(156,t.tag))};function vP(e,t){return GE(e,t)}function _D(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 Ms(e,t,n,r){return new _D(e,t,n,r)}function Ek(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ED(e){if(typeof e=="function")return Ek(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ub)return 11;if(e===Yb)return 14}return 2}function ea(e,t){var n=e.alternate;return n===null?(n=Ms(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 hh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")Ek(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Jl:return Wa(n.children,s,o,t);case qb:a=8,s|=8;break;case Fw:return e=Ms(12,n,t,s|2),e.elementType=Fw,e.lanes=o,e;case zw:return e=Ms(13,n,t,s),e.elementType=zw,e.lanes=o,e;case Bw:return e=Ms(19,n,t,s),e.elementType=Bw,e.lanes=o,e;case RE:return Ym(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case PE:a=10;break e;case IE:a=9;break e;case Ub:a=11;break e;case Yb:a=14;break e;case Lo:a=16,r=null;break e}throw Error(Ae(130,e==null?e:typeof e,""))}return t=Ms(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Wa(e,t,n,r){return e=Ms(7,e,r,t),e.lanes=n,e}function Ym(e,t,n,r){return e=Ms(22,e,r,t),e.elementType=RE,e.lanes=n,e.stateNode={isHidden:!1},e}function Oy(e,t,n){return e=Ms(6,e,null,t),e.lanes=n,e}function Dy(e,t,n){return t=Ms(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function AD(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=wy(0),this.expirationTimes=wy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ak(e,t,n,r,s,o,a,l,c){return e=new AD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ms(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fk(o),e}function PD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Gl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function SP(e){if(!e)return sa;e=e._reactInternals;e:{if(fl(e)!==e||e.tag!==1)throw Error(Ae(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(es(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ae(171))}if(e.tag===1){var n=e.type;if(es(n))return SA(e,n,t)}return t}function jP(e,t,n,r,s,o,a,l,c){return e=Ak(n,r,!0,e,s,o,a,l,c),e.context=SP(null),n=e.current,r=Br(),s=Zo(n),o=io(r,s),o.callback=t??null,Xo(n,o,s),e.current.lanes=s,ff(e,s,r),ts(e,r),e}function Gm(e,t,n,r){var s=t.current,o=Br(),a=Zo(s);return n=SP(n),t.context===null?t.context=n:t.pendingContext=n,t=io(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Xo(s,t,a),e!==null&&(ai(e,s,a,o),lh(e,s,a)),a}function Qh(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 sN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Pk(e,t){sN(e,t),(e=e.alternate)&&sN(e,t)}function ID(){return null}var NP=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ik(e){this._internalRoot=e}Jm.prototype.render=Ik.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ae(409));Gm(e,t,null,null)};Jm.prototype.unmount=Ik.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Za(function(){Gm(null,e,null,null)}),t[uo]=null}};function Jm(e){this._internalRoot=e}Jm.prototype.unstable_scheduleHydration=function(e){if(e){var t=nA();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Fo.length&&t!==0&&t<Fo[n].priority;n++);Fo.splice(n,0,e),n===0&&sA(e)}};function Rk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Xm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function iN(){}function RD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=Qh(a);o.call(u)}}var a=jP(t,r,e,0,null,!1,!1,"",iN);return e._reactRootContainer=a,e[uo]=a.current,Td(e.nodeType===8?e.parentNode:e),Za(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Qh(c);l.call(u)}}var c=Ak(e,0,!1,null,null,!1,!1,"",iN);return e._reactRootContainer=c,e[uo]=c.current,Td(e.nodeType===8?e.parentNode:e),Za(function(){Gm(t,c,n,r)}),c}function Qm(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=Qh(a);l.call(c)}}Gm(t,a,e,s)}else a=RD(n,t,e,s,r);return Qh(a)}eA=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Gu(t.pendingLanes);n!==0&&(Xb(t,n|1),ts(t,Dn()),!(qt&6)&&(Tc=Dn()+500,ha()))}break;case 13:Za(function(){var r=fo(e,1);if(r!==null){var s=Br();ai(r,e,1,s)}}),Pk(e,1)}};Qb=function(e){if(e.tag===13){var t=fo(e,134217728);if(t!==null){var n=Br();ai(t,e,134217728,n)}Pk(e,134217728)}};tA=function(e){if(e.tag===13){var t=Zo(e),n=fo(e,t);if(n!==null){var r=Br();ai(n,e,t,r)}Pk(e,t)}};nA=function(){return rn};rA=function(e,t){var n=rn;try{return rn=e,t()}finally{rn=n}};Xw=function(e,t,n){switch(t){case"input":if(Vw(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=Hm(r);if(!s)throw Error(Ae(90));ME(r),Vw(r,s)}}}break;case"textarea":LE(e,n);break;case"select":t=n.value,t!=null&&pc(e,!!n.multiple,t,!1)}};WE=Nk;VE=Za;var TD={usingClientEntryPoint:!1,Events:[hf,ec,Hm,BE,HE,Nk]},$u={findFiberByHostInstance:La,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},MD={bundleType:$u.bundleType,version:$u.version,rendererPackageName:$u.rendererPackageName,rendererConfig:$u.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:wo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=UE(e),e===null?null:e.stateNode},findFiberByHostInstance:$u.findFiberByHostInstance||ID,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 Np=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Np.isDisabled&&Np.supportsFiber)try{Dm=Np.inject(MD),Pi=Np}catch{}}ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=TD;ys.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Rk(t))throw Error(Ae(200));return PD(e,t,null,n)};ys.createRoot=function(e,t){if(!Rk(e))throw Error(Ae(299));var n=!1,r="",s=NP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Ak(e,1,!1,null,null,n,!1,r,s),e[uo]=t.current,Td(e.nodeType===8?e.parentNode:e),new Ik(t)};ys.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(Ae(188)):(e=Object.keys(e).join(","),Error(Ae(268,e)));return e=UE(t),e=e===null?null:e.stateNode,e};ys.flushSync=function(e){return Za(e)};ys.hydrate=function(e,t,n){if(!Xm(t))throw Error(Ae(200));return Qm(null,e,t,!0,n)};ys.hydrateRoot=function(e,t,n){if(!Rk(e))throw Error(Ae(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=NP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=jP(t,null,e,1,n??null,s,!1,o,a),e[uo]=t.current,Td(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 Jm(t)};ys.render=function(e,t,n){if(!Xm(t))throw Error(Ae(200));return Qm(null,e,t,!1,n)};ys.unmountComponentAtNode=function(e){if(!Xm(e))throw Error(Ae(40));return e._reactRootContainer?(Za(function(){Qm(null,null,e,!1,function(){e._reactRootContainer=null,e[uo]=null})}),!0):!1};ys.unstable_batchedUpdates=Nk;ys.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Xm(n))throw Error(Ae(200));if(e==null||e._reactInternals===void 0)throw Error(Ae(38));return Qm(e,t,n,!1,r)};ys.version="18.3.1-next-f1338f8080-20240426";function CP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(CP)}catch(e){console.error(e)}}CP(),CE.exports=ys;var lr=CE.exports,oN=lr;Ow.createRoot=oN.createRoot,Ow.hydrateRoot=oN.hydrateRoot;const _P=m.createContext(null);function Px(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function $D(){const e=Px(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function LD({children:e}){const[t,n]=m.useState($D);m.useEffect(()=>{const o=()=>n(Px(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=m.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Px(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(_P.Provider,{value:s,children:e})}function xs(){const e=m.useContext(_P);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function OD(){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 aN={};function Ix(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&aN[t[0]]||(typeof t[0]=="string"&&(aN[t[0]]=new Date),OD(...t))}const EP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function lN(e,t,n){e.loadNamespaces(t,EP(e,n))}function cN(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,EP(e,r))}function DD(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 u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(o,e)))}function FD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Ix("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}}):DD(e,t,n)}const zD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,BD={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},HD=e=>BD[e],WD=e=>e.replace(zD,HD);let Rx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:WD};function VD(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rx={...Rx,...e}}function KD(){return Rx}let AP;function qD(e){AP=e}function UD(){return AP}const YD={type:"3rdParty",init(e){VD(e.options.react),qD(e)}},GD=m.createContext();class JD{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const XD=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Vr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(GD)||{},o=n||r||UD();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new JD),!o){Ix("You will need to pass in an i18next instance by using initReactI18next");const x=(S,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(S)?S[S.length-1]:S,j=[x,{},!1];return j.t=x,j.i18n={},j.ready=!1,j}o.options.react&&o.options.react.wait!==void 0&&Ix("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...KD(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||s||o.options&&o.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const d=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>FD(x,o,a));function f(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[p,h]=m.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=XD(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:j}=a;b.current=!0,!d&&!l&&(t.lng?cN(o,t.lng,u,()=>{b.current&&h(f)}):lN(o,u,()=>{b.current&&h(f)})),d&&v&&v!==y&&b.current&&h(f);function S(){b.current&&h(f)}return x&&o&&o.on(x,S),j&&o&&o.store.on(j,S),()=>{b.current=!1,x&&o&&x.split(" ").forEach(C=>o.off(C,S)),j&&o&&j.split(" ").forEach(C=>o.store.off(C,S))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(f),g.current=!1},[o,c]);const k=[p,o,d];if(k.t=p,k.i18n=o,k.ready=d,d||!d&&!l)return k;throw new Promise(x=>{t.lng?cN(o,t.lng,u,()=>x()):lN(o,u,()=>x())})}const PP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20fill='none'%20role='img'%20aria-label='AgentFlow'%3e%3ctitle%3eAgentFlow%3c/title%3e%3crect%20width='32'%20height='32'%20rx='9'%20fill='%23131313'/%3e%3crect%20x='4.5'%20y='11'%20width='10.5'%20height='10'%20rx='3'%20fill='%232a2a2a'%20stroke='%237c4dff'%20stroke-width='1.2'/%3e%3cpath%20d='M15.25%2014.25C17.8%2012.2%2019.2%209.8%2022.25%209.25'%20stroke='%23cdbdff'%20stroke-width='1.65'%20stroke-linecap='round'%20/%3e%3cpath%20d='M15.25%2017.75C17.8%2019.8%2019.2%2022.2%2022.25%2022.75'%20stroke='%237c4dff'%20stroke-width='1.65'%20stroke-linecap='round'%20opacity='0.92'%20/%3e%3crect%20x='21.75'%20y='6'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%23e8deff'%20stroke-width='0.95'%20opacity='0.95'/%3e%3crect%20x='21.75'%20y='19'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%239ecaff'%20stroke-width='0.95'%20opacity='0.9'/%3e%3c/svg%3e",QD=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workflows",label:"迭代",icon:"timeline"},{to:"/workspaces",label:"知识库",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/admin/teams",label:"团队管理",icon:"groups",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],ZD=[{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 eF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function tF({authUser:e,onLogout:t}){const{path:n,navigate:r}=xs(),{t:s}=Vr(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:PP,alt:"",width:"36",height:"36",decoding:"async"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),i.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),i.jsx("nav",{className:"af-nav",children:QD.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(eF(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&&ZD.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 nF="agentflow.pipelineRecent",rF=15;function sF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function iF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(nF);return e?sF(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 oF(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 uN(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,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const d=Math.floor(a/24);return d<7?t("flow:time.daysAgo",{n:d}):`${l.getMonth()+1}/${l.getDate()}`}function aF(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:oF(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,rF)}var cs=Uint8Array,ac=Uint16Array,lF=Int32Array,IP=new cs([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]),RP=new cs([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]),cF=new cs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),TP=function(e,t){for(var n=new ac(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new lF(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}},MP=TP(IP,2),$P=MP.b,uF=MP.r;$P[28]=258,uF[258]=28;var dF=TP(RP,0),fF=dF.b,Tx=new ac(32768);for(var gn=0;gn<32768;++gn){var Io=(gn&43690)>>1|(gn&21845)<<1;Io=(Io&52428)>>2|(Io&13107)<<2,Io=(Io&61680)>>4|(Io&3855)<<4,Tx[gn]=((Io&65280)>>8|(Io&255)<<8)>>1}var hd=function(e,t,n){for(var r=e.length,s=0,o=new ac(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new ac(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new ac(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],d=t-e[s],f=a[e[s]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)l[Tx[f]>>c]=u}else for(l=new ac(r),s=0;s<r;++s)e[s]&&(l[s]=Tx[a[e[s]-1]++]>>15-e[s]);return l},gf=new cs(288);for(var gn=0;gn<144;++gn)gf[gn]=8;for(var gn=144;gn<256;++gn)gf[gn]=9;for(var gn=256;gn<280;++gn)gf[gn]=7;for(var gn=280;gn<288;++gn)gf[gn]=8;var LP=new cs(32);for(var gn=0;gn<32;++gn)LP[gn]=5;var pF=hd(gf,9,1),hF=hd(LP,5,1),Fy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Js=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},zy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},mF=function(e){return(e+7)/8|0},Tk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new cs(e.subarray(t,n))},gF=["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"],As=function(e,t,n){var r=new Error(t||gF[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,As),!n)throw r;return r},yF=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new cs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new cs(s*3));var u=function(ce){var de=n.length;if(ce>de){var pe=new cs(Math.max(de*2,ce));pe.set(n),n=pe}},d=t.f||0,f=t.p||0,p=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!h){d=Js(e,f,1);var k=Js(e,f+1,3);if(f+=3,k)if(k==1)h=pF,y=hF,v=9,b=5;else if(k==2){var C=Js(e,f,31)+257,P=Js(e,f+10,15)+4,R=C+Js(e,f+5,31)+1;f+=14;for(var B=new cs(R),A=new cs(19),O=0;O<P;++O)A[cF[O]]=Js(e,f+O*3,7);f+=P*3;for(var D=Fy(A),L=(1<<D)-1,M=hd(A,D,1),O=0;O<R;){var V=M[Js(e,f,L)];f+=V&15;var x=V>>4;if(x<16)B[O++]=x;else{var z=0,F=0;for(x==16?(F=3+Js(e,f,3),f+=2,z=B[O-1]):x==17?(F=3+Js(e,f,7),f+=3):x==18&&(F=11+Js(e,f,127),f+=7);F--;)B[O++]=z}}var $=B.subarray(0,C),W=B.subarray(C);v=Fy($),b=Fy(W),h=hd($,v,1),y=hd(W,b,1)}else As(1);else{var x=mF(f)+4,j=e[x-4]|e[x-3]<<8,S=x+j;if(S>s){c&&As(0);break}l&&u(p+j),n.set(e.subarray(x,S),p),t.b=p+=j,t.p=f=S*8,t.f=d;continue}if(f>g){c&&As(0);break}}l&&u(p+131072);for(var E=(1<<v)-1,Q=(1<<b)-1,K=f;;K=f){var z=h[zy(e,f)&E],H=z>>4;if(f+=z&15,f>g){c&&As(0);break}if(z||As(2),H<256)n[p++]=H;else if(H==256){K=f,h=null;break}else{var ee=H-254;if(H>264){var O=H-257,ue=IP[O];ee=Js(e,f,(1<<ue)-1)+$P[O],f+=ue}var G=y[zy(e,f)&Q],te=G>>4;G||As(3),f+=G&15;var W=fF[te];if(te>3){var ue=RP[te];W+=zy(e,f)&(1<<ue)-1,f+=ue}if(f>g){c&&As(0);break}l&&u(p+131072);var se=p+ee;if(p<W){var ie=o-W,Z=Math.min(W,se);for(ie+p<0&&As(3);p<Z;++p)n[p]=r[ie+p]}for(;p<se;++p)n[p]=n[p-W]}}t.l=h,t.p=K,t.b=p,t.f=d,h&&(d=1,t.m=v,t.d=y,t.n=b)}while(!d);return p!=n.length&&a?Tk(n,0,p):n.subarray(0,p)},wF=new cs(0),Ni=function(e,t){return e[t]|e[t+1]<<8},ni=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},By=function(e,t){return ni(e,t)+ni(e,t+4)*4294967296};function xF(e,t){return yF(e,{i:2},t&&t.out,t&&t.dictionary)}var Mx=typeof TextDecoder<"u"&&new TextDecoder,bF=0;try{Mx.decode(wF,{stream:!0}),bF=1}catch{}var kF=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:Tk(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 vF(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(Mx)return Mx.decode(e);var s=kF(e),o=s.s,n=s.r;return n.length&&As(8),o}}var SF=function(e,t){return t+30+Ni(e,t+26)+Ni(e,t+28)},jF=function(e,t,n){var r=Ni(e,t+28),s=vF(e.subarray(t+46,t+46+r),!(Ni(e,t+8)&2048)),o=t+46+r,a=ni(e,t+20),l=n&&a==4294967295?NF(e,o):[a,ni(e,t+24),ni(e,t+42)],c=l[0],u=l[1],d=l[2];return[Ni(e,t+10),c,u,s,o+Ni(e,t+30)+Ni(e,t+32),d]},NF=function(e,t){for(;Ni(e,t)!=1;t+=4+Ni(e,t+2));return[By(e,t+12),By(e,t+4),By(e,t+20)]};function CF(e,t){for(var n={},r=e.length-22;ni(e,r)!=101010256;--r)(!r||e.length-r>65558)&&As(13);var s=Ni(e,r+8);if(!s)return{};var o=ni(e,r+16),a=o==4294967295||s==65535;if(a){var l=ni(e,r-12);a=ni(e,l)==101075792,a&&(s=ni(e,l+32),o=ni(e,l+48))}for(var c=0;c<s;++c){var u=jF(e,o,a),d=u[0],f=u[1],p=u[2],h=u[3],y=u[4],v=u[5],b=SF(e,v);o=y,d?d==8?n[h]=xF(e.subarray(b,b+f),{out:new cs(p)}):As(14,"unknown compression type "+d):n[h]=Tk(e,b,b+f)}return n}const _F=8*1024*1024,EF=500;function AF(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 PF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function IF(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 RF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function TF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=CF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=AF(c);if(!d||PF(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>_F||(o+=1,o>EF))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=IF(c);u!==null&&a.add(u)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return RF.test(l)?l:null}catch{return null}}const Hy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function MF({file:e,onClose:t,onImported:n}){const{t:r}=Vr(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,d]=m.useState("user"),[f,p]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const S=requestAnimationFrame(()=>{var C;return(C=o.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(S)},[]),m.useEffect(()=>{let S=!1;return(async()=>{const C=g.name||"",P=C.toLowerCase();let R="";if(P.endsWith(".zip")){if(R=await TF(g)||"",!R){const B=C.replace(/\.zip$/i,"");Hy.test(B)&&(R=B)}}else if(P.endsWith(".yaml")||P.endsWith(".yml")){const B=C.replace(/\.ya?ml$/i,"");Hy.test(B)&&(R=B)}S||c(R)})(),()=>{S=!0}},[g]);const k=l.trim(),x=k.length>0&&Hy.test(k);async function j(S){if(S.preventDefault(),!(!x||f)){p(!0),y("");try{const C=new FormData;C.set("flowId",k),C.set("targetSpace",u),C.set("file",g,g.name);const P=await fetch("/api/flows/import",{method:"POST",body:C}),R=await P.json().catch(()=>({}));if(!P.ok){y(typeof R.error=="string"?R.error:r("project:importModal.importFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(C){y(String((C==null?void 0:C.message)||C))}finally{p(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:S=>{S.target===S.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:S=>S.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:g.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:S=>{var P;const C=(P=S.target.files)==null?void 0:P[0];C&&b(C),S.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:S=>c(S.target.value),"aria-invalid":k.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 S;return(S=a.current)==null?void 0:S.click()},children:r("project:importModal.changeFile")})}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const $F=/^[a-zA-Z][a-zA-Z0-9_-]*$/,dN="af:newPipelineGuide";function LF({open:e,onClose:t,onCreated:n}){const{t:r}=Vr(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("user"),[p,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(dN)==="true"&&g(!0);const P=requestAnimationFrame(()=>{var R;return(R=o.current)==null?void 0:R.focus()});return()=>cancelAnimationFrame(P)},[e]);const k=()=>{localStorage.removeItem(dN),g(!1)};if(!e)return null;const x=a.trim(),j=x.length>0&&$F.test(x);async function S(C){if(C.preventDefault(),!(!j||p)){h(!0),v(""),k();try{const P=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:d})}),R=await P.json().catch(()=>({}));if(!P.ok){v(typeof R.error=="string"?R.error:r("project:newPipelineModal.createFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(P){v(String((P==null?void 0:P.message)||P))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&(k(),t())},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),b?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:k,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:S,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:C=>l(C.target.value),"aria-invalid":x.length>0&&!j}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"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(b?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:C=>u(C.target.value)}),b?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?i.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||p,children:r(p?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const OP="agentflow.pipelineViewPreference";function DP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function FP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(OP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function OF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(OP,JSON.stringify(e))}catch{}}function Mk(e){return e==="display"?"display":"workspace"}function DF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function zP(e,t){const n=Mk(t);return n==="pipeline"&&DF(e==null?void 0:e.source)?"workspace":n}function FF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function zF(e,t,n,r=!1){if(!e)return;const s=FP();s[DP(e,t,r)]={view:Mk(n),at:Date.now()},OF(s)}function BF(e,t="workspace"){if(!(e!=null&&e.id))return Mk(t);const r=FP()[DP(e.id,e.source??"user",!!e.archived)],s=zP(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!FF(e)?"workspace":s}function HF(e,t="workspace"){var s;const n=zP(e,t);if(!(e!=null&&e.id))return n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return(s=e.collaboration)!=null&&s.id&&r.set("workspaceId",e.collaboration.id),e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function Cp(e,t="workspace"){return HF(e,BF(e,t))}function WF(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 $x(e){return String((e==null?void 0:e.version)||"").trim()}function VF(e){const t=$x(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 KF({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("keyword"),[p,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,S]=m.useState(""),C=m.useCallback(async()=>{x("");try{const[D,L]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await D.json().catch(()=>({}));D.ok&&r({available:!!M.available,version:typeof M.version=="string"?M.version:"",loggedIn:!!M.loggedIn,user:typeof M.user=="string"?M.user:"",error:typeof M.error=="string"?M.error:""});const V=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+L.status);o(Array.isArray(V.skills)?V.skills:[]),l(typeof V.skillsRoot=="string"?V.skillsRoot:""),v({})}catch(D){x(String(D.message||D))}},[]);m.useEffect(()=>{C()},[C]);const P=m.useCallback(async()=>{const D=c.trim();if(D){g("search"),x(""),S("");try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(d)}`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+L.status);h(Array.isArray(M.items)?M.items:[])}catch(L){x(String(L.message||L))}finally{g("")}}},[c,d]),R=m.useCallback(async(D,L=!1)=>{if(!t)return;const M=D&&typeof D=="object"?D:null,V=String(M?M.slug||M.name||M.collection||M.skillId||M.id:D||"").trim();if(V){g(`install:${V}`),x(""),S("");try{const z=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:L}:{slug:V,target:"agentflow",agent:"codex",force:L},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);S(L?`已更新 ${V}`:`已安装 ${V}`),await C(),typeof e=="function"&&await e()}catch(z){x(String(z.message||z))}finally{g("")}}},[t,C,e]),B=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),x(""),S("");try{const D=await Promise.all(s.map(async V=>{const z=String(V.name||"").trim();if(!z)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(z)}&mode=keyword`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);const W=Array.isArray($.items)?$.items:[],E=W.find(ee=>ee.slug===z||ee.name===z||ee.id===z)||W[0],Q=$x(V),K=String((E==null?void 0:E.version)||"").trim();let H="unknown";return E?Q&&K?H=WF(Q,K)<0?"update":"current":K&&(H="remote-only"):H="missing",[z,{state:H,latestVersion:K,installedVersion:Q,summary:(E==null?void 0:E.summary)||""}]}catch(F){return[z,{state:"error",error:String(F.message||F),installedVersion:$x(V)}]}})),L={};for(const V of D)V&&(L[V[0]]=V[1]);v(L);const M=Object.values(L).filter(V=>V.state==="update").length;S(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),A=m.useCallback(async D=>{if(!t)return;const L=String(D||"").trim();if(L){g(`uninstall:${L}`),x(""),S("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:L,target:"agentflow",agent:"codex"})}),V=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+M.status);S(`已卸载 ${L}`),await C(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{g("")}}},[t,C,e]),O=m.useCallback(async()=>{if(t){g("update-cli"),x(""),S("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),L=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+D.status);S("SkillHub CLI 已更新"),await C()}catch(D){x(String(D.message||D))}finally{g("")}}},[t,C]);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:C,disabled:!!b,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:!t||!!b||s.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:!t||!!b,children:b==="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:d,onChange:D=>{f(D.target.value),h([])},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:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&P()},placeholder:d==="collectionId"?"输入 collection id,例如 1":d==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>P(),disabled:!c.trim()||b==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):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(D=>{const L=y[D.name],M=!L||L.state==="update"||L.state==="remote-only"||L.state==="unknown"||L.state==="error",V=b===`install:${D.name}`?"更新中…":(L==null?void 0:L.state)==="current"?"已最新":(L==null?void 0:L.state)==="update"&&L.latestVersion?`更新到 v${L.latestVersion}`:(L==null?void 0:L.state)==="remote-only"&&L.latestVersion?`安装 v${L.latestVersion}`:"重装";return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:VF(D)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:L?L.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",L.installedVersion?`v${L.installedVersion} -> `:"","v",L.latestVersion]}):L.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",L.latestVersion||L.installedVersion]}):L.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",L.latestVersion,",本地版本未知"]}):L.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):L.state==="error"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),i.jsxs("div",{className:"af-set-skillhub-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(D.name,!0),disabled:!t||!!b||!M,children:V}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>A(D.name),disabled:!t||!!b,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.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:p.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:p.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):p.map(D=>{const L=D.slug||D.name,M=D.kind==="collection"||D.collection,V=!M&&s.some(z=>z.name===L||z.name===D.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:D.name||L}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${D.collection}`:L,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),i.jsx("button",{type:"button",className:V?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>R(D,V),disabled:!t||!!b,children:V?"更新":M?"安装合集":"安装"})]},D.id||L)})})]})]})]})}function Va(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function qF(e){return{version:1,collections:Va({collections:e})}}function UF(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function BP(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(UF(s)))||""}}function ia(e,t){const n=BP(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function YF(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 GF(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function JF(e,t,n){const r=ia(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 XF(e,t,n){const r=String(e).trim().toLowerCase(),s=Va({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return ia(s,t)}function QF(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Va({collections:r}),l=XF(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const d=JSON.parse(u);if(Array.isArray(d)){const f=BP(n),p=Array.from(new Set(d.map(f).filter(Boolean)));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),y=new Set(l),v=l.length>0&&l.every(g=>h.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=ia(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:p}}}catch{}return c}function Dl(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 ZF(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function ez(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 Lx(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 HP(e){var n;if((n=e.collaboration)!=null&&n.role&&e.collaboration.role!=="owner")return`共享 Project / ${e.collaboration.ownerUsername||e.collaboration.ownerId} / ${e.id}`;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 tz="project:defaultCardDesc";function WP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(tz)}function nz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ln({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(`(${nz(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 rz(e,t,n){const r=[String(e.id),WP(e,n),HP(e),Lx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function sz(e,t,n){return t?rz(e,t,n).includes(t):!0}function iz(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 Wy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function fN(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 pN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const oz=["all","agent","control","provide","marketplace"],az=["all","agent","control","provide"],VP="agentflow.projects.activityPanelOpen",Ox="agentflow.projects.activitySelected";function lz(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(VP);return e!=="0"}function hN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function cz(){return typeof localStorage>"u"?"":localStorage.getItem(Ox)||""}function _p(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function On(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 uz(e,t){if((e==null?void 0:e.source)!=="marketplace")return!1;const n=String((e==null?void 0:e.ownerUserId)||(e==null?void 0:e.createdBy)||"").trim();return n?new Set([String((t==null?void 0:t.userId)||"").trim(),String((t==null?void 0:t.username)||"").trim()].filter(Boolean)).has(n):!0}function Ro(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function KP(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 qP(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 Dx(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 mN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Dx(e,t))}function dz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function gN(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 fz(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 Vy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function pz(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 hz(e,t){const n=e.map(d=>d.id),r=new Set(n),s=new Map(n.map(d=>[d,0])),o=new Map(n.map(d=>[d,[]]));t.forEach(d=>{var f;!r.has(d.sourceId)||!r.has(d.targetId)||(s.set(d.targetId,(s.get(d.targetId)||0)+1),(f=o.get(d.sourceId))==null||f.push(d.targetId))});const a=new Map,l=n.filter(d=>(s.get(d)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(d=>a.set(d,0));for(let d=0;d<l.length;d+=1){const f=l[d],p=(a.get(f)||0)+1;for(const h of o.get(f)||[])(!a.has(h)||p>a.get(h))&&(a.set(h,p),l.push(h))}n.forEach((d,f)=>{a.has(d)||a.set(d,f%3)});const c=new Map,u=new Map;return n.forEach(d=>{const f=a.get(d)||0,p=c.get(f)||0;c.set(f,p+1),u.set(d,{x:f*190,y:p*86})}),u}function mz(e){var v,b,g,k;const t=KP(e),n=qP(e),r=new Map(t.map((x,j)=>[Dx(x,j),mN(x,j)])),s=t.map((x,j)=>({id:Dx(x,j),title:mN(x,j),meta:dz(x)})),o=n.map((x,j)=>{const S=gN(x,"source"),C=gN(x,"target");return{key:(x==null?void 0:x.id)||`${S}-${C}-${j}`,sourceId:S,targetId:C,source:r.get(S)||S||"?",target:r.get(C)||C||"?",label:fz(x)}}),a=(b=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&b.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(g=e==null?void 0:e.snippet)==null?void 0:g.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=hz(s,o),u=s.map(x=>{const j=pz(a[x.id])||c.get(x.id)||{x:0,y:0},S=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},C=Number(S.width),P=Number(S.height),R=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),B=Math.max(48,Math.min(76,Number.isFinite(P)?P*.46:54));return{...x,x:j.x,y:j.y,width:R,height:B}}),d=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const j=d.get(x.sourceId),S=d.get(x.targetId);if(!j||!S)return null;const C=j.x+j.width,P=j.y+j.height/2,R=S.x,B=S.y+S.height/2,A=Math.max(48,Math.abs(R-C)*.45);return{...x,path:`M ${C} ${P} C ${C+A} ${P}, ${R-A} ${B}, ${R} ${B}`,labelX:(C+R)/2,labelY:(P+B)/2}}).filter(Boolean),p=u.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}),h=36,y=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Fl({resourceKind:e="",authUser:t=null}){var Rt,Qt,pn,$n,ks,vs;const{t:n}=Vr(),{navigate:r,path:s}=xs(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[d,f]=m.useState("personal"),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState([]),[j,S]=m.useState(""),[C,P]=m.useState(!1),[R,B]=m.useState([]),[A,O]=m.useState(""),[D,L]=m.useState(""),[M,V]=m.useState(!1),[z,F]=m.useState(!1),[$,W]=m.useState(!1),[E,Q]=m.useState(null),[K,H]=m.useState(!1),[ee,ue]=m.useState(""),[G,te]=m.useState(lz),[se,ie]=m.useState(cz),[Z,ce]=m.useState("all"),[de,pe]=m.useState(""),[Me,Ne]=m.useState("overview"),[Ce,We]=m.useState({}),[ct,yt]=m.useState(""),[Re,ot]=m.useState({}),[kt,$t]=m.useState(""),[ye,ze]=m.useState(""),[re,ke]=m.useState({}),[Be,Qe]=m.useState(""),[_e,_t]=m.useState(""),[Xt,Ft]=m.useState(""),[at,Fn]=m.useState(""),[ne,Pe]=m.useState(""),[et,qe]=m.useState(!1),[It,vt]=m.useState(""),[tr,Yn]=m.useState({hiddenBuiltins:[],promoted:[]}),Tr=m.useRef(0),kn=m.useRef(0),nr=m.useRef(0),pr=m.useCallback(async()=>{var we,$e;const q=++kn.current;O("");try{const Ee=await fetch(`/api/flows?view=${encodeURIComponent(d)}`);if(q!==kn.current)return;if(!Ee.ok)throw new Error("HTTP "+Ee.status);const Ze=await Ee.json();if(q!==kn.current)return;u(Array.isArray(Ze)?Ze:[])}catch(Ee){if(q!==kn.current)return;u([]),O(String(Ee.message||Ee))}try{const Ee=await fetch("/api/pipeline-recent-runs");if(q!==kn.current)return;if(Ee.ok){const Ze=await Ee.json();if(q!==kn.current)return;B(Array.isArray(Ze.runs)?Ze.runs:[])}else B([])}catch{if(q!==kn.current)return;B([])}if(t!=null&&t.isAdmin)try{const Ee=await fetch("/api/admin/builtin-flows");if(q!==kn.current)return;const Ze=await Ee.json().catch(()=>({}));Ee.ok&&Yn({hiddenBuiltins:Array.isArray((we=Ze==null?void 0:Ze.config)==null?void 0:we.hiddenBuiltins)?Ze.config.hiddenBuiltins:[],promoted:Array.isArray(($e=Ze==null?void 0:Ze.config)==null?void 0:$e.promoted)?Ze.config.promoted:[]})}catch{if(q!==kn.current)return;Yn({hiddenBuiltins:[],promoted:[]})}else Yn({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,d]),hr=m.useCallback(async(q,we)=>{if(!(t!=null&&t.isAdmin)||!(q!=null&&q.id))return;const $e=`${we}:${q.source}:${q.id}`;vt($e),O("");try{const Ee=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:we,flowId:q.id,ownerUserId:q.ownerUserId||t.userId})}),Ze=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(Ze.error||"更新内置配置失败");await pr()}catch(Ee){O(String(Ee.message||Ee))}finally{vt("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,pr]),fn=m.useCallback(async()=>{const q=++nr.current;L(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";h([]),g([]),pe("");try{const[Ee,Ze,wn,Lt]=await Promise.all([fetch(we),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Sn=await Ee.json().catch(()=>({})),rr=await Ze.json().catch(()=>({})),yr=await wn.json().catch(()=>({})),Zt=await Lt.json().catch(()=>({}));if(!Ee.ok)throw new Error(Sn.error||"Nodes HTTP "+Ee.status);if(!Ze.ok)throw new Error(rr.error||"Skills HTTP "+Ze.status);if(!wn.ok)throw new Error(yr.error||"Collections HTTP "+wn.status);if(!Lt.ok)throw new Error(Zt.error||"Flow snippets HTTP "+Lt.status);if(q!==nr.current)return;h(Array.isArray(Sn.nodes)?Sn.nodes:Array.isArray(Sn)?Sn:[]),v(Array.isArray(rr.skills)?rr.skills:[]),x(Va(yr)),g(Array.isArray(Zt.snippets)?Zt.snippets:[])}catch(Ee){if(q!==nr.current)return;h([]),v([]),g([]),x([]),L(String(Ee.message||Ee))}finally{if(q!==nr.current)return;F(!0)}},[e]);m.useEffect(()=>{V(!1),pr(),fn()},[pr,fn]),m.useEffect(()=>{try{localStorage.setItem(VP,G?"1":"0")}catch{}},[G]),m.useEffect(()=>{try{se?localStorage.setItem(Ox,se):localStorage.removeItem(Ox)}catch{}},[se]),m.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{q||qe(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const zn=m.useCallback(async q=>{if(!o)return;const we=Va({collections:q});P(!0),L("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(qF(we))}),Ee=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ee.error||"Collections HTTP "+$e.status);x(Va(Ee))}catch($e){L(String($e.message||$e))}finally{P(!1)}},[o]),ss=m.useCallback(()=>{if(!o)return;const q=j.trim();if(!q)return;const we=q.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(Lt=>Lt.id));let Ee=we,Ze=2;for(;$e.has(Ee);)Ee=`${we}-${Ze++}`;const wn=Date.now();zn([...k,{id:Ee,name:q,skillKeys:[],createdAt:wn,updatedAt:wn}]),S(""),ce(`collection:${Ee}`)},[o,j,zn,k]),Ds=m.useCallback(q=>{if(!o)return;const we=k.find(Ee=>Ee.id===q);if(we!=null&&we.builtin)return;const $e=k.filter(Ee=>Ee.id!==q);Z===`collection:${q}`&&ce("all"),zn($e)},[o,Z,zn,k]),vn=m.useCallback((q,we,$e)=>{if(!o)return;const Ee=String(we||"").trim();if(!Ee)return;const Ze=Date.now(),wn=k.map(Lt=>{if(Lt.id!==q)return Lt;const Sn=new Set(Lt.skillKeys||[]);return $e?Sn.add(Ee):Sn.delete(Ee),{...Lt,skillKeys:Array.from(Sn),updatedAt:Ze}});zn(wn)},[o,zn,k]),Gn=m.useCallback(async q=>{const we=q==null?void 0:q.packageId,$e=q==null?void 0:q.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ee=On(q);_t(Ee),Ft(""),L("");try{const Ze=new URLSearchParams({id:we,version:$e}),wn=await fetch(`/api/marketplace/node?${Ze.toString()}`,{method:"DELETE"}),Lt=await wn.json().catch(()=>({}));if(!wn.ok||(Lt==null?void 0:Lt.ok)===!1){const Sn=Array.isArray(Lt==null?void 0:Lt.usage)&&Lt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Lt.usage.length})}`:"";throw new Error(((Lt==null?void 0:Lt.error)||"Delete failed")+Sn)}Ft(n("project:deleteMyNodeSuccess",{id:we,version:$e})),ot(Sn=>{const rr={...Sn};return delete rr[Ee],rr}),ke(Sn=>{const rr={};for(const[yr,Zt]of Object.entries(Sn))yr.startsWith(`${Ee}:`)||(rr[yr]=Zt);return rr}),pe(""),await fn()}catch(Ze){Ft(String(Ze.message||Ze))}finally{_t("")}},[fn,n]),bs=m.useCallback(async q=>{const we=q==null?void 0:q.id,$e=(q==null?void 0:q.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ee=Ro(q);Fn(Ee),Pe(""),L("");try{const Ze=new URLSearchParams({id:we,version:$e}),wn=await fetch(`/api/marketplace/flow-snippet?${Ze.toString()}`,{method:"DELETE"}),Lt=await wn.json().catch(()=>({}));if(!wn.ok||(Lt==null?void 0:Lt.ok)===!1)throw new Error((Lt==null?void 0:Lt.error)||"Delete failed");Pe(n("project:deleteMyFlowSuccess",{id:we,version:$e})),pe(""),await fn()}catch(Ze){Pe(String(Ze.message||Ze))}finally{Fn("")}},[fn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ce("all"),pe(""),Ne("overview");return}l(q=>q==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const q=new URLSearchParams(window.location.search),we=q.get("tab");let $e=!1;if(we==="nodes"){r("/nodes");return}if(we==="my-nodes"){r("/my-nodes");return}if(we==="my-flows"){r("/my-flows");return}if(we==="skills"){r("/skills");return}if(we==="archived"?(l("archived"),q.delete("tab"),$e=!0):we&&(l("all"),q.delete("tab"),$e=!0),q.get("new")==="1"&&(W(!0),q.delete("new"),$e=!0),$e){const Ee=q.toString();window.history.replaceState({},"",Ee?`/projects?${Ee}`:"/projects")}},[s,r]);const Jn=m.useMemo(()=>aF(R,iF(),c),[R,c,s]),Bn=m.useMemo(()=>Jn.filter(q=>iz(ee,q)),[Jn,ee]),vr=ee.trim().toLowerCase(),Sr=m.useMemo(()=>a==="archived"?c.filter(q=>q.archived):c.filter(q=>!q.archived),[c,a]),Hn=m.useMemo(()=>Sr.filter(q=>sz(q,vr,n)),[Sr,vr,n]),Mr=m.useMemo(()=>new Set((tr.promoted||[]).map(q=>String((q==null?void 0:q.id)||"").trim()).filter(Boolean)),[tr.promoted]),$r=m.useMemo(()=>(tr.hiddenBuiltins||[]).map(q=>String(q||"").trim()).filter(Boolean),[tr.hiddenBuiltins]),le=a==="nodes"||a==="my-nodes",me=a==="my-nodes",tt=a==="my-flows",rt=m.useMemo(()=>p.filter(q=>me&&!uz(q,t)?!1:(Z==="all"||(Z==="marketplace"?q.source==="marketplace":q.type===Z))&&Wy(ee,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[t,p,me,ee,Z]),zt=m.useMemo(()=>{const q=new Map;for(const we of k)q.set(we.id,new Set(ia(we,y)));return q},[y,k]),Rn=m.useMemo(()=>[{id:"all",label:"全部"},...k.map(q=>{var we;return{id:`collection:${q.id}`,label:q.name,count:((we=zt.get(q.id))==null?void 0:we.size)||0,collection:q}}),{id:"ungrouped",label:"未分组"}],[zt,k]),jr=m.useMemo(()=>y.filter(q=>{var Ee;const we=On(q);let $e=Z==="all";if(Z.startsWith("collection:")){const Ze=Z.slice(11);$e=!!((Ee=zt.get(Ze))!=null&&Ee.has(we))}else Z==="ungrouped"&&($e=!Array.from(zt.values()).some(Ze=>Ze.has(we)));return $e&&Wy(ee,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[y,ee,Z,zt]),Nr=m.useMemo(()=>b.filter(q=>Wy(ee,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[b,ee]),mr=le||tt||a==="skills",ut=m.useMemo(()=>rt.find(q=>On(q)===de)||rt[0]||null,[rt,de]),Ut=m.useMemo(()=>jr.find(q=>On(q)===de)||jr[0]||null,[jr,de]),Yt=m.useMemo(()=>Nr.find(q=>Ro(q)===de)||Nr[0]||null,[Nr,de]),Xn=Ut?Ce[On(Ut)]:null,it=ut?Re[On(ut)]:null,gr=ut&&ye?re[`${On(ut)}:${ye}`]:null,Fs=n(le?"project:searchNodes":tt?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Ut)return;const q=On(Ut);if(Ce[q])return;let we=!1;return yt(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then($e=>$e.json().then(Ee=>({ok:$e.ok,json:Ee}))).then(({ok:$e,json:Ee})=>{we||$e&&Ee.skill&&We(Ze=>({...Ze,[q]:Ee.skill}))}).catch(()=>{}).finally(()=>{we||yt("")}),()=>{we=!0}},[a,Ut,Ce]),m.useEffect(()=>{if(!le||!ut)return;const q=On(ut);if(Re[q])return;let we=!1;return $t(q),fetch(`/api/nodes/detail?id=${encodeURIComponent(ut.id)}`).then($e=>$e.json().then(Ee=>({ok:$e.ok,json:Ee}))).then(({ok:$e,json:Ee})=>{we||$e&&ot(Ze=>({...Ze,[q]:Ee}))}).catch(()=>{}).finally(()=>{we||$t("")}),()=>{we=!0}},[le,ut,Re]),m.useEffect(()=>{if(!le)return;const q=Array.isArray(it==null?void 0:it.files)?it.files:[];ze(we=>{var $e;return we&&q.some(Ee=>Ee.path===we)?we:(($e=q[0])==null?void 0:$e.path)||""})},[le,it]),m.useEffect(()=>{if(!le||!ut||!ye)return;const q=`${On(ut)}:${ye}`;if(re[q])return;let we=!1;return Qe(q),fetch(`/api/nodes/file?id=${encodeURIComponent(ut.id)}&path=${encodeURIComponent(ye)}`).then($e=>$e.json().then(Ee=>({ok:$e.ok,json:Ee}))).then(({ok:$e,json:Ee})=>{we||$e&&ke(Ze=>({...Ze,[q]:Ee}))}).catch(()=>{}).finally(()=>{we||Qe("")}),()=>{we=!0}},[le,ut,ye,re]),m.useEffect(()=>{Ft("")},[de,a]);const Bi=q=>{r(Cp(q,"workspace"))},zs=q=>{ie(hN(q)),r(Cp({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},oe=m.useCallback(q=>{var we,$e;q.preventDefault(),q.stopPropagation(),($e=(we=q.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(Tr.current+=1,H(!0))},[]),ve=m.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Tr.current-=1,Tr.current<=0&&(Tr.current=0,H(!1))},[]),Te=m.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),bt=m.useCallback(q=>{var Ee,Ze;q.preventDefault(),q.stopPropagation(),Tr.current=0,H(!1);const we=(Ze=(Ee=q.dataTransfer)==null?void 0:Ee.files)==null?void 0:Ze[0];if(!we)return;const $e=we.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||Q(we)},[]);return i.jsxs("div",{className:"af-projects"+(K?" af-projects--drop-target":""),onDragEnter:oe,onDragLeave:ve,onDragOver:Te,onDrop:bt,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:[mr?null:i.jsxs("div",{className:"af-scope-switch af-project-scope-switch","aria-label":"Project 视图",children:[i.jsx("button",{type:"button",className:d==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人"}),i.jsx("button",{type:"button",className:d==="team"?"is-active":"",onClick:()=>f("team"),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:Fs,"aria-label":Fs,autoComplete:"off",value:ee,onChange:q=>ue(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(ue(""),q.currentTarget.blur())}}),ee.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>ue(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),mr?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>fn(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(G?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":G,"aria-controls":"af-recent-activity-panel",onClick:()=>te(q=>!q),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>W(!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:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),i.jsx("p",{className:"af-projects-sub",children:vr?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?rt.length:a==="my-flows"?Nr.length:a==="skills"?jr.length:Hn.length}):a==="my-nodes"?n("project:myNodesHint",{count:rt.length}):a==="my-flows"?n("project:myFlowsHint",{count:Nr.length}):a==="nodes"?n("project:nodesHint",{count:p.length}):a==="skills"?n("project:skillsHint",{count:y.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),A?i.jsx("p",{className:"af-err af-projects-api-hint",children:A}):null,D&&mr?i.jsx("p",{className:"af-err af-projects-api-hint",children:D}):null]}),mr?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(KF,{onChanged:fn,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:tt?"schema":le?me?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(tt?"project:myFlowsPurposeTitle":me?"project:myNodesPurposeTitle":le?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(tt?"project:myFlowsPurposeDesc":me?"project:myNodesPurposeDesc":le?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),tt?null:i.jsxs(i.Fragment,{children:[le?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(me?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ce("all"),pe("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(me?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ce("all"),pe("")},children:n("project:nodeScopeMine")})]}):null,i.jsx("div",{className:"af-resource-filter-row",children:(le?(me?az:oz).map(q=>({id:q,label:n(`project:resourceFilter.${q}`)})):Rn).map(q=>q.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(Z===q.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ce(q.id),pe("")},children:[q.label,i.jsx("em",{children:q.count}),q.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!q.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:C,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Ds(q.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},q.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(Z===q.id?" af-resource-filter--active":""),onClick:()=>{ce(q.id),pe("")},children:q.label},q.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:j,onChange:q=>S(q.target.value),onKeyDown:q=>{q.key==="Enter"&&ss()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!j.trim()||C,onClick:()=>ss(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,le?i.jsx("div",{className:"af-resource-grid",children:rt.length>0?rt.map(q=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ut&&On(q)===On(ut)?" af-resource-card--active":""),onClick:()=>pe(On(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Dl(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:i.jsx(Ln,{query:ee,children:q.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Ln,{query:ee,children:fN(q.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:ee,children:q.label||q.displayName||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:ee,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Ln,{query:ee,children:q.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(q.inputs||{}).length,outputs:Object.keys(q.outputs||{}).length})})]}),q.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(Ln,{query:ee,children:`${q.packageId}${q.version?` / ${q.version}`:""}`})})]}):null]},`${q.id}:${q.source||""}:${q.packageId||""}`)):z?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?n("project:noNodeMatch",{query:ee.trim()}):n(me?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):tt?i.jsx("div",{className:"af-resource-grid",children:Nr.length>0?Nr.map(q=>{const we=KP(q),$e=qP(q),Ee=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):we.length,Ze=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):$e.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Yt&&Ro(q)===Ro(Yt)?" af-resource-card--active":""),onClick:()=>pe(Ro(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Dl("primary"),children:i.jsx(Ln,{query:ee,children:q.version?`v${q.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:ee,children:q.displayName||q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:ee,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ee,edges:Ze})}),i.jsx("span",{children:i.jsx(Ln,{query:ee,children:q.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(Ln,{query:ee,children:pN(q)})})]})]},Ro(q))}):z?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?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:jr.length>0?jr.map(q=>{const we=On(q),$e=k.filter(Ee=>{var Ze;return(Ze=zt.get(Ee.id))==null?void 0:Ze.has(we)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(Ut&&we===On(Ut)?" af-resource-card--active":""),onClick:()=>pe(we),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Dl(q.source==="builtin"?"muted":"primary"),children:i.jsx(Ln,{query:ee,children:q.sourceLabel||q.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:ee,children:q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:ee,children:q.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(Ln,{query:ee,children:q.path||q.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ee=>i.jsx("span",{children:Ee.name},Ee.id)),$e.length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},q.key||`${q.source}:${q.name}`)}):z?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?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"&&$r.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:$r.map(q=>{const we=It===`show-builtin:builtin:${q}`;return i.jsxs("button",{type:"button",disabled:we,onClick:()=>hr({id:q,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:q}),i.jsx("em",{children:we?"恢复中":"恢复"})]},q)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[Hn.length>0?Hn.map(q=>{var wn,Lt,Sn,rr,yr;const we=(t==null?void 0:t.isAdmin)&&q.source==="user"&&!q.archived&&!Mr.has(q.id),$e=(t==null?void 0:t.isAdmin)&&q.source==="admin",Ee=(t==null?void 0:t.isAdmin)&&q.source==="builtin",Ze=It.endsWith(`:${q.source}:${q.id}`);return i.jsx("div",{className:ZF(q.source),role:"button",tabIndex:0,onClick:()=>Bi(q),onKeyDown:Zt=>{(Zt.key==="Enter"||Zt.key===" ")&&(Zt.preventDefault(),Bi(q))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Dl(Lx(q.source,n).tone),children:i.jsx(Ln,{query:ee,children:Lx(q.source,n).label})}),(wn=q.collaboration)!=null&&wn.role?i.jsx("span",{className:Dl(q.collaboration.role==="owner"?"primary":"muted"),children:q.collaboration.role==="owner"?(Lt=q.collaboration.teamShares)!=null&&Lt.length?"已分享团队":"我创建的":q.collaboration.accessSource==="team"?`${((rr=(Sn=q.collaboration.teamShares)==null?void 0:Sn.find(Zt=>Zt.teamId===q.collaboration.teamId))==null?void 0:rr.teamName)||"团队"}共享`:`${q.collaboration.ownerUsername||q.collaboration.ownerId} 分享`}):null,q.archived?i.jsx("span",{className:Dl("muted"),children:i.jsx(Ln,{query:ee,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:ee,children:q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:ee,children:WP(q,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(Ln,{query:ee,children:HP(q)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:Zt=>Zt.stopPropagation(),onKeyDown:Zt=>Zt.stopPropagation(),children:[we?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(q,"promote"),children:"设为内置"}):null,$e?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(q,"unpromote"),children:"取消内置"}):null,Ee?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(q,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}:${((yr=q.collaboration)==null?void 0:yr.id)||"own"}`)}):M?Sr.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(A?"project:loadFailed":"project:noPipelines")}),!A&&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:()=>W(!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")})]}),et?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")})]})]})]})]}),mr?i.jsx("aside",{className:"af-resource-detail","aria-label":n(le?"project:nodeDetail":tt?"project:flowDetail":"project:skillDetail"),children:le&&ut?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:ut.label||ut.displayName||ut.id}),i.jsx("p",{children:ut.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(q=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Me===q?" af-resource-detail-tab--active":""),onClick:()=>Ne(q),children:n(`project:nodeDetailTabs.${q}`)},q))}),kt===On(ut)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):Me==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:ut.description||((Rt=it==null?void 0:it.node)==null?void 0:Rt.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:ut.type||((Qt=it==null?void 0:it.node)==null?void 0:Qt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:fN(ut.source,n)})]}),ut.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:ut.packageId})]}):null,ut.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:ut.version})]}):null,ut.packageDir||it!=null&&it.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ut.packageDir||(it==null?void 0:it.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(it==null?void 0:it.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),me&&ut.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:_e===On(ut),onClick:()=>Gn(ut),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),_e===On(ut)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),Xt?i.jsx("p",{className:"af-resource-action-message",children:Xt}):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")})]})]}):Me==="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")}),_p(((pn=it==null?void 0:it.node)==null?void 0:pn.inputs)||ut.inputs).length>0?_p((($n=it==null?void 0:it.node)==null?void 0:$n.inputs)||ut.inputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),_p(((ks=it==null?void 0:it.node)==null?void 0:ks.outputs)||ut.outputs).length>0?_p(((vs=it==null?void 0:it.node)==null?void 0:vs.outputs)||ut.outputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):Me==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),it!=null&&it.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(it.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),it!=null&&it.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:it.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):Me==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(it==null?void 0:it.files)&&it.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:it.files.map(q=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(ye===q.path?" af-node-file-item--active":""),onClick:()=>ze(q.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:q.path})]},q.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[Be===`${On(ut)}:${ye}`?n("project:loadingResources"):gr!=null&&gr.binary?n("project:binaryFile"):(gr==null?void 0:gr.content)||n("project:selectNodeFile"),gr!=null&&gr.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):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(it==null?void 0:it.usage)&&it.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:it.usage.map(q=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:q.flowId}),i.jsxs("span",{children:[q.flowSource,q.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:q.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):tt&&Yt?(()=>{const q=mz(Yt);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:Yt.displayName||Yt.name||Yt.id}),i.jsx("p",{children:Yt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Yt.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:Yt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:pN(Yt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Yt.nodeCount))?Number(Yt.nodeCount):q.nodes.length,edges:Number.isFinite(Number(Yt.edgeCount))?Number(Yt.edgeCount):q.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:at===Ro(Yt),onClick:()=>bs(Yt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),at===Ro(Yt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),ne?i.jsx("p",{className:"af-resource-action-message",children:ne}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),q.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:q.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:q.diagram.edges.map(we=>i.jsxs("g",{children:[i.jsx("path",{d:we.path}),we.label?i.jsx("text",{x:we.labelX,y:we.labelY-5,textAnchor:"middle",children:Vy(we.label,18)}):null]},we.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:q.diagram.nodes.map((we,$e)=>i.jsxs("g",{transform:`translate(${we.x} ${we.y})`,children:[i.jsx("rect",{width:we.width,height:we.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:we.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:we.height/2+4,textAnchor:"middle",children:$e+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:we.height/2-3,children:Vy(we.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:Vy(we.meta||we.id,20)})]},we.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(Yt.snippet||{},null,2)})]})]})]})})():a==="skills"&&Ut?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:Ut.name||Ut.id}),i.jsx("p",{children:Ut.sourceLabel||Ut.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Ut.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:Ut.sourceLabel||Ut.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:Ut.path||Ut.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(q=>{const we=On(Ut),$e=zt.get(q.id)||new Set,Ee=$e.has(we);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ee,disabled:C||!o,onChange:Ze=>vn(q.id,we,Ze.target.checked)}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},q.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:ct===On(Ut)?n("project:loadingResources"):(Xn==null?void 0:Xn.body)||(Xn==null?void 0:Xn.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"+(G?"":" af-activity--hidden"),"aria-hidden":!G,"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:Bn.length===0?i.jsx("p",{className:"af-activity-empty",children:Jn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Bn.map(q=>{const we=se===hN(q);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(we?" af-activity-row--active":""),"aria-current":we?"page":void 0,onClick:()=>zs(q),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Ln,{query:ee,children:q.flowId})}),i.jsx("span",{className:"af-activity-time",children:uN(q.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:ez(q.kind),children:q.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[q.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",uN(q.at,n)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`)})})]})]}),i.jsx(LF,{open:$,onClose:()=>W(!1),onCreated:async q=>{W(!1),await pr();const we=q.source??"user";r(Cp({id:q.id,source:we},"workspace"))}}),E?i.jsx(MF,{file:E,onClose:()=>Q(null),onImported:async q=>{Q(null),await pr();const we=q.source??"user";r(Cp({id:q.id,source:we},"workspace"))}},`${E.name}-${E.size}-${E.lastModified}`):null]})}function Un(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=Un(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var gz={value:()=>{}};function Zm(){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 mh(n)}function mh(e){this._=e}function yz(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}})}mh.prototype=Zm.prototype={constructor:mh,on:function(e,t){var n=this._,r=yz(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=wz(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]=yN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=yN(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 mh(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 wz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function yN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=gz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fx="http://www.w3.org/1999/xhtml";const wN={svg:"http://www.w3.org/2000/svg",xhtml:Fx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function eg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),wN.hasOwnProperty(t)?{space:wN[t],local:e}:e}function xz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fx&&t.documentElement.namespaceURI===Fx?t.createElement(e):t.createElementNS(n,e)}}function bz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function UP(e){var t=eg(e);return(t.local?bz:xz)(t)}function kz(){}function $k(e){return e==null?kz:function(){return this.querySelector(e)}}function vz(e){typeof e!="function"&&(e=$k(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,u,d=0;d<a;++d)(c=o[d])&&(u=e.call(c,c.__data__,d,o))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new gs(r,this._parents)}function Sz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function jz(){return[]}function YP(e){return e==null?jz:function(){return this.querySelectorAll(e)}}function Nz(e){return function(){return Sz(e.apply(this,arguments))}}function Cz(e){typeof e=="function"?e=Nz(e):e=YP(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,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),s.push(c));return new gs(r,s)}function GP(e){return function(){return this.matches(e)}}function JP(e){return function(t){return t.matches(e)}}var _z=Array.prototype.find;function Ez(e){return function(){return _z.call(this.children,e)}}function Az(){return this.firstElementChild}function Pz(e){return this.select(e==null?Az:Ez(typeof e=="function"?e:JP(e)))}var Iz=Array.prototype.filter;function Rz(){return Array.from(this.children)}function Tz(e){return function(){return Iz.call(this.children,e)}}function Mz(e){return this.selectAll(e==null?Rz:Tz(typeof e=="function"?e:JP(e)))}function $z(e){typeof e!="function"&&(e=GP(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,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new gs(r,this._parents)}function XP(e){return new Array(e.length)}function Lz(){return new gs(this._enter||this._groups.map(XP),this._parents)}function Zh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Zh.prototype={constructor:Zh,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 Oz(e){return function(){return e}}function Dz(e,t,n,r,s,o){for(var a=0,l,c=t.length,u=o.length;a<u;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new Zh(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function Fz(e,t,n,r,s,o,a){var l,c,u=new Map,d=t.length,f=o.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,o[l],l,o)+"",(c=u.get(h))?(r[l]=c,c.__data__=o[l],u.delete(h)):n[l]=new Zh(e,o[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function zz(e){return e.__data__}function Bz(e,t){if(!arguments.length)return Array.from(this,zz);var n=t?Fz:Dz,r=this._parents,s=this._groups;typeof e!="function"&&(e=Oz(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var d=r[u],f=s[u],p=f.length,h=Hz(e.call(d,d&&d.__data__,u,r)),y=h.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(p);n(d,f,v,b,g,h,t);for(var k=0,x=0,j,S;k<y;++k)if(j=v[k]){for(k>=x&&(x=k+1);!(S=b[x])&&++x<y;);j._next=S||null}}return a=new gs(a,r),a._enter=l,a._exit=c,a}function Hz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Wz(){return new gs(this._exit||this._groups.map(XP),this._parents)}function Vz(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 Kz(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 u=n[c],d=r[c],f=u.length,p=l[c]=new Array(f),h,y=0;y<f;++y)(h=u[y]||d[y])&&(p[y]=h);for(;c<s;++c)l[c]=n[c];return new gs(l,this._parents)}function qz(){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 Uz(e){e||(e=Yz);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=s[o]=new Array(l),u,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new gs(s,this._parents).order()}function Yz(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Gz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Jz(){return Array.from(this)}function Xz(){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 Qz(){let e=0;for(const t of this)++e;return e}function Zz(){return!this.node()}function e3(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 t3(e){return function(){this.removeAttribute(e)}}function n3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function r3(e,t){return function(){this.setAttribute(e,t)}}function s3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function i3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function o3(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 a3(e,t){var n=eg(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?n3:t3:typeof t=="function"?n.local?o3:i3:n.local?s3:r3)(n,t))}function QP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function l3(e){return function(){this.style.removeProperty(e)}}function c3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function u3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function d3(e,t,n){return arguments.length>1?this.each((t==null?l3:typeof t=="function"?u3:c3)(e,t,n??"")):Mc(this.node(),e)}function Mc(e,t){return e.style.getPropertyValue(t)||QP(e).getComputedStyle(e,null).getPropertyValue(t)}function f3(e){return function(){delete this[e]}}function p3(e,t){return function(){this[e]=t}}function h3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function m3(e,t){return arguments.length>1?this.each((t==null?f3:typeof t=="function"?h3:p3)(e,t)):this.node()[e]}function ZP(e){return e.trim().split(/^|\s+/)}function Lk(e){return e.classList||new eI(e)}function eI(e){this._node=e,this._names=ZP(e.getAttribute("class")||"")}eI.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 tI(e,t){for(var n=Lk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function nI(e,t){for(var n=Lk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function g3(e){return function(){tI(this,e)}}function y3(e){return function(){nI(this,e)}}function w3(e,t){return function(){(t.apply(this,arguments)?tI:nI)(this,e)}}function x3(e,t){var n=ZP(e+"");if(arguments.length<2){for(var r=Lk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?w3:t?g3:y3)(n,t))}function b3(){this.textContent=""}function k3(e){return function(){this.textContent=e}}function v3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function S3(e){return arguments.length?this.each(e==null?b3:(typeof e=="function"?v3:k3)(e)):this.node().textContent}function j3(){this.innerHTML=""}function N3(e){return function(){this.innerHTML=e}}function C3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _3(e){return arguments.length?this.each(e==null?j3:(typeof e=="function"?C3:N3)(e)):this.node().innerHTML}function E3(){this.nextSibling&&this.parentNode.appendChild(this)}function A3(){return this.each(E3)}function P3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function I3(){return this.each(P3)}function R3(e){var t=typeof e=="function"?e:UP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function T3(){return null}function M3(e,t){var n=typeof e=="function"?e:UP(e),r=t==null?T3:typeof t=="function"?t:$k(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function $3(){var e=this.parentNode;e&&e.removeChild(this)}function L3(){return this.each($3)}function O3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function D3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function F3(e){return this.select(e?D3:O3)}function z3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function B3(e){return function(t){e.call(this,t,this.__data__)}}function H3(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 W3(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 V3(e,t,n){return function(){var r=this.__on,s,o=B3(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 K3(e,t,n){var r=H3(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<o;++s)if((a=r[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?V3:W3,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function rI(e,t,n){var r=QP(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 q3(e,t){return function(){return rI(this,e,t)}}function U3(e,t){return function(){return rI(this,e,t.apply(this,arguments))}}function Y3(e,t){return this.each((typeof t=="function"?U3:q3)(e,t))}function*G3(){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 sI=[null];function gs(e,t){this._groups=e,this._parents=t}function yf(){return new gs([[document.documentElement]],sI)}function J3(){return this}gs.prototype=yf.prototype={constructor:gs,select:vz,selectAll:Cz,selectChild:Pz,selectChildren:Mz,filter:$z,data:Bz,enter:Lz,exit:Wz,join:Vz,merge:Kz,selection:J3,order:qz,sort:Uz,call:Gz,nodes:Jz,node:Xz,size:Qz,empty:Zz,each:e3,attr:a3,style:d3,property:m3,classed:x3,text:S3,html:_3,raise:A3,lower:I3,append:R3,insert:M3,remove:L3,clone:F3,datum:z3,on:K3,dispatch:Y3,[Symbol.iterator]:G3};function us(e){return typeof e=="string"?new gs([[document.querySelector(e)]],[document.documentElement]):new gs([[e]],sI)}function X3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ei(e,t){if(e=X3(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 Q3={passive:!1},Hd={capture:!0,passive:!1};function Ky(e){e.stopImmediatePropagation()}function xc(e){e.preventDefault(),e.stopImmediatePropagation()}function iI(e){var t=e.document.documentElement,n=us(e).on("dragstart.drag",xc,Hd);"onselectstart"in t?n.on("selectstart.drag",xc,Hd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function oI(e,t){var n=e.document.documentElement,r=us(e).on("dragstart.drag",null);t&&(r.on("click.drag",xc,Hd),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 Ep=e=>()=>e;function zx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:u,dispatch:d}){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:u,enumerable:!0,configurable:!0},_:{value:d}})}zx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Z3(e){return!e.ctrlKey&&!e.button}function eB(){return this.parentNode}function tB(e,t){return t??{x:e.x,y:e.y}}function nB(){return navigator.maxTouchPoints||"ontouchstart"in this}function aI(){var e=Z3,t=eB,n=tB,r=nB,s={},o=Zm("start","drag","end"),a=0,l,c,u,d,f=0;function p(j){j.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,Q3).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(j,S){if(!(d||!e.call(this,j,S))){var C=x(this,t.call(this,j,S),j,S,"mouse");C&&(us(j.view).on("mousemove.drag",y,Hd).on("mouseup.drag",v,Hd),iI(j.view),Ky(j),u=!1,l=j.clientX,c=j.clientY,C("start",j))}}function y(j){if(xc(j),!u){var S=j.clientX-l,C=j.clientY-c;u=S*S+C*C>f}s.mouse("drag",j)}function v(j){us(j.view).on("mousemove.drag mouseup.drag",null),oI(j.view,u),xc(j),s.mouse("end",j)}function b(j,S){if(e.call(this,j,S)){var C=j.changedTouches,P=t.call(this,j,S),R=C.length,B,A;for(B=0;B<R;++B)(A=x(this,P,j,S,C[B].identifier,C[B]))&&(Ky(j),A("start",j,C[B]))}}function g(j){var S=j.changedTouches,C=S.length,P,R;for(P=0;P<C;++P)(R=s[S[P].identifier])&&(xc(j),R("drag",j,S[P]))}function k(j){var S=j.changedTouches,C=S.length,P,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<C;++P)(R=s[S[P].identifier])&&(Ky(j),R("end",j,S[P]))}function x(j,S,C,P,R,B){var A=o.copy(),O=ei(B||C,S),D,L,M;if((M=n.call(j,new zx("beforestart",{sourceEvent:C,target:p,identifier:R,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:A}),P))!=null)return D=M.x-O[0]||0,L=M.y-O[1]||0,function V(z,F,$){var W=O,E;switch(z){case"start":s[R]=V,E=a++;break;case"end":delete s[R],--a;case"drag":O=ei($||F,S),E=a;break}A.call(z,j,new zx(z,{sourceEvent:F,subject:M,target:p,identifier:R,active:E,x:O[0]+D,y:O[1]+L,dx:O[0]-W[0],dy:O[1]-W[1],dispatch:A}),P)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Ep(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:Ep(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:Ep(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:Ep(!!j),p):r},p.on=function(){var j=o.on.apply(o,arguments);return j===o?p:j},p.clickDistance=function(j){return arguments.length?(f=(j=+j)*j,p):Math.sqrt(f)},p}function Ok(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function lI(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function wf(){}var Wd=.7,em=1/Wd,bc="\\s*([+-]?\\d+)\\s*",Vd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ri="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rB=/^#([0-9a-f]{3,8})$/,sB=new RegExp(`^rgb\\(${bc},${bc},${bc}\\)$`),iB=new RegExp(`^rgb\\(${Ri},${Ri},${Ri}\\)$`),oB=new RegExp(`^rgba\\(${bc},${bc},${bc},${Vd}\\)$`),aB=new RegExp(`^rgba\\(${Ri},${Ri},${Ri},${Vd}\\)$`),lB=new RegExp(`^hsl\\(${Vd},${Ri},${Ri}\\)$`),cB=new RegExp(`^hsla\\(${Vd},${Ri},${Ri},${Vd}\\)$`),xN={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};Ok(wf,el,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bN,formatHex:bN,formatHex8:uB,formatHsl:dB,formatRgb:kN,toString:kN});function bN(){return this.rgb().formatHex()}function uB(){return this.rgb().formatHex8()}function dB(){return cI(this).formatHsl()}function kN(){return this.rgb().formatRgb()}function el(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=rB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?vN(t):n===3?new Xr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ap(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ap(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=sB.exec(e))?new Xr(t[1],t[2],t[3],1):(t=iB.exec(e))?new Xr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oB.exec(e))?Ap(t[1],t[2],t[3],t[4]):(t=aB.exec(e))?Ap(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lB.exec(e))?NN(t[1],t[2]/100,t[3]/100,1):(t=cB.exec(e))?NN(t[1],t[2]/100,t[3]/100,t[4]):xN.hasOwnProperty(e)?vN(xN[e]):e==="transparent"?new Xr(NaN,NaN,NaN,0):null}function vN(e){return new Xr(e>>16&255,e>>8&255,e&255,1)}function Ap(e,t,n,r){return r<=0&&(e=t=n=NaN),new Xr(e,t,n,r)}function fB(e){return e instanceof wf||(e=el(e)),e?(e=e.rgb(),new Xr(e.r,e.g,e.b,e.opacity)):new Xr}function Bx(e,t,n,r){return arguments.length===1?fB(e):new Xr(e,t,n,r??1)}function Xr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ok(Xr,Bx,lI(wf,{brighter(e){return e=e==null?em:Math.pow(em,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Wd:Math.pow(Wd,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xr(Ka(this.r),Ka(this.g),Ka(this.b),tm(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:SN,formatHex:SN,formatHex8:pB,formatRgb:jN,toString:jN}));function SN(){return`#${Fa(this.r)}${Fa(this.g)}${Fa(this.b)}`}function pB(){return`#${Fa(this.r)}${Fa(this.g)}${Fa(this.b)}${Fa((isNaN(this.opacity)?1:this.opacity)*255)}`}function jN(){const e=tm(this.opacity);return`${e===1?"rgb(":"rgba("}${Ka(this.r)}, ${Ka(this.g)}, ${Ka(this.b)}${e===1?")":`, ${e})`}`}function tm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ka(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fa(e){return e=Ka(e),(e<16?"0":"")+e.toString(16)}function NN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ri(e,t,n,r)}function cI(e){if(e instanceof ri)return new ri(e.h,e.s,e.l,e.opacity);if(e instanceof wf||(e=el(e)),!e)return new ri;if(e instanceof ri)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 ri(a,l,c,e.opacity)}function hB(e,t,n,r){return arguments.length===1?cI(e):new ri(e,t,n,r??1)}function ri(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ok(ri,hB,lI(wf,{brighter(e){return e=e==null?em:Math.pow(em,e),new ri(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Wd:Math.pow(Wd,e),new ri(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 Xr(qy(e>=240?e-240:e+120,s,r),qy(e,s,r),qy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ri(CN(this.h),Pp(this.s),Pp(this.l),tm(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=tm(this.opacity);return`${e===1?"hsl(":"hsla("}${CN(this.h)}, ${Pp(this.s)*100}%, ${Pp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function CN(e){return e=(e||0)%360,e<0?e+360:e}function Pp(e){return Math.max(0,Math.min(1,e||0))}function qy(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 Dk=e=>()=>e;function mB(e,t){return function(n){return e+n*t}}function gB(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 yB(e){return(e=+e)==1?uI:function(t,n){return n-t?gB(t,n,e):Dk(isNaN(t)?n:t)}}function uI(e,t){var n=t-e;return n?mB(e,n):Dk(isNaN(e)?t:e)}const nm=function e(t){var n=yB(t);function r(s,o){var a=n((s=Bx(s)).r,(o=Bx(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=uI(s.opacity,o.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function wB(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 xB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bB(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]=md(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 kB(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function vi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function vB(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]=md(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Hx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Uy=new RegExp(Hx.source,"g");function SB(e){return function(){return e}}function jB(e){return function(t){return e(t)+""}}function dI(e,t){var n=Hx.lastIndex=Uy.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Hx.exec(e))&&(s=Uy.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:vi(r,s)})),n=Uy.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?jB(c[0].x):SB(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function md(e,t){var n=typeof t,r;return t==null||n==="boolean"?Dk(t):(n==="number"?vi:n==="string"?(r=el(t))?(t=r,nm):dI:t instanceof el?nm:t instanceof Date?kB:xB(t)?wB:Array.isArray(t)?bB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?vB:vi)(e,t)}var _N=180/Math.PI,Wx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function fI(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)*_N,skewX:Math.atan(c)*_N,scaleX:a,scaleY:l}}var Ip;function NB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Wx:fI(t.a,t.b,t.c,t.d,t.e,t.f)}function CB(e){return e==null||(Ip||(Ip=document.createElementNS("http://www.w3.org/2000/svg","g")),Ip.setAttribute("transform",e),!(e=Ip.transform.baseVal.consolidate()))?Wx:(e=e.matrix,fI(e.a,e.b,e.c,e.d,e.e,e.f))}function pI(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function o(u,d,f,p,h,y){if(u!==f||d!==p){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:vi(u,f)},{i:v-2,x:vi(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:vi(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:vi(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,y){if(u!==f||d!==p){var v=h.push(s(h)+"scale(",null,",",null,")");y.push({i:v-4,x:vi(u,f)},{i:v-2,x:vi(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),o(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var y=-1,v=p.length,b;++y<v;)f[(b=p[y]).i]=b.x(h);return f.join("")}}}var _B=pI(NB,"px, ","px)","deg)"),EB=pI(CB,", ",")",")"),AB=1e-12;function EN(e){return((e=Math.exp(e))+1/e)/2}function PB(e){return((e=Math.exp(e))-1/e)/2}function IB(e){return((e=Math.exp(2*e))-1)/(e+1)}const gh=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],u=o[2],d=a[0],f=a[1],p=a[2],h=d-l,y=f-c,v=h*h+y*y,b,g;if(v<AB)g=Math.log(p/u)/t,b=function(P){return[l+P*h,c+P*y,u*Math.exp(t*P*g)]};else{var k=Math.sqrt(v),x=(p*p-u*u+r*v)/(2*u*n*k),j=(p*p-u*u-r*v)/(2*p*n*k),S=Math.log(Math.sqrt(x*x+1)-x),C=Math.log(Math.sqrt(j*j+1)-j);g=(C-S)/t,b=function(P){var R=P*g,B=EN(S),A=u/(n*k)*(B*IB(t*R+S)-PB(S));return[l+A*h,c+A*y,u*B/EN(t*R+S)]}}return b.duration=g*1e3*t/Math.SQRT2,b}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 $c=0,Xu=0,Lu=0,hI=1e3,rm,Qu,sm=0,tl=0,tg=0,Kd=typeof performance=="object"&&performance.now?performance:Date,mI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fk(){return tl||(mI(RB),tl=Kd.now()+tg)}function RB(){tl=0}function im(){this._call=this._time=this._next=null}im.prototype=gI.prototype={constructor:im,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Fk():+n)+(t==null?0:+t),!this._next&&Qu!==this&&(Qu?Qu._next=this:rm=this,Qu=this),this._call=e,this._time=n,Vx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Vx())}};function gI(e,t,n){var r=new im;return r.restart(e,t,n),r}function TB(){Fk(),++$c;for(var e=rm,t;e;)(t=tl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$c}function AN(){tl=(sm=Kd.now())+tg,$c=Xu=0;try{TB()}finally{$c=0,$B(),tl=0}}function MB(){var e=Kd.now(),t=e-sm;t>hI&&(tg-=t,sm=e)}function $B(){for(var e,t=rm,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:rm=n);Qu=e,Vx(r)}function Vx(e){if(!$c){Xu&&(Xu=clearTimeout(Xu));var t=e-tl;t>24?(e<1/0&&(Xu=setTimeout(AN,e-Kd.now()-tg)),Lu&&(Lu=clearInterval(Lu))):(Lu||(sm=Kd.now(),Lu=setInterval(MB,hI)),$c=1,mI(AN))}}function PN(e,t,n){var r=new im;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var LB=Zm("start","end","cancel","interrupt"),OB=[],yI=0,IN=1,Kx=2,yh=3,RN=4,qx=5,wh=6;function ng(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;DB(e,n,{name:t,index:r,group:s,on:LB,tween:OB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:yI})}function zk(e,t){var n=fi(e,t);if(n.state>yI)throw new Error("too late; already scheduled");return n}function Fi(e,t){var n=fi(e,t);if(n.state>yh)throw new Error("too late; already running");return n}function fi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function DB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=gI(o,0,n.time);function o(u){n.state=IN,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==IN)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===yh)return PN(a);h.state===RN?(h.state=wh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=wh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(PN(function(){n.state===yh&&(n.state=RN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Kx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kx){for(n.state=yh,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=qx,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===qx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=wh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function xh(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>Kx&&r.state<qx,r.state=wh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function FB(e){return this.each(function(){xh(this,e)})}function zB(e,t){var n,r;return function(){var s=Fi(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 BB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Fi(this,e),a=o.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}o.tween=s}}function HB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=fi(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?zB:BB)(n,e,t))}function Bk(e,t,n){var r=e._id;return e.each(function(){var s=Fi(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return fi(s,r).value[t]}}function wI(e,t){var n;return(typeof t=="number"?vi:t instanceof el?nm:(n=el(t))?(t=n,nm):dI)(e,t)}function WB(e){return function(){this.removeAttribute(e)}}function VB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function KB(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 qB(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 UB(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 YB(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 GB(e,t){var n=eg(e),r=n==="transform"?EB:wI;return this.attrTween(e,typeof t=="function"?(n.local?YB:UB)(n,r,Bk(this,"attr."+e,t)):t==null?(n.local?VB:WB)(n):(n.local?qB:KB)(n,r,t))}function JB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function XB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function QB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&XB(e,o)),n}return s._value=t,s}function ZB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&JB(e,o)),n}return s._value=t,s}function eH(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=eg(e);return this.tween(n,(r.local?QB:ZB)(r,t))}function tH(e,t){return function(){zk(this,e).delay=+t.apply(this,arguments)}}function nH(e,t){return t=+t,function(){zk(this,e).delay=t}}function rH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?tH:nH)(t,e)):fi(this.node(),t).delay}function sH(e,t){return function(){Fi(this,e).duration=+t.apply(this,arguments)}}function iH(e,t){return t=+t,function(){Fi(this,e).duration=t}}function oH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sH:iH)(t,e)):fi(this.node(),t).duration}function aH(e,t){if(typeof t!="function")throw new Error;return function(){Fi(this,e).ease=t}}function lH(e){var t=this._id;return arguments.length?this.each(aH(t,e)):fi(this.node(),t).ease}function cH(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fi(this,e).ease=n}}function uH(e){if(typeof e!="function")throw new Error;return this.each(cH(this._id,e))}function dH(e){typeof e!="function"&&(e=GP(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,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new ho(r,this._parents,this._name,this._id)}function fH(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],u=n[l],d=c.length,f=a[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new ho(a,this._parents,this._name,this._id)}function pH(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 hH(e,t,n){var r,s,o=pH(t)?zk:Fi;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function mH(e,t){var n=this._id;return arguments.length<2?fi(this.node(),n).on.on(e):this.each(hH(n,e,t))}function gH(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function yH(){return this.on("end.remove",gH(this._id))}function wH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$k(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,u=o[a]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,ng(u[p],t,n,p,u,fi(d,n)));return new ho(o,this._parents,t,n)}function xH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=YP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,y=fi(d,n),v=0,b=p.length;v<b;++v)(h=p[v])&&ng(h,t,n,v,p,y);o.push(p),a.push(d)}return new ho(o,a,t,n)}var bH=yf.prototype.constructor;function kH(){return new bH(this._groups,this._parents)}function vH(e,t){var n,r,s;return function(){var o=Mc(this,e),a=(this.style.removeProperty(e),Mc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function xI(e){return function(){this.style.removeProperty(e)}}function SH(e,t,n){var r,s=n+"",o;return function(){var a=Mc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function jH(e,t,n){var r,s,o;return function(){var a=Mc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Mc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function NH(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Fi(this,e),u=c.on,d=c.value[o]==null?l||(l=xI(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function CH(e,t,n){var r=(e+="")=="transform"?_B:wI;return t==null?this.styleTween(e,vH(e,r)).on("end.style."+e,xI(e)):typeof t=="function"?this.styleTween(e,jH(e,r,Bk(this,"style."+e,t))).each(NH(this._id,e)):this.styleTween(e,SH(e,r,t),n).on("end.style."+e,null)}function _H(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function EH(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&_H(e,a,n)),r}return o._value=t,o}function AH(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,EH(e,t,n??""))}function PH(e){return function(){this.textContent=e}}function IH(e){return function(){var t=e(this);this.textContent=t??""}}function RH(e){return this.tween("text",typeof e=="function"?IH(Bk(this,"text",e)):PH(e==null?"":e+""))}function TH(e){return function(t){this.textContent=e.call(this,t)}}function MH(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&TH(s)),t}return r._value=e,r}function $H(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,MH(e))}function LH(){for(var e=this._name,t=this._id,n=bI(),r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var d=fi(c,t);ng(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ho(r,this._parents,e,n)}function OH(){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 u=Fi(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&o()})}var DH=0;function ho(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function bI(){return++DH}var Yi=yf.prototype;ho.prototype={constructor:ho,select:wH,selectAll:xH,selectChild:Yi.selectChild,selectChildren:Yi.selectChildren,filter:dH,merge:fH,selection:kH,transition:LH,call:Yi.call,nodes:Yi.nodes,node:Yi.node,size:Yi.size,empty:Yi.empty,each:Yi.each,on:mH,attr:GB,attrTween:eH,style:CH,styleTween:AH,text:RH,textTween:$H,remove:yH,tween:HB,delay:rH,duration:oH,ease:lH,easeVarying:uH,end:OH,[Symbol.iterator]:Yi[Symbol.iterator]};function FH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zH={time:null,delay:0,duration:250,ease:FH};function BH(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 HH(e){var t,n;e instanceof ho?(t=e._id,e=e._name):(t=bI(),(n=zH).time=Fk(),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,u=0;u<l;++u)(c=a[u])&&ng(c,e,t,u,a,n||BH(c,t));return new ho(r,this._parents,e,t)}yf.prototype.interrupt=FB;yf.prototype.transition=HH;const Rp=e=>()=>e;function WH(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 no(e,t,n){this.k=e,this.x=t,this.y=n}no.prototype={constructor:no,scale:function(e){return e===1?this:new no(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new no(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 rg=new no(1,0,0);kI.prototype=no.prototype;function kI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return rg;return e.__zoom}function Yy(e){e.stopImmediatePropagation()}function Ou(e){e.preventDefault(),e.stopImmediatePropagation()}function VH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function KH(){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 TN(){return this.__zoom||rg}function qH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function UH(){return navigator.maxTouchPoints||"ontouchstart"in this}function YH(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 vI(){var e=VH,t=KH,n=YH,r=qH,s=UH,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=gh,u=Zm("start","zoom","end"),d,f,p,h=500,y=150,v=0,b=10;function g(M){M.property("__zoom",TN).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",A).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,V,z,F){var $=M.selection?M.selection():M;$.property("__zoom",TN),M!==$?S(M,V,z,F):$.interrupt().each(function(){C(this,arguments).event(F).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},g.scaleBy=function(M,V,z,F){g.scaleTo(M,function(){var $=this.__zoom.k,W=typeof V=="function"?V.apply(this,arguments):V;return $*W},z,F)},g.scaleTo=function(M,V,z,F){g.transform(M,function(){var $=t.apply(this,arguments),W=this.__zoom,E=z==null?j($):typeof z=="function"?z.apply(this,arguments):z,Q=W.invert(E),K=typeof V=="function"?V.apply(this,arguments):V;return n(x(k(W,K),E,Q),$,a)},z,F)},g.translateBy=function(M,V,z,F){g.transform(M,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),a)},null,F)},g.translateTo=function(M,V,z,F,$){g.transform(M,function(){var W=t.apply(this,arguments),E=this.__zoom,Q=F==null?j(W):typeof F=="function"?F.apply(this,arguments):F;return n(rg.translate(Q[0],Q[1]).scale(E.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof z=="function"?-z.apply(this,arguments):-z),W,a)},F,$)};function k(M,V){return V=Math.max(o[0],Math.min(o[1],V)),V===M.k?M:new no(V,M.x,M.y)}function x(M,V,z){var F=V[0]-z[0]*M.k,$=V[1]-z[1]*M.k;return F===M.x&&$===M.y?M:new no(M.k,F,$)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function S(M,V,z,F){M.on("start.zoom",function(){C(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(F).end()}).tween("zoom",function(){var $=this,W=arguments,E=C($,W).event(F),Q=t.apply($,W),K=z==null?j(Q):typeof z=="function"?z.apply($,W):z,H=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),ee=$.__zoom,ue=typeof V=="function"?V.apply($,W):V,G=c(ee.invert(K).concat(H/ee.k),ue.invert(K).concat(H/ue.k));return function(te){if(te===1)te=ue;else{var se=G(te),ie=H/se[2];te=new no(ie,K[0]-se[0]*ie,K[1]-se[1]*ie)}E.zoom(null,te)}})}function C(M,V,z){return!z&&M.__zooming||new P(M,V)}function P(M,V){this.that=M,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,V),this.taps=0}P.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,V){return this.mouse&&M!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var V=us(this.that).datum();u.call(M,this.that,new WH(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),V)}};function R(M,...V){if(!e.apply(this,arguments))return;var z=C(this,V).event(M),F=this.__zoom,$=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),W=ei(M);if(z.wheel)(z.mouse[0][0]!==W[0]||z.mouse[0][1]!==W[1])&&(z.mouse[1]=F.invert(z.mouse[0]=W)),clearTimeout(z.wheel);else{if(F.k===$)return;z.mouse=[W,F.invert(W)],xh(this),z.start()}Ou(M),z.wheel=setTimeout(E,y),z.zoom("mouse",n(x(k(F,$),z.mouse[0],z.mouse[1]),z.extent,a));function E(){z.wheel=null,z.end()}}function B(M,...V){if(p||!e.apply(this,arguments))return;var z=M.currentTarget,F=C(this,V,!0).event(M),$=us(M.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",H,!0),W=ei(M,z),E=M.clientX,Q=M.clientY;iI(M.view),Yy(M),F.mouse=[W,this.__zoom.invert(W)],xh(this),F.start();function K(ee){if(Ou(ee),!F.moved){var ue=ee.clientX-E,G=ee.clientY-Q;F.moved=ue*ue+G*G>v}F.event(ee).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ei(ee,z),F.mouse[1]),F.extent,a))}function H(ee){$.on("mousemove.zoom mouseup.zoom",null),oI(ee.view,F.moved),Ou(ee),F.event(ee).end()}}function A(M,...V){if(e.apply(this,arguments)){var z=this.__zoom,F=ei(M.changedTouches?M.changedTouches[0]:M,this),$=z.invert(F),W=z.k*(M.shiftKey?.5:2),E=n(x(k(z,W),F,$),t.apply(this,V),a);Ou(M),l>0?us(this).transition().duration(l).call(S,E,F,M):us(this).call(g.transform,E,F,M)}}function O(M,...V){if(e.apply(this,arguments)){var z=M.touches,F=z.length,$=C(this,V,M.changedTouches.length===F).event(M),W,E,Q,K;for(Yy(M),E=0;E<F;++E)Q=z[E],K=ei(Q,this),K=[K,this.__zoom.invert(K),Q.identifier],$.touch0?!$.touch1&&$.touch0[2]!==K[2]&&($.touch1=K,$.taps=0):($.touch0=K,W=!0,$.taps=1+!!d);d&&(d=clearTimeout(d)),W&&($.taps<2&&(f=K[0],d=setTimeout(function(){d=null},h)),xh(this),$.start())}}function D(M,...V){if(this.__zooming){var z=C(this,V).event(M),F=M.changedTouches,$=F.length,W,E,Q,K;for(Ou(M),W=0;W<$;++W)E=F[W],Q=ei(E,this),z.touch0&&z.touch0[2]===E.identifier?z.touch0[0]=Q:z.touch1&&z.touch1[2]===E.identifier&&(z.touch1[0]=Q);if(E=z.that.__zoom,z.touch1){var H=z.touch0[0],ee=z.touch0[1],ue=z.touch1[0],G=z.touch1[1],te=(te=ue[0]-H[0])*te+(te=ue[1]-H[1])*te,se=(se=G[0]-ee[0])*se+(se=G[1]-ee[1])*se;E=k(E,Math.sqrt(te/se)),Q=[(H[0]+ue[0])/2,(H[1]+ue[1])/2],K=[(ee[0]+G[0])/2,(ee[1]+G[1])/2]}else if(z.touch0)Q=z.touch0[0],K=z.touch0[1];else return;z.zoom("touch",n(x(E,Q,K),z.extent,a))}}function L(M,...V){if(this.__zooming){var z=C(this,V).event(M),F=M.changedTouches,$=F.length,W,E;for(Yy(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),W=0;W<$;++W)E=F[W],z.touch0&&z.touch0[2]===E.identifier?delete z.touch0:z.touch1&&z.touch1[2]===E.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(E=ei(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<b)){var Q=us(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Rp(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Rp(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Rp(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Rp([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),g):t},g.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],g):[o[0],o[1]]},g.translateExtent=function(M){return arguments.length?(a[0][0]=+M[0][0],a[1][0]=+M[1][0],a[0][1]=+M[0][1],a[1][1]=+M[1][1],g):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},g.constrain=function(M){return arguments.length?(n=M,g):n},g.duration=function(M){return arguments.length?(l=+M,g):l},g.interpolate=function(M){return arguments.length?(c=M,g):c},g.on=function(){var M=u.on.apply(u,arguments);return M===u?g:M},g.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,g):Math.sqrt(v)},g.tapDistance=function(M){return arguments.length?(b=+M,g):b},g}const Oi={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."},qd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],SI=["Enter"," ","Escape"],jI={"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 Lc;(function(e){e.Strict="strict",e.Loose="loose"})(Lc||(Lc={}));var qa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(qa||(qa={}));var Ud;(function(e){e.Partial="partial",e.Full="full"})(Ud||(Ud={}));const NI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Bo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Bo||(Bo={}));var Ci;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ci||(Ci={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));const MN={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};function CI(e){return e===null?null:e?"valid":"invalid"}const _I=e=>"id"in e&&"source"in e&&"target"in e,GH=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Hk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),xf=(e,t=[0,0])=>{const{width:n,height:r}=xo(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},JH=(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):Hk(s)?s:t.nodeLookup.get(s.id));const l=a?om(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return sg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ig(n)},bf=(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=sg(n,om(s)),r=!0)}),r?ig(n):{x:0,y:0,width:0,height:0}},Wk=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...vf(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,y=d.height??u.height??u.initialHeight??null,v=Yd(l,Dc(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},XH=(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 QH(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 ZH({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=QH(e,a),c=bf(l),u=Vk(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(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function EI({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:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Oi.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(f=[[c,u],[c+h,u+y]])}else l&&Fc(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Fc(f)?nl(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Oi.error015())),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function e4({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=o.has(p.id),y=!h&&p.parentId&&a.find(v=>v.id===p.parentId);(h||y)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=XH(a,c);for(const p of c)l.has(p.id)&&!d.find(y=>y.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const Oc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),nl=(e={x:0,y:0},t,n)=>({x:Oc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Oc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function AI(e,t,n){const{width:r,height:s}=xo(n),{x:o,y:a}=n.internals.positionAbsolute;return nl(e,[[o,a],[o+r,a+s]],t)}const $N=(e,t,n)=>e<t?Oc(Math.abs(e-t),1,t)/t:e>n?-Oc(Math.abs(e-n),1,t)/t:0,PI=(e,t,n=15,r=40)=>{const s=$N(e.x,r,t.width-r)*n,o=$N(e.y,r,t.height-r)*n;return[s,o]},sg=(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)}),Ux=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ig=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Dc=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Hk(e)?e.internals.positionAbsolute:xf(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}},om=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Hk(e)?e.internals.positionAbsolute:xf(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)}},II=(e,t)=>ig(sg(Ux(e),Ux(t))),Yd=(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)},LN=e=>si(e.width)&&si(e.height)&&si(e.x)&&si(e.y),si=e=>!isNaN(e)&&isFinite(e),t4=(e,t)=>{},kf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),vf=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?kf(l,a):l},am=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function zl(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 n4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=zl(e,n),s=zl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=zl(e.top??e.y??0,n),s=zl(e.bottom??e.y??0,n),o=zl(e.left??e.x??0,t),a=zl(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 r4(e,t,n,r,s,o){const{x:a,y:l}=am(e,[t,n,r]),{x:c,y:u}=am({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Vk=(e,t,n,r,s,o)=>{const a=n4(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Oc(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,y=n/2-p*d,v=r4(e,h,y,d,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:h-b.left+b.right,y:y-b.top+b.bottom,zoom:d}},Gd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Fc(e){return e!=null&&e!=="parent"}function xo(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 RI(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 TI(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 ON(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function s4(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function i4(e){return{...jI,...e||{}}}function gd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=ii(e),l=vf({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?kf(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Kk=e=>({width:e.offsetWidth,height:e.offsetHeight}),MI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},o4=["INPUT","SELECT","TEXTAREA"];function $I(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:o4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const LI=e=>"clientX"in e,ii=(e,t)=>{var o,a;const n=LI(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)}},DN=(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,...Kk(a)}})};function OI({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,u=t*.125+o*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function Tp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function FN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ue.Left:return[t-Tp(t-r,o),n];case Ue.Right:return[t+Tp(r-t,o),n];case Ue.Top:return[t,n-Tp(n-s,o)];case Ue.Bottom:return[t,n+Tp(s-n,o)]}}function DI({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,curvature:a=.25}){const[l,c]=FN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=FN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,y]=OI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,h,y]}function FI({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 a4({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 l4({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=sg(om(e),om(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 Yd(a,ig(o))>0}const c4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,u4=(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)),bh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||c4;let s;return _I(e)?s={...e}:s={...e,id:r(e)},u4(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function zI({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=FI({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const zN={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},d4=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},BN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function f4({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:s,offset:o,stepPosition:a}){const l=zN[t],c=zN[r],u={x:e.x+l.x*o,y:e.y+l.y*o},d={x:n.x+c.x*o,y:n.y+c.y*o},f=d4({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,j]=FI({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??u.x+(d.x-u.x)*a,b=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,b=s.y??u.y+(d.y-u.y)*a);const R=[{x:v,y:u.y},{x:v,y:d.y}],B=[{x:u.x,y:b},{x:d.x,y:b}];l[p]===h?y=p==="x"?R:B:y=p==="x"?B:R}else{const R=[{x:u.x,y:d.y}],B=[{x:d.x,y:u.y}];if(p==="x"?y=l.x===h?B:R:y=l.y===h?R:B,t===r){const M=Math.abs(e[p]-n[p]);if(M<=o){const V=Math.min(o-1,o-M);l[p]===h?g[p]=(u[p]>e[p]?-1:1)*V:k[p]=(d[p]>n[p]?-1:1)*V}}if(t!==r){const M=p==="x"?"y":"x",V=l[p]===c[M],z=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!V&&z||V&&F)||l[p]!==1&&(!V&&F||V&&z))&&(y=p==="x"?R:B)}const A={x:u.x+g.x,y:u.y+g.y},O={x:d.x+k.x,y:d.y+k.y},D=Math.max(Math.abs(A.x-y[0].x),Math.abs(O.x-y[0].x)),L=Math.max(Math.abs(A.y-y[0].y),Math.abs(O.y-y[0].y));D>=L?(v=(A.x+O.x)/2,b=y[0].y):(v=y[0].x,b=(A.y+O.y)/2)}const S={x:u.x+g.x,y:u.y+g.y},C={x:d.x+k.x,y:d.y+k.y};return[[e,...S.x!==y[0].x||S.y!==y[0].y?[S]:[],...y,...C.x!==y[y.length-1].x||C.y!==y[y.length-1].y?[C]:[],n],v,b,x,j]}function p4(e,t,n,r){const s=Math.min(BN(e,t)/2,BN(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${o+s*u},${a}Q ${o},${a} ${o},${a+s*d}`}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 Yx({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,y,v]=f4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:d});let b=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)b+=p4(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,p,h,y,v]}function HN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function h4(e){var f;const{sourceNode:t,targetNode:n}=e;if(!HN(t)||!HN(n))return null;const r=t.internals.handleBounds||WN(t.handles),s=n.internals.handleBounds||WN(n.handles),o=VN((r==null?void 0:r.source)??[],e.sourceHandle),a=VN(e.connectionMode===Lc.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(f=e.onError)==null||f.call(e,"008",Oi.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Ue.Bottom,c=(a==null?void 0:a.position)||Ue.Top,u=rl(t,o,l),d=rl(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function WN(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 rl(e,t,n=Ue.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??xo(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Ue.Top:return{x:s+a/2,y:o};case Ue.Right:return{x:s+a,y:o+l/2};case Ue.Bottom:return{x:s+a/2,y:o+l};case Ue.Left:return{x:s,y:o+l/2}}}function VN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Gx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function m4(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 u=Gx(c,t);o.has(u)||(a.push({id:u,color:c.color||n,...c}),o.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const BI=1e3,g4=10,qk={nodeOrigin:[0,0],nodeExtent:qd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},y4={...qk,checkEquality:!0};function Uk(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function w4(e,t,n){const r=Uk(qk,n);for(const s of e.values())if(s.parentId)Gk(s,e,t,r);else{const o=xf(s,r.nodeOrigin),a=Fc(s.extent)?s.extent:r.nodeExtent,l=nl(o,a,xo(s));s.internals.positionAbsolute=l}}function x4(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 Yk(e){return e==="manual"}function Jx(e,t,n,r={}){var d,f;const s=Uk(y4,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Yk(s.zIndexMode)?BI:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const y=xf(p,s.nodeOrigin),v=Fc(p.extent)?p.extent:s.nodeExtent,b=nl(y,v,xo(p));h={...s.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:x4(p,h),z:HI(p,l,s.zIndexMode),userNode:p}},t.set(p.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),p.parentId&&Gk(h,t,n,r,o),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function b4(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 Gk(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Uk(qk,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b4(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*g4),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=o&&!Yk(c)?BI:0,{x:p,y:h,z:y}=k4(e,d,a,l,f,c),{positionAbsolute:v}=e.internals,b=p!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:p,y:h}:v,z:y}})}function HI(e,t,n){const r=si(e.zIndex)?e.zIndex:0;return Yk(n)?r:r+(e.selected?t:0)}function k4(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=xo(e),u=xf(e,n),d=Fc(e.extent)?nl(u,e.extent,c):u;let f=nl({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=AI(f,c,t));const p=HI(e,s,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Jk(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 u=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??Dc(c),d=II(u,l.rect);o.set(l.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=xo(c),p=c.origin??r,h=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,y=l.y<d.y?Math.round(Math.abs(d.y-l.y)):0,v=Math.max(f.width,Math.round(l.width)),b=Math.max(f.height,Math.round(l.height)),g=(v-f.width)*p[0],k=(b-f.height)*p[1];(h>0||y>0||g||k)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(j=>{e.some(S=>S.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+h,y:j.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?p[0]*h-g:0),height:b+(y?p[1]*y-k:0)}})}),s}function v4(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 u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const y=t.get(h.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Kk(h.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||h.force))){const k=h.nodeElement.getBoundingClientRect(),x=Fc(y.extent)?y.extent:o;let{positionAbsolute:j}=y.internals;y.parentId&&y.extent==="parent"?j=AI(j,v,t.get(y.parentId)):x&&(j=nl(j,x,v));const S={...y,measured:v,internals:{...y.internals,positionAbsolute:j,handleBounds:{source:DN("source",h.nodeElement,k,f,y.id),target:DN("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,S),y.parentId&&Gk(S,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:Dc(S,s)}))}}if(p.length>0){const h=Jk(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function S4({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 KN(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 u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function WI(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},u=`${s}-${a}--${o}-${l}`,d=`${o}-${l}--${s}-${a}`;KN("source",c,d,e,s,a),KN("target",c,u,e,o,l),t.set(r.id,r)}}function VI(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:VI(n,t):!1}function qN(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 j4(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!VI(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 Gy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.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 N4({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=kf(o,t);return{x:a.x-o.x,y:a.y-o.y}}function C4({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:j,isSelectable:S,nodeId:C,nodeClickDistance:P=0}){p=us(j);function R({x:D,y:L}){const{nodeLookup:M,nodeExtent:V,snapGrid:z,snapToGrid:F,nodeOrigin:$,onNodeDrag:W,onSelectionDrag:E,onError:Q,updateNodePositions:K}=t();o={x:D,y:L};let H=!1;const ee=l.size>1,ue=ee&&V?Ux(bf(l)):null,G=ee&&F?N4({dragItems:l,snapGrid:z,x:D,y:L}):null;for(const[te,se]of l){if(!M.has(te))continue;let ie={x:D-se.distance.x,y:L-se.distance.y};F&&(ie=G?{x:Math.round(ie.x+G.x),y:Math.round(ie.y+G.y)}:kf(ie,z));let Z=null;if(ee&&V&&!se.extent&&ue){const{positionAbsolute:pe}=se.internals,Me=pe.x-ue.x+V[0][0],Ne=pe.x+se.measured.width-ue.x2+V[1][0],Ce=pe.y-ue.y+V[0][1],We=pe.y+se.measured.height-ue.y2+V[1][1];Z=[[Me,Ce],[Ne,We]]}const{position:ce,positionAbsolute:de}=EI({nodeId:te,nextPosition:ie,nodeLookup:M,nodeExtent:Z||V,nodeOrigin:$,onError:Q});H=H||se.position.x!==ce.x||se.position.y!==ce.y,se.position=ce,se.internals.positionAbsolute=de}if(y=y||H,!!H&&(K(l,!0),v&&(r||W||!C&&E))){const[te,se]=Gy({nodeId:C,dragItems:l,nodeLookup:M});r==null||r(v,l,te,se),W==null||W(v,te,se),C||E==null||E(v,se)}}async function B(){if(!d)return;const{transform:D,panBy:L,autoPanSpeed:M,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[z,F]=PI(u,d,M);(z!==0||F!==0)&&(o.x=(o.x??0)-z/D[2],o.y=(o.y??0)-F/D[2],await L({x:z,y:F})&&R(o)),a=requestAnimationFrame(B)}function A(D){var ee;const{nodeLookup:L,multiSelectionActive:M,nodesDraggable:V,transform:z,snapGrid:F,snapToGrid:$,selectNodesOnDrag:W,onNodeDragStart:E,onSelectionDragStart:Q,unselectNodesAndEdges:K}=t();f=!0,(!W||!S)&&!M&&C&&((ee=L.get(C))!=null&&ee.selected||K()),S&&W&&C&&(e==null||e(C));const H=gd(D.sourceEvent,{transform:z,snapGrid:F,snapToGrid:$,containerBounds:d});if(o=H,l=j4(L,V,H,C),l.size>0&&(n||E||!C&&Q)){const[ue,G]=Gy({nodeId:C,dragItems:l,nodeLookup:L});n==null||n(D.sourceEvent,l,ue,G),E==null||E(D.sourceEvent,ue,G),C||Q==null||Q(D.sourceEvent,G)}}const O=aI().clickDistance(P).on("start",D=>{const{domNode:L,nodeDragThreshold:M,transform:V,snapGrid:z,snapToGrid:F}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,h=!1,y=!1,v=D.sourceEvent,M===0&&A(D),o=gd(D.sourceEvent,{transform:V,snapGrid:z,snapToGrid:F,containerBounds:d}),u=ii(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:L,transform:M,snapGrid:V,snapToGrid:z,nodeDragThreshold:F,nodeLookup:$}=t(),W=gd(D.sourceEvent,{transform:M,snapGrid:V,snapToGrid:z,containerBounds:d});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||C&&!$.has(C))&&(h=!0),!h){if(!c&&L&&f&&(c=!0,B()),!f){const E=ii(D.sourceEvent,d),Q=E.x-u.x,K=E.y-u.y;Math.sqrt(Q*Q+K*K)>F&&A(D)}(o.x!==W.xSnapped||o.y!==W.ySnapped)&&l&&f&&(u=ii(D.sourceEvent,d),R(W))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:L,updateNodePositions:M,onNodeDragStop:V,onSelectionDragStop:z}=t();if(y&&(M(l,!1),y=!1),s||V||!C&&z){const[F,$]=Gy({nodeId:C,dragItems:l,nodeLookup:L,dragging:!1});s==null||s(D.sourceEvent,l,F,$),V==null||V(D.sourceEvent,F,$),C||z==null||z(D.sourceEvent,$)}}}).filter(D=>{const L=D.target;return!D.button&&(!k||!qN(L,`.${k}`,j))&&(!x||qN(L,x,j))});p.call(O)}function g(){p==null||p.on(".drag",null)}return{update:b,destroy:g}}function _4(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())Yd(s,Dc(o))>0&&r.push(o);return r}const E4=250;function A4(e,t,n,r){var l,c;let s=[],o=1/0;const a=_4(e,n,t+E4);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:h}=rl(u,f,f.position,!0),y=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(s=[{...f,x:p,y:h}],o=y):y===o&&s.push({...f,x:p,y:h}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function KI(e,t,n,r,s,o=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...rl(a,c,c.position,!0)}:c}function qI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function P4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const UI=()=>!0;function I4(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=UI,onReconnectEnd:k,updateConnection:x,getTransform:j,getFromHandle:S,autoPanSpeed:C,dragThreshold:P=1,handleDomNode:R}){const B=MI(e.target);let A=0,O;const{x:D,y:L}=ii(e),M=qI(o,R),V=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!V||!M)return;const F=KI(s,M,r,c,t);if(!F)return;let $=ii(e,V),W=!1,E=null,Q=!1,K=null;function H(){if(!d||!V)return;const[ce,de]=PI($,V,C);p({x:ce,y:de}),A=requestAnimationFrame(H)}const ee={...F,nodeId:s,type:M,position:F.position},ue=c.get(s);let te={inProgress:!0,isValid:null,from:rl(ue,ee,Ue.Left,!0),fromHandle:ee,fromPosition:ee.position,fromNode:ue,to:$,toHandle:null,toPosition:MN[ee.position],toNode:null,pointer:$};function se(){z=!0,x(te),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}P===0&&se();function ie(ce){if(!z){const{x:We,y:ct}=ii(ce),yt=We-D,Re=ct-L;if(!(yt*yt+Re*Re>P*P))return;se()}if(!S()||!ee){Z(ce);return}const de=j();$=ii(ce,V),O=A4(vf($,de,!1,[1,1]),n,c,ee),W||(H(),W=!0);const pe=YI(ce,{handle:O,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:B,lib:u,flowId:f,nodeLookup:c});K=pe.handleDomNode,E=pe.connection,Q=P4(!!O,pe.isValid);const Me=c.get(s),Ne=Me?rl(Me,ee,Ue.Left,!0):te.from,Ce={...te,from:Ne,isValid:Q,to:pe.toHandle&&Q?am({x:pe.toHandle.x,y:pe.toHandle.y},de):$,toHandle:pe.toHandle,toPosition:Q&&pe.toHandle?pe.toHandle.position:MN[ee.position],toNode:pe.toHandle?c.get(pe.toHandle.nodeId):null,pointer:$};x(Ce),te=Ce}function Z(ce){if(!("touches"in ce&&ce.touches.length>0)){if(z){(O||K)&&E&&Q&&(v==null||v(E));const{inProgress:de,...pe}=te,Me={...pe,toPosition:te.toHandle?te.toPosition:null};b==null||b(ce,Me),o&&(k==null||k(ce,Me))}h(),cancelAnimationFrame(A),W=!1,Q=!1,E=null,K=null,B.removeEventListener("mousemove",ie),B.removeEventListener("mouseup",Z),B.removeEventListener("touchmove",ie),B.removeEventListener("touchend",Z)}}B.addEventListener("mousemove",ie),B.addEventListener("mouseup",Z),B.addEventListener("touchmove",ie),B.addEventListener("touchend",Z)}function YI(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=UI,nodeLookup:d}){const f=o==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y}=ii(e),v=a.elementFromPoint(h,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:p,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=qI(void 0,b),x=b.getAttribute("data-nodeid"),j=b.getAttribute("data-handleid"),S=b.classList.contains("connectable"),C=b.classList.contains("connectableend");if(!x||!k)return g;const P={source:f?x:r,sourceHandle:f?j:s,target:f?r:x,targetHandle:f?s:j};g.connection=P;const B=S&&C&&(n===Lc.Strict?f&&k==="source"||!f&&k==="target":x!==r||j!==s);g.isValid=B&&u(P),g.toHandle=KI(x,k,j,d,n,!0)}return g}const Xx={onPointerDown:I4,isValid:YI};function R4({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=us(e);function o({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const j=n(),S=x.sourceEvent.ctrlKey&&Gd()?10:1,C=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,P=j[2]*Math.pow(2,C*S);t.scaleTo(P)};let v=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(v=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},g=x=>{const j=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const S=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],C=[S[0]-v[0],S[1]-v[1]];v=S;const P=r()*Math.max(j[2],Math.log(j[2]))*(h?-1:1),R={x:j[0]-C[0]*P,y:j[1]-C[1]*P},B=[[0,0],[c,u]];t.setViewportConstrained({x:R.x,y:R.y,zoom:j[2]},B,l)},k=vI().on("start",b).on("zoom",f?g:null).on("zoom.wheel",p?y:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:ei}}const og=e=>({x:e.x,y:e.y,zoom:e.k}),Jy=({x:e,y:t,zoom:n})=>rg.translate(e,t).scale(n),lc=(e,t)=>e.target.closest(`.${t}`),GI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),T4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Xy=(e,t=0,n=T4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},JI=e=>{const t=e.ctrlKey&&Gd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function M4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(lc(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const b=ei(d),g=JI(d),k=f*Math.pow(2,g);r.scaleTo(n,k,b,d);return}const p=d.deltaMode===1?20:1;let h=s===qa.Vertical?0:d.deltaX*p,y=s===qa.Horizontal?0:d.deltaY*p;!Gd()&&d.shiftKey&&s!==qa.Vertical&&(h=d.deltaY*p,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=og(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,v))}}function $4({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=lc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function L4({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=og(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 O4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&GI(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,og(o.transform)))}}function D4({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&&GI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=og(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function F4({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var b;const p=e||t,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(lc(f,`${u}-flow__node`)||lc(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!o&&!n||a||d&&!y||lc(f,l)&&y||lc(f,c)&&(!y||s&&y&&!e)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&((b=f.touches)==null?void 0:b.length)>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function z4({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=vI().scaleExtent([t,n]).translateExtent(r),p=us(e).call(f);k({x:s.x,y:s.y,zoom:Oc(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),y=p.on("dblclick.zoom");f.wheelDelta(JI);function v(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?md:gh).transform(Xy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function b({noWheelClassName:O,noPanClassName:D,onPaneContextMenu:L,userSelectionActive:M,panOnScroll:V,panOnDrag:z,panOnScrollMode:F,panOnScrollSpeed:$,preventScrolling:W,zoomOnPinch:E,zoomOnScroll:Q,zoomOnDoubleClick:K,zoomActivationKeyPressed:H,lib:ee,onTransformChange:ue,connectionInProgress:G,paneClickDistance:te,selectionOnDrag:se}){M&&!u.isZoomingOrPanning&&g();const ie=V&&!H&&!M;f.clickDistance(se?1/0:!si(te)||te<0?0:te);const Z=ie?M4({zoomPanValues:u,noWheelClassName:O,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):$4({noWheelClassName:O,preventScrolling:W,d3ZoomHandler:h});if(p.on("wheel.zoom",Z,{passive:!1}),!M){const de=L4({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const pe=O4({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!L,onPanZoom:o,onTransformChange:ue});f.on("zoom",pe);const Me=D4({zoomPanValues:u,panOnDrag:z,panOnScroll:V,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",Me)}const ce=F4({zoomActivationKeyPressed:H,panOnDrag:z,zoomOnScroll:Q,panOnScroll:V,zoomOnDoubleClick:K,zoomOnPinch:E,userSelectionActive:M,noPanClassName:D,noWheelClassName:O,lib:ee,connectionInProgress:G});f.filter(ce),K?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(O,D,L){const M=Jy(O),V=f==null?void 0:f.constrain()(M,D,L);return V&&await v(V),new Promise(z=>z(V))}async function x(O,D){const L=Jy(O);return await v(L,D),new Promise(M=>M(L))}function j(O){if(p){const D=Jy(O),L=p.property("__zoom");(L.k!==O.zoom||L.x!==O.x||L.y!==O.y)&&(f==null||f.transform(p,D,null,{sync:!0}))}}function S(){const O=p?kI(p.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function C(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?md:gh).scaleTo(Xy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function P(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?md:gh).scaleBy(Xy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function R(O){f==null||f.scaleExtent(O)}function B(O){f==null||f.translateExtent(O)}function A(O){const D=!si(O)||O<0?0:O;f==null||f.clickDistance(D)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:S,scaleTo:C,scaleBy:P,setScaleExtent:R,setTranslateExtent:B,syncViewport:j,setClickDistance:A}}var zc;(function(e){e.Line="line",e.Handle="handle"})(zc||(zc={}));function B4({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 UN(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 To(e,t){return Math.max(0,t-e)}function Mo(e,t){return Math.max(0,e-t)}function Mp(e,t,n){return Math.max(0,t-e,e-n)}function YN(e,t){return e?!t:t}function H4(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:j,width:S,height:C,aspectRatio:P}=e;let R=Math.floor(d?h-e.pointerX:0),B=Math.floor(f?y-e.pointerY:0);const A=S+(c?-R:R),O=C+(u?-B:B),D=-o[0]*S,L=-o[1]*C;let M=Mp(A,v,b),V=Mp(O,g,k);if(a){let $=0,W=0;c&&R<0?$=To(x+R+D,a[0][0]):!c&&R>0&&($=Mo(x+A+D,a[1][0])),u&&B<0?W=To(j+B+L,a[0][1]):!u&&B>0&&(W=Mo(j+O+L,a[1][1])),M=Math.max(M,$),V=Math.max(V,W)}if(l){let $=0,W=0;c&&R>0?$=Mo(x+R,l[0][0]):!c&&R<0&&($=To(x+A,l[1][0])),u&&B>0?W=Mo(j+B,l[0][1]):!u&&B<0&&(W=To(j+O,l[1][1])),M=Math.max(M,$),V=Math.max(V,W)}if(s){if(d){const $=Mp(A/P,g,k)*P;if(M=Math.max(M,$),a){let W=0;!c&&!u||c&&!u&&p?W=Mo(j+L+A/P,a[1][1])*P:W=To(j+L+(c?R:-R)/P,a[0][1])*P,M=Math.max(M,W)}if(l){let W=0;!c&&!u||c&&!u&&p?W=To(j+A/P,l[1][1])*P:W=Mo(j+(c?R:-R)/P,l[0][1])*P,M=Math.max(M,W)}}if(f){const $=Mp(O*P,v,b)/P;if(V=Math.max(V,$),a){let W=0;!c&&!u||u&&!c&&p?W=Mo(x+O*P+D,a[1][0])/P:W=To(x+(u?B:-B)*P+D,a[0][0])/P,V=Math.max(V,W)}if(l){let W=0;!c&&!u||u&&!c&&p?W=To(x+O*P,l[1][0])/P:W=Mo(x+(u?B:-B)*P,l[0][0])/P,V=Math.max(V,W)}}}B=B+(B<0?V:-V),R=R+(R<0?M:-M),s&&(p?A>O*P?B=(YN(c,u)?-R:R)/P:R=(YN(c,u)?-B:B)*P:d?(B=R/P,u=c):(R=B*P,c=u));const z=c?x+R:x,F=u?j+B:j;return{width:S+(c?-R:R),height:C+(u?-B:B),x:o[0]*R*(c?-1:1)+z,y:o[1]*B*(u?-1:1)+F}}const XI={width:0,height:0,x:0,y:0},W4={...XI,pointerX:0,pointerY:0,aspectRatio:1};function V4(e){return[[0,0],[e.measured.width,e.measured.height]]}function K4(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 q4({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=us(e);let a={controlDirection:UN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...XI},k={...W4};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:UN(u)};let x,j=null,S=[],C,P,R,B=!1;const A=aI().on("start",O=>{const{nodeLookup:D,transform:L,snapGrid:M,snapToGrid:V,nodeOrigin:z,paneDomNode:F}=n();if(x=D.get(t),!x)return;j=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:W}=gd(O.sourceEvent,{transform:L,snapGrid:M,snapToGrid:V,containerBounds:j});g={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},k={...g,pointerX:$,pointerY:W,aspectRatio:g.width/g.height},C=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(C=D.get(x.parentId),P=C&&x.extent==="parent"?V4(C):void 0),S=[],R=void 0;for(const[E,Q]of D)if(Q.parentId===t&&(S.push({id:E,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const K=K4(Q,x,Q.origin??z);R?R=[[Math.min(K[0][0],R[0][0]),Math.min(K[0][1],R[0][1])],[Math.max(K[1][0],R[1][0]),Math.max(K[1][1],R[1][1])]]:R=K}h==null||h(O,{...g})}).on("drag",O=>{const{transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V}=n(),z=gd(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:M,containerBounds:j}),F=[];if(!x)return;const{x:$,y:W,width:E,height:Q}=g,K={},H=x.origin??V,{width:ee,height:ue,x:G,y:te}=H4(k,a.controlDirection,z,a.boundaries,a.keepAspectRatio,H,P,R),se=ee!==E,ie=ue!==Q,Z=G!==$&&se,ce=te!==W&&ie;if(!Z&&!ce&&!se&&!ie)return;if((Z||ce||H[0]===1||H[1]===1)&&(K.x=Z?G:g.x,K.y=ce?te:g.y,g.x=K.x,g.y=K.y,S.length>0)){const Ne=G-$,Ce=te-W;for(const We of S)We.position={x:We.position.x-Ne+H[0]*(ee-E),y:We.position.y-Ce+H[1]*(ue-Q)},F.push(We)}if((se||ie)&&(K.width=se&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ee:g.width,K.height=ie&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:g.height,g.width=K.width,g.height=K.height),C&&x.expandParent){const Ne=H[0]*(K.width??0);K.x&&K.x<Ne&&(g.x=Ne,k.x=k.x-(K.x-Ne));const Ce=H[1]*(K.height??0);K.y&&K.y<Ce&&(g.y=Ce,k.y=k.y-(K.y-Ce))}const de=B4({width:g.width,prevWidth:E,height:g.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),pe={...g,direction:de};(b==null?void 0:b(O,pe))!==!1&&(B=!0,y==null||y(O,pe),r(K,F))}).on("end",O=>{B&&(v==null||v(O,{...g}),s==null||s({...g}),B=!1)});o.call(A)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var QI={exports:{}},ZI={},eR={exports:{}},tR={};/**
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 Bc=m;function U4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Y4=typeof Object.is=="function"?Object.is:U4,G4=Bc.useState,J4=Bc.useEffect,X4=Bc.useLayoutEffect,Q4=Bc.useDebugValue;function Z4(e,t){var n=t(),r=G4({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return X4(function(){s.value=n,s.getSnapshot=t,Qy(s)&&o({inst:s})},[e,n,t]),J4(function(){return Qy(s)&&o({inst:s}),e(function(){Qy(s)&&o({inst:s})})},[e]),Q4(n),n}function Qy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Y4(e,n)}catch{return!0}}function eW(e,t){return t()}var tW=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?eW:Z4;tR.useSyncExternalStore=Bc.useSyncExternalStore!==void 0?Bc.useSyncExternalStore:tW;eR.exports=tR;var nR=eR.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 ag=m,nW=nR;function rW(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var sW=typeof Object.is=="function"?Object.is:rW,iW=nW.useSyncExternalStore,oW=ag.useRef,aW=ag.useEffect,lW=ag.useMemo,cW=ag.useDebugValue;ZI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=oW(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=lW(function(){function c(h){if(!u){if(u=!0,d=h,h=r(h),s!==void 0&&a.hasValue){var y=a.value;if(s(y,h))return f=y}return f=h}if(y=f,sW(d,h))return y;var v=r(h);return s!==void 0&&s(y,v)?(d=h,y):(d=h,f=v)}var u=!1,d,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=iW(e,o[0],o[1]);return aW(function(){a.hasValue=!0,a.value=l},[l]),cW(l),l};QI.exports=ZI;var uW=QI.exports;const dW=da(uW),fW={},GN=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(fW?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},pW=e=>e?GN(e):GN,{useDebugValue:hW}=pt,{useSyncExternalStoreWithSelector:mW}=dW,gW=e=>e;function rR(e,t=gW,n){const r=mW(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return hW(r),r}const JN=(e,t)=>{const n=pW(e),r=(s,o=t)=>rR(n,s,o);return Object.assign(r,n),r},yW=(e,t)=>e?JN(e,t):JN;function bn(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 lg=m.createContext(null),wW=lg.Provider,sR=Oi.error001();function Vt(e,t){const n=m.useContext(lg);if(n===null)throw new Error(sR);return rR(n,e,t)}function dn(){const e=m.useContext(lg);if(e===null)throw new Error(sR);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const XN={display:"none"},xW={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},iR="react-flow__node-desc",oR="react-flow__edge-desc",bW="react-flow__aria-live",kW=e=>e.ariaLiveMessage,vW=e=>e.ariaLabelConfig;function SW({rfId:e}){const t=Vt(kW);return i.jsx("div",{id:`${bW}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:xW,children:t})}function jW({rfId:e,disableKeyboardA11y:t}){const n=Vt(vW);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${iR}-${e}`,style:XN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${oR}-${e}`,style:XN,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(SW,{rfId:e})]})}const cg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Un(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});cg.displayName="Panel";function NW({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(cg,{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 CW=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},$p=e=>e.id;function _W(e,t){return bn(e.selectedNodes.map($p),t.selectedNodes.map($p))&&bn(e.selectedEdges.map($p),t.selectedEdges.map($p))}function EW({onSelectionChange:e}){const t=dn(),{selectedNodes:n,selectedEdges:r}=Vt(CW,_W);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const AW=e=>!!e.onSelectionChangeHandlers;function PW({onSelectionChange:e}){const t=Vt(AW);return e||t?i.jsx(EW,{onSelectionChange:e}):null}const Qx=typeof window<"u"?m.useLayoutEffect:m.useEffect,aR=[0,0],IW={x:0,y:0,zoom:1},RW=["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"],QN=[...RW,"rfId"],TW=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}),ZN={translateExtent:qd,nodeOrigin:aR,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function MW(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Vt(TW,bn),u=dn();Qx(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=ZN,l()}),[]);const d=m.useRef(ZN);return Qx(()=>{for(const f of QN){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?o(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:i4(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},QN.map(f=>e[f])),null}function e1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $W(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=e1(),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=e1())!=null&&r.matches?"dark":"light"}const t1=typeof document<"u"?document:null;function Jd(e=null,t={target:t1,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),d=u.reduce((f,p)=>f.concat(...p),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??t1,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var b,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&$I(h))return!1;const v=r1(h.code,l);if(o.current.add(h[v]),n1(a,o.current,!1)){const k=((g=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:g[0])||h.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const y=r1(h.code,l);n1(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.key==="Meta"&&o.current.clear(),s.current=!1},p=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function n1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function r1(e,t){return t.includes(e)?"code":"key"}const LW=()=>{const e=dn();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=Vk(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(),u={x:t.x-l,y:t.y-c},d=n.snapGrid??s,f=n.snapToGrid??o;return vf(u,r,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=am(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function lR(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)OW(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 OW(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 yd(e,t){return lR(e,t)}function lm(e,t){return lR(e,t)}function Ia(e,t){return{id:e,type:"select",selected:t}}function cc(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(Ia(o.id,a)))}return r}function s1({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 i1(e){return{id:e.id,type:"remove"}}const o1=e=>GH(e),DW=e=>_I(e);function cR(e){return m.forwardRef(e)}function a1(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>FW(()=>n(s=>s+BigInt(1))));return Qx(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function FW(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const uR=m.createContext(null);function zW({children:e}){const t=dn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=s1({items:v,lookup:p});for(const g of y.values())b=g(b);d&&u(v),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=a1(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;d?u(h):f&&f(s1({items:h,lookup:p}))},[]),o=a1(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(uR.Provider,{value:a,children:e})}function BW(){const e=m.useContext(uR);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const HW=e=>!!e.panZoom;function Gc(){const e=LW(),t=dn(),n=BW(),r=Vt(HW),s=m.useMemo(()=>{const o=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var g,k;const{nodeLookup:p,nodeOrigin:h}=t.getState(),y=o1(f)?f:p.get(f.id),v=y.parentId?TI(y.position,y.measured,y.parentId,p,h):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Dc(b)},u=(f,p,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&o1(b)?b:{...v,...b}}return v}))},d=(f,p,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&DW(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var p;return(p=o(f))==null?void 0:p.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(p=>({...p}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const p=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:h}=t.getState(),[y,v,b]=h;return{nodes:f.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:j}=t.getState(),{nodes:S,edges:C}=await e4({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:y,onBeforeDelete:j}),P=C.length>0,R=S.length>0;if(P){const B=C.map(i1);b==null||b(C),k(B)}if(R){const B=S.map(i1);v==null||v(S),g(B)}return(R||P)&&(x==null||x({nodes:S,edges:C})),{deletedNodes:S,deletedEdges:C}},getIntersectingNodes:(f,p=!0,h)=>{const y=LN(f),v=y?f:c(f),b=h!==void 0;return v?(h||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===f.id||!k.internals.positionAbsolute))return!1;const x=Dc(b?g:k),j=Yd(x,v);return p&&j>0||j>=x.width*x.height||j>=v.width*v.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const v=LN(f)?f:c(f);if(!v)return!1;const b=Yd(v,p);return h&&b>0||b>=p.width*p.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,p,h={replace:!1})=>{u(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:d,updateEdgeData:(f,p,h={replace:!1})=>{d(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return JH(f,{nodeLookup:p,nodeOrigin:h})},getHandleConnections:({type:f,id:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${f}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??s4();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(h=>[...h]),p.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const l1=e=>e.selected,WW=typeof window<"u"?window:void 0;function VW({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=dn(),{deleteElements:r}=Gc(),s=Jd(e,{actInsideInputWithModifier:!1}),o=Jd(t,{target:WW});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(l1),edges:a.filter(l1)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function KW(e){const t=dn();m.useEffect(()=>{const n=()=>{var s,o,a,l;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=Kk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Oi.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 ug={position:"absolute",width:"100%",height:"100%",top:0,left:0},qW=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function UW({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=qa.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:j}){const S=dn(),C=m.useRef(null),{userSelectionActive:P,lib:R,connectionInProgress:B}=Vt(qW,bn),A=Jd(p),O=m.useRef();KW(C);const D=m.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),k||S.setState({transform:L})},[g,k]);return m.useEffect(()=>{if(C.current){O.current=z4({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:z=>S.setState(F=>F.paneDragging===z?F:{paneDragging:z}),onPanZoomStart:(z,F)=>{const{onViewportChangeStart:$,onMoveStart:W}=S.getState();W==null||W(z,F),$==null||$(F)},onPanZoom:(z,F)=>{const{onViewportChange:$,onMove:W}=S.getState();W==null||W(z,F),$==null||$(F)},onPanZoomEnd:(z,F)=>{const{onViewportChangeEnd:$,onMoveEnd:W}=S.getState();W==null||W(z,F),$==null||$(F)}});const{x:L,y:M,zoom:V}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[L,M,V],domNode:C.current.closest(".react-flow")}),()=>{var z;(z=O.current)==null||z.destroy()}}},[]),m.useEffect(()=>{var L;(L=O.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:A,preventScrolling:h,noPanClassName:b,userSelectionActive:P,noWheelClassName:v,lib:R,onTransformChange:D,connectionInProgress:B,selectionOnDrag:j,paneClickDistance:x})},[e,t,n,r,s,o,a,l,A,h,b,P,v,R,D,B,j,x]),i.jsx("div",{className:"react-flow__renderer",ref:C,style:ug,children:y})}const YW=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function GW(){const{userSelectionActive:e,userSelectionRect:t}=Vt(YW,bn);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 Zy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},JW=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function XW({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ud.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:y}){const v=dn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Vt(JW,bn),j=g&&(e||b),S=m.useRef(null),C=m.useRef(),P=m.useRef(new Set),R=m.useRef(new Set),B=m.useRef(!1),A=$=>{if(B.current||x){B.current=!1;return}c==null||c($),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},O=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}u==null||u($)},D=d?$=>d($):void 0,L=$=>{B.current&&($.stopPropagation(),B.current=!1)},M=$=>{var ue,G;const{domNode:W}=v.getState();if(C.current=W==null?void 0:W.getBoundingClientRect(),!C.current)return;const E=$.target===S.current;if(!E&&!!$.target.closest(".nokey")||!e||!(o&&E||t)||$.button!==0||!$.isPrimary)return;(G=(ue=$.target)==null?void 0:ue.setPointerCapture)==null||G.call(ue,$.pointerId),B.current=!1;const{x:H,y:ee}=ii($.nativeEvent,C.current);v.setState({userSelectionRect:{width:0,height:0,startX:H,startY:ee,x:H,y:ee}}),E||($.stopPropagation(),$.preventDefault())},V=$=>{const{userSelectionRect:W,transform:E,nodeLookup:Q,edgeLookup:K,connectionLookup:H,triggerNodeChanges:ee,triggerEdgeChanges:ue,defaultEdgeOptions:G,resetSelectedElements:te}=v.getState();if(!C.current||!W)return;const{x:se,y:ie}=ii($.nativeEvent,C.current),{startX:Z,startY:ce}=W;if(!B.current){const Ce=t?0:s;if(Math.hypot(se-Z,ie-ce)<=Ce)return;te(),a==null||a($)}B.current=!0;const de={startX:Z,startY:ce,x:se<Z?se:Z,y:ie<ce?ie:ce,width:Math.abs(se-Z),height:Math.abs(ie-ce)},pe=P.current,Me=R.current;P.current=new Set(Wk(Q,de,E,n===Ud.Partial,!0).map(Ce=>Ce.id)),R.current=new Set;const Ne=(G==null?void 0:G.selectable)??!0;for(const Ce of P.current){const We=H.get(Ce);if(We)for(const{edgeId:ct}of We.values()){const yt=K.get(ct);yt&&(yt.selectable??Ne)&&R.current.add(ct)}}if(!ON(pe,P.current)){const Ce=cc(Q,P.current,!0);ee(Ce)}if(!ON(Me,R.current)){const Ce=cc(K,R.current);ue(Ce)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},z=$=>{var W,E;$.button===0&&((E=(W=$.target)==null?void 0:W.releasePointerCapture)==null||E.call(W,$.pointerId),!b&&$.target===S.current&&v.getState().userSelectionRect&&(A==null||A($)),v.setState({userSelectionActive:!1,userSelectionRect:null}),B.current&&(l==null||l($),v.setState({nodesSelectionActive:P.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Un(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:j?void 0:Zy(A,S),onContextMenu:Zy(O,S),onWheel:Zy(D,S),onPointerEnter:j?void 0:f,onPointerMove:j?V:p,onPointerUp:j?z:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?L:void 0,onPointerLeave:h,ref:S,style:ug,children:[y,i.jsx(GW,{})]})}function Zx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Oi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function dR({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=dn(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=C4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Zx({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,r,t,o,e,s,a]),c}const QW=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function fR(){const e=dn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,p=QW(a),h=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*h*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!p(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=kf(k,o));const{position:x,positionAbsolute:j}=EI({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});g.position=x,g.internals.positionAbsolute=j,f.set(g.id,g)}c(f)},[])}const Xk=m.createContext(null),ZW=Xk.Provider;Xk.Consumer;const pR=()=>m.useContext(Xk),e5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),t5=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=(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:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===Lc.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:d&&u}};function n5({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:d,onTouchStart:f,...p},h){var V,z;const y=a||null,v=e==="target",b=dn(),g=pR(),{connectOnClick:k,noPanClassName:x,rfId:j}=Vt(e5,bn),{connectingFrom:S,connectingTo:C,clickConnecting:P,isPossibleEndHandle:R,connectionInProcess:B,clickConnectionInProcess:A,valid:O}=Vt(t5(g,y,e),bn);g||(z=(V=b.getState()).onError)==null||z.call(V,"010",Oi.error010());const D=F=>{const{defaultEdgeOptions:$,onConnect:W,hasDefaultEdges:E}=b.getState(),Q={...$,...F};if(E){const{edges:K,setEdges:H}=b.getState();H(bh(Q,K))}W==null||W(Q),l==null||l(Q)},L=F=>{if(!g)return;const $=LI(F.nativeEvent);if(s&&($&&F.button===0||!$)){const W=b.getState();Xx.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:v,handleId:y,nodeId:g,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...E)=>{var Q,K;return(K=(Q=b.getState()).onConnectEnd)==null?void 0:K.call(Q,...E)},updateConnection:W.updateConnection,onConnect:D,isValidConnection:n||((...E)=>{var Q,K;return((K=(Q=b.getState()).isValidConnection)==null?void 0:K.call(Q,...E))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}$?d==null||d(F):f==null||f(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:W,connectionClickStartHandle:E,connectionMode:Q,isValidConnection:K,lib:H,rfId:ee,nodeLookup:ue,connection:G}=b.getState();if(!g||!E&&!s)return;if(!E){$==null||$(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const te=MI(F.target),se=n||K,{connection:ie,isValid:Z}=Xx.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:Q,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:se,flowId:ee,doc:te,lib:H,nodeLookup:ue});Z&&ie&&D(ie);const ce=structuredClone(G);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,W==null||W(F,ce),b.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${j}-${g}-${y}-${e}`,className:Un(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:P,connectingfrom:S,connectingto:C,valid:O,connectionindicator:r&&(!B||R)&&(B||A?o:s)}]),onMouseDown:L,onTouchStart:L,onClick:k?M:void 0,ref:h,...p,children:c})}const qn=m.memo(cR(n5));function r5({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(qn,{type:"source",position:n,isConnectable:t})]})}function s5({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:r=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(qn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(qn,{type:"source",position:r,isConnectable:t})]})}function i5(){return null}function o5({data:e,isConnectable:t,targetPosition:n=Ue.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(qn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const cm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},c1={input:r5,default:s5,output:o5,group:i5};function a5(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 l5=e=>{const{width:t,height:n,x:r,y:s}=bf(e.nodeLookup,{filter:o=>!!o.selected});return{width:si(t)?t:null,height:si(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function c5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=dn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Vt(l5,bn),c=fR(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const d=!l&&s!==null&&o!==null;if(dR({nodeRef:u,disabled:!d}),!d)return null;const f=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(cm,h.key)&&(h.preventDefault(),c({direction:cm[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:Un(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:o}})})}const u1=typeof window<"u"?window:void 0,u5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function hR({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:j,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:P,panOnDrag:R,defaultViewport:B,translateExtent:A,minZoom:O,maxZoom:D,preventScrolling:L,onSelectionContextMenu:M,noWheelClassName:V,noPanClassName:z,disableKeyboardA11y:F,onViewportChange:$,isControlledViewport:W}){const{nodesSelectionActive:E,userSelectionActive:Q}=Vt(u5,bn),K=Jd(u,{target:u1}),H=Jd(v,{target:u1}),ee=H||R,ue=H||j,G=d&&ee!==!0,te=K||Q||G;return VW({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(UW,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:ue,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:P,panOnDrag:!K&&ee,defaultViewport:B,translateExtent:A,minZoom:O,maxZoom:D,zoomActivationKeyCode:b,preventScrolling:L,noWheelClassName:V,noPanClassName:z,onViewportChange:$,isControlledViewport:W,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(XW,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:ee,isSelecting:!!te,selectionMode:f,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:G,children:[e,E&&i.jsx(c5,{onSelectionContextMenu:M,noPanClassName:z,disableKeyboardA11y:F})]})})}hR.displayName="FlowRenderer";const d5=m.memo(hR),f5=e=>t=>e?Wk(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 p5(e){return Vt(m.useCallback(f5(e),[e]),bn)}const h5=e=>e.updateNodeInternals;function m5(){const e=Vt(h5),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function g5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=dn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!d||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[d,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const f=u.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(u.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 y5({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:p,noPanClassName:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:j,isParent:S}=Vt(se=>{const ie=se.nodeLookup.get(e),Z=se.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:Z}},bn);let C=x.type||"default",P=(b==null?void 0:b[C])||c1[C];P===void 0&&(k==null||k("003",Oi.error003(C)),C="default",P=(b==null?void 0:b.default)||c1.default);const R=!!(x.draggable||l&&typeof x.draggable>"u"),B=!!(x.selectable||c&&typeof x.selectable>"u"),A=!!(x.connectable||u&&typeof x.connectable>"u"),O=!!(x.focusable||d&&typeof x.focusable>"u"),D=dn(),L=RI(x),M=g5({node:x,nodeType:C,hasDimensions:L,resizeObserver:f}),V=dR({nodeRef:M,disabled:x.hidden||!R,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:B,nodeClickDistance:g}),z=fR();if(x.hidden)return null;const F=xo(x),$=a5(x),W=B||R||t||n||r||s,E=n?se=>n(se,{...j.userNode}):void 0,Q=r?se=>r(se,{...j.userNode}):void 0,K=s?se=>s(se,{...j.userNode}):void 0,H=o?se=>o(se,{...j.userNode}):void 0,ee=a?se=>a(se,{...j.userNode}):void 0,ue=se=>{const{selectNodesOnDrag:ie,nodeDragThreshold:Z}=D.getState();B&&(!ie||!R||Z>0)&&Zx({id:e,store:D,nodeRef:M}),t&&t(se,{...j.userNode})},G=se=>{if(!($I(se.nativeEvent)||y)){if(SI.includes(se.key)&&B){const ie=se.key==="Escape";Zx({id:e,store:D,unselect:ie,nodeRef:M})}else if(R&&x.selected&&Object.prototype.hasOwnProperty.call(cm,se.key)){se.preventDefault();const{ariaLabelConfig:ie}=D.getState();D.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:se.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),z({direction:cm[se.key],factor:se.shiftKey?4:1})}}},te=()=>{var Me;if(y||!((Me=M.current)!=null&&Me.matches(":focus-visible")))return;const{transform:se,width:ie,height:Z,autoPanOnNodeFocus:ce,setCenter:de}=D.getState();if(!ce)return;Wk(new Map([[e,x]]),{x:0,y:0,width:ie,height:Z},se,!0).length>0||de(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:se[2]})};return i.jsx("div",{className:Un(["react-flow__node",`react-flow__node-${C}`,{[h]:R},x.className,{selected:x.selected,selectable:B,parent:S,draggable:R,dragging:V}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:L?"visible":"hidden",...x.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Q,onMouseLeave:K,onContextMenu:H,onClick:ue,onDoubleClick:ee,onKeyDown:O?G:void 0,tabIndex:O?0:void 0,onFocus:O?te:void 0,role:x.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${iR}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(ZW,{value:e,children:i.jsx(P,{id:e,data:x.data,type:C,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:x.selected??!1,selectable:B,draggable:R,deletable:x.deletable??!0,isConnectable:A,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:j.z,parentId:x.parentId,...F})})})}var w5=m.memo(y5);const x5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function mR(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Vt(x5,bn),a=p5(e.onlyRenderVisibleElements),l=m5();return i.jsx("div",{className:"react-flow__nodes",style:ug,children:a.map(c=>i.jsx(w5,{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))})}mR.displayName="NodeRenderer";const b5=m.memo(mR);function k5(e){return Vt(m.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const o=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);o&&a&&l4({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),bn)}const v5=({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"})},S5=({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"})},d1={[Ci.Arrow]:v5,[Ci.ArrowClosed]:S5};function j5(e){const t=dn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(d1,e)?d1[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Oi.error009(e)),null)},[e])}const N5=({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=j5(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},gR=({defaultColor:e,rfId:t})=>{const n=Vt(o=>o.edges),r=Vt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>m4(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(N5,{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};gR.displayName="MarkerDefinitions";var C5=m.memo(gR);function yR({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d}){const[f,p]=m.useState({x:1,y:0,width:0,height:0}),h=Un(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.useEffect(()=>{if(y.current){const v=y.current.getBBox();p({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...d,children:[s&&i.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}yR.displayName="EdgeText";const _5=m.memo(yR);function dg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...d,d:e,fill:"none",className:Un(["react-flow__edge-path",d.className])}),u?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&si(t)&&si(n)?i.jsx(_5,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function f1({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ue.Left||e===Ue.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function wR({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top}){const[a,l]=f1({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=f1({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,f,p,h]=OI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,d,f,p,h]}function xR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,j]=wR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),S=e.isInternal?void 0:t;return i.jsx(dg,{id:S,path:k,labelX:x,labelY:j,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const E5=xR({isInternal:!1}),bR=xR({isInternal:!0});E5.displayName="SimpleBezierEdge";bR.displayName="SimpleBezierEdgeInternal";function kR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,sourcePosition:h=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,j,S]=Yx({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),C=e.isInternal?void 0:t;return i.jsx(dg,{id:C,path:x,labelX:j,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:b,interactionWidth:k})})}const vR=kR({isInternal:!1}),SR=kR({isInternal:!0});vR.displayName="SmoothStepEdge";SR.displayName="SmoothStepEdgeInternal";function jR(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(vR,{...n,id:r,pathOptions:m.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const A5=jR({isInternal:!1}),NR=jR({isInternal:!0});A5.displayName="StepEdge";NR.displayName="StepEdgeInternal";function CR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=zI({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(dg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})})}const P5=CR({isInternal:!1}),_R=CR({isInternal:!0});P5.displayName="StraightEdge";_R.displayName="StraightEdgeInternal";function ER(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,j,S]=DI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),C=e.isInternal?void 0:t;return i.jsx(dg,{id:C,path:x,labelX:j,labelY:S,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const I5=ER({isInternal:!1}),AR=ER({isInternal:!0});I5.displayName="BezierEdge";AR.displayName="BezierEdgeInternal";const p1={default:AR,straight:_R,step:NR,smoothstep:SR,simplebezier:bR},h1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},R5=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,T5=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,m1="react-flow__edgeupdater";function g1({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:Un([m1,`${m1}-${l}`]),cx:R5(t,r,e),cy:T5(n,r,e),r,stroke:"transparent",fill:"transparent"})}function M5({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:p,setUpdateHover:h}){const y=dn(),v=(j,S)=>{if(j.button!==0)return;const{autoPanOnConnect:C,domNode:P,connectionMode:R,connectionRadius:B,lib:A,onConnectStart:O,cancelConnection:D,nodeLookup:L,rfId:M,panBy:V,updateConnection:z}=y.getState(),F=S.type==="target",$=(Q,K)=>{p(!1),f==null||f(Q,n,S.type,K)},W=Q=>u==null?void 0:u(n,Q),E=(Q,K)=>{p(!0),d==null||d(j,n,S.type),O==null||O(Q,K)};Xx.onPointerDown(j.nativeEvent,{autoPanOnConnect:C,connectionMode:R,connectionRadius:B,domNode:P,handleId:S.id,nodeId:S.nodeId,nodeLookup:L,isTarget:F,edgeUpdaterType:S.type,lib:A,flowId:M,cancelConnection:D,panBy:V,isValidConnection:(...Q)=>{var K,H;return((H=(K=y.getState()).isValidConnection)==null?void 0:H.call(K,...Q))??!0},onConnect:W,onConnectStart:E,onConnectEnd:(...Q)=>{var K,H;return(H=(K=y.getState()).onConnectEnd)==null?void 0:H.call(K,...Q)},onReconnectEnd:$,updateConnection:z,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},b=j=>v(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=j=>v(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>h(!0),x=()=>h(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(g1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(g1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function $5({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Vt(de=>de.edgeLookup.get(e));const j=Vt(de=>de.defaultEdgeOptions);x=j?{...j,...x}:x;let S=x.type||"default",C=(v==null?void 0:v[S])||p1[S];C===void 0&&(g==null||g("011",Oi.error011(S)),S="default",C=(v==null?void 0:v.default)||p1.default);const P=!!(x.focusable||t&&typeof x.focusable>"u"),R=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),B=!!(x.selectable||r&&typeof x.selectable>"u"),A=m.useRef(null),[O,D]=m.useState(!1),[L,M]=m.useState(!1),V=dn(),{zIndex:z,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:K}=Vt(m.useCallback(de=>{const pe=de.nodeLookup.get(x.source),Me=de.nodeLookup.get(x.target);if(!pe||!Me)return{zIndex:x.zIndex,...h1};const Ne=h4({id:e,sourceNode:pe,targetNode:Me,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:a4({selected:x.selected,zIndex:x.zIndex,sourceNode:pe,targetNode:Me,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ne||h1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),bn),H=m.useMemo(()=>x.markerStart?`url('#${Gx(x.markerStart,y)}')`:void 0,[x.markerStart,y]),ee=m.useMemo(()=>x.markerEnd?`url('#${Gx(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||$===null||W===null||E===null)return null;const ue=de=>{var Ce;const{addSelectedEdges:pe,unselectNodesAndEdges:Me,multiSelectionActive:Ne}=V.getState();B&&(V.setState({nodesSelectionActive:!1}),x.selected&&Ne?(Me({nodes:[],edges:[x]}),(Ce=A.current)==null||Ce.blur()):pe([e])),s&&s(de,x)},G=o?de=>{o(de,{...x})}:void 0,te=a?de=>{a(de,{...x})}:void 0,se=l?de=>{l(de,{...x})}:void 0,ie=c?de=>{c(de,{...x})}:void 0,Z=u?de=>{u(de,{...x})}:void 0,ce=de=>{var pe;if(!k&&SI.includes(de.key)&&B){const{unselectNodesAndEdges:Me,addSelectedEdges:Ne}=V.getState();de.key==="Escape"?((pe=A.current)==null||pe.blur(),Me({edges:[x]})):Ne([e])}};return i.jsx("svg",{style:{zIndex:z},children:i.jsxs("g",{className:Un(["react-flow__edge",`react-flow__edge-${S}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!B&&!s,updating:O,selectable:B}]),onClick:ue,onDoubleClick:G,onContextMenu:te,onMouseEnter:se,onMouseMove:ie,onMouseLeave:Z,onKeyDown:P?ce:void 0,tabIndex:P?0:void 0,role:x.ariaRole??(P?"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":P?`${oR}-${y}`:void 0,ref:A,...x.domAttributes,children:[!L&&i.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:B,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:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:K,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:H,markerEnd:ee,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),R&&i.jsx(M5,{edge:x,isReconnectable:R,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:K,setUpdateHover:D,setReconnecting:M})]})})}var L5=m.memo($5);const O5=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function PR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Vt(O5,bn),j=k5(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(C5,{defaultColor:e,rfId:n}),j.map(S=>i.jsx(L5,{id:S,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:p,onReconnectStart:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},S))]})}PR.displayName="EdgeRenderer";const D5=m.memo(PR),F5=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function z5({children:e}){const t=Vt(F5);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function B5(e){const t=Gc(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const H5=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function W5(e){const t=Vt(H5),n=dn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function V5(e){return e.connection.inProgress?{...e.connection,to:vf(e.connection.to,e.transform)}:{...e.connection}}function K5(e){return V5}function q5(e){const t=K5();return Vt(t,bn)}const U5=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Y5({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Vt(U5,bn);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:Un(["react-flow__connection",CI(l)]),children:i.jsx(IR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const IR=({style:e,type:t=Bo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:p,pointer:h}=q5();if(!s)return;if(n)return i.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:p,connectionStatus:CI(r),toNode:d,toHandle:f,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:p};switch(t){case Bo.Bezier:[y]=DI(v);break;case Bo.SimpleBezier:[y]=wR(v);break;case Bo.Step:[y]=Yx({...v,borderRadius:0});break;case Bo.SmoothStep:[y]=Yx(v);break;default:[y]=zI(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};IR.displayName="ConnectionLine";const G5={};function y1(e=G5){m.useRef(e),dn(),m.useEffect(()=>{},[e])}function J5(){dn(),m.useRef(!1),m.useEffect(()=>{},[])}function RR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:j,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:P,deleteKeyCode:R,onlyRenderVisibleElements:B,elementsSelectable:A,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:M,preventScrolling:V,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:$,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,zoomOnDoubleClick:K,panOnDrag:H,onPaneClick:ee,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:te,onPaneScroll:se,onPaneContextMenu:ie,paneClickDistance:Z,nodeClickDistance:ce,onEdgeContextMenu:de,onEdgeMouseEnter:pe,onEdgeMouseMove:Me,onEdgeMouseLeave:Ne,reconnectRadius:Ce,onReconnect:We,onReconnectStart:ct,onReconnectEnd:yt,noDragClassName:Re,noWheelClassName:ot,noPanClassName:kt,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze,viewport:re,onViewportChange:ke}){return y1(e),y1(t),J5(),B5(n),W5(re),i.jsx(d5,{onPaneClick:ee,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:te,onPaneContextMenu:ie,onPaneScroll:se,paneClickDistance:Z,deleteKeyCode:R,selectionKeyCode:k,selectionOnDrag:x,selectionMode:j,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:P,elementsSelectable:A,zoomOnScroll:F,zoomOnPinch:$,zoomOnDoubleClick:K,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,panOnDrag:H,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:M,onSelectionContextMenu:f,preventScrolling:V,noDragClassName:Re,noWheelClassName:ot,noPanClassName:kt,disableKeyboardA11y:$t,onViewportChange:ke,isControlledViewport:!!re,children:i.jsxs(z5,{children:[i.jsx(D5,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:We,onReconnectStart:ct,onReconnectEnd:yt,onlyRenderVisibleElements:B,onEdgeContextMenu:de,onEdgeMouseEnter:pe,onEdgeMouseMove:Me,onEdgeMouseLeave:Ne,reconnectRadius:Ce,defaultMarkerColor:z,noPanClassName:kt,disableKeyboardA11y:$t,rfId:ze}),i.jsx(Y5,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(b5,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ce,onlyRenderVisibleElements:B,noPanClassName:kt,noDragClassName:Re,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}RR.displayName="GraphView";const X5=m.memo(RR),w1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:p="basic"}={})=>{const h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=d??[0,0],j=f??qd;WI(v,b,g);const{nodesInitialized:S}=Jx(k,h,y,{nodeOrigin:x,nodeExtent:j,zIndexMode:p});let C=[0,0,1];if(a&&s&&o){const P=bf(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:R,y:B,zoom:A}=Vk(P,s,o,c,u,(l==null?void 0:l.padding)??.1);C=[R,B,A]}return{rfId:"1",width:s??0,height:o??0,transform:C,nodes:k,nodesInitialized:S,nodeLookup:h,parentLookup:y,edges:g,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:qd,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Lc.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:{...NI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:t4,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:jI,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Q5=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p})=>yW((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:j,height:S,minZoom:C,maxZoom:P}=y();g&&(await ZH({nodes:b,width:j,height:S,panZoom:g,minZoom:C,maxZoom:P},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...w1({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:j,fitViewQueued:S,zIndexMode:C,nodesSelectionActive:P}=y(),{nodesInitialized:R,hasSelectedNodes:B}=Jx(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:C}),A=P&&B;S&&R?(v(),h({nodes:b,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:A})):h({nodes:b,nodesInitialized:R,nodesSelectionActive:A})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();WI(g,k,b),h({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),h({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:j,nodeOrigin:S,nodeExtent:C,debug:P,fitViewQueued:R,zIndexMode:B}=y(),{changes:A,updatedInternals:O}=v4(b,k,x,j,S,C,B);O&&(w4(k,x,{nodeOrigin:S,nodeExtent:C,zIndexMode:B}),R?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(A==null?void 0:A.length)>0&&(P&&console.log("React Flow: trigger node changes",A),g==null||g(A)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:j,triggerNodeChanges:S,connection:C,updateConnection:P,onNodesChangeMiddlewareMap:R}=y();for(const[B,A]of b){const O=j.get(B),D=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(A!=null&&A.position)),L={id:B,type:"position",position:D?{x:Math.max(0,A.position.x),y:Math.max(0,A.position.y)}:A.position,dragging:g};if(O&&C.inProgress&&C.fromNode.id===O.id){const M=rl(O,C.fromHandle,Ue.Left,!0);P({...C,from:M})}D&&O.parentId&&k.push({id:B,parentId:O.parentId,rect:{...A.internals.positionAbsolute,width:A.measured.width??0,height:A.measured.height??0}}),x.push(L)}if(k.length>0){const{parentLookup:B,nodeOrigin:A}=y(),O=Jk(k,j,B,A);x.push(...O)}for(const B of R.values())x=B(x);S(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:j,debug:S}=y();if(b!=null&&b.length){if(j){const C=yd(b,x);k(C)}S&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:j,debug:S}=y();if(b!=null&&b.length){if(j){const C=lm(b,x);k(C)}S&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:S}=y();if(g){const C=b.map(P=>Ia(P,!0));j(C);return}j(cc(x,new Set([...b]),!0)),S(cc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:S}=y();if(g){const C=b.map(P=>Ia(P,!0));S(C);return}S(cc(k,new Set([...b]))),j(cc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:j,triggerNodeChanges:S,triggerEdgeChanges:C}=y(),P=b||x,R=g||k,B=[];for(const O of P){if(!O.selected)continue;const D=j.get(O.id);D&&(D.selected=!1),B.push(Ia(O.id,!1))}const A=[];for(const O of R)O.selected&&A.push(Ia(O.id,!1));S(B),C(A)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),h({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:j}=y();if(!j)return;const S=g.reduce((P,R)=>R.selected?[...P,Ia(R.id,!1)]:P,[]),C=b.reduce((P,R)=>R.selected?[...P,Ia(R.id,!1)]:P,[]);k(S),x(C)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:j,elevateNodesOnSelect:S,nodeExtent:C,zIndexMode:P}=y();b[0][0]===C[0][0]&&b[0][1]===C[0][1]&&b[1][0]===C[1][0]&&b[1][1]===C[1][1]||(Jx(g,k,x,{nodeOrigin:j,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:P}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:j,translateExtent:S}=y();return S4({delta:b,panZoom:j,transform:g,translateExtent:S,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:j,maxZoom:S,panZoom:C}=y();if(!C)return Promise.resolve(!1);const P=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:S;return await C.setViewport({x:x/2-b*P,y:j/2-g*P,zoom:P},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...NI}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...w1()})}},Object.is);function Qk({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:h}){const[y]=m.useState(()=>Q5({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:p}));return i.jsx(wW,{value:y,children:i.jsx(zW,{children:h})})}function Z5({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h}){return m.useContext(lg)?i.jsx(i.Fragment,{children:e}):i.jsx(Qk,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:e})}const e6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function t6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:P,onNodeDrag:R,onNodeDragStop:B,onNodesDelete:A,onEdgesDelete:O,onDelete:D,onSelectionChange:L,onSelectionDragStart:M,onSelectionDrag:V,onSelectionDragStop:z,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onBeforeDelete:E,connectionMode:Q,connectionLineType:K=Bo.Bezier,connectionLineStyle:H,connectionLineComponent:ee,connectionLineContainerStyle:ue,deleteKeyCode:G="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:se=!1,selectionMode:ie=Ud.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:ce=Gd()?"Meta":"Control",zoomActivationKeyCode:de=Gd()?"Meta":"Control",snapToGrid:pe,snapGrid:Me,onlyRenderVisibleElements:Ne=!1,selectNodesOnDrag:Ce,nodesDraggable:We,autoPanOnNodeFocus:ct,nodesConnectable:yt,nodesFocusable:Re,nodeOrigin:ot=aR,edgesFocusable:kt,edgesReconnectable:$t,elementsSelectable:ye=!0,defaultViewport:ze=IW,minZoom:re=.5,maxZoom:ke=2,translateExtent:Be=qd,preventScrolling:Qe=!0,nodeExtent:_e,defaultMarkerColor:_t="#b1b1b7",zoomOnScroll:Xt=!0,zoomOnPinch:Ft=!0,panOnScroll:at=!1,panOnScrollSpeed:Fn=.5,panOnScrollMode:ne=qa.Free,zoomOnDoubleClick:Pe=!0,panOnDrag:et=!0,onPaneClick:qe,onPaneMouseEnter:It,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Yn,onPaneContextMenu:Tr,paneClickDistance:kn=1,nodeClickDistance:nr=0,children:pr,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:ss,onEdgeDoubleClick:Ds,onEdgeMouseEnter:vn,onEdgeMouseMove:Gn,onEdgeMouseLeave:bs,reconnectRadius:Jn=10,onNodesChange:Bn,onEdgesChange:vr,noDragClassName:Sr="nodrag",noWheelClassName:Hn="nowheel",noPanClassName:Mr="nopan",fitView:$r,fitViewOptions:le,connectOnClick:me,attributionPosition:tt,proOptions:rt,defaultEdgeOptions:zt,elevateNodesOnSelect:Rn=!0,elevateEdgesOnSelect:jr=!1,disableKeyboardA11y:Nr=!1,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,connectionRadius:Yt,isValidConnection:Xn,onError:it,style:gr,id:Fs,nodeDragThreshold:Bi,connectionDragThreshold:zs,viewport:oe,onViewportChange:ve,width:Te,height:bt,colorMode:Rt="light",debug:Qt,onScroll:pn,ariaLabelConfig:$n,zIndexMode:ks="basic",...vs},q){const we=Fs||"1",$e=$W(Rt),Ee=m.useCallback(Ze=>{Ze.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),pn==null||pn(Ze)},[pn]);return i.jsx("div",{"data-testid":"rf__wrapper",...vs,onScroll:Ee,style:{...gr,...e6},ref:q,className:Un(["react-flow",s,$e]),id:Fs,role:"application",children:i.jsxs(Z5,{nodes:e,edges:t,width:Te,height:bt,fitView:$r,fitViewOptions:le,minZoom:re,maxZoom:ke,nodeOrigin:ot,nodeExtent:_e,zIndexMode:ks,children:[i.jsx(MW,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:We,autoPanOnNodeFocus:ct,nodesConnectable:yt,nodesFocusable:Re,edgesFocusable:kt,edgesReconnectable:$t,elementsSelectable:ye,elevateNodesOnSelect:Rn,elevateEdgesOnSelect:jr,minZoom:re,maxZoom:ke,nodeExtent:_e,onNodesChange:Bn,onEdgesChange:vr,snapToGrid:pe,snapGrid:Me,connectionMode:Q,translateExtent:Be,connectOnClick:me,defaultEdgeOptions:zt,fitView:$r,fitViewOptions:le,onNodesDelete:A,onEdgesDelete:O,onDelete:D,onNodeDragStart:P,onNodeDrag:R,onNodeDragStop:B,onSelectionDrag:V,onSelectionDragStart:M,onSelectionDragStop:z,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Mr,nodeOrigin:ot,rfId:we,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,onError:it,connectionRadius:Yt,isValidConnection:Xn,selectNodesOnDrag:Ce,nodeDragThreshold:Bi,connectionDragThreshold:zs,onBeforeDelete:E,debug:Qt,ariaLabelConfig:$n,zIndexMode:ks}),i.jsx(X5,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:a,connectionLineType:K,connectionLineStyle:H,connectionLineComponent:ee,connectionLineContainerStyle:ue,selectionKeyCode:te,selectionOnDrag:se,selectionMode:ie,deleteKeyCode:G,multiSelectionKeyCode:ce,panActivationKeyCode:Z,zoomActivationKeyCode:de,onlyRenderVisibleElements:Ne,defaultViewport:ze,translateExtent:Be,minZoom:re,maxZoom:ke,preventScrolling:Qe,zoomOnScroll:Xt,zoomOnPinch:Ft,zoomOnDoubleClick:Pe,panOnScroll:at,panOnScrollSpeed:Fn,panOnScrollMode:ne,panOnDrag:et,onPaneClick:qe,onPaneMouseEnter:It,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Yn,onPaneContextMenu:Tr,paneClickDistance:kn,nodeClickDistance:nr,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:ss,onEdgeDoubleClick:Ds,onEdgeMouseEnter:vn,onEdgeMouseMove:Gn,onEdgeMouseLeave:bs,reconnectRadius:Jn,defaultMarkerColor:_t,noDragClassName:Sr,noWheelClassName:Hn,noPanClassName:Mr,rfId:we,disableKeyboardA11y:Nr,nodeExtent:_e,viewport:oe,onViewportChange:ve}),i.jsx(PW,{onSelectionChange:L}),pr,i.jsx(NW,{proOptions:rt,position:tt}),i.jsx(jW,{rfId:we,disableKeyboardA11y:Nr})]})})}var TR=cR(t6);function n6(){const e=dn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],o=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function r6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>yd(s,o)),[]);return[t,n,r]}function s6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>lm(s,o)),[]);return[t,n,r]}function i6({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:Un(["react-flow__background-pattern",n,r])})}function o6({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Un(["react-flow__background-pattern","dots",t])})}var ta;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ta||(ta={}));const a6={[ta.Dots]:1,[ta.Lines]:1,[ta.Cross]:6},l6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function MR({id:e,variant:t=ta.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:p,patternId:h}=Vt(l6,bn),y=r||a6[t],v=t===ta.Dots,b=t===ta.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],j=Array.isArray(o)?o:[o,o],S=b?[x,x]:k,C=[j[0]*p[2]||1+S[0]/2,j[1]*p[2]||1+S[1]/2],P=`${h}${e||""}`;return i.jsxs("svg",{className:Un(["react-flow__background",u]),style:{...c,...ug,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:P,x:p[0]%k[0],y:p[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:v?i.jsx(o6,{radius:x/2,className:d}):i.jsx(i6,{dimensions:S,lineWidth:s,variant:t,className:d})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}MR.displayName="Background";const $R=m.memo(MR);function c6(){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 u6(){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 d6(){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 f6(){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 p6(){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 Lp({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Un(["react-flow__controls-button",t]),...n,children:e})}const h6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function LR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:p="vertical","aria-label":h}){const y=dn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Vt(h6,bn),{zoomIn:x,zoomOut:j,fitView:S}=Gc(),C=()=>{x(),o==null||o()},P=()=>{j(),a==null||a()},R=()=>{S(s),l==null||l()},B=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},A=p==="horizontal"?"horizontal":"vertical";return i.jsxs(cg,{className:Un(["react-flow__controls",A,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Lp,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(c6,{})}),i.jsx(Lp,{onClick:P,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(u6,{})})]}),n&&i.jsx(Lp,{className:"react-flow__controls-fitview",onClick:R,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(d6,{})}),r&&i.jsx(Lp,{className:"react-flow__controls-interactive",onClick:B,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(p6,{}):i.jsx(f6,{})}),d]})}LR.displayName="Controls";m.memo(LR);function m6({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:p,onClick:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:Un(["react-flow__minimap-node",{selected:p},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?g=>h(g,e):void 0})}const g6=m.memo(m6),y6=e=>e.nodes.map(t=>t.id),ew=e=>e instanceof Function?e:()=>e;function w6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=g6,onClick:a}){const l=Vt(y6,bn),c=ew(t),u=ew(e),d=ew(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(p=>i.jsx(b6,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},p))})}function x6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:f,width:p,height:h}=Vt(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const b=v.internals.userNode,{x:g,y:k}=v.internals.positionAbsolute,{width:x,height:j}=xo(b);return{node:b,x:g,y:k,width:x,height:j}},bn);return!u||u.hidden||!RI(u)?null:i.jsx(l,{x:d,y:f,width:p,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const b6=m.memo(x6);var k6=m.memo(w6);const v6=200,S6=150,j6=e=>!e.hidden,N6=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?II(bf(e.nodeLookup,{filter:j6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},C6="react-flow__minimap-desc";function OR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:p="bottom-right",onClick:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:j=5}){const S=dn(),C=m.useRef(null),{boundingRect:P,viewBB:R,rfId:B,panZoom:A,translateExtent:O,flowWidth:D,flowHeight:L,ariaLabelConfig:M}=Vt(N6,bn),V=(e==null?void 0:e.width)??v6,z=(e==null?void 0:e.height)??S6,F=P.width/V,$=P.height/z,W=Math.max(F,$),E=W*V,Q=W*z,K=j*W,H=P.x-(E-P.width)/2-K,ee=P.y-(Q-P.height)/2-K,ue=E+K*2,G=Q+K*2,te=`${C6}-${B}`,se=m.useRef(0),ie=m.useRef();se.current=W,m.useEffect(()=>{if(C.current&&A)return ie.current=R4({domNode:C.current,panZoom:A,getTransform:()=>S.getState().transform,getViewScale:()=>se.current}),()=>{var pe;(pe=ie.current)==null||pe.destroy()}},[A]),m.useEffect(()=>{var pe;(pe=ie.current)==null||pe.update({translateExtent:O,width:D,height:L,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,O,D,L]);const Z=h?pe=>{var Ce;const[Me,Ne]=((Ce=ie.current)==null?void 0:Ce.pointer(pe))||[0,0];h(pe,{x:Me,y:Ne})}:void 0,ce=y?m.useCallback((pe,Me)=>{const Ne=S.getState().nodeLookup.get(Me).internals.userNode;y(pe,Ne)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(cg,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*W: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:Un(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:V,height:z,viewBox:`${H} ${ee} ${ue} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:C,onClick:Z,children:[de&&i.jsx("title",{id:te,children:de}),i.jsx(k6,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${H-K},${ee-K}h${ue+K*2}v${G+K*2}h${-ue-K*2}z
66
- M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}OR.displayName="MiniMap";m.memo(OR);const _6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E6={[zc.Line]:"right",[zc.Handle]:"bottom-right"};function A6({nodeId:e,position:t,variant:n=zc.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=pR(),x=typeof e=="string"?e:k,j=dn(),S=m.useRef(null),C=n===zc.Handle,P=Vt(m.useCallback(_6(C&&h),[C,h]),bn),R=m.useRef(null),B=t??E6[n];m.useEffect(()=>{if(!(!S.current||!x))return R.current||(R.current=q4({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V,domNode:z}=j.getState();return{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V,paneDomNode:z}},onChange:(O,D)=>{const{triggerNodeChanges:L,nodeLookup:M,parentLookup:V,nodeOrigin:z}=j.getState(),F=[],$={x:O.x,y:O.y},W=M.get(x);if(W&&W.expandParent&&W.parentId){const E=W.origin??z,Q=O.width??W.measured.width??0,K=O.height??W.measured.height??0,H={id:W.id,parentId:W.parentId,rect:{width:Q,height:K,...TI({x:O.x??W.position.x,y:O.y??W.position.y},{width:Q,height:K},W.parentId,M,E)}},ee=Jk([H],M,V,z);F.push(...ee),$.x=O.x?Math.max(E[0]*Q,O.x):void 0,$.y=O.y?Math.max(E[1]*K,O.y):void 0}if($.x!==void 0&&$.y!==void 0){const E={id:x,type:"position",position:{...$}};F.push(E)}if(O.width!==void 0&&O.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};F.push(Q)}for(const E of D){const Q={...E,type:"position"};F.push(Q)}L(F)},onEnd:({width:O,height:D})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:O,height:D}};j.getState().triggerNodeChanges([L])}})),R.current.update({controlPosition:B,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var O;(O=R.current)==null||O.destroy()}},[B,l,c,u,d,f,v,b,g,y]);const A=B.split("-");return i.jsx("div",{className:Un(["react-flow__resize-control","nodrag",...A,n,r]),ref:S,style:{...s,scale:P,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:o})}const Zk=m.memo(A6),P6="modulepreload",I6=function(e){return"/"+e},x1={},R6=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=I6(c),c in x1)return;x1[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":P6,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(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)})};function T6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const M6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L6={};function b1(e,t){return(L6.jsx?$6:M6).test(e)}const O6=/[ \t\n\f\r]/g;function D6(e){return typeof e=="object"?e.type==="text"?k1(e.value):!1:k1(e)}function k1(e){return e.replace(O6,"")===""}class Sf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Sf.prototype.normal={};Sf.prototype.property={};Sf.prototype.space=void 0;function DR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Sf(n,r,t)}function eb(e){return e.toLowerCase()}class rs{constructor(t,n){this.attribute=n,this.property=t}}rs.prototype.attribute="";rs.prototype.booleanish=!1;rs.prototype.boolean=!1;rs.prototype.commaOrSpaceSeparated=!1;rs.prototype.commaSeparated=!1;rs.prototype.defined=!1;rs.prototype.mustUseProperty=!1;rs.prototype.number=!1;rs.prototype.overloadedBoolean=!1;rs.prototype.property="";rs.prototype.spaceSeparated=!1;rs.prototype.space=void 0;let F6=0;const jt=pl(),Vn=pl(),tb=pl(),Ie=pl(),ln=pl(),kc=pl(),as=pl();function pl(){return 2**++F6}const nb=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:Vn,commaOrSpaceSeparated:as,commaSeparated:kc,number:Ie,overloadedBoolean:tb,spaceSeparated:ln},Symbol.toStringTag,{value:"Module"})),tw=Object.keys(nb);class ev extends rs{constructor(t,n,r,s){let o=-1;if(super(t,n),v1(this,"space",s),typeof r=="number")for(;++o<tw.length;){const a=tw[o];v1(this,tw[o],(r&nb[a])===nb[a])}}}ev.prototype.defined=!0;function v1(e,t,n){n&&(e[t]=n)}function Jc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new ev(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[eb(r)]=r,n[eb(o.attribute)]=r}return new Sf(t,n,e.space)}const FR=Jc({properties:{ariaActiveDescendant:null,ariaAtomic:Vn,ariaAutoComplete:null,ariaBusy:Vn,ariaChecked:Vn,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:ln,ariaCurrent:null,ariaDescribedBy:ln,ariaDetails:null,ariaDisabled:Vn,ariaDropEffect:ln,ariaErrorMessage:null,ariaExpanded:Vn,ariaFlowTo:ln,ariaGrabbed:Vn,ariaHasPopup:null,ariaHidden:Vn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ln,ariaLevel:Ie,ariaLive:null,ariaModal:Vn,ariaMultiLine:Vn,ariaMultiSelectable:Vn,ariaOrientation:null,ariaOwns:ln,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Vn,ariaReadOnly:Vn,ariaRelevant:null,ariaRequired:Vn,ariaRoleDescription:ln,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Vn,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function zR(e,t){return t in e?e[t]:t}function BR(e,t){return zR(e,t.toLowerCase())}const z6=Jc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:kc,acceptCharset:ln,accessKey:ln,action:null,allow:null,allowFullScreen:jt,allowPaymentRequest:jt,allowUserMedia:jt,alt:null,as:null,async:jt,autoCapitalize:null,autoComplete:ln,autoFocus:jt,autoPlay:jt,blocking:ln,capture:null,charSet:null,checked:jt,cite:null,className:ln,cols:Ie,colSpan:null,content:null,contentEditable:Vn,controls:jt,controlsList:ln,coords:Ie|kc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:tb,draggable:Vn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:jt,formTarget:null,headers:ln,height:Ie,hidden:tb,high:Ie,href:null,hrefLang:null,htmlFor:ln,httpEquiv:ln,id:null,imageSizes:null,imageSrcSet:null,inert:jt,inputMode:null,integrity:null,is:null,isMap:jt,itemId:null,itemProp:ln,itemRef:ln,itemScope:jt,itemType:ln,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:jt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:jt,muted:jt,name:null,nonce:null,noModule:jt,noValidate:jt,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:jt,optimum:Ie,pattern:null,ping:ln,placeholder:null,playsInline:jt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:jt,referrerPolicy:null,rel:ln,required:jt,reversed:jt,rows:Ie,rowSpan:Ie,sandbox:ln,scope:null,scoped:jt,seamless:jt,selected:jt,shadowRootClonable:jt,shadowRootDelegatesFocus:jt,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Vn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:jt,useMap:null,value:Vn,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ln,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:jt,declare:jt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:jt,noHref:jt,noShade:jt,noWrap:jt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Vn,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:jt,disableRemotePlayback:jt,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:BR}),B6=Jc({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:as,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:ln,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:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:jt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,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:kc,g2:kc,glyphName:kc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:as,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,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:Ie,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:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ln,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:as,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:as,rev:as,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:as,requiredFeatures:as,requiredFonts:as,requiredFormats:as,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:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:as,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:as,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:as,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zR}),HR=Jc({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()}}),WR=Jc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:BR}),VR=Jc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),H6={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"},W6=/[A-Z]/g,S1=/-[a-z]/g,V6=/^data[-\w.:]+$/i;function K6(e,t){const n=eb(t);let r=t,s=rs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&V6.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(S1,U6);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!S1.test(o)){let a=o.replace(W6,q6);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=ev}return new s(r,t)}function q6(e){return"-"+e.toLowerCase()}function U6(e){return e.charAt(1).toUpperCase()}const Y6=DR([FR,z6,HR,WR,VR],"html"),tv=DR([FR,B6,HR,WR,VR],"svg");function G6(e){return e.join(" ").trim()}var nv={},j1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,J6=/\n/g,X6=/^\s*/,Q6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Z6=/^:\s*/,e8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,t8=/^[;\s]*/,n8=/^\s+|\s+$/g,r8=`
67
- `,N1="/",C1="*",Ta="",s8="comment",i8="declaration";function o8(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(y){var v=y.match(J6);v&&(n+=v.length);var b=y.lastIndexOf(r8);r=~b?y.length-b:r+y.length}function o(){var y={line:n,column:r};return function(v){return v.position=new a(y),u(),v}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var v=new Error(t.source+":"+n+":"+r+": "+y);if(v.reason=y,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function c(y){var v=y.exec(e);if(v){var b=v[0];return s(b),e=e.slice(b.length),v}}function u(){c(X6)}function d(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(N1!=e.charAt(0)||C1!=e.charAt(1))){for(var v=2;Ta!=e.charAt(v)&&(C1!=e.charAt(v)||N1!=e.charAt(v+1));)++v;if(v+=2,Ta===e.charAt(v-1))return l("End of comment missing");var b=e.slice(2,v-2);return r+=2,s(b),e=e.slice(v),r+=2,y({type:s8,comment:b})}}function p(){var y=o(),v=c(Q6);if(v){if(f(),!c(Z6))return l("property missing ':'");var b=c(e8),g=y({type:i8,property:_1(v[0].replace(j1,Ta)),value:b?_1(b[0].replace(j1,Ta)):Ta});return c(t8),g}}function h(){var y=[];d(y);for(var v;v=p();)v!==!1&&(y.push(v),d(y));return y}return u(),h()}function _1(e){return e?e.replace(n8,Ta):Ta}var a8=o8,l8=jd&&jd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(nv,"__esModule",{value:!0});nv.default=u8;const c8=l8(a8);function u8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,c8.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 fg={};Object.defineProperty(fg,"__esModule",{value:!0});fg.camelCase=void 0;var d8=/^--[a-zA-Z0-9_-]+$/,f8=/-([a-z])/g,p8=/^[^-]+$/,h8=/^-(webkit|moz|ms|o|khtml)-/,m8=/^-(ms)-/,g8=function(e){return!e||p8.test(e)||d8.test(e)},y8=function(e,t){return t.toUpperCase()},E1=function(e,t){return"".concat(t,"-")},w8=function(e,t){return t===void 0&&(t={}),g8(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(m8,E1):e=e.replace(h8,E1),e.replace(f8,y8))};fg.camelCase=w8;var x8=jd&&jd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},b8=x8(nv),k8=fg;function rb(e,t){var n={};return!e||typeof e!="string"||(0,b8.default)(e,function(r,s){r&&s&&(n[(0,k8.camelCase)(r,t)]=s)}),n}rb.default=rb;var v8=rb;const S8=da(v8),KR=qR("end"),rv=qR("start");function qR(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 j8(e){const t=rv(e),n=KR(e);if(t&&n)return{start:t,end:n}}function wd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A1(e.position):"start"in e||"end"in e?A1(e):"line"in e||"column"in e?sb(e):""}function sb(e){return P1(e&&e.line)+":"+P1(e&&e.column)}function A1(e){return sb(e&&e.start)+"-"+sb(e&&e.end)}function P1(e){return e&&typeof e=="number"?e:1}class Rr 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=wd(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}}Rr.prototype.file="";Rr.prototype.name="";Rr.prototype.reason="";Rr.prototype.message="";Rr.prototype.stack="";Rr.prototype.column=void 0;Rr.prototype.line=void 0;Rr.prototype.ancestors=void 0;Rr.prototype.cause=void 0;Rr.prototype.fatal=void 0;Rr.prototype.place=void 0;Rr.prototype.ruleId=void 0;Rr.prototype.source=void 0;const sv={}.hasOwnProperty,N8=new Map,C8=/[A-Z]/g,_8=new Set(["table","tbody","thead","tfoot","tr"]),E8=new Set(["td","th"]),UR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function A8(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=O8(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=L8(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"?tv:Y6,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=YR(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function YR(e,t,n){if(t.type==="element")return P8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return I8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return T8(e,t,n);if(t.type==="mdxjsEsm")return R8(e,t);if(t.type==="root")return M8(e,t,n);if(t.type==="text")return $8(e,t)}function P8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=tv,e.schema=s),e.ancestors.push(t);const o=JR(e,t.tagName,!1),a=D8(e,t);let l=ov(e,t);return _8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!D6(c):!0})),GR(e,a,o,t),iv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function I8(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Xd(e,t.position)}function R8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xd(e,t.position)}function T8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=tv,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:JR(e,t.name,!0),a=F8(e,t),l=ov(e,t);return GR(e,a,o,t),iv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function M8(e,t,n){const r={};return iv(r,ov(e,t)),e.create(t,e.Fragment,r,n)}function $8(e,t){return t.value}function GR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function iv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function L8(e,t,n){return r;function r(s,o,a,l){const u=Array.isArray(a.children)?n:t;return l?u(o,a,l):u(o,a)}}function O8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=rv(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 D8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&sv.call(t.properties,s)){const o=z8(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&E8.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 F8(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 Xd(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 Xd(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function ov(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:N8;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 u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const l=YR(e,o,a);l!==void 0&&n.push(l)}return n}function z8(e,t,n){const r=K6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?T6(n):G6(n)),r.property==="style"){let s=typeof n=="object"?n:B8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=H8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?H6[r.property]||r.property:r.attribute,n]}}function B8(e,t){try{return S8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Rr("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=UR+"#cannot-parse-style-attribute",s}}function JR(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=b1(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=b1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return sv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Xd(e)}function Xd(e,t){const n=new Rr("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=UR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function H8(e){const t={};let n;for(n in e)sv.call(e,n)&&(t[W8(n)]=e[n]);return t}function W8(e){let t=e.replace(C8,V8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function V8(e){return"-"+e.toLowerCase()}const nw={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"]},K8={};function q8(e,t){const n=K8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return XR(e,r,s)}function XR(e,t,n){if(U8(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 I1(e.children,t,n)}return Array.isArray(e)?I1(e,t,n):""}function I1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=XR(e[s],t,n);return r.join("")}function U8(e){return!!(e&&typeof e=="object")}const R1=document.createElement("i");function av(e){const t="&"+e+";";R1.innerHTML=t;const n=R1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Di(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 Rs(e,t){return e.length>0?(Di(e,e.length,0,t),e):t}const T1={}.hasOwnProperty;function Y8(e){const t={};let n=-1;for(;++n<e.length;)G8(t,e[n]);return t}function G8(e,t){let n;for(n in t){const s=(T1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){T1.call(s,a)||(s[a]=[]);const l=o[a];J8(s[a],Array.isArray(l)?l:l?[l]:[])}}}function J8(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Di(e,0,0,r)}function QR(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 vc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const _i=ma(/[A-Za-z]/),fs=ma(/[\dA-Za-z]/),X8=ma(/[#-'*+\--9=?A-Z^-~]/);function ib(e){return e!==null&&(e<32||e===127)}const ob=ma(/\d/),Q8=ma(/[\dA-Fa-f]/),Z8=ma(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function ns(e){return e!==null&&(e<0||e===32)}function Jt(e){return e===-2||e===-1||e===32}const e9=ma(new RegExp("\\p{P}|\\p{S}","u")),t9=ma(/\s/);function ma(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Xc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&fs(e.charCodeAt(n+1))&&fs(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 un(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return Jt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Jt(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const n9={tokenize:r9};function r9(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"),un(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 wt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const s9={tokenize:i9},M1={tokenize:o9};function i9(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,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const j=t.events.length;let S=j,C;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){C=t.events[S][1].end;break}g(r);let P=j;for(;P<t.events.length;)t.events[P][1].end={...C},P++;return Di(t.events,S+1,0,t.events.slice(j)),t.events.length=P,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(M1,d,f)(x)}function d(x){return s&&k(),g(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function p(x){return t.containerState={},e.attempt(M1,h,y)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function y(x){if(x===null){s&&k(),g(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),v(x)}function v(x){if(x===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return wt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,j){const S=t.sliceStream(x);if(j&&S.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(S),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const P=t.events.length;let R=P,B,A;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(B){A=t.events[R][1].end;break}B=!0}for(g(r),C=P;C<t.events.length;)t.events[C][1].end={...A},C++;Di(t.events,R+1,0,t.events.slice(P)),t.events.length=C}}function g(x){let j=n.length;for(;j-- >x;){const S=n[j];t.containerState=S[1],S[0].exit.call(t,e)}n.length=x}function k(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function o9(e,t,n){return un(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function $1(e){if(e===null||ns(e)||t9(e))return 1;if(e9(e))return 2}function lv(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 ab={name:"attention",resolveAll:a9,tokenize:l9};function a9(e,t){let n=-1,r,s,o,a,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};L1(f,-c),L1(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},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},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Rs(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Rs(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Rs(u,lv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Rs(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Rs(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Di(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function l9(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=$1(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 u=e.exit("attentionSequence"),d=$1(c),f=!d||d===2&&s||n.includes(c),p=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?f:f&&(s||!p)),u._close=!!(o===42?p:p&&(d||!f)),t(c)}}function L1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const c9={name:"autolink",tokenize:u9};function u9(e,t,n){let r=0;return s;function s(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return _i(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||fs(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||fs(h))&&r++<32?(e.consume(h),l):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||ib(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):X8(h)?(e.consume(h),u):n(h)}function d(h){return fs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||fs(h))&&r++<63){const y=h===45?p:f;return e.consume(h),y}return n(h)}}const pg={partial:!0,tokenize:d9};function d9(e,t,n){return r;function r(o){return Jt(o)?un(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||wt(o)?t(o):n(o)}}const ZR={continuation:{tokenize:p9},exit:h9,name:"blockQuote",tokenize:f9};function f9(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 Jt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function p9(e,t,n){const r=this;return s;function s(a){return Jt(a)?un(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(ZR,t,n)(a)}}function h9(e){e.exit("blockQuote")}const eT={name:"characterEscape",tokenize:m9};function m9(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 Z8(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const tT={name:"characterReference",tokenize:g9};function g9(e,t,n){const r=this;let s=0,o,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=fs,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=Q8,d):(e.enter("characterReferenceValue"),o=7,a=ob,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===fs&&!av(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<o?(e.consume(f),d):n(f)}}const O1={partial:!0,tokenize:w9},D1={concrete:!0,name:"codeFenced",tokenize:y9};function y9(e,t,n){const r=this,s={partial:!0,tokenize:S};let o=0,a=0,l;return c;function c(C){return u(C)}function u(C){const P=r.events[r.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(C)}function d(C){return C===l?(a++,e.consume(C),d):a<3?n(C):(e.exit("codeFencedFenceSequence"),Jt(C)?un(e,f,"whitespace")(C):f(C))}function f(C){return C===null||wt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(O1,v,j)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(C)):Jt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),un(e,h,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function h(C){return C===null||wt(C)?f(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(C)):C===96&&C===l?n(C):(e.consume(C),y)}function v(C){return e.attempt(s,j,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return o>0&&Jt(C)?un(e,k,"linePrefix",o+1)(C):k(C)}function k(C){return C===null||wt(C)?e.check(O1,v,j)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||wt(C)?(e.exit("codeFlowValue"),k(C)):(e.consume(C),x)}function j(C){return e.exit("codeFenced"),t(C)}function S(C,P,R){let B=0;return A;function A(V){return C.enter("lineEnding"),C.consume(V),C.exit("lineEnding"),O}function O(V){return C.enter("codeFencedFence"),Jt(V)?un(C,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):D(V)}function D(V){return V===l?(C.enter("codeFencedFenceSequence"),L(V)):R(V)}function L(V){return V===l?(B++,C.consume(V),L):B>=a?(C.exit("codeFencedFenceSequence"),Jt(V)?un(C,M,"whitespace")(V):M(V)):R(V)}function M(V){return V===null||wt(V)?(C.exit("codeFencedFence"),P(V)):R(V)}}}function w9(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 rw={name:"codeIndented",tokenize:b9},x9={partial:!0,tokenize:k9};function b9(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),un(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):wt(u)?e.attempt(x9,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||wt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function k9(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):un(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):wt(a)?s(a):n(a)}}const v9={name:"codeText",previous:j9,resolve:S9,tokenize:N9};function S9(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 j9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function N9(e,t,n){let r=0,s,o;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),s=0,d(f)):wt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||wt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class C9{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&&Du(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),Du(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Du(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Du(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Du(this.left,n.reverse())}}}function Du(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function nT(e){const t={};let n=-1,r,s,o,a,l,c,u;const d=new C9(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.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,_9(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=d.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(d.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={...d.get(s)[1].start},l=d.slice(s,n),l.unshift(r),d.splice(s,n-s+1,l))}}return Di(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function _9(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=[],u={};let d,f,p=-1,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(v=p+1,b.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),p=b.length;p--;){const g=l.slice(b[p],b[p+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),p=-1;++p<c.length;)u[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return u}const E9={resolve:P9,tokenize:I9},A9={partial:!0,tokenize:R9};function P9(e){return nT(e),e}function I9(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):wt(l)?e.check(A9,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 R9(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),un(e,o,"linePrefix")}function o(a){if(a===null||wt(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 rT(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(g){return g===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(g),e.exit(o),p):g===null||g===32||g===41||ib(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function p(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:h)}function y(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function v(g){return!d&&(g===null||g===41||ns(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,v):g===41?(e.consume(g),d--,v):g===null||g===32||g===40||ib(g)?n(g):(e.consume(g),g===92?b:v)}function b(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function sT(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(o),d}function d(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):wt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||wt(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!Jt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function iT(e,t,n,r,s,o){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(o),u(p))}function u(p){return p===a?(e.exit(o),c(a)):p===null?n(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),un(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||wt(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:d)}function f(p){return p===a||p===92?(e.consume(p),d):d(p)}}function xd(e,t){let n;return r;function r(s){return wt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Jt(s)?un(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const T9={name:"definition",tokenize:$9},M9={partial:!0,tokenize:L9};function $9(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return sT.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=vc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return ns(h)?xd(e,u)(h):u(h)}function u(h){return rT(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(M9,f,f)(h)}function f(h){return Jt(h)?un(e,p,"whitespace")(h):p(h)}function p(h){return h===null||wt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function L9(e,t,n){return r;function r(l){return ns(l)?xd(e,s)(l):n(l)}function s(l){return iT(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return Jt(l)?un(e,a,"whitespace")(l):a(l)}function a(l){return l===null||wt(l)?t(l):n(l)}}const O9={name:"hardBreakEscape",tokenize:D9};function D9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return wt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const F9={name:"headingAtx",resolve:z9,tokenize:B9};function z9(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"},Di(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function B9(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||ns(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||wt(d)?(e.exit("atxHeading"),t(d)):Jt(d)?un(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||ns(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const H9=["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"],F1=["pre","script","style","textarea"],W9={concrete:!0,name:"htmlFlow",resolveTo:q9,tokenize:U9},V9={partial:!0,tokenize:G9},K9={partial:!0,tokenize:Y9};function q9(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 U9(e,t,n){const r=this;let s,o,a,l,c;return u;function u(H){return d(H)}function d(H){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(H),f}function f(H){return H===33?(e.consume(H),p):H===47?(e.consume(H),o=!0,v):H===63?(e.consume(H),s=3,r.interrupt?t:E):_i(H)?(e.consume(H),a=String.fromCharCode(H),b):n(H)}function p(H){return H===45?(e.consume(H),s=2,h):H===91?(e.consume(H),s=5,l=0,y):_i(H)?(e.consume(H),s=4,r.interrupt?t:E):n(H)}function h(H){return H===45?(e.consume(H),r.interrupt?t:E):n(H)}function y(H){const ee="CDATA[";return H===ee.charCodeAt(l++)?(e.consume(H),l===ee.length?r.interrupt?t:D:y):n(H)}function v(H){return _i(H)?(e.consume(H),a=String.fromCharCode(H),b):n(H)}function b(H){if(H===null||H===47||H===62||ns(H)){const ee=H===47,ue=a.toLowerCase();return!ee&&!o&&F1.includes(ue)?(s=1,r.interrupt?t(H):D(H)):H9.includes(a.toLowerCase())?(s=6,ee?(e.consume(H),g):r.interrupt?t(H):D(H)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(H):o?k(H):x(H))}return H===45||fs(H)?(e.consume(H),a+=String.fromCharCode(H),b):n(H)}function g(H){return H===62?(e.consume(H),r.interrupt?t:D):n(H)}function k(H){return Jt(H)?(e.consume(H),k):A(H)}function x(H){return H===47?(e.consume(H),A):H===58||H===95||_i(H)?(e.consume(H),j):Jt(H)?(e.consume(H),x):A(H)}function j(H){return H===45||H===46||H===58||H===95||fs(H)?(e.consume(H),j):S(H)}function S(H){return H===61?(e.consume(H),C):Jt(H)?(e.consume(H),S):x(H)}function C(H){return H===null||H===60||H===61||H===62||H===96?n(H):H===34||H===39?(e.consume(H),c=H,P):Jt(H)?(e.consume(H),C):R(H)}function P(H){return H===c?(e.consume(H),c=null,B):H===null||wt(H)?n(H):(e.consume(H),P)}function R(H){return H===null||H===34||H===39||H===47||H===60||H===61||H===62||H===96||ns(H)?S(H):(e.consume(H),R)}function B(H){return H===47||H===62||Jt(H)?x(H):n(H)}function A(H){return H===62?(e.consume(H),O):n(H)}function O(H){return H===null||wt(H)?D(H):Jt(H)?(e.consume(H),O):n(H)}function D(H){return H===45&&s===2?(e.consume(H),z):H===60&&s===1?(e.consume(H),F):H===62&&s===4?(e.consume(H),Q):H===63&&s===3?(e.consume(H),E):H===93&&s===5?(e.consume(H),W):wt(H)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(V9,K,L)(H)):H===null||wt(H)?(e.exit("htmlFlowData"),L(H)):(e.consume(H),D)}function L(H){return e.check(K9,M,K)(H)}function M(H){return e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),V}function V(H){return H===null||wt(H)?L(H):(e.enter("htmlFlowData"),D(H))}function z(H){return H===45?(e.consume(H),E):D(H)}function F(H){return H===47?(e.consume(H),a="",$):D(H)}function $(H){if(H===62){const ee=a.toLowerCase();return F1.includes(ee)?(e.consume(H),Q):D(H)}return _i(H)&&a.length<8?(e.consume(H),a+=String.fromCharCode(H),$):D(H)}function W(H){return H===93?(e.consume(H),E):D(H)}function E(H){return H===62?(e.consume(H),Q):H===45&&s===2?(e.consume(H),E):D(H)}function Q(H){return H===null||wt(H)?(e.exit("htmlFlowData"),K(H)):(e.consume(H),Q)}function K(H){return e.exit("htmlFlow"),t(H)}}function Y9(e,t,n){const r=this;return s;function s(a){return wt(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 G9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(pg,t,n)}}const J9={name:"htmlText",tokenize:X9};function X9(e,t,n){const r=this;let s,o,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),u):E===47?(e.consume(E),S):E===63?(e.consume(E),x):_i(E)?(e.consume(E),R):n(E)}function u(E){return E===45?(e.consume(E),d):E===91?(e.consume(E),o=0,y):_i(E)?(e.consume(E),k):n(E)}function d(E){return E===45?(e.consume(E),h):n(E)}function f(E){return E===null?n(E):E===45?(e.consume(E),p):wt(E)?(a=f,F(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?z(E):E===45?p(E):f(E)}function y(E){const Q="CDATA[";return E===Q.charCodeAt(o++)?(e.consume(E),o===Q.length?v:y):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):wt(E)?(a=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),g):v(E)}function g(E){return E===62?z(E):E===93?(e.consume(E),g):v(E)}function k(E){return E===null||E===62?z(E):wt(E)?(a=k,F(E)):(e.consume(E),k)}function x(E){return E===null?n(E):E===63?(e.consume(E),j):wt(E)?(a=x,F(E)):(e.consume(E),x)}function j(E){return E===62?z(E):x(E)}function S(E){return _i(E)?(e.consume(E),C):n(E)}function C(E){return E===45||fs(E)?(e.consume(E),C):P(E)}function P(E){return wt(E)?(a=P,F(E)):Jt(E)?(e.consume(E),P):z(E)}function R(E){return E===45||fs(E)?(e.consume(E),R):E===47||E===62||ns(E)?B(E):n(E)}function B(E){return E===47?(e.consume(E),z):E===58||E===95||_i(E)?(e.consume(E),A):wt(E)?(a=B,F(E)):Jt(E)?(e.consume(E),B):z(E)}function A(E){return E===45||E===46||E===58||E===95||fs(E)?(e.consume(E),A):O(E)}function O(E){return E===61?(e.consume(E),D):wt(E)?(a=O,F(E)):Jt(E)?(e.consume(E),O):B(E)}function D(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,L):wt(E)?(a=D,F(E)):Jt(E)?(e.consume(E),D):(e.consume(E),M)}function L(E){return E===s?(e.consume(E),s=void 0,V):E===null?n(E):wt(E)?(a=L,F(E)):(e.consume(E),L)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ns(E)?B(E):(e.consume(E),M)}function V(E){return E===47||E===62||ns(E)?B(E):n(E)}function z(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),$}function $(E){return Jt(E)?un(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):W(E)}function W(E){return e.enter("htmlTextData"),a(E)}}const cv={name:"labelEnd",resolveAll:tV,resolveTo:nV,tokenize:rV},Q9={tokenize:sV},Z9={tokenize:iV},eV={tokenize:oV};function tV(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&&Di(e,0,e.length,n),e}function nV(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}},u={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Rs(l,e.slice(o+1,o+r+3)),l=Rs(l,[["enter",d,t]]),l=Rs(l,lv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Rs(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=Rs(l,e.slice(a+1)),l=Rs(l,[["exit",c,t]]),Di(e,o,e.length,l),e}function rV(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(p){return o?o._inactive?f(p):(a=r.parser.defined.includes(vc(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(Q9,d,a?d:f)(p):p===91?e.attempt(Z9,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(eV,d,f)(p)}function d(p){return t(p)}function f(p){return o._balanced=!0,n(p)}}function sV(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return ns(f)?xd(e,o)(f):o(f)}function o(f){return f===41?d(f):rT(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return ns(f)?xd(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?iT(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return ns(f)?xd(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function iV(e,t,n){const r=this;return s;function s(l){return sT.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(vc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function oV(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 aV={name:"labelStartImage",resolveAll:cv.resolveAll,tokenize:lV};function lV(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 cV={name:"labelStartLink",resolveAll:cv.resolveAll,tokenize:uV};function uV(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 sw={name:"lineEnding",tokenize:dV};function dV(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),un(e,t,"linePrefix")}}const kh={name:"thematicBreak",tokenize:fV};function fV(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||wt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Jt(u)?un(e,l,"whitespace")(u):l(u))}}const Ur={continuation:{tokenize:gV},exit:wV,name:"list",tokenize:mV},pV={partial:!0,tokenize:xV},hV={partial:!0,tokenize:yV};function mV(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(h){const y=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:ob(h)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(kh,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return ob(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(pg,r.interrupt?n:d,e.attempt(pV,p,f))}function d(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function f(h){return Jt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function gV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(pg,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,un(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!Jt(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(hV,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,un(e,e.attempt(Ur,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function yV(e,t,n){const r=this;return un(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 wV(e){e.exit(this.containerState.type)}function xV(e,t,n){const r=this;return un(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!Jt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const z1={name:"setextUnderline",resolveTo:bV,tokenize:kV};function bV(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 kV(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Jt(u)?un(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||wt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const vV={tokenize:SV};function SV(e){const t=this,n=e.attempt(pg,r,e.attempt(this.parser.constructs.flowInitial,s,un(e,e.attempt(this.parser.constructs.flow,s,e.attempt(E9,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 jV={resolveAll:aT()},NV=oT("string"),CV=oT("text");function oT(e){return{resolveAll:aT(e==="text"?_V: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(d){return u(d)?o(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function aT(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 _V(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 u=s[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={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={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const EV={42:Ur,43:Ur,45:Ur,48:Ur,49:Ur,50:Ur,51:Ur,52:Ur,53:Ur,54:Ur,55:Ur,56:Ur,57:Ur,62:ZR},AV={91:T9},PV={[-2]:rw,[-1]:rw,32:rw},IV={35:F9,42:kh,45:[z1,kh],60:W9,61:z1,95:kh,96:D1,126:D1},RV={38:tT,92:eT},TV={[-5]:sw,[-4]:sw,[-3]:sw,33:aV,38:tT,42:ab,60:[c9,J9],91:cV,92:[O9,eT],93:cv,95:ab,96:v9},MV={null:[ab,jV]},$V={null:[42,95]},LV={null:[]},OV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:$V,contentInitial:AV,disable:LV,document:EV,flow:IV,flowInitial:PV,insideSpan:MV,string:RV,text:TV},Symbol.toStringTag,{value:"Module"}));function DV(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:P(S),check:P(C),consume:k,enter:x,exit:j,interrupt:P(C,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(O){return a=Rs(a,O),b(),a[a.length-1]!==null?[]:(R(t,0),u.events=lv(o,u.events,u),u.events)}function p(O,D){return zV(h(O),D)}function h(O){return FV(a,O)}function y(){const{_bufferIndex:O,_index:D,line:L,column:M,offset:V}=r;return{_bufferIndex:O,_index:D,line:L,column:M,offset:V}}function v(O){s[O.line]=O.column,A()}function b(){let O;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(O){d=d(O)}function k(O){wt(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,A()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=O}function x(O,D){const L=D||{};return L.type=O,L.start=y(),u.events.push(["enter",L,u]),l.push(L),L}function j(O){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function S(O,D){R(O,D.from)}function C(O,D){D.restore()}function P(O,D){return L;function L(M,V,z){let F,$,W,E;return Array.isArray(M)?K(M):"tokenize"in M?K([M]):Q(M);function Q(G){return te;function te(se){const ie=se!==null&&G[se],Z=se!==null&&G.null,ce=[...Array.isArray(ie)?ie:ie?[ie]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return K(ce)(se)}}function K(G){return F=G,$=0,G.length===0?z:H(G[$])}function H(G){return te;function te(se){return E=B(),W=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?ue():G.tokenize.call(D?Object.assign(Object.create(u),D):u,c,ee,ue)(se)}}function ee(G){return O(W,E),V}function ue(G){return E.restore(),++$<F.length?H(F[$]):z}}}function R(O,D){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&Di(u.events,D,u.events.length-D,O.resolve(u.events.slice(D),u)),O.resolveTo&&(u.events=O.resolveTo(u.events,u))}function B(){const O=y(),D=u.previous,L=u.currentConstruct,M=u.events.length,V=Array.from(l);return{from:M,restore:z};function z(){r=O,u.previous=D,u.currentConstruct=L,u.events.length=M,l=V,A()}}function A(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function FV(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 zV(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 BV(e){const r={constructs:Y8([OV,...(e||{}).extensions||[]]),content:s(n9),defined:[],document:s(s9),flow:s(vV),lazy:{},string:s(NV),text:s(CV)};return r;function s(o){return a;function a(l){return DV(r,o,l)}}}function HV(e){for(;!nT(e););return e}const B1=/[\0\t\n\r]/g;function WV(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,d,f,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(B1.lastIndex=f,u=B1.exec(o),p=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(p),!u){t=o.slice(f);break}if(h===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(o.slice(f,p)),e+=p-f),h){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const VV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function KV(e){return e.replace(VV,qV)}function qV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return QR(n.slice(o?2:1),o?16:10)}return av(n)||e}const lT={}.hasOwnProperty;function UV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),YV(n)(HV(BV(n).document().write(WV()(e,t,!0))))}function YV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(yt),autolinkProtocol:B,autolinkEmail:B,atxHeading:o(Ne),blockQuote:o(Z),characterEscape:B,characterReference:B,codeFenced:o(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ce,a),codeText:o(de,a),codeTextData:B,data:B,codeFlowValue:B,definition:o(pe),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Me),hardBreakEscape:o(Ce),hardBreakTrailing:o(Ce),htmlFlow:o(We,a),htmlFlowData:B,htmlText:o(We,a),htmlTextData:B,image:o(ct),label:a,link:o(yt),listItem:o(ot),listItemValue:p,listOrdered:o(Re,f),listUnordered:o(Re),paragraph:o(kt),reference:H,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ne),strong:o($t),thematicBreak:o(ze)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:ie,autolinkProtocol:se,blockQuote:c(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:G,characterReference:te,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:A,codeIndented:c(g),codeText:c(V),codeTextData:A,data:A,definition:c(),definitionDestinationString:j,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(L),htmlFlowData:A,htmlText:c(M),htmlTextData:A,image:c(F),label:W,labelText:$,lineEnding:O,link:c(z),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ee,resourceDestinationString:E,resourceTitleString:Q,resource:K,setextHeading:c(R),setextHeadingLineSequence:P,setextHeadingText:C,strong:c(),thematicBreak:c()}};cT(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(re){let ke={type:"root",children:[]};const Be={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},Qe=[];let _e=-1;for(;++_e<re.length;)if(re[_e][1].type==="listOrdered"||re[_e][1].type==="listUnordered")if(re[_e][0]==="enter")Qe.push(_e);else{const _t=Qe.pop();_e=s(re,_t,_e)}for(_e=-1;++_e<re.length;){const _t=t[re[_e][0]];lT.call(_t,re[_e][1].type)&&_t[re[_e][1].type].call(Object.assign({sliceSerialize:re[_e][2].sliceSerialize},Be),re[_e][1])}if(Be.tokenStack.length>0){const _t=Be.tokenStack[Be.tokenStack.length-1];(_t[1]||H1).call(Be,void 0,_t[0])}for(ke.position={start:$o(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:$o(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<t.transforms.length;)ke=t.transforms[_e](ke)||ke;return ke}function s(re,ke,Be){let Qe=ke-1,_e=-1,_t=!1,Xt,Ft,at,Fn;for(;++Qe<=Be;){const ne=re[Qe];switch(ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ne[0]==="enter"?_e++:_e--,Fn=void 0;break}case"lineEndingBlank":{ne[0]==="enter"&&(Xt&&!Fn&&!_e&&!at&&(at=Qe),Fn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Fn=void 0}if(!_e&&ne[0]==="enter"&&ne[1].type==="listItemPrefix"||_e===-1&&ne[0]==="exit"&&(ne[1].type==="listUnordered"||ne[1].type==="listOrdered")){if(Xt){let Pe=Qe;for(Ft=void 0;Pe--;){const et=re[Pe];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;Ft&&(re[Ft][1].type="lineEndingBlank",_t=!0),et[1].type="lineEnding",Ft=Pe}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"||et[1].type==="blockQuoteMarker"||et[1].type==="listItemIndent"))break}at&&(!Ft||at<Ft)&&(Xt._spread=!0),Xt.end=Object.assign({},Ft?re[Ft][1].start:ne[1].end),re.splice(Ft||Qe,0,["exit",Xt,ne[2]]),Qe++,Be++}if(ne[1].type==="listItemPrefix"){const Pe={type:"listItem",_spread:!1,start:Object.assign({},ne[1].start),end:void 0};Xt=Pe,re.splice(Qe,0,["enter",Pe,ne[2]]),Qe++,Be++,at=void 0,Fn=!0}}}return re[ke][1]._spread=_t,Be}function o(re,ke){return Be;function Be(Qe){l.call(this,re(Qe),Qe),ke&&ke.call(this,Qe)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(re,ke,Be){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([ke,Be||void 0]),re.position={start:$o(ke.start),end:void 0}}function c(re){return ke;function ke(Be){re&&re.call(this,Be),u.call(this,Be)}}function u(re,ke){const Be=this.stack.pop(),Qe=this.tokenStack.pop();if(Qe)Qe[0].type!==re.type&&(ke?ke.call(this,re,Qe[0]):(Qe[1]||H1).call(this,re,Qe[0]));else throw new Error("Cannot close `"+re.type+"` ("+wd({start:re.start,end:re.end})+"): it’s not open");Be.position.end=$o(re.end)}function d(){return q8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(re){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function h(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=re}function y(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=re}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.value=re.replace(/(\r?\n|\r)$/g,"")}function k(re){const ke=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ke,Be.identifier=vc(this.sliceSerialize(re)).toLowerCase()}function x(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.title=re}function j(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.url=re}function S(re){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Be=this.sliceSerialize(re).length;ke.depth=Be}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function P(re){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function B(re){const Be=this.stack[this.stack.length-1].children;let Qe=Be[Be.length-1];(!Qe||Qe.type!=="text")&&(Qe=ye(),Qe.position={start:$o(re.start),end:void 0},Be.push(Qe)),this.stack.push(Qe)}function A(re){const ke=this.stack.pop();ke.value+=this.sliceSerialize(re),ke.position.end=$o(re.end)}function O(re){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=ke.children[ke.children.length-1];Be.position.end=$o(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(B.call(this,re),A.call(this,re))}function D(){this.data.atHardBreak=!0}function L(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.value=re}function M(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.value=re}function V(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.value=re}function z(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ke,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function F(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ke,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function $(re){const ke=this.sliceSerialize(re),Be=this.stack[this.stack.length-2];Be.label=KV(ke),Be.identifier=vc(ke).toLowerCase()}function W(){const re=this.stack[this.stack.length-1],ke=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const Qe=re.children;Be.children=Qe}else Be.alt=ke}function E(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.url=re}function Q(){const re=this.resume(),ke=this.stack[this.stack.length-1];ke.title=re}function K(){this.data.inReference=void 0}function H(){this.data.referenceType="collapsed"}function ee(re){const ke=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ke,Be.identifier=vc(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function ue(re){this.data.characterReferenceType=re.type}function G(re){const ke=this.sliceSerialize(re),Be=this.data.characterReferenceType;let Qe;Be?(Qe=QR(ke,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=av(ke);const _e=this.stack[this.stack.length-1];_e.value+=Qe}function te(re){const ke=this.stack.pop();ke.position.end=$o(re.end)}function se(re){A.call(this,re);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(re)}function ie(re){A.call(this,re);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(re)}function Z(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Me(){return{type:"emphasis",children:[]}}function Ne(){return{type:"heading",depth:0,children:[]}}function Ce(){return{type:"break"}}function We(){return{type:"html",value:""}}function ct(){return{type:"image",title:null,url:"",alt:null}}function yt(){return{type:"link",title:null,url:"",children:[]}}function Re(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function ot(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function kt(){return{type:"paragraph",children:[]}}function $t(){return{type:"strong",children:[]}}function ye(){return{type:"text",value:""}}function ze(){return{type:"thematicBreak"}}}function $o(e){return{line:e.line,column:e.column,offset:e.offset}}function cT(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?cT(e,r):GV(e,r)}}function GV(e,t){let n;for(n in t)if(lT.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 H1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+wd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+wd({start:t.start,end:t.end})+") is still open")}function JV(e){const t=this;t.parser=n;function n(r){return UV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function XV(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 QV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function ZV(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 eK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function tK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Xc(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 u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function rK(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 sK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function uT(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 iK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return uT(e,t);const s={src:Xc(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 oK(e,t){const n={src:Xc(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 aK(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 lK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return uT(e,t);const s={href:Xc(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 cK(e,t){const n={href:Xc(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 uK(e,t,n){const r=e.all(t),s=n?dK(n):dT(t),o={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const d=r[l];(s||l!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),d.type==="element"&&d.tagName==="p"&&!s?a.push(...d.children):a.push(d)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function dK(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=dT(n[r])}return t}function dT(e){const t=e.spread;return t??e.children.length>1}function fK(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 pK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function mK(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gK(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=rv(t.children[1]),c=KR(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 yK(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 u=[];for(;++c<l;){const f=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let y={type:"element",tagName:o,properties:p,children:[]};f&&(y.children=e.all(f),e.patch(f,y),y=e.applyData(f,y)),u.push(y)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function wK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const W1=9,V1=32;function xK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(K1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(K1(t.slice(s),s>0,!1)),o.join("")}function K1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===W1||o===V1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===W1||o===V1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function bK(e,t){const n={type:"text",value:xK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function kK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const vK={blockquote:XV,break:QV,code:ZV,delete:eK,emphasis:tK,footnoteReference:nK,heading:rK,html:sK,imageReference:iK,image:oK,inlineCode:aK,linkReference:lK,link:cK,listItem:uK,list:fK,paragraph:pK,root:hK,strong:mK,table:gK,tableCell:wK,tableRow:yK,text:bK,thematicBreak:kK,toml:Op,yaml:Op,definition:Op,footnoteDefinition:Op};function Op(){}const fT=-1,hg=0,bd=1,um=2,uv=3,dv=4,fv=5,pv=6,pT=7,hT=8,q1=typeof self=="object"?self:globalThis,SK=(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 hg:case fT:return n(a,s);case bd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case um:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case uv:return n(new Date(a),s);case dv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case fv:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case pv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case pT:{const{name:l,message:c}=a;return n(new q1[l](c),s)}case hT: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 q1[o](a),s)};return r},U1=e=>SK(new Map,e)(0),Bl="",{toString:jK}={},{keys:NK}=Object,Fu=e=>{const t=typeof e;if(t!=="object"||!e)return[hg,t];const n=jK.call(e).slice(8,-1);switch(n){case"Array":return[bd,Bl];case"Object":return[um,Bl];case"Date":return[uv,Bl];case"RegExp":return[dv,Bl];case"Map":return[fv,Bl];case"Set":return[pv,Bl];case"DataView":return[bd,n]}return n.includes("Array")?[bd,n]:n.includes("Error")?[pT,n]:[um,n]},Dp=([e,t])=>e===hg&&(t==="function"||t==="symbol"),CK=(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]=Fu(a);switch(l){case hg:{let d=a;switch(c){case"bigint":l=hT,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([fT],a)}return s([l,d],a)}case bd:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const d=[],f=s([l,d],a);for(const p of a)d.push(o(p));return f}case um:{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 d=[],f=s([l,d],a);for(const p of NK(a))(e||!Dp(Fu(a[p])))&&d.push([o(p),o(a[p])]);return f}case uv:return s([l,a.toISOString()],a);case dv:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case fv:{const d=[],f=s([l,d],a);for(const[p,h]of a)(e||!(Dp(Fu(p))||Dp(Fu(h))))&&d.push([o(p),o(h)]);return f}case pv:{const d=[],f=s([l,d],a);for(const p of a)(e||!Dp(Fu(p)))&&d.push(o(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},Y1=(e,{json:t,lossy:n}={})=>{const r=[];return CK(!(t||n),!!t,new Map,r)(e),r},dm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?U1(Y1(e,t)):structuredClone(e):(e,t)=>U1(Y1(e,t));function _K(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 EK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function AK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||_K,r=e.options.footnoteBackLabel||EK,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 u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),f=String(u.identifier).toUpperCase(),p=Xc(f.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,h);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=d[d.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const k=b.children[b.children.length-1];k&&k.type==="text"?k.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...y)}else d.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...dm(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 mT=function(e){if(e==null)return TK;if(typeof e=="function")return mg(e);if(typeof e=="object")return Array.isArray(e)?PK(e):IK(e);if(typeof e=="string")return RK(e);throw new Error("Expected function, string, or object as test")};function PK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=mT(e[n]);return mg(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function IK(e){const t=e;return mg(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function RK(e){return mg(t);function t(n){return n&&n.type===e}}function mg(e){return t;function t(n,r,s){return!!(MK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function TK(){return!0}function MK(e){return e!==null&&typeof e=="object"&&"type"in e}const gT=[],$K=!0,G1=!1,LK="skip";function OK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=mT(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=gT,y,v,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(h=DK(n(c,d)),h[0]===G1))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==LK)for(v=(r?g.children.length:-1)+a,b=d.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===G1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function DK(e){return Array.isArray(e)?e:typeof e=="number"?[$K,e]:e==null?gT:[e]}function yT(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),OK(e,o,l,s);function l(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return a(c,f,d)}}const lb={}.hasOwnProperty,FK={};function zK(e,t){const n=t||FK,r=new Map,s=new Map,o=new Map,a={...vK,...n.handlers},l={all:u,applyData:HK,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:BK,wrap:VK};return yT(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:s,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),l;function c(d,f){const p=d.type,h=l.handlers[p];if(lb.call(l.handlers,p)&&h)return h(l,d,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:v,...b}=d,g=dm(b);return g.children=l.all(d),g}return dm(d)}return(l.options.unknownHandler||WK)(l,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const y=l.one(p[h],d);if(y){if(h&&p[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=J1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=J1(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function BK(e,t){e.position&&(t.position=j8(e))}function HK(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,dm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function WK(e,t){const n=t.data||{},r="value"in t&&!(lb.call(n,"hProperties")||lb.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 VK(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 J1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function X1(e,t){const n=zK(e,t),r=n.one(e,void 0),s=AK(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 KK(e,t){return e&&"run"in e?async function(n,r){const s=X1(n,{file:r,...t});await e.run(s,r)}:function(n,r){return X1(n,{file:r,...e||t})}}function Q1(e){if(e)throw e}var vh=Object.prototype.hasOwnProperty,wT=Object.prototype.toString,Z1=Object.defineProperty,eC=Object.getOwnPropertyDescriptor,tC=function(t){return typeof Array.isArray=="function"?Array.isArray(t):wT.call(t)==="[object Array]"},nC=function(t){if(!t||wT.call(t)!=="[object Object]")return!1;var n=vh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&vh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||vh.call(t,s)},rC=function(t,n){Z1&&n.name==="__proto__"?Z1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},sC=function(t,n){if(n==="__proto__")if(vh.call(t,n)){if(eC)return eC(t,n).value}else return;return t[n]},qK=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,u=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=sC(l,n),s=sC(t,n),l!==s&&(d&&s&&(nC(s)||(o=tC(s)))?(o?(o=!1,a=r&&tC(r)?r:[]):a=r&&nC(r)?r:{},rC(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&rC(l,{name:n,newValue:s}));return l};const iw=da(qK);function cb(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 UK(){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,...u){const d=e[++o];let f=-1;if(c){a(c);return}for(;++f<s.length;)(u[f]===null||u[f]===void 0)&&(u[f]=s[f]);s=u,d?YK(d,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function YK(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(u){const d=u;if(l&&n)throw d;return s(d)}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 ki={basename:GK,dirname:JK,extname:XK,join:QK,sep:"/"};function GK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');jf(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 JK(e){if(jf(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 XK(e){jf(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 QK(...e){let t=-1,n;for(;++t<e.length;)jf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":ZK(n)}function ZK(e){jf(e);const t=e.codePointAt(0)===47;let n=e7(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function e7(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 jf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const t7={cwd:n7};function n7(){return"/"}function ub(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function r7(e){if(typeof e=="string")e=new URL(e);else if(!ub(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return s7(e)}function s7(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 ow=["history","path","basename","stem","extname","dirname"];class xT{constructor(t){let n;t?ub(t)?n={path:t}:typeof t=="string"||i7(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":t7.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ow.length;){const o=ow[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)ow.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?ki.basename(this.path):void 0}set basename(t){lw(t,"basename"),aw(t,"basename"),this.path=ki.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ki.dirname(this.path):void 0}set dirname(t){iC(this.basename,"dirname"),this.path=ki.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ki.extname(this.path):void 0}set extname(t){if(aw(t,"extname"),iC(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=ki.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ub(t)&&(t=r7(t)),lw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ki.basename(this.path,this.extname):void 0}set stem(t){lw(t,"stem"),aw(t,"stem"),this.path=ki.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 Rr(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 aw(e,t){if(e&&e.includes(ki.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ki.sep+"`")}function lw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function iC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function i7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const o7=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},a7={}.hasOwnProperty;class hv extends o7{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=UK()}copy(){const t=new hv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(iw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(dw("data",this.frozen),this.namespace[t]=n,this):a7.call(this.namespace,t)&&this.namespace[t]||void 0:t?(dw("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=Fp(t),r=this.parser||this.Parser;return cw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),cw("process",this.parser||this.Parser),uw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Fp(t),c=r.parse(l);r.run(c,l,function(d,f,p){if(d||!f||!p)return u(d);const h=f,y=r.stringify(h,p);u7(y)?p.value=y:p.result=y,u(d,p)});function u(d,f){d||!f?a(d):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),cw("processSync",this.parser||this.Parser),uw("processSync",this.compiler||this.Compiler),this.process(t,s),aC("processSync","process",n),r;function s(o,a){n=!0,Q1(o),r=a}}run(t,n,r){oC(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=Fp(n);s.run(t,c,u);function u(d,f,p){const h=f||t;d?l(d):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),aC("runSync","run",r),s;function o(a,l){Q1(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Fp(n),s=this.compiler||this.Compiler;return uw("stringify",s),oC(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(dw("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(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;c(d,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(s.settings=iw(!0,s.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[h,...y]=d;const v=r[p][1];cb(v)&&cb(h)&&(h=iw(!0,v,h)),r[p]=[u,h,...y]}}}}const l7=new hv().freeze();function cw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function uw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function dw(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 oC(e){if(!cb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function aC(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Fp(e){return c7(e)?e:new xT(e)}function c7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function u7(e){return typeof e=="string"||d7(e)}function d7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const f7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",lC=[],cC={allowDangerousHtml:!0},p7=/^(https?|ircs?|mailto|xmpp)$/i,h7=[{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 bT(e){const t=m7(e),n=g7(e);return y7(t.runSync(t.parse(n),n),e)}function m7(e){const t=e.rehypePlugins||lC,n=e.remarkPlugins||lC,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...cC}:cC;return l7().use(JV).use(n).use(KK,r).use(t)}function g7(e){const t=e.children||"",n=new xT;return typeof t=="string"&&(n.value=t),n}function y7(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||w7;for(const d of h7)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+f7+d.id,void 0);return yT(e,u),A8(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in nw)if(Object.hasOwn(nw,h)&&Object.hasOwn(d.properties,h)){const y=d.properties[h],v=nw[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=c(String(y||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function w7(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||p7.test(e.slice(0,t))?e:""}const x7=new Set(["echarts"]),b7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),k7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),v7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function na(e){return e&&typeof e=="object"&&!Array.isArray(e)}function sl(e,t){if(!na(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:na(n[r])&&na(s)&&(n[r]=sl(n[r],s));return n}function gg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>na(n)?sl(n,t):n):na(e)?sl(e,t):e}function S7(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 db(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)=>db(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||k7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);db(r,`${t}.${n}`)}}}function j7(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(!b7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function N7(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:sl(e,t)}function C7(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!na(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return sl(o,n)}):na(e)?sl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function _7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:gg(e,n)}function uC(e,t="rgba(255, 255, 255, 0.62)"){return gg(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 E7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:gg(e,n)}function A7(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:gg(e,t)}function P7(e,t,n){const r=C7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>na(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??v7,textStyle:sl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:N7(e.tooltip),legend:_7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?E7(e.grid,s||o):e.grid,xAxis:uC(e.xAxis),yAxis:uC(e.yAxis),radar:A7(e.radar),series:t}}function I7(e){const t=S7(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(!x7.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");db(n);const r=j7(n.option.series),s=n.title==null?"":String(n.title),o=P7(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 zp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function R7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function ro(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!zp(t,t.length-1)&&(t=t.slice(0,-1));const n=[];let r="",s=0;for(let o=0;o<t.length;o+=1){const a=t[o];if(a==="`"&&!zp(t,o)){const l=R7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!zp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&zp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function kT(e,t){if(!t)return e;const n=e.slice(0,t);for(e.length>t&&(n[t-1]=[e[t-1],...e.slice(t)].filter(Boolean).join(" | "));n.length<t;)n.push("");return n}function vT(e){const t=ro(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function ST(e){return ro(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function T7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function M7(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function $7({code:e}){const t=m.useMemo(()=>M7(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((d,f)=>{l.set(d.id,{x:28+(n?f*(r+o):f%3*(r+o)),y:28+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(d=>d.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(d=>d.y+s+28));return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,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((d,f)=>{const p=l.get(d.from),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:d.label.slice(0,24)})]},d.id)})]})}function L7(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 O7({code:e}){const t=m.useMemo(()=>L7(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),u=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),d=f=>{const p=Math.max(0,n.findIndex(h=>h.id===f));return s+p*r+r/2};return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,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((f,p)=>{const h=s+p*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,p)=>{const h=o+a+p*l+24;if(f.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${p}`);const y=d(f.from),v=d(f.to),b=(y+v)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:h,x2:v,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function jT({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(O7,{code:t}):i.jsx($7,{code:t})})}function D7(e){const t=String(e||"").replace(/\r\n/g,`
80
- `).split(`
81
- `),n=[];let r=[],s=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
82
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&c){o();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
83
- `)});continue}if(!s&&T7(l)){o();const u=[];for(;a<t.length;){const d=t[a]||"";if(u.length>0&&(!d.trim()||/^-{3,}\s*$/.test(d)||/^#{1,6}\s+/.test(d)))break;u.push(d),a++}n.push({type:"mermaid",text:u.join(`
84
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&ro(l).length>1&&vT(t[a+1])){o();const u=ro(l),d=ST(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&ro(t[a]).length>1;)f.push(kT(ro(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return o(),n}function dC(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 NT(e){const t=String(e||"").replace(/\r\n/g,`
85
- `).split(`
86
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",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 d=o;for(;d<r.length&&!/\s|<|>/.test(r[d]);)d+=1;let f=r.slice(o,d),p="";for(;/[.,;:!?)}\]]$/.test(f);)p=f.slice(-1)+p,f=f.slice(0,-1);f?s+=`[${f}](${f})${p}`:s+=r.slice(o,d),o=d}return s}).join(`
87
- `)}function CT(e,t=!1,n=""){const r=o=>{const a=String(o||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=dC(a,n);return e?e(l,{kind:"link",download:!0}):l},s=(o,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(o.stopPropagation(),!(o.defaultPrevented||o.button!==0)&&(o.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:o})=>i.jsx(i.Fragment,{children:o})}:{},code:({inline:o,className:a,children:l})=>{var d;const c=((d=String(a||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?i.jsx(jT,{code:u}):o?i.jsx("code",{className:a,children:l}):i.jsx("code",{className:a,children:l})},img:({src:o,alt:a})=>i.jsx("img",{src:e?e(dC(o,n)):o||"",alt:a||"",loading:"lazy"}),a:({href:o,children:a})=>i.jsx("a",{href:r(o),target:"_blank",rel:"noopener noreferrer",onClick:l=>s(l,o),children:a})}}function fC({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(bT,{components:CT(t,!0,n),children:NT(e)})}function mv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>D7(e),[e]),s=m.useMemo(()=>CT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(jT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(bT,{components:s,children:NT(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(fC,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((u,d)=>i.jsx("td",{style:{textAlign:o.align[d]||"left"},children:i.jsx(fC,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function F7(e,t=","){const n=[];let r=[],s="",o=!1;const a=String(e||"").replace(/\r\n/g,`
88
- `);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(o){c==='"'&&u==='"'?(s+='"',l+=1):c==='"'?o=!1:s+=c;continue}c==='"'?o=!0:c===t?(r.push(s.trim()),s=""):c===`
89
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function xi(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 z7(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=>xi(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>xi(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)=>xi(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:xi(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:xi(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>xi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>xi(s[a])):s&&typeof s=="object"?r.map(o=>xi(s[o.key])):r.map((o,a)=>a===0?xi(s):""))}}function B7(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=z7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
90
- `).split(`
91
- `).filter(l=>l.trim());if(s.length>=2&&ro(s[0]).length>1&&vT(s[1])){const l=ro(s[0]),c=ST(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>kT(ro(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=F7(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function gv({content:e}){const t=m.useMemo(()=>B7(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:xi(n[o])},`${s.key}-${o}`))},r))})]})})}function yv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>I7(e),[e]),[r,s]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),R6(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{o||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||s({loading:!1,error:""}))}).catch(u=>{o||s({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,d;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(d=a==null?void 0:a.dispose)==null||d.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]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function _T(e){return typeof e>"u"||e===null}function H7(e){return typeof e=="object"&&e!==null}function W7(e){return Array.isArray(e)?e:_T(e)?[]:[e]}function V7(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 K7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function q7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var U7=_T,Y7=H7,G7=W7,J7=K7,X7=q7,Q7=V7,wv={isNothing:U7,isObject:Y7,toArray:G7,repeat:J7,isNegativeZero:X7,extend:Q7};function ET(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
92
-
93
- `+e.mark.snippet),r+" "+n):r}function Qd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=ET(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Qd.prototype=Object.create(Error.prototype);Qd.prototype.constructor=Qd;Qd.prototype.toString=function(t){return this.name+": "+ET(this,t)};var Ma=Qd,Z7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],eq=["scalar","sequence","mapping"];function tq(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function nq(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(Z7.indexOf(n)===-1)throw new Ma('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=tq(t.styleAliases||null),eq.indexOf(this.kind)===-1)throw new Ma('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Ar=nq;function pC(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 rq(){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 fb(e){return this.extend(e)}fb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Ar)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 Ma("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Ar))throw new Ma("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Ma("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 Ma("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 Ar))throw new Ma("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(fb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=pC(s,"implicit"),s.compiledExplicit=pC(s,"explicit"),s.compiledTypeMap=rq(s.compiledImplicit,s.compiledExplicit),s};var sq=fb,iq=new Ar("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),oq=new Ar("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),aq=new Ar("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),lq=new sq({explicit:[iq,oq,aq]});function cq(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function uq(){return null}function dq(e){return e===null}var fq=new Ar("tag:yaml.org,2002:null",{kind:"scalar",resolve:cq,construct:uq,predicate:dq,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function pq(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 hq(e){return e==="true"||e==="True"||e==="TRUE"}function mq(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var gq=new Ar("tag:yaml.org,2002:bool",{kind:"scalar",resolve:pq,construct:hq,predicate:mq,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 yq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function wq(e){return 48<=e&&e<=55}function xq(e){return 48<=e&&e<=57}function bq(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(!yq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!wq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!xq(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function kq(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 vq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!wv.isNegativeZero(e)}var Sq=new Ar("tag:yaml.org,2002:int",{kind:"scalar",resolve:bq,construct:kq,predicate:vq,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"]}}),jq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Nq(e){return!(e===null||!jq.test(e)||e[e.length-1]==="_")}function Cq(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 _q=/^[-+]?[0-9]+e/;function Eq(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(wv.isNegativeZero(e))return"-0.0";return n=e.toString(10),_q.test(n)?n.replace("e",".e"):n}function Aq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||wv.isNegativeZero(e))}var Pq=new Ar("tag:yaml.org,2002:float",{kind:"scalar",resolve:Nq,construct:Cq,predicate:Aq,represent:Eq,defaultStyle:"lowercase"}),Iq=lq.extend({implicit:[fq,gq,Sq,Pq]}),Rq=Iq,AT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),PT=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 Tq(e){return e===null?!1:AT.exec(e)!==null||PT.exec(e)!==null}function Mq(e){var t,n,r,s,o,a,l,c=0,u=null,d,f,p;if(t=AT.exec(e),t===null&&(t=PT.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]&&(d=+t[10],f=+(t[11]||0),u=(d*60+f)*6e4,t[9]==="-"&&(u=-u)),p=new Date(Date.UTC(n,r,s,o,a,l,c)),u&&p.setTime(p.getTime()-u),p}function $q(e){return e.toISOString()}var Lq=new Ar("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Tq,construct:Mq,instanceOf:Date,represent:$q});function Oq(e){return e==="<<"||e===null}var Dq=new Ar("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Oq}),xv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
- \r`;function Fq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=xv;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 zq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=xv,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 Bq(e){var t="",n=0,r,s,o=e.length,a=xv;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 Hq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Wq=new Ar("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Fq,construct:zq,predicate:Hq,represent:Bq}),Vq=Object.prototype.hasOwnProperty,Kq=Object.prototype.toString;function qq(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,Kq.call(s)!=="[object Object]")return!1;for(o in s)if(Vq.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 Uq(e){return e!==null?e:[]}var Yq=new Ar("tag:yaml.org,2002:omap",{kind:"sequence",resolve:qq,construct:Uq}),Gq=Object.prototype.toString;function Jq(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],Gq.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function Xq(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 Qq=new Ar("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Jq,construct:Xq}),Zq=Object.prototype.hasOwnProperty;function eU(e){if(e===null)return!0;var t,n=e;for(t in n)if(Zq.call(n,t)&&n[t]!==null)return!1;return!0}function tU(e){return e!==null?e:{}}var nU=new Ar("tag:yaml.org,2002:set",{kind:"mapping",resolve:eU,construct:tU});Rq.extend({implicit:[Lq,Dq],explicit:[Wq,Yq,Qq,nU]});function hC(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
95
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}var rU=new Array(256),sU=new Array(256);for(var Hl=0;Hl<256;Hl++)rU[Hl]=hC(Hl)?1:0,sU[Hl]=hC(Hl);const Zd=["requirement","planning","code","test","normal"],mC={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function bv(e,t){var s,o,a,l,c,u,d,f,p,h,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((s=k==null?void 0:k.data)!=null&&s.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},j=((o=k.data)==null?void 0:o.definitionId)||k.id,S=((a=k.data)==null?void 0:a.inputs)??[],C=((l=k.data)==null?void 0:l.outputs)??[],P=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",R=x.role!=null?String(x.role).trim():"",B=mC[P]||P,A=mC[R]||R,O=Zd.includes(B)?B:Zd.includes(A)?A:"normal",D=Array.isArray(S)?S.map(n):Array.isArray(x.input)?x.input.map(ue=>n(ue)):[],L=Array.isArray(C)?C.map(n):Array.isArray(x.output)?x.output.map(ue=>n(ue)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,V=(d=k.data)==null?void 0:d.body,z=V!=null?String(V):x.body!=null?String(x.body):"";let F=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const $={...x,definitionId:j,label:M,role:O,model:F,input:D,output:L},W=((p=k.data)==null?void 0:p.marketplaceRef)||x.marketplaceRef;W?$.marketplaceRef=String(W):delete $.marketplaceRef;const E=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;E?$.marketplacePackageId=String(E):delete $.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;Q?$.marketplaceVersion=String(Q):delete $.marketplaceVersion,j.startsWith("provide_")||z.trim()===""?delete $.body:$.body=z;const K=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];K.length>0?$.images=K:delete $.images;const H=(b=k.data)==null?void 0:b.script,ee=H!=null?String(H):x.script!=null?String(x.script):"";ee.trim()===""?delete $.script:$.script=ee;for(const ue of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[ue],te=G!=null?String(G):x[ue]!=null?String(x[ue]):"";te.trim()===""?delete $[ue]:$[ue]=te.trim()}delete $.temperature,delete $.maxTokens,delete $.description,r[k.id]=$}return r}function kd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function iU(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 oU(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=>kd(a)),edges:o.map(a=>kd(a)),instances:bv(r,n||{})}}function aU(e,t,n,r,s={}){var f;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(p=>p.id)),l=new Map;for(const p of e.nodes)l.set(p.id,iU(p.id,a));const c=e.nodes.map(p=>{var y,v;const h=l.get(p.id);return{...kd(p),id:h,selected:!0,dragging:!1,position:{x:Number(((y=p.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=p.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,h)=>{const y=l.get(p.source),v=l.get(p.target);return{...kd(p),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),d={...r||{}};for(const[p,h]of l.entries()){const y=(f=e.instances)==null?void 0:f[p];y&&(d[h]={...kd(y),label:y.label!=null?String(y.label):h})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...u],instances:d,pastedNodeIds:c.map(p=>p.id)}}function An(e){switch(fm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function fm(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 lU(e,t){const n=fm(e),r=fm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const cU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function pb(e){const t=fm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&cU.has(n)?`${t}+${n}`:t}function uU(e){return pb(e)}function ef(e,t){if(!e||!t||!lU(e.type,t.type))return!1;const n=pb(e),r=pb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function dU(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 hb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=dU(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}const pm=/\[image\s+(\d+)\]/gi;function bo(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 fU(e){return`image ${bo(e).length+1}`}function pU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function hU(e,t){const n=bo(e),r=String(t||""),s=new Set;pm.lastIndex=0;let o;for(;o=pm.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function mU(e){return new Promise((t,n)=>{if(!e||!String(e.type||"").startsWith("image/")){n(new Error("Only image files are supported"));return}const r=new FileReader;r.onload=()=>{t({name:e.name||"image",mimeType:e.type||"image/png",dataUrl:String(r.result||"")})},r.onerror=()=>n(r.error||new Error("Failed to read image")),r.readAsDataURL(e)})}function IT(e){var n;return Array.from(((n=e==null?void 0:e.clipboardData)==null?void 0:n.items)||[]).filter(r=>r.kind==="file"&&String(r.type||"").startsWith("image/")).map(r=>r.getAsFile()).filter(Boolean)}function vd(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 RT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=bo(n);for(const a of r){const l=await mU(a),c=fU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=pU(s,c)}return{body:s,images:o}}function _s(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function gU(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 yU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function tn(e){e.stopPropagation()}function wU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xU(e,t){const n=`\\[${wU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
- `).replace(/\n{3,}/g,`
97
-
98
- `).trimEnd()}function fw(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function bU(e){const t=String(e||"");let n="",r=0;pm.lastIndex=0;let s;for(;s=pm.exec(t);)n+=fw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${fw(s[0])}</span>`,r=s.index+s[0].length;return n+=fw(t.slice(r)),n||" "}function kU(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,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+s+o+a+l)}function vU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:d=!1}){var Mr,$r;const{t:f}=Vr(),p=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=gU(e),b=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",P=C.startsWith("provide_"),R=C==="provide_bool",B=C==="provide_str",A=C==="provide_file",O=C==="provide_password",D=C==="agent_subAgent",L=C==="control_agent_toBool",M=(D||L)&&!b,V=R?yU(h[0]):!1,z=P?String(((Mr=h[0])==null?void 0:Mr.value)??(($r=h[0])==null?void 0:$r.default)??(e==null?void 0:e.body)??""):"",F=String((e==null?void 0:e.body)||""),$=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),W=!P&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",E=bo(e==null?void 0:e.images),Q=R||B||A||O||M||!!W,K=m.useRef(!1),H=m.useRef(!1),ee=m.useRef(null),ue=m.useRef(null),G=m.useRef(null),te=m.useRef(null),se=m.useRef(null),[ie,Z]=m.useState(z),[ce,de]=m.useState(!1),[pe,Me]=m.useState(F),[Ne,Ce]=m.useState(!1),[We,ct]=m.useState({visible:!1,top:0,height:100}),[yt,Re]=m.useState(!1),ot=m.useCallback(()=>{const le=ue.current;if(!le)return;const me=Math.max(1,le.scrollHeight),tt=Math.max(1,le.clientHeight),rt=me>tt+1,zt=rt?Math.max(12,tt/me*100):100,Rn=Math.max(0,100-zt),jr=rt?Math.min(Rn,le.scrollTop/Math.max(1,me-tt)*Rn):0;ct({visible:rt,top:jr,height:zt})},[]);m.useEffect(()=>{K.current||Z(z)},[n,z]),m.useEffect(()=>{H.current||Me(F)},[n,F]),m.useEffect(()=>{const le=ue.current;if(!le)return;if(M){le.style.minHeight="",le.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const me=kU(le,pe);le.style.minHeight=`${me}px`,le.style.height="",G.current&&(G.current.style.minHeight=`${me}px`,G.current.style.height="")},[pe,M]),m.useEffect(()=>{if(!M)return;const le=window.requestAnimationFrame(ot),me=ue.current;if(!me||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(le);const tt=new ResizeObserver(ot);return tt.observe(me),()=>{window.cancelAnimationFrame(le),tt.disconnect()}},[pe,M,ot]),m.useEffect(()=>{const le=ee.current,me=e==null?void 0:e.onNodeContentResize;if(!M||!le||!me||typeof ResizeObserver>"u")return;let tt=0;const rt=()=>{window.cancelAnimationFrame(tt),tt=window.requestAnimationFrame(()=>me(n))},zt=new ResizeObserver(rt);return zt.observe(le),rt(),()=>{window.cancelAnimationFrame(tt),zt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!yt)return;const le=window.setTimeout(()=>{const me=se.current;if(!me)return;me.focus();const tt=me.value.length;me.setSelectionRange(tt,tt)},0);return()=>window.clearTimeout(le)},[yt]);const kt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],$t=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],ye=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],ze=Array.isArray(c==null?void 0:c.codex)?c.codex:[],re=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!C.startsWith("tool_nodejs"),Be=new Set(kt.map(_s)),Qe=new Set($t.map(_s)),_e=new Set(ye.map(_s)),_t=new Set(ze.map(_s)),Xt=re?re.startsWith("cursor:")||re.startsWith("opencode:")||re.startsWith("codex:")||re.startsWith("claude-code:")?re:_e.has(re)?`claude-code:${re}`:_t.has(re)?`codex:${re}`:Qe.has(re)?`opencode:${re}`:Be.has(re)?`cursor:${re}`:re:"",Ft=re&&!Xt.startsWith("cursor:")&&!Xt.startsWith("opencode:")&&!Xt.startsWith("codex:")&&!Xt.startsWith("claude-code:")&&!Be.has(re)&&!Qe.has(re)&&!_e.has(re)&&!_t.has(re),at=re.startsWith("cursor:")?re.slice(7):re.startsWith("opencode:")?re.slice(9):re.startsWith("codex:")?re.slice(6):re.startsWith("claude-code:")?re.slice(12):re,Fn=le=>{if(g)return;const me=le.target.value;u&&u(n,me)},ne=le=>{le.stopPropagation(),!g&&r&&r(n)},Pe=le=>{le.stopPropagation(),s&&s()},et=le=>{le.stopPropagation(),!g&&(o==null||o(n,le.target.value==="true"?"true":"false"))},qe=le=>{if(le.stopPropagation(),g)return;const me=le.target.value;Z(me),!d&&!K.current&&(o==null||o(n,me))},It=le=>{le.stopPropagation(),K.current=!0},vt=le=>{if(le.stopPropagation(),g)return;K.current=!1;const me=le.currentTarget.value;Z(me),d||o==null||o(n,me)},tr=()=>{g||d&&ie===z||o==null||o(n,ie)},Yn=le=>{if(le.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ie);return}const me=window.prompt("文件路径",ie);me!=null&&(Z(me),o==null||o(n,me))},Tr=le=>{le.stopPropagation(),de(me=>!me)},kn=le=>{if(Me(le),a==null||a(n,le),l){const me=hU(E,le);(me.length!==E.length||me.some((tt,rt)=>{var zt;return tt.id!==((zt=E[rt])==null?void 0:zt.id)}))&&l(n,me)}},nr=le=>{if(le.stopPropagation(),g)return;const me=le.target.value;d||H.current?Me(me):kn(me)},pr=le=>{le.stopPropagation(),!g&&(H.current=!0,Ce(!0))},hr=le=>{if(le.stopPropagation(),g)return;H.current=!1,Ce(!1);const me=le.currentTarget.value;d?Me(me):kn(me)},fn=()=>{g||(H.current=!1,Ce(!1),!(d&&pe===F)&&kn(pe))},zn=le=>{le.stopPropagation(),le.preventDefault(),!g&&Re(!0)},ss=()=>{Re(!1),fn()},Ds=le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),ss())},vn=m.useCallback(le=>{const me=ue.current;if(!me)return;const tt=Math.max(0,me.scrollHeight-me.clientHeight);me.scrollTop=Math.min(1,Math.max(0,le))*tt,ot()},[ot]),Gn=m.useCallback((le,me=0)=>{const tt=te.current;if(!tt)return 0;const rt=tt.getBoundingClientRect(),zt=We.height/100*rt.height,Rn=Math.max(1,rt.height-zt);return(le-rt.top-me)/Rn},[We.height]),bs=m.useCallback(le=>{var Ut,Yt;if(!We.visible)return;le.preventDefault(),le.stopPropagation();const me=te.current;if(!me)return;const tt=me.getBoundingClientRect(),rt=We.top/100*tt.height,zt=We.height/100*tt.height,jr=le.clientY>=tt.top+rt&&le.clientY<=tt.top+rt+zt?le.clientY-tt.top-rt:zt/2;vn(Gn(le.clientY,jr));const Nr=le.pointerId;(Yt=(Ut=le.currentTarget).setPointerCapture)==null||Yt.call(Ut,Nr);const mr=Xn=>{Xn.preventDefault(),vn(Gn(Xn.clientY,jr))},ut=()=>{window.removeEventListener("pointermove",mr),window.removeEventListener("pointerup",ut),window.removeEventListener("pointercancel",ut)};window.addEventListener("pointermove",mr),window.addEventListener("pointerup",ut),window.addEventListener("pointercancel",ut)},[Gn,We.height,We.top,We.visible,vn]),Jn=async le=>{if(g)return;const me=await RT({files:le,body:pe,images:E});me&&(Me(me.body),a==null||a(n,me.body),l==null||l(n,me.images))},Bn=(le,me)=>{if(le.stopPropagation(),g)return;const tt=E.filter(zt=>zt.id!==me.id),rt=xU(pe,me.label);Me(rt),a==null||a(n,rt),l==null||l(n,tt)},vr=le=>{if(g)return;const me=IT(le);me.length!==0&&(le.preventDefault(),le.stopPropagation(),Jn(me).catch(()=>{}))},Sr=le=>{if(g)return;const me=vd(le);me.length!==0&&(le.preventDefault(),le.stopPropagation(),Jn(me).catch(()=>{}))},Hn=()=>{const le=ue.current,me=G.current;!le||!me||(me.scrollTop=le.scrollTop,me.scrollLeft=le.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(B?" af-flow-node--provide-text":"")+(O?" af-flow-node--provide-password":"")+" af-flow-node--"+y.replace(/[^a-z0-9_-]/g,""),"data-schema":y,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${$}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:$}),!b&&ke&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:Xt,onChange:Fn,onPointerDown:tn,onMouseDown:tn,onClick:tn,"aria-label":f("flow:node.model"),title:at||f("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Ft&&i.jsx("option",{value:re,children:re}),kt.length>0&&i.jsx("optgroup",{label:"Cursor",children:kt.map(le=>i.jsx("option",{value:`cursor:${_s(le)}`,children:_s(le)},`c-${le}`))}),$t.length>0&&i.jsx("optgroup",{label:"OpenCode",children:$t.map(le=>i.jsx("option",{value:`opencode:${_s(le)}`,children:_s(le)},`o-${le}`))}),ze.length>0&&i.jsx("optgroup",{label:"Codex",children:ze.map(le=>i.jsx("option",{value:`codex:${_s(le)}`,children:_s(le)},`codex-${le}`))}),ye.length>0&&i.jsx("optgroup",{label:"Claude Code",children:ye.map(le=>i.jsx("option",{value:`claude-code:${_s(le)}`,children:_s(le)},`cc-${le}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),j==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&P&&!R&&!B&&!A&&!O&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Pe,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:ne,"aria-label":f("flow:node.deleteNode"),title:f("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:p.map((le,me)=>{if(le.showOnNode===!1)return null;const tt=f("flow:node.inputTooltip",{name:le.name||`#${me}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),rt=le.name||`#${me+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[rt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${me}`,className:"af-flow-node__handle",style:{background:An(le.type)},title:tt})]},`in-${me}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[R?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(V?" af-flow-node__bool-select--true":""),value:V?"true":"false",onChange:et,onPointerDown:tn,onMouseDown:tn,onClick:tn,"aria-label":"Boolean value",title:V?"true":"false",disabled:g,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):B?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ie,onChange:qe,onCompositionStart:It,onCompositionEnd:vt,onBlur:tr,onPointerDown:tn,onMouseDown:tn,onClick:tn,placeholder:"输入文本",rows:2,readOnly:g}):A?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ie,onChange:qe,onCompositionStart:It,onCompositionEnd:vt,onBlur:tr,placeholder:"选择或输入文件路径",title:ie||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:Yn,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):O?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ce?"text":"password",value:ie,onChange:qe,onCompositionStart:It,onCompositionEnd:vt,onBlur:tr,placeholder:"输入密码或密钥",title:ce?ie:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:Tr,"aria-label":ce?"隐藏密码":"预览密码",title:ce?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ce?"visibility_off":"visibility"})})]}):M?i.jsxs("div",{ref:ee,className:"af-flow-node__prompt-stack nodrag"+(Ne?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:bU(pe)+`
99
- `}}),i.jsx("textarea",{ref:ue,className:"af-flow-node__prompt-editor nodrag",value:pe,onChange:nr,onCompositionStart:pr,onCompositionEnd:hr,onBlur:fn,onPaste:vr,onDrop:Sr,onScroll:le=>{Hn(),ot()},onPointerDown:tn,onMouseDown:tn,onClick:tn,onKeyDown:tn,onDragOver:le=>{vd(le).length>0&&le.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:tn,onMouseDown:tn,onClick:zn,"aria-label":"放大编辑",title:"放大编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsx("div",{ref:te,className:"af-flow-node__prompt-scrollbar"+(We.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:bs,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${We.height}%`,top:`${We.top}%`}})})]}):null,M&&E.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:E.map((le,me)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:le.name,children:[i.jsx("img",{src:le.dataUrl,alt:""}),i.jsxs("span",{children:["[",le.label||`image ${me+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:tt=>Bn(tt,le),onPointerDown:tn,onMouseDown:tn,"aria-label":`删除 ${le.label||`image ${me+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},le.id||me))}):null,W?i.jsx("span",{className:"af-flow-node__prompt-preview",title:W,children:W}):null,Q?null:i.jsx("span",{className:"af-flow-node__body-title",title:$,children:$})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:h.map((le,me)=>{if(le.showOnNode===!1)return null;const tt=f("flow:node.outputTooltip",{name:le.name||`#${me}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),rt=le.name||`#${me+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[rt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${me}`,className:"af-flow-node__handle",style:{background:An(le.type)},title:tt})]},`out-${me}`)})})]}),yt?lr.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,onWheel:tn,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:$}),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:ss,"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:pe,onChange:nr,onCompositionStart:pr,onCompositionEnd:hr,onPaste:vr,onDrop:Sr,onKeyDown:Ds,onDragOver:le=>{vd(le).length>0&&le.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const Sc="flowNode";function mb(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 SU={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","Load Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_react_app:["React App"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function jU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(SU[e]||[]).includes(s)?r:s}const NU={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"])},CU={control_cd_workspace:new Set(["mode","label","workspaceContext","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},_U={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},EU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function AU(e,t){if(!EU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function PU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function IU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function TT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function RU(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:TT(t):""}function MU(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[RU(t,n),TT(s),...o].join(" ")}return String(t.command||"").trim()}function gC(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,d,f;const o=n[s],l=n.find(p=>(p==null?void 0:p.name)&&p.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=NU[e])==null?void 0:u.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...!r._showOnNodeExplicit&&AU(e,r)?{showOnNode:!0}:{},...(d=_U[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=CU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function $U(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=mb(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 gb(e,t,n,r,s){var $,W,E,Q,K,H,ee,ue,G,te,se,ie,Z,ce,de,pe,Me,Ne,Ce,We,ct,yt;const o=(($=e.data)==null?void 0:$.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Re=>Re.id===o),l=t[e.id];let c=[],u=[],d=((W=e.data)==null?void 0:W.label)??e.id,f,p,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(mb)),Array.isArray(l.output)&&(u=l.output.map(mb)),l.label&&(d=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=f??(typeof((E=e.data)==null?void 0:E.role)=="string"?e.data.role:"普通"),k=p??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=x!==""?x:void 0,S=h??((K=e.data)==null?void 0:K.body)??"",C=Array.isArray(y)?y:Array.isArray((H=e.data)==null?void 0:H.images)?e.data.images:[],P=MU(a),R=v!==void 0?v:((ee=e.data)==null?void 0:ee.script)!=null?String(e.data.script):P,B=String(e.id),A=(ue=r==null?void 0:r[s])==null?void 0:ue[B],O=(G=A==null?void 0:A.label)==null?void 0:G.label,D=A==null?void 0:A.body,L=A==null?void 0:A.description;b||(c.length===0&&((te=a==null?void 0:a.inputs)!=null&&te.length)&&(c=a.inputs.map(Re=>({...Re}))),u.length===0&&((se=a==null?void 0:a.outputs)!=null&&se.length)&&(u=a.outputs.map(Re=>({...Re}))));const M=IU(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((ie=e.data)==null?void 0:ie.marketplaceRef)||PU(a);if(M==="agent_subAgent"&&!u.some(Re=>(Re==null?void 0:Re.name)==="result")){const Re=(Z=a==null?void 0:a.outputs)==null?void 0:Z.find(ot=>(ot==null?void 0:ot.name)==="result");u=[...u,Re?{...Re}:{type:"text",name:"result",default:""}]}if(M==="agent_subAgent"&&!c.some(Re=>(Re==null?void 0:Re.name)==="knowledgeContext")){const Re=(ce=a==null?void 0:a.inputs)==null?void 0:ce.find(ot=>(ot==null?void 0:ot.name)==="knowledgeContext");c=[...c,Re?{...Re}:{type:"text",name:"knowledgeContext",default:"",showOnNode:!0}]}if((M==="display_markdown"||M==="display_mermaid"||M==="display_ascii"||M==="display_chart"||M==="display_table")&&!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(de=a==null?void 0:a.outputs)==null?void 0:de.find(ot=>(ot==null?void 0:ot.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}if(M==="workspace_run"){if(!c.some(Re=>(Re==null?void 0:Re.name)==="prev")){const Re=(pe=a==null?void 0:a.inputs)==null?void 0:pe.find(ot=>(ot==null?void 0:ot.name)==="prev");c=[Re?{...Re}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(Me=a==null?void 0:a.outputs)==null?void 0:Me.find(ot=>(ot==null?void 0:ot.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}}c=gC(M,c,a==null?void 0:a.inputs),u=gC(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(S).trim()!==""&&(u=u.map((Re,ot)=>ot===0?{...Re,default:S,value:S}:Re));const z=jU(M,d,a),F=M==="tool_nodejs"||String(R).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:O||d,displayLabel:z,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...V?{marketplaceRef:V}:{},...l!=null&&l.marketplacePackageId||(Ne=e.data)!=null&&Ne.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Ce=e.data)==null?void 0:Ce.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(We=e.data)!=null&&We.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((ct=e.data)==null?void 0:ct.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((yt=e.data)==null?void 0:yt.schemaType)??e.type??"agent",role:g,model:k,body:D||S,images:C,script:R,inputs:c,outputs:u,description:L||j,originalLabel:d,originalBody:S,...F?{script:R}:{}}}}function LU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var d,f,p,h;const s=n.get(r.source),o=n.get(r.target),a=((f=(d=s==null?void 0:s.data)==null?void 0:d.outputs)==null?void 0:f.length)??0,l=((h=(p=o==null?void 0:o.data)==null?void 0:p.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&c>=0&&c<a&&u>=0&&u<l})}function yC(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 wC(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function pw(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=yC(t==null?void 0:t.sourceHandle,"output"),o=yC(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,d,f,p;if(c.id===n){const h=wC((u=c.data)==null?void 0:u.outputs,s);if(h!==((d=c.data)==null?void 0:d.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=wC((f=c.data)==null?void 0:f.inputs,o);if(h!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function OU(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 xC(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function DU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function FU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Xs({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(FU,{children:t})]},n))})}function zU({open:e,onClose:t}){const{t:n}=Vr(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const o=DU()?"⌘":"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(Xs,{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(Xs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function BU(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 HU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Vr(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const f=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,j;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((j=g.data)==null?void 0:j.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:BU(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const y=(v=d.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=y=>{const v=f[y];v&&(n(v.id),t())},h=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),p(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:y=>y.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:u,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:y=>{a(y.target.value),c(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:d,className:"af-jump-panel__list",role:"listbox",children:f.map((y,v)=>i.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:b=>{b.preventDefault(),p(v)},children:[i.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&i.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.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 bC(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=s=>String(s).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function WU(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),s=n%60;return`${r}m${String(s).padStart(2,"0")}s`}function kC(e){if(!e||typeof e!="object")return"";if(e.line)return String(e.line);if(e.text)return String(e.text);if(e.error)return String(e.error);if(e.message)return String(e.message);if(e.status)return String(e.status);if(e.type==="graph"){const n=Array.isArray(e.displayNodeIds)?e.displayNodeIds.join(", "):"";return n?`graph updated: ${n}`:"graph updated"}const t=JSON.stringify(e);return t.length>4e3?`${t.slice(0,4e3)}
100
- ... [truncated]`:t}function hw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function vC(e){const t=String(e||"").toLowerCase();return t.includes("success")?"success":t.includes("fail")||t.includes("error")?"failed":t.includes("skip")||t.includes("disabled")?"skipped":t.includes("running")?"running":t.includes("stop")?"stopped":"idle"}function VU({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(null),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),j=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const R=new URLSearchParams;R.set("flowId",e.flowId),R.set("flowSource",e.flowSource||"user"),t?R.set("scheduleNodeId",t):n&&R.set("runNodeId",n),R.set("limit","80");const B=await fetch(`/api/workspace/run-logs?${R.toString()}`),A=await B.json().catch(()=>({}));if(!B.ok)throw new Error(A.error||"读取日志失败");const O=Array.isArray(A.runs)?A.runs:[];l(O),u(D=>{const L=O[0]||null;return L&&String(L.status||"")==="running"&&L.runId!==D?L.runId:D&&O.some(M=>M.runId===D)?D:r&&O.some(M=>M.runId===r)?r:(L==null?void 0:L.runId)||""})}catch(R){g(String(R.message||R)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),S=m.useCallback(async R=>{if(!R){f(null);return}v(!0);try{const B=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&B.set("archived","1");const A=await fetch(`/api/workspace/run-logs/${encodeURIComponent(R)}?${B.toString()}`),O=await A.json().catch(()=>({}));if(!A.ok)throw new Error(O.error||"读取日志详情失败");f(O)}catch(B){f({error:String(B.message||B),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{j()},[j]),m.useEffect(()=>{S(c)},[S,c]),m.useEffect(()=>{const R=a.find(A=>A.runId===c),B=window.setInterval(()=>{j(),(!R||R.status==="running")&&c&&S(c)},2e3);return()=>window.clearInterval(B)},[S,j,a,c]);const C=m.useMemo(()=>{const R=Array.isArray(d==null?void 0:d.events)?d.events:[],B=k.trim().toLowerCase();return B?R.filter(A=>String(A.type||"").toLowerCase().includes(B)||hw(A).toLowerCase().includes(B)||kC(A).toLowerCase().includes(B)):R},[d==null?void 0:d.events,k]),P=(d==null?void 0:d.run)||a.find(R=>R.runId===c)||null;return i.jsxs("div",{className:"af-work-run-logs",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:o,"aria-label":"关闭日志侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-logs__meta",children:[i.jsx("span",{children:s||t||n||"Workspace Run"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void j(),title:"刷新日志","aria-label":"刷新日志",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?i.jsx("div",{className:"af-work-run-logs__error",children:b}):null,i.jsxs("div",{className:"af-work-run-logs__body",children:[i.jsxs("div",{className:"af-work-run-logs__list",children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),p?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!p&&a.length===0?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(R=>i.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(R.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(R.runId),title:R.runId,children:[i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${vC(R.status)}`,children:R.status||"unknown"}),i.jsx("span",{className:"af-work-run-logs__run-label",children:R.label||R.runNodeId||R.scheduleNodeId||"Workspace Run"}),i.jsx("span",{children:bC(R.startedAt)}),i.jsx("span",{children:WU(R.durationMs)})]},R.runId))]}),i.jsxs("div",{className:"af-work-run-logs__detail",children:[i.jsxs("div",{className:"af-work-run-logs__detail-head",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),P!=null&&P.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:P.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(P==null?void 0:P.runId)||"-"})]}),P?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${vC(P.status)}`,children:P.status}):null]}),i.jsxs("label",{className:"af-work-run-logs__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:k,onChange:R=>x(R.target.value),placeholder:"搜索事件、节点、错误"})]}),y?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,d!=null&&d.error?i.jsx("div",{className:"af-work-run-logs__error",children:d.error}):null,!y&&!C.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:C.map((R,B)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:bC(R.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:R.type||"event"}),hw(R)?i.jsx("span",{className:"af-work-run-logs__event-node",children:hw(R)}):null,i.jsx("pre",{children:kC(R)})]},`${R.ts||B}-${B}`))})]})]})]})}function KU(e){let t=String(e||"").trim();const n=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*?)```/i);if(n&&n[1])t=n[1].trim();else{const r=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*)$/i);r&&r[1]&&(t=r[1].trim())}return t.replace(/```\s*$/g,"").trim()}function MT(e){const t=KU(e);if(!t)return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":"export default function App() { return <main><h1>React App</h1><p>No project files yet.</p></main>; }"},inputs:{}};try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.files&&typeof n.files=="object"&&!Array.isArray(n.files)?n.files:{};return{title:String(n.title||n.name||"React App"),entry:String(n.entry||n.main||"src/App.jsx"),files:Object.fromEntries(Object.entries(r).map(([s,o])=>[String(s),String(o??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function qU(e){let t=String(e||"");return t=t.replace(/^\s*import\s+[^;]+;\s*$/gm,""),t=t.replace(/^\s*import\s+["'][^"']+["'];\s*$/gm,""),t=t.replace(/\bexport\s+default\s+function\s+([A-Za-z_$][\w$]*)\s*\(/g,"const __AgentFlowDefault = function $1("),t=t.replace(/\bexport\s+default\s+function\s*\(/g,"const __AgentFlowDefault = function App("),t=t.replace(/\bexport\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends/g,"const __AgentFlowDefault = class $1 extends"),t=t.replace(/\bexport\s+default\s+class\s+extends/g,"const __AgentFlowDefault = class extends"),t=t.replace(/\bexport\s+default\s+(\([^)]*\)\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/g,"const __AgentFlowDefault = $1;"),t=t.replace(/\bexport\s+(const|let|var|function|class)\s+/g,"$1 "),t=t.replace(/^\s*export\s+\{[^}]+\};?\s*$/gm,""),t.trim()}function UU(e){return String(e).replace(/<\/script/gi,"<\\/script")}function yg(e){const t=MT(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function kv(e,t=""){const n=MT(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(p=>/(?:^|\/)App\.[jt]sx$/i.test(p))||Object.keys(r).find(p=>/\.[jt]sx?$/i.test(p))||n.entry,o=qU(r[s]||""),a=Object.entries(r).filter(([p])=>/\.css$/i.test(p)).map(([,p])=>String(p||"")).join(`
101
-
102
- `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),d=UU(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
103
- * { box-sizing: border-box; }
104
- body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
105
- main { min-height: 100vh; padding: 24px; }
106
- button, input, select, textarea { font: inherit; }
107
- `;return`<!doctype html>
108
- <html>
109
- <head>
110
- <meta charset="utf-8" />
111
- <meta name="viewport" content="width=device-width, initial-scale=1" />
112
- <base target="_blank" />
113
- <title>${l.replace(/[<&>]/g,p=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[p])}</title>
114
- <style>${f.replace(/<\/style/gi,"<\\/style")}</style>
115
- </head>
116
- <body>
117
- <div id="root"></div>
118
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
119
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
120
- <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
121
- <script>
122
- window.AGENTFLOW_INPUTS = ${u};
123
- window.addEventListener("error", (event) => {
124
- const root = document.getElementById("root");
125
- if (root && !root.__agentflowRendered) {
126
- root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'&lt;','>':'&gt;','&':'&amp;'}[ch])) + '</pre>';
127
- }
128
- });
129
- document.addEventListener("click", (event) => {
130
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
131
- if (!link) return;
132
- const rawHref = String(link.getAttribute("href") || "").trim();
133
- if (!rawHref || rawHref.startsWith("#")) return;
134
- if (/^javascript:/i.test(rawHref)) {
135
- event.preventDefault();
136
- return;
137
- }
138
- event.preventDefault();
139
- window.open(link.href, "_blank", "noopener,noreferrer");
140
- }, true);
141
- <\/script>
142
- <script type="text/babel">
143
- const { useCallback, useEffect, useMemo, useRef, useState } = React;
144
- ${d}
145
- const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
146
- return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
147
- });
148
- ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
149
- document.getElementById("root").__agentflowRendered = true;
150
- <\/script>
151
- <script>
152
- (() => {
153
- const frameId = ${c};
154
- const postSize = () => {
155
- const doc = document.documentElement;
156
- const body = document.body;
157
- const height = Math.ceil(Math.max(
158
- doc ? doc.scrollHeight : 0,
159
- doc ? doc.offsetHeight : 0,
160
- doc ? doc.clientHeight : 0,
161
- body ? body.scrollHeight : 0,
162
- body ? body.offsetHeight : 0,
163
- body ? body.clientHeight : 0,
164
- window.innerHeight || 0
165
- ));
166
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
167
- };
168
- window.addEventListener("load", postSize);
169
- window.addEventListener("resize", postSize);
170
- requestAnimationFrame(postSize);
171
- setTimeout(postSize, 300);
172
- setTimeout(postSize, 1000);
173
- if (typeof ResizeObserver !== "undefined") {
174
- const resizeObserver = new ResizeObserver(postSize);
175
- resizeObserver.observe(document.documentElement);
176
- if (document.body) resizeObserver.observe(document.body);
177
- }
178
- })();
179
- <\/script>
180
- </body>
181
- </html>`}const $T=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),YU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function GU(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 JU(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 SC(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 LT(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($T.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 OT(e){return{inputNames:SC(e==null?void 0:e.inputs),outputNames:SC(e==null?void 0:e.outputs)}}function XU(e,t,n){const r=OT(t),s=JU(e),o=[];for(const a of s)if(!LT(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 QU(e,t){const n=OT(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=LT(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 ZU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function eY(e){return e.map(t=>{const n=ZU(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 tY(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 YU)$T.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function nY(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 rY(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),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function Bp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:d}=Vr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),j=m.useMemo(()=>bo(c),[c]),S=m.useMemo(()=>XU(e,a,d),[e,a,d]),C=S.length>0,P=m.useMemo(()=>QU(e,a),[e,a]),R=m.useMemo(()=>eY(P),[P]),B=m.useMemo(()=>n?null:GU(e,y),[e,y,n]),A=m.useMemo(()=>{if(!B)return[];const z=tY(a,d);return nY(z,B.query)},[B,a,d]);m.useEffect(()=>{g(z=>{const F=Math.max(0,A.length-1);return Math.min(Math.max(0,z),F)})},[A.length]);const O=m.useCallback(()=>{const z=p.current;if(!z||!B||A.length===0){x(null);return}const F=rY(z,y);if(!F){x(null);return}const $=4,W=44,E=13.5*16,Q=Math.min(A.length*W+8,E);let K=F.bottom+$;K+Q>window.innerHeight-8&&(K=Math.max(8,F.top-Q-$));const H=288;let ee=F.left;ee=Math.max(8,Math.min(ee,window.innerWidth-H-8)),x({top:K,left:ee})},[B,A.length,y]);m.useLayoutEffect(()=>{if(!B||A.length===0){x(null);return}const z=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(z)},[B,A.length,y,e,O]),m.useEffect(()=>{if(!B||A.length===0)return;const z=()=>O();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[B,A.length,O]);const D=m.useCallback(z=>{if(!B)return;const{atIndex:F}=B,$=e.slice(0,F)+"${"+z+"}"+e.slice(y);t($);const W=F+z.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),v(W)})},[B,e,y,t]),L=m.useCallback(()=>{const z=p.current,F=h.current;!z||!F||(F.scrollTop=z.scrollTop,F.scrollLeft=z.scrollLeft,B&&A.length>0&&queueMicrotask(()=>O()))},[B,A.length,O]),M=m.useCallback(z=>{if(!n&&B&&A.length>0&&(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="Enter")){if(z.key==="ArrowDown")z.preventDefault(),g(F=>(F+1)%A.length);else if(z.key==="ArrowUp")z.preventDefault(),g(F=>(F-1+A.length)%A.length);else if(z.key==="Enter"&&!z.shiftKey){z.preventDefault();const F=A[b];F&&D(F.insert)}}},[n,B,A,b,D]),V=m.useCallback(async z=>{if(n||typeof u!="function")return!1;const F=await RT({files:z,body:e,images:j});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=p.current;if(!$)return;$.focus();const W=F.body.length;$.setSelectionRange(W,W),v(W)}),!0):!1},[n,j,t,u,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((z,F)=>i.jsxs("span",{className:"af-body-image-chip",title:z.name,children:[i.jsx("img",{src:z.dataUrl,alt:""}),i.jsxs("span",{children:["[",z.label||`image ${F+1}`,"]"]})]},z.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
182
- `}}),i.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?f:void 0,onChange:z=>{t(z.target.value),v(z.target.selectionStart??z.target.value.length)},onSelect:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:z=>{const F=IT(z);F.length!==0&&(z.preventDefault(),V(F).catch(()=>{}))},onDragOver:z=>{vd(z).length>0&&z.preventDefault()},onDrop:z=>{const F=vd(z);F.length!==0&&(z.preventDefault(),V(F).catch(()=>{}))},onScroll:L})]}),B&&A.length>0&&k?lr.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":d("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:A.map((z,F)=>i.jsx("li",{role:"option","aria-selected":F===b,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===b?" af-composer-mention-item--active":""),onMouseDown:$=>$.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(z.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${z.insert}}`}),z.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:z.subtitle}):null]})},`${z.section}-${z.insert}`))}),document.body):null,C?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:S.map(z=>z.message).join(" · ")}):null]})}const sY=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function zu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function jC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Vr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),u=(f,p,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[p]:h};return p==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},d=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:d})}),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((f,p)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${d}-${p}`,children:[d,"-",p]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(p,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:p})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{o||u(p,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>u(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${d}-${p}`))]}):null]})}function iY({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:d,ioSlots:f}){const{t:p}=Vr(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(L=>{t(M=>M&&{...M,...L})},[t]),{cursorList:j,opencodeList:S,claudeCodeList:C,codexList:P,currentNotInLists:R}=m.useMemo(()=>{const L=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],M=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],V=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],z=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...L,...M,...V,...z].map(zu)),$=((e==null?void 0:e.model)??"").trim(),W=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,E=$&&!F.has(W)?$:"";return{cursorList:L,opencodeList:M,claudeCodeList:V,codexList:z,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const B=String(e.script??""),A=n==="tool_nodejs"||B.trim()!=="",O=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(O){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const L=await c(e,n);k({status:"success",message:L!=null&&L.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(L){k({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:p("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!O||g.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[d?i.jsx("p",{className:"af-err af-node-props-err",children:d}):null,g.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("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:[p("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:p("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":p("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:[p("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:[p("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Zd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:Zd.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:[p("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?R||L:""})(),onChange:L=>x({model:L.target.value}),disabled:o,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?i.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map(L=>i.jsx("option",{value:zu(L),children:L},`c-${L}`))}):null,S.length>0?i.jsx("optgroup",{label:"OpenCode",children:S.map(L=>i.jsx("option",{value:`opencode:${zu(L)}`,children:L},`o-${L}`))}):null,P.length>0?i.jsx("optgroup",{label:"Codex",children:P.map(L=>i.jsx("option",{value:`codex:${zu(L)}`,children:L},`codex-${L}`))}):null,C.length>0?i.jsx("optgroup",{label:"Claude Code",children:C.map(L=>i.jsx("option",{value:`claude-code:${zu(L)}`,children:L},`cc-${L}`))}):null]})]}),i.jsx(jC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!u}),i.jsx(jC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>x({outputs:L}),disabled:o,requiredReadonly:!u}),A?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:[p("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Bp,{value:B,onChange:L=>x({script:L}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,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:p("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Bp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&b(!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:p("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Bp,{value:B,onChange:L=>x({script:L}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&y(!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:p("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Bp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function oY({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Vr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||d)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.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:g=>g.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:b,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:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),p?i.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||d,children:o(d?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function aY({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Vr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),b(""),y(!1);const j=requestAnimationFrame(()=>{var S;return(S=d.current)==null?void 0:S.focus()});return()=>cancelAnimationFrame(j)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(j){if(j.preventDefault(),!k||h)return;y(!0),b("");let S=null;try{const C=new AbortController;S=setTimeout(()=>C.abort(),15e3);const P=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:s,workspaceId:o}),signal:C.signal}),R=await P.json().catch(()=>({}));if(!P.ok){b(typeof R.error=="string"?R.error:c("project:deleteModal.deleteFailed"));return}try{for(let B=localStorage.length-1;B>=0;B--){const A=localStorage.key(B);A&&(A.startsWith(`af:composer-sessions:${n}:${r}`)||A.startsWith(`af:composer-active-session:${n}:${r}`)||A.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(A)}}catch{}await l()}catch(C){if((C==null?void 0:C.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((C==null?void 0:C.message)||C))}finally{S&&clearTimeout(S),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.currentTarget&&t()},children:i.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:j=>j.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("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:x,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:j=>p(j.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?i.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const NC=80,lY=220;function cY(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 uY(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Hp(e,t,n){const r={nodes:Array.isArray(e)?e.map(cY):[],edges:Array.isArray(t)?t.map(uY):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function mw(e,t){const n=[...e,t];return n.length>NC?n.slice(n.length-NC):n}function dY({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(S=>S+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=m.useCallback(()=>{v();const S=d.current,C=f.current;return d.current=null,f.current=null,!S||!C||S.signature===C.signature?(C&&(u.current=C),!1):(l.current=mw(l.current,S),c.current=[],u.current=C,y(),!0)},[y,v]),g=m.useCallback((S=[],C=[],P={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Hp(S,C,P),h.current=!1,y()},[y,v]),k=m.useCallback(S=>{h.current=!0,u.current=S,d.current=null,f.current=null,v(),s==null||s(S.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const S=u.current||Hp(e,t,n),C=l.current.pop();return C?(c.current=mw(c.current,S),k(C),!0):(y(),!1)},[y,t,n,b,e,k]),j=m.useCallback(()=>{b();const S=u.current||Hp(e,t,n),C=c.current.pop();return C?(l.current=mw(l.current,S),k(C),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const S=Hp(e,t,n);if(!u.current){u.current=S;return}if(h.current){h.current=!1,u.current=S;return}S.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=S,v(),p.current=window.setTimeout(()=>{b()},lY))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:j,version:o}}function mo(e){return String(e??"").trim()}function CC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(mo(e).toLowerCase())}function fY(e){return e===!1?!0:["false","no","not_required","waived"].includes(mo(e).toLowerCase())}function pY(e,t=""){return mo((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||t)}function DT(e){return mo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function FT(e){return DT(e)==="all"}function hY(e,t=[]){const n=mo((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=DT(e),s=pY(e);if(!s||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!s.endsWith(o))return"";const a=s.slice(0,-o.length);return new Set(t.map(l=>mo(l))).has(a)?a:""}function hm(e){const t=mo(e==null?void 0:e.label).toLowerCase(),n=mo((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function mY(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[hm(n)]-t[hm(r)])}function gY(e){const t=mo((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function yY(e,t=[]){if(FT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(hm);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return CC(e==null?void 0:e.implementationNotRequired)||CC(e==null?void 0:e.implementation_not_required)||fY(r)?{kind:"not-required",label:gY(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function yb(e=[]){return e.reduce((t,n)=>t+1+yb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function ur(e){return String(e||"").trim()}function Ho(e){return ur(e).toLowerCase()}function mm(e){return typeof e=="string"?Ho(e):!e||typeof e!="object"||Array.isArray(e)?"":Ho(e.kind||e.type||e.persistence||e.durability)}function zT(e,t="http://localhost"){const n=ur(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function BT(e={}){const t=ur(e.href||e.url);if(!t)return!1;const n=Ho(e.kind||e.type),r=Ho(e.durability),s=Ho(e.persistence),o=Ho(e.truth||e.stateTruth||e.state_truth),a=Ho(e.authority),l=mm(e.source)||mm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(ur).join(" "),u=[e.label,e.title,n,s,a,l,t].map(ur).join(" ");if(r==="temporary"||s==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const p=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function HT(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(ur).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function wY(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=ur(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(ur(t)?ur(t):HT(e)==="tech-design"&&ur(n)?ur(n):ur(e.title||e.label))}function xY(e={},t="http://localhost"){const n=ur(e.issueKey||e.issue_key||e.issue),r=HT(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=ur(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${zT(e.href||e.url,t)}`}function _C(e={}){const t=ur(e.href||e.url),n=Ho(e.kind||e.type),r=mm(e.source)||mm(e.sourceArtifact||e.source_artifact),s=ur(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(s)||(o+=10),o}function bY(e,t){const n=_C(t)>_C(e)?t:e,r=n===t?e:t;return{...r,...n,title:EC(e.title)>=EC(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function EC(e){const t=ur(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function gw(e,t){const n=new Map,r=[];for(const s of e){const o=t(s);if(!o){r.push(s);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(s);continue}r[a]=bY(r[a],s)}return r}function kY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>BT(o)),r=gw(n,o=>zT(o.href||o.url,t)),s=gw(r,o=>ur(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return gw(s,o=>xY(o,t))}function Pt(e){return String(e||"").trim()}function go(e){return typeof e=="string"?Pt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Pt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function uc(e){return Pt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function WT(e){return Pt((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function VT(e){const t=Pt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function vY(e){const t=Pt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function SY(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Pt(e.issueKey||e.issue_key||e.issue),n=Pt(e.action||e.actionId||e.action_id),r=Pt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),s=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Pt(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(s)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function jY(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Pt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Pt(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Pt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",s=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||s===!1)}function Hc(e){const t=uc(e);if(/^prd-review:/i.test(t)||Pt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(WT(e)))return!0;const n=Pt((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=Pt(e==null?void 0:e.durability).toLowerCase(),o=go(e==null?void 0:e.source)||go((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||s==="temporary"||s==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function AC(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,go(e==null?void 0:e.source)].map(Pt).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function PC(e){const t=[],n=uc(e);if(n&&t.push(`key:${n}`),Hc(e)){const s=VT(WT(e));s&&t.push(`review:${s}`)}const r=vY((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Pt(e==null?void 0:e.label)}
183
- ${r}`),t}function NY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=PC(r),o=s.map(h=>n.get(h)).find(h=>h!=null);if(o==null){s.forEach(h=>n.set(h,t.length)),t.push(r);continue}const a=t[o],l=AC(r)>=AC(a)?Pt(r==null?void 0:r.label)||Pt(a==null?void 0:a.label):Pt(a==null?void 0:a.label)||Pt(r==null?void 0:r.label),c=!!uc(a),u=!!uc(r),d=c&&!u?a:r,f=d===a?r:a,p=uc(d)&&!uc(f)&&Pt(d==null?void 0:d.label)||l;t[o]={...f,...d,...p?{label:p}:{}},PC(t[o]).forEach(h=>n.set(h,o))}return t}function KT(e){const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.durability).toLowerCase(),r=Pt(e==null?void 0:e.persistence).toLowerCase(),s=go(e==null?void 0:e.source)||go((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Pt).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function CY(e){if(!Hc(e)||KT(e))return!1;const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.durability).toLowerCase(),r=Pt(e==null?void 0:e.persistence).toLowerCase(),s=go(e==null?void 0:e.source)||go((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Pt).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function _Y(e){if(Hc(e))return!1;const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.persistence).toLowerCase(),r=go(e==null?void 0:e.source)||go((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(Pt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function EY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Pt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function AY(e=[],t={}){const n=NY(Array.isArray(e)?e:[]);if(!EY(t))return n;const r=n.filter(Hc);if(r.length===0)return n;const s=r.filter(CY),a=s.length>0||n.some(_Y)?s.at(-1):r.filter(KT).at(-1);return n.filter(l=>!Hc(l)||l===a)}function Ei(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Pt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=VT(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const d=Pt(a.path);return d&&l.push(`path:${d}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=s(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(d=>r.set(d,u));return}n[c]=a,s(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function Gr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function gm(e){return Array.isArray(e)?e.map(gm):Gr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,gm(e[t])])):e}function oo(e,t){return JSON.stringify(gm(e))===JSON.stringify(gm(t))}function qT(e){return Gr(e==null?void 0:e.instances)?e.instances:{}}function tf(e){return Gr(e==null?void 0:e.ui)?e.ui:{}}function Wp(e,t){if(!Gr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function PY(e,t){if(!Gr(e)||!Gr(t)||!Gr(e.instances)||!Gr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!Gr(e.ui)||!Gr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Wp(e,["version","instances","edges","ui"]),r=Wp(t,["version","instances","edges","ui"]);if(!oo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return oo(Wp(e.ui,s),Wp(t.ui,s))}function UT(e){const t=Array.isArray(tf(e).groups)?tf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function IC(e){const t=new Set(Object.keys(qT(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of UT(e).keys())t.add(n);return t}function RC(e,t){const n=qT(e),r=tf(e),s=UT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:Gr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:Gr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function TC(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),s=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(s)})}function IY(e,t){if(!PY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...IC(e),...IC(t)]),r=Array.from(n).filter(s=>!oo(RC(e,s),RC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!oo(TC(e),TC(t)),displayPageChanged:!oo(tf(e).displayPage||null,tf(t).displayPage||null)}}function RY(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!s.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function MC(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function $C(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function TY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[MC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(MC(r));return s?oo($C(s),$C(r))?s:{...r,selected:s.selected===!0}:r})}function MY(e,t,n){const r=Gr(e)?e:{},s=Gr(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(s).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function $Y({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:s=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==s||l!==a)?"local-edits":""}function LY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function YT(e=[]){let t=!1,n=!1,r=!1;for(const s of Array.isArray(e)?e:[]){if((s==null?void 0:s.type)==="position"&&s.position){r=!0,s.dragging===!0&&(t=!0),s.dragging===!1&&(n=!0);continue}if((s==null?void 0:s.type)==="dimensions"&&s.dimensions){r=!0,s.resizing===!0&&(t=!0),s.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(s==null?void 0:s.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function OY({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function DY(e=[]){const t=YT(e);return t.mutated&&!t.active}function FY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function zY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function BY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(FY(s)){t.push(s);continue}n.push(s),zY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function wb(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const s=String((r==null?void 0:r.id)||"").trim();if(!(s&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${s}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function HY(e=[]){return wb(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function LC(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function WY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function VY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const KY="af:workspace-graph:v2",OC="agentflow.workspace.sidebarCollapsed",ql=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],qY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),UY={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:""}]},YY={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:""}]},GY={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}]},JY={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}]},XY={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},QY={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},ZY=new Set(["png","jpg","jpeg","gif","webp","svg"]),GT=320,JT=180,XT=960,ym=96,QT=900,xb=520,bb=320,Vp=52,il=240,ol=160,kb="display-ref:",nf="0 9 * * *",eG="Asia/Shanghai",tG="0.1.134";function nG(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Fr(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),t}function vv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
184
- ...[truncated ${n.length-t} chars]`:n:""}function rG(e){const t=vv(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function Sv(e,t=80){return(Array.isArray(e)?e:[]).map(rG).filter(Boolean).slice(-t)}function sG(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,s]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!s||typeof s!="object")continue;const a=Sv(s.messages,40),l=vv(s.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(s.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function iG(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Sv(t==null?void 0:t.messages,80);if(!r.length)return null;const s=String((t==null?void 0:t.status)||"done");return{id:n,label:vv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function DC(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:Sv(n.messages,100),runSessions:iG(n.runSessions)},nodeChats:sG(t.nodeChats)}}function wm(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 ZY.has(n)}function rf(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=Fr(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function oG(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",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function aG(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${OC}:${t}`:OC}function lG(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function FC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function cG(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 uG(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!cG(e)}function dG(e){const t=String(e||"").trim();if(!t||fG(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 fG(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function pG(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function yw(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),o=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===s):null,a=t&&typeof t=="object"?t[s]:null;return String(((c=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function ww(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function $a(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 zC(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function hG(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function mG(e){const t=hG(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let s="pending";return t>r?s="done":t===r&&(s=r===3?"done":"current"),{label:n,status:s}})}function ZT(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function jc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return ZT(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ga(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function oa(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function jv(e){return ga(e==null?void 0:e.status)==="done"&&oa(e)!=="observation"}function ao(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function Sh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function Nv(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function gG(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(s=>String(s||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function yG(e,t){const n=ao(e,t),r=ga(e==null?void 0:e.status),s=jv(e),a=`${al(e)} ${Nv(e)}`,l=gG(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(s)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||oa(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(s)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||oa(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function wG(e){if(!e||typeof e!="object")return"";const t=ga(e.status),n=oa(e),r=jv(e),o=`${al(e)} ${Nv(e)}`,a=Cv(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const d=Sh(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function xm(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const eM="Asia/Shanghai",xG=new Intl.DateTimeFormat("zh-CN",{timeZone:eM,year:"numeric",month:"2-digit",day:"2-digit"}),bG=new Intl.DateTimeFormat("zh-CN",{timeZone:eM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function tM(e){const t=xm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function kG(e){const t=tM(e);return t?xG.format(t).replace(/\//g,"-"):"无时间"}function vG(e){const t=tM(e);return t?bG.format(t):""}function SG(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=kG(n);let o=t[t.length-1];(!o||o.day!==s)&&(o={day:s,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function nM(e){const t=ga(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function za(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function jG(e){const t=ga(e==null?void 0:e.status);return oa(e)==="observation"&&t==="done"?"已观察":nM(t)}function rM(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=ga(e.status),s=oa(e)==="observation"&&r==="done"?"observed":r;return n("status",nM(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",za(e.platform),e.platform),t}function NG(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{rM(n).forEach(r=>{const s=t.get(r.key);t.set(r.key,{...r,count:((s==null?void 0:s.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const s={status:0,issue:1,platform:2,source:3,actor:4};return(s[n.type]??9)-(s[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function CG(e,t){const n=String(t||"all");return!n||n==="all"?!0:rM(e).some(r=>r.key===n)}function _G(e){if(!e||typeof e!="object")return[];const t=[],n=(r,s)=>{const o=String(s||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",za(e.platform)),t}function Cv(e){const t=[],n=(c,u,d={})=>{const f=ZT(u);f&&t.push({...d,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",d=0)=>{if(d>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((p,h)=>r(p,`${u} ${h+1}`,d+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",jc(c),c);n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const o=c=>{const u=String(c||"").trim();try{const d=new URL(u,window.location.origin);return`${d.origin}${d.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=Hc(c),d=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=d?`key:${d}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
185
- ${c.href}`,p=l.get(f);if(!p){l.set(f,c);continue}if(u){const h=a(p.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(p.label||"").length)&&l.set(f,c)}}return AY(Array.from(l.values()),e)}function EG(e,t=[]){var a,l,c,u;const n=[],r=new Map,s=String(((l=(a=e==null?void 0:e.overall)==null?void 0:a.requirement)==null?void 0:l.title)||((u=(c=e==null?void 0:e.overall)==null?void 0:c.requirement)==null?void 0:u.name)||"").trim();for(const d of vb(e)){const f=Ti(d),p=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();f&&p&&r.set(f,p)}const o=(d,f={})=>{if(!d||typeof d!="object")return;const p=(y,v={})=>{if(!y||typeof y!="object")return;const b=String(f.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),g=y.source||y.sourceArtifact||y.source_artifact||d.sourceArtifact||d.source_artifact||d.source||f.source||null,k=wY({...y,title:y.title||f.documentTitle||(d==null?void 0:d.title)||"",documentTitle:y.documentTitle||y.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(b)||"",requirementTitle:s}),x={label:String(y.label||"ai-doc").trim()||"ai-doc",href:String(y.href||y.url||"").trim(),kind:String(y.kind||y.type||d.kind||d.type||"").trim(),title:k,issueKey:b,platform:f.platform||za(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||oa(d)||f.truth||"",authority:y.authority||d.authority||f.authority||"",confirmed:y.confirmed??d.confirmed??f.confirmed,source:g,documentPath:y.documentPath||y.document_path||y.path||v.documentPath||(g==null?void 0:g.path)||(g==null?void 0:g.documentPath)||(g==null?void 0:g.document_path)||""};x.href&&n.push(x)};for(const y of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:jc(y)},{documentPath:y.path});for(const y of Array.isArray(d==null?void 0:d.links)?d.links:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:jc(y)},{documentPath:y.path});const h=jc(d);h&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:h},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:za(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const f of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(f,{issueKey:String((f==null?void 0:f.issueKey)||(f==null?void 0:f.issue_key)||(f==null?void 0:f.issue)||"").trim(),platform:za(f==null?void 0:f.platform),documentTitle:String((f==null?void 0:f.documentTitle)||(f==null?void 0:f.document_title)||(f==null?void 0:f.title)||"").trim()});for(const d of vb(e))o(d,{issueKey:Ti(d),platform:za(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});return kY(n,window.location.origin)}function AG(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function Ti(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function PG(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||Ti(e,t)||`Issue ${t+1}`).trim()}function IG(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function RG(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function TG(e){const t=Cv(e),n=(s,o)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(s=>{const o=String(s.href||"").trim();if(!o)return!1;const a=`${s.label}
186
- ${o}`;return r.has(a)?!1:(r.add(a),!0)})}function MG(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,s=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=s(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const d of u)d&&typeof d=="object"&&c.issues.push({...d,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)s(IG(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((d,f)=>Ti(d,f));return a.forEach((d,f)=>{const p=Ti(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=Ti(d,f),h=RG(d)||hY(d,u),y=l.get(p);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function bm(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function al(e){return SY(e)}function km(e){const t=xm(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function vb(e){var s,o,a,l,c,u,d,f,p,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(h=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function $G(e,t){const n=String(t||"").trim();return n&&vb(e).find((r,s)=>Ti(r,s)===n)||null}function LG(e){var t,n,r,s,o,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((s=e==null?void 0:e.raw)==null?void 0:s.gitlab_epic)||((a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function OG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=$G(e,n),s=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=s&&!t.platform?{...t,platform:s}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=LG(e);if(!a&&!l)return o;const c=al(o),u=`${c} ${Nv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(s||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=ga(o.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Ei(o.artifacts,f)}}function BC(e,t){const n=km(t),r=km(e),s=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(s==null?void 0:s.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:ao(s,0)||ao(t,0)||ao(e,0),detail:Sh(s)||Sh(t)||Sh(e),status:o,links:Ei(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Ei(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Ei(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Ei(e==null?void 0:e.results,t==null?void 0:t.results),events:Ei(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(s==null?void 0:s.updatedAt)||(s==null?void 0:s.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function DG(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var p,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||jY(f)||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((p=f.conflict)==null?void 0:p.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links:Ei(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:Ei(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:Ei(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:Ei(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],p);return}o.set(f,l(o.get(f)||{},p))},u=(f,p)=>f&&o.has(f)?l(p,o.get(f)):p,d=f=>{if(Array.isArray(f))for(const p of f){const h=al(p);if(a(p)){c(h,p);continue}const y=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,BC(n[b],p)),h&&r.set(h,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(h,p)))}};if(d(e==null?void 0:e.actions),d(e==null?void 0:e.workflowActions),d(e==null?void 0:e.workflow_actions),d(e==null?void 0:e.timeline),d(e==null?void 0:e.history),d(e==null?void 0:e.events),d(e==null?void 0:e.runtimeEvents),d(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=bm(t),p=al(t),h=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=BC(n[h],y))}return n.map((f,p)=>({item:f,index:p,ts:km(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>OG(e,f.item))}function FG(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(s=>s&&typeof s=="object").map((s,o)=>({item:s,index:o,ts:km(s)})).sort((s,o)=>{const a=Number.isFinite(s.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-s.ts||o.index-s.index:a?-1:l?1:o.index-s.index}).slice(0,8).map(s=>s.item)}function zG(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function BG(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)?`(+${$a(r)} / 总 ${$a(s)})`:"";return`${t+1}. ${n}${o}`}function sM(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 Ul(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function HG(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 WG(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 VG(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 KG(e){var o,a,l;const t=sM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Ul(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=WG(t),u=HG(t),d=Ul(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Ul(t.completedAtMs,c==null?void 0:c.completedAtMs),p=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Ul(p.executionTime,p.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),v=y?y.split(`
187
- `).find(Boolean)||y:"";return{kind:"tool",label:VG(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Ul(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 HC(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...s].reverse().find(b=>Number.isFinite(Number(b.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=Ul(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),d=s.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),f=o.filter(b=>(b==null?void 0:b.kind)==="tool"),p=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),h=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...s.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${$a(u)}`),d>0&&v.push(`- 模型相关间隔:约 ${$a(d)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${$a(p)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${$a(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(BG(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${$a(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
188
- `)}function WC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=sM(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 iM(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 oM(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function _v(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function aM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function qG(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 UG(e){const t=String(e??"").trim();return t?t.includes("${")?t:aM(t):""}function lM(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(UG).filter(Boolean):[];return[qG(t,n),aM(o),...a].join(" ")}return String(t.command||"").trim()}function Zu(e){const t=String(_v(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 VC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function vm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ed(e){return vm(e)}function Sb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Kp(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 KC(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 qC(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 xw(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=hb(s.get(n),e.sourceHandle||"output-0","source"),a=hb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&ef(o,a))}function YG(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=hb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:uU(a)}:null}function GG(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"?ef(t.slot,a):ef(a,t.slot)))continue;const c=Zu(n);return{def:n,order:r,category:c,categoryRank:ql.indexOf(c),slot:a,slotIndex:o,displayLabel:ed(n),description:Sb(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 JG(e,t,n){var o,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const d=Array.isArray(s?(o=u.data)==null?void 0:o.inputs:(a=u.data)==null?void 0:a.outputs)?s?u.data.inputs:u.data.outputs:[];for(let f=0;f<d.length;f+=1){const p=d[f];if((p==null?void 0:p.showOnNode)===!1||!(s?ef(n.slot,p):ef(p,n.slot)))continue;const y=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},v=(t||[]).some(b=>b.target===y.target&&b.targetHandle===y.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:p,slotIndex:f,handleId:s?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,d)=>{var v,b,g,k,x,j,S,C;const f=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),p=Number(((k=(g=d.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((j=(x=u.node)==null?void 0:x.position)==null?void 0:j.x)||0),y=Number(((C=(S=d.node)==null?void 0:S.position)==null?void 0:C.x)||0);return f-p||h-y||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function dc(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 XG(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 QG(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function ZG(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return nf;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} * * *`:nf}function Ko(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 Ev(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Ko(t[1],9,0,23)}:${Ko(t[2],0,0,59)}`:"09:00"}function td(e,t,n,r,s){const o=Ev(t),[a,l]=o.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(s||"").trim()||nf:`${l} ${a} * * *`}function eJ(e){const n=String(e||nf).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),u=Number.parseInt(s,10),d=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=d?`${Ko(u,9,0,23)}:${Ko(c,0,0,59)}`:"09:00";return d&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:d&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:d&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function Av(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=ZG(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=eJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Ev(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),d=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=td(l,c,u,d,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:eG,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function tJ(e){const t=Av(JSON.stringify(e||{}));return JSON.stringify(t)}function nJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function rJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function UC(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 qp(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:UC(n.nextRunAt),lastAt:UC(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 Sm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function jm(e){return e>0?`Group ${e+1}`:"Group"}function sJ(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)||jm(r)).trim()||jm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(il,Math.round(l)),height:Math.max(ol,Math.round(c))}}).filter(Boolean)}function iJ(e){var n;return sJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Sc,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 jb(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(il,Math.round(t)),height:Math.max(ol,Math.round(n))}}function nd(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:QG(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 cM(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 oJ(e){var o,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},s=wg(t);return[cM(e),_n(t)||"",s?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function YC(e,t){return!e||!t?!1:e.selected===t.selected&&e.isExecuting===t.isExecuting&&e.nodeStatus===t.nodeStatus&&e.nodeElapsed===t.nodeElapsed&&e.optimizingRun===t.optimizingRun&&e.scheduledRunState===t.scheduledRunState&&e.nodeChatActive===t.nodeChatActive&&e.nodeChat===t.nodeChat}const aJ=new Map,lJ=[];function Bu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=fM(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(y=e==null?void 0:e.ui)!=null&&y.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const v of s)v!=null&&v.source&&l.add(String(v.source)),v!=null&&v.target&&l.add(String(v.target));const u=Array.from(l).map(v=>{const b=r[v]||{},g=b.definitionId||v,k=t.find(D=>D.id===g),x=_v(k)||g,j=t.find(D=>D.id===x)||k,S=b.marketplaceRef||oM(k),C=lM(k),P=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},R=!!_n({definitionId:x,inputs:b.input,outputs:b.output}),B=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,A=Ua(B,{display:R}),O=A&&!li(x);return{id:v,type:Sc,position:P,...O?{width:A.width,height:A.height}:{},data:{label:b.label||vm(k)||vm(j)||v,definitionId:x,...S?{marketplaceRef:S}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:iM(x,j||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||C||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...O?{nodeSize:A}:{},...R&&O?{displaySize:A}:{}}}}).map(v=>gb(v,r,t)),d=iJ(e),f=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!d.some(b=>b.id===String(v.source)||b.id===String(v.target))).map((v,b)=>({id:v.id||`we-${v.source}-${v.target}-${b}`,source:String(v.source),target:String(v.target),sourceHandle:v.sourceHandle??void 0,targetHandle:v.targetHandle??void 0,markerEnd:{type:Ci.ArrowClosed}})),p=[...d,...u];return{nodes:p,edges:LU(f,p),instances:r}}function GC(e){return`${kb}${e}`}function Up(e){const t=String(e||"");return t.startsWith(kb)?t.slice(kb.length):t}function Nb(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 jh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return ll((p=f==null?void 0:f.data)==null?void 0:p.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const f of r){const p=String(f||"").trim();!p||o.has(p)||!n.has(p)||(o.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,p)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+p*36,y:120+p*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const p=Ua(u[f],{display:!0});p&&(c[f]=p)});const d=Nb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function JC(e,t=[]){return jh(e,t)}const bw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function kw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function XC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function QC(e={}){if(e.permanent)return{expiresMode:"permanent",permanent:!0};const t=Number(e.expiresInDays||30);return{expiresMode:"days",expiresInDays:Number.isFinite(t)?t:30}}function cJ(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function ZC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const uM="af:workspace:canvas-clipboard",dM="agentflow.workspace.canvas-clipboard";function uJ(e){return JSON.stringify({type:dM,version:1,clipboard:e})}function dJ(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==dM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function fJ(e){try{localStorage.setItem(uM,uJ(e))}catch{}}function pJ(){try{return dJ(localStorage.getItem(uM))}catch{return null}}function hJ(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Cb(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 e_(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Ua(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:e_(n,JT,XT)||GT,height:e_(r,ym,QT)||ym}}function Nm(e){const t=Ua(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function mJ(e){const t=String(e||"").trim().toLowerCase();return t==="html"||t==="react"?{width:720,height:520}:t==="table"||t==="chart"?{width:640,height:380}:t==="image"?{width:520,height:360}:{width:xb,height:bb}}function gJ(e,t=""){const n=Nm(e==null?void 0:e.displaySize);if(n)return n;const r=Nm(e==null?void 0:e.nodeSize);if(r)return r;const s=ll(t)||Nf(la((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return mJ(s)}function Yl(e){var s,o,a,l,c,u,d,f,p,h,y;if(li((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!_n(e==null?void 0:e.data),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?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(d=e==null?void 0:e.data)==null?void 0:d.displaySize)==null?void 0:f.height)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Ua({width:n,height:r},{display:t})}function Wl(e,t,n){var d,f,p,h,y,v,b,g,k,x,j,S,C;const r=(e||[]).filter(P=>!Sm(P)),s=(e||[]).filter(Sm),o=fM(bv(r,n||{})),a=t.map(P=>({source:P.source,target:P.target,sourceHandle:P.sourceHandle??null,targetHandle:P.targetHandle??null})).filter(P=>!s.some(R=>R.id===P.source||R.id===P.target)),l={},c={},u=[];for(const P of r){l[P.id]={x:((d=P.position)==null?void 0:d.x)||0,y:((f=P.position)==null?void 0:f.y)||0};const R=Yl(P);R&&(c[P.id]=R)}for(const P of s){const R=Number(((h=(p=P.data)==null?void 0:p.nodeSize)==null?void 0:h.width)||P.width||((y=P.measured)==null?void 0:y.width)||0),B=Number(((b=(v=P.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||P.height||((g=P.measured)==null?void 0:g.height)||0);u.push({id:P.id,title:String(((k=P.data)==null?void 0:k.title)||((x=P.data)==null?void 0:x.label)||"Group"),color:String(((j=P.data)==null?void 0:j.color)||"purple"),x:Number(((S=P.position)==null?void 0:S.x)||0),y:Number(((C=P.position)==null?void 0:C.y)||0),width:Math.max(il,Math.round(R||il)),height:Math.max(ol,Math.round(B||ol))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function fM(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!ll(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 ll(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_react_app"?"react":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function _n(e){const t=ll(e==null?void 0:e.definitionId);return t||(li(e==null?void 0:e.definitionId)&&wg(e)?Nf(la((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function lo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=_n(e),r=li(e==null?void 0:e.definitionId),s=n==="image"?"src":"content",o=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>o(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===s&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?o(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function aa(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),react:new Set(["json","jsx","tsx","js","txt"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function yJ(e){let t=String(e||"").replace(/\r\n/g,`
189
- `).trim();return t.includes(`
190
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
191
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
192
- $2`)),t}function Mi(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=yJ(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 d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
193
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
194
- `).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),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 cl(e,t){const n=Fr(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 _b(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 wJ(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(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
195
- `)}).filter(Boolean).join(`
196
-
197
- `)}function Qc(e){let t=Mi(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 xJ(e){const t=Qc(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ba(e,t){return e==="html"?xJ(t):""}function pM(e,t=""){const n=Qc(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
198
- (() => {
199
- const frameId = ${JSON.stringify(String(t||""))};
200
- const postSize = () => {
201
- const doc = document.documentElement;
202
- const body = document.body;
203
- const height = Math.ceil(Math.max(
204
- doc ? doc.scrollHeight : 0,
205
- doc ? doc.offsetHeight : 0,
206
- doc ? doc.clientHeight : 0,
207
- body ? body.scrollHeight : 0,
208
- body ? body.offsetHeight : 0,
209
- body ? body.clientHeight : 0,
210
- window.innerHeight || 0
211
- ));
212
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
213
- };
214
- document.addEventListener("click", (event) => {
215
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
216
- if (!link) return;
217
- const rawHref = String(link.getAttribute("href") || "").trim();
218
- if (!rawHref || rawHref.startsWith("#")) return;
219
- if (/^javascript:/i.test(rawHref)) {
220
- event.preventDefault();
221
- return;
222
- }
223
- event.preventDefault();
224
- window.open(link.href, "_blank", "noopener,noreferrer");
225
- }, true);
226
- window.addEventListener("load", postSize);
227
- window.addEventListener("resize", postSize);
228
- requestAnimationFrame(postSize);
229
- setTimeout(postSize, 60);
230
- setTimeout(postSize, 300);
231
- if (typeof ResizeObserver !== "undefined") {
232
- const resizeObserver = new ResizeObserver(postSize);
233
- resizeObserver.observe(document.documentElement);
234
- if (document.body) resizeObserver.observe(document.body);
235
- }
236
- if (typeof MutationObserver !== "undefined") {
237
- const mutationObserver = new MutationObserver(postSize);
238
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
239
- }
240
- })();
241
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function bJ(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 kJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function vJ(e,t){const n=URL.createObjectURL(e);try{kJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function hM(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 SJ(e){const t=hM(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>"}
242
- ${t.documentElement.outerHTML}`:""}function vw(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 jJ(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=hM(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,d=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,p={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((f==null?void 0:f.width)||0)||null,displaySizeHeight:Number((f==null?void 0:f.height)||0)||null,rectWidth:s!=null&&s.width?Math.round(s.width):null,rectHeight:s!=null&&s.height?Math.round(s.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:vw(c),displayBody:vw(u),scroller:vw(d)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.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(g=>Math.ceil(g)).filter(g=>g>0),y=Math.max(1,...h.length?h:[960]),v=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:y,height:v,debug:p}}async function NJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=jJ(r,s,o,{...l||{},displaySize:c}),d=SJ(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:d||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const p=await f.blob();vJ(p,a)}function CJ(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 mM(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function _J(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function gM({code:e}){const t=m.useMemo(()=>_J(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((d,f)=>{l.set(d.id,{x:24+(n?f*(r+o):f%3*(r+o)),y:24+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(d=>d.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(d=>d.y+s+24));return i.jsx("div",{className:"af-work-node__mermaid-preview",children:i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,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((d,f)=>{const p=l.get(d.from),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:d.label.slice(0,22)})]},d.id)})]})})}function wi({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,S;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(S=(j=d.currentTarget).setPointerCapture)==null||S.call(j,g);const k=C=>{C.preventDefault(),l(c(C.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),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:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function yM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=_n(e),o=lo(e),a=s==="image"?o:Mi(o),l=s==="image"?"":aa(a,s),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),f(""),u(""),cl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),f(""),h(!1),()=>{k=!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 y=l?c:a,v=s==="html"?Qc(y):s==="react"?yg(y):Mi(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=Ba(s,v);if(p)return i.jsxs(wi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(d)return i.jsx(wi,{className:"af-work-display-empty",children:d});if(g)return i.jsx(wi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(wi,{className:"af-work-display-empty",children:"No display content"});if(s==="html"||s==="react")return i.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:i.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(s==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:s==="react"?kv(v,b.current):pM(v,b.current)},r)});if(s==="image"){const k=rf(v,t);return i.jsx(wi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:CJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(mv,{content:v,basePath:l,resolveSrc:(k,x)=>rf(k,t,x)})}):s==="chart"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(yv,{content:v})}):s==="table"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(gv,{content:v})}):s==="mermaid"?i.jsxs(wi,{className:"af-work-display-body",children:[i.jsx(gM,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(wi,{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:v})})}function EJ({node:e,onClose:t}){var k,x,j,S,C,P,R,B,A,O,D;const n=m.useRef(null),r=_n(e==null?void 0:e.data),s=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1),y=lo(e==null?void 0:e.data),v=r==="markdown"?Mi(y):"",b=r==="markdown"?aa(v,"markdown"):"",g=r==="markdown"?b?d:v:"";return m.useEffect(()=>{const L=M=>{if(M.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[g,a,t]),m.useEffect(()=>{var M;let L=!1;return r!=="markdown"||!b?(f(""),h(!1),()=>{L=!0}):(h(!0),cl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(V=>{L||f(V)}).catch(V=>{var z,F;L||(f(""),(F=(z=e==null?void 0:e.data)==null?void 0:z.onStatus)==null||F.call(z,String(V.message||V)))}).finally(()=>{L||h(!1)}),()=>{L=!0})},[r,b,(S=(j=e==null?void 0:e.data)==null?void 0:j.flowParams)==null?void 0:S.flowId,(P=(C=e==null?void 0:e.data)==null?void 0:C.flowParams)==null?void 0:P.flowSource,(B=(R=e==null?void 0:e.data)==null?void 0:R.flowParams)==null?void 0:B.archived,(A=e==null?void 0:e.data)==null?void 0:A.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?lr.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:mM(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||p,onClick:async()=>{var L,M;try{await xM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(V){(M=(L=e==null?void 0:e.data)==null?void 0:L.onStatus)==null||M.call(L,String(V.message||V))}},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(g||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||p,onClick:()=>{u(String(g||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),i.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?i.jsx(wM,{value:c,onChange:u,onUploadImage:(O=e.data)==null?void 0:O.onUploadWorkspaceImage,readOnly:o}):i.jsx(yM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function AJ({node:e}){var p,h,y,v,b,g,k,x,j,S;const t=_n(e==null?void 0:e.data),n=lo(e==null?void 0:e.data),r=t==="image"?n:Mi(n),s=t==="image"?"":aa(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var P;let C=!1;return s?(c(!0),a(""),cl(((P=e==null?void 0:e.data)==null?void 0:P.flowParams)||{},s).then(R=>{C||a(R)}).catch(()=>{C||a("")}).finally(()=>{C||c(!1)}),()=>{C=!0}):(a(""),c(!1),()=>{C=!0})},[s,(h=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=s?o:r,d=t==="html"?Qc(u):t==="react"?yg(u):Mi(u),f=Ba(t,d);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?i.jsx("div",{className:"af-display-picker-preview__empty",children:f}):d.trim()?t==="html"||t==="react"?i.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?kv(d):pM(d)}):t==="image"?i.jsx("img",{src:rf(d,(j=e==null?void 0:e.data)==null?void 0:j.flowParams),alt:((S=e==null?void 0:e.data)==null?void 0:S.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(mv,{content:d,basePath:s,resolveSrc:(C,P)=>{var R;return rf(C,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,P)}})}):t==="chart"?i.jsx(yv,{content:d}):t==="table"?i.jsx(gv,{content:d}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(gM,{code:d}),i.jsx("pre",{children:d})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:d}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function wM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,d]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),j=k>x+1,S=j?Math.max(12,x/k*100):100,C=Math.max(0,100-S),P=j?Math.min(C,g.scrollTop/Math.max(1,k-x)*C):0;d({visible:j,top:P,height:S})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(f);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[f,e]);const p=m.useCallback(g=>{const k=s.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,f()},[f]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const j=x.getBoundingClientRect(),S=u.height/100*j.height,C=Math.max(1,j.height-S);return(g-j.top-k)/C},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),j=u.top/100*x.height,S=u.height/100*x.height,P=g.clientY>=x.top+j&&g.clientY<=x.top+j+S?g.clientY-x.top-j:S/2;p(h(g.clientY,P));const R=A=>{A.preventDefault(),p(h(A.clientY,P))},B=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",B)},[h,p,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=s.current,j=Number((x==null?void 0:x.selectionStart)??k.length),S=Number((x==null?void 0:x.selectionEnd)??j),C=k.slice(0,j),P=k.slice(S),R=C&&!C.endsWith(`
243
- `)?`
244
- `:"",B=P&&!P.startsWith(`
245
- `)?`
246
- `:"",A=`${C}${R}${g}${B}${P}`;t==null||t(A),window.requestAnimationFrame(()=>{var D,L;const O=C.length+R.length+g.length;(D=s.current)==null||D.focus(),(L=s.current)==null||L.setSelectionRange(O,O)})},[t,e]),b=m.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),x=String(k||"").trim();if(x){const j=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(`![${j}](${x})`)}}finally{c(!1)}}},[v,n,r,l]);return i.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:g=>g.stopPropagation(),onDragOver:g=>{var x;Array.from(((x=g.dataTransfer)==null?void 0:x.items)||[]).some(j=>String((j==null?void 0:j.type)||"").startsWith("image/"))&&(g.preventDefault(),g.dataTransfer.dropEffect="copy")},onDrop:g=>{var x;const k=Array.from(((x=g.dataTransfer)==null?void 0:x.files)||[]).find(wm);k&&(g.preventDefault(),b(k))},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 g;return(g=o.current)==null?void 0:g.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:g=>{var x;const k=(x=g.target.files)==null?void 0:x[0];g.target.value="",k&&b(k)}})]}),i.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:g=>t==null?void 0:t(g.target.value),onScroll:f,onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),i.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:y,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function PJ({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]=m.useState(a),u=m.useRef(!1),d=String(s.candidateContent||""),f=!!s.running,p=!!(t!=null&&t.readOnly),h=String(s.error||""),y=o.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.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 v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||f||h?i.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:v.role==="assistant"?"AI":"你"}),i.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),f?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?i.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||p,"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:f||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:v=>{var g;u.current=!1;const b=v.currentTarget.value;c(b),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onChange:v=>{var g;const b=v.target.value;c(b),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onKeyDown:v=>{var b,g;v.isComposing||(b=v.nativeEvent)!=null&&b.isComposing||v.keyCode===229||(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),(g=t==null?void 0:t.onSendNodeChat)==null||g.call(t,e,l))}}),i.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||p||!l.trim(),onClick:()=>{var v;return(v=t==null?void 0:t.onSendNodeChat)==null?void 0:v.call(t,e,l)},"aria-label":"发送",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),d.trim()?i.jsx("div",{className:"af-work-node-chat__messages",children:i.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[i.jsx("span",{children:"AI"}),i.jsx("p",{children:d})]})}):null]}):i.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:v=>{var b;v.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function IJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function RJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function TJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function t_(e,t=""){const n=aa(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function MJ(e,t){const n=TJ(e),r=new Set,s=_n(t)||"";li(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=t_(lo(t),s);return o&&r.add(o),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),d=t_(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function n_(e,t){const n=_n(t)||"markdown";return`outputs/${RJ((t==null?void 0:t.label)||e||n)}.${IJ(n)}`}async function xM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await _b((t==null?void 0:t.flowParams)||{},n,r);s==null||s(r),(o=t==null?void 0:t.onSetDisplayNodeContent)==null||o.call(t,e,l,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${l}`});return}(a=t==null?void 0:t.onSetDisplayNodeContent)==null||a.call(t,e,r,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"})}function bM({id:e,data:t,selected:n,deleteNode:r}){var te,se,ie;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Z,ce)=>({slot:Z,idx:ce})).sort((Z,ce)=>{var Ce,We,ct,yt;const de=String(((Ce=Z.slot)==null?void 0:Ce.name)||"").trim(),pe=String(((We=ce.slot)==null?void 0:We.name)||"").trim();if(de==="next"&&pe!=="next")return-1;if(pe==="next"&&de!=="next")return 1;const Me=String(((ct=Z.slot)==null?void 0:ct.type)||"").trim(),Ne=String(((yt=ce.slot)==null?void 0:yt.type)||"").trim();return Me==="node"&&Ne!=="node"?-1:Ne==="node"&&Me!=="node"?1:Z.idx-ce.idx}),l=_n(t),c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[j,S]=m.useState(""),[C,P]=m.useState(!1),[R,B]=m.useState(!1),A=m.useRef(null),O=lo(t),D=l==="markdown"?Mi(O):"",L=l==="markdown"?aa(D,"markdown"):"",M=l==="markdown"?L?j:D:"",V=!!(t!=null&&t.readOnly),z=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!L?(S(""),P(!1),()=>{Z=!0}):(P(!0),cl((t==null?void 0:t.flowParams)||{},L).then(ce=>{Z||S(ce)}).catch(ce=>{var de;Z||(S(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ce.message||ce)))}).finally(()=>{Z||P(!1)}),()=>{Z=!0})},[l,L,(te=t==null?void 0:t.flowParams)==null?void 0:te.flowId,(se=t==null?void 0:t.flowParams)==null?void 0:se.flowSource,(ie=t==null?void 0:t.flowParams)==null?void 0:ie.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const Z=()=>v(!1);return window.addEventListener("pointerup",Z,!0),window.addEventListener("pointercancel",Z,!0),window.addEventListener("mouseup",Z,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointerup",Z,!0),window.removeEventListener("pointercancel",Z,!0),window.removeEventListener("mouseup",Z,!0),window.removeEventListener("blur",Z)}},[y]),m.useEffect(()=>{b||x(String(M||""))},[M,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),$=String((t==null?void 0:t.sourceNodeId)||e),W=(t==null?void 0:t.sharingDisplayNodeId)===$,E=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Re,ot,kt,$t,ye,ze,re,ke,Be,Qe;if(l!=="html"||p)return;const Z=lo(t),ce=aa(Z,l);let de=Z;if(ce)try{de=await cl((t==null?void 0:t.flowParams)||{},ce)}catch(_e){h(!1),console.warn("Failed to read HTML display file before saving image.",_e);return}const pe=Qc(de);if(!pe.trim())return;const Me=Ba(l,pe);if(Me){console.warn(Me);return}const Ne=(ot=(Re=u.current)==null?void 0:Re.getBoundingClientRect)==null?void 0:ot.call(Re),Ce=($t=(kt=c.current)==null?void 0:kt.querySelector)==null?void 0:$t.call(kt,".af-work-display-body"),We=(ze=(ye=c.current)==null?void 0:ye.querySelector)==null?void 0:ze.call(ye,".af-visible-scroll-frame__scroller"),ct=Math.round(Math.max(Number((Ne==null?void 0:Ne.width)||0),Number((E==null?void 0:E.width)||0),Number(((re=c.current)==null?void 0:re.clientWidth)||0),Number((Ce==null?void 0:Ce.clientWidth)||0),Number((We==null?void 0:We.clientWidth)||0),Math.max(320,Number((E==null?void 0:E.width)||960)-2))),yt=Math.round(Math.max(Number((Ne==null?void 0:Ne.height)||0),Number((E==null?void 0:E.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((Ce==null?void 0:Ce.clientHeight)||0),Number((We==null?void 0:We.clientHeight)||0),Math.max(180,Number((E==null?void 0:E.height)||640)-46)));h(!0);try{await NJ({flowParams:(t==null?void 0:t.flowParams)||{},content:pe,sourceFilePath:ce,iframe:u.current,width:ct,height:yt,filename:bJ((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Ce,scroller:We},displaySize:E}),(Be=t==null?void 0:t.onStatus)==null||Be.call(t,"已导出 HTML 展示截图")}catch(_e){const _t=String((_e==null?void 0:_e.message)||_e||"截图失败");(Qe=t==null?void 0:t.onStatus)==null||Qe.call(t,`HTML 截图失败:${_t}`),console.warn("Failed to save HTML display as PNG.",_e)}finally{h(!1)}},[t,E==null?void 0:E.height,E==null?void 0:E.width,e,l,p]),K=m.useCallback(Z=>{var ce;V||!Z||l!=="image"||(ce=t==null?void 0:t.onUploadImageToDisplayNode)==null||ce.call(t,e,Z)},[t,e,l,V]),H=m.useCallback(Z=>{var ce,de;(ce=Z==null?void 0:Z.stopPropagation)==null||ce.call(Z),!V&&((de=t==null?void 0:t.onSetDisplayNodeContent)==null||de.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),g(!1)))},[t,e,l,V]),ee=m.useCallback(Z=>{var pe,Me;V||l!=="image"||!(Array.from(((pe=Z.dataTransfer)==null?void 0:pe.files)||[]).some(wm)||Array.from(((Me=Z.dataTransfer)==null?void 0:Me.items)||[]).some(Ne=>String((Ne==null?void 0:Ne.type)||"").startsWith("image/")))||(Z.preventDefault(),Z.stopPropagation(),Z.dataTransfer.dropEffect="copy",B(!0))},[l,V]),ue=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||B(!1))},[l]),G=m.useCallback(Z=>{var de;if(l!=="image")return;const ce=Array.from(((de=Z.dataTransfer)==null?void 0:de.files)||[]).find(wm);ce&&(Z.preventDefault(),Z.stopPropagation(),B(!1),K(ce))},[l,K]);return i.jsxs("div",{className:"af-work-display-card"+(E?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(R?" af-work-display-card--image-drop":"")+(z?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:E?{width:E.width,height:E.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:ee,onDragLeave:ue,onDrop:G,children:[i.jsx(Zk,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>v(!0),onResizeEnd:()=>v(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((Z,ce)=>{if(Z.showOnNode===!1)return null;const de=`${4.15+ce*1.75}rem`,pe=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:pe}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:An(Z.type)},title:`${pe} · ${Z.type}`})]},`in-${ce}`)}),a.map(({slot:Z,idx:ce},de)=>{if(Z.showOnNode===!1)return null;const pe=`${4.15+de*1.75}rem`,Me=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:pe},children:Me}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:pe,background:An(Z.type)},title:`${Me} · ${Z.type}`})]},`out-${ce}`)}),i.jsxs("div",{className:"af-work-display-card__head",children:[i.jsxs("div",{className:"af-work-display-card__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:mM(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:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,ce,de,pe;try{(pe=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.history)==null?void 0:de.back)==null||pe.call(de)}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 Z,ce,de,pe;try{(pe=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.history)==null?void 0:de.forward)==null||pe.call(de)}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:()=>f(Z=>Z+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:p,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:p?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:V||C,onClick:async()=>{var Z;try{await xM({nodeId:e,data:t,filePath:L,content:k,setFileContent:S}),g(!1)}catch(ce){(Z=t==null?void 0:t.onStatus)==null||Z.call(t,String(ce.message||ce))}},"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(M||"")),g(!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:V||C,onClick:Z=>{Z.stopPropagation(),x(String(M||"")),g(!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:A,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var de;const ce=(de=Z.target.files)==null?void 0:de[0];Z.target.value="",ce&&K(ce)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:Z=>{var ce;Z.stopPropagation(),(ce=A.current)==null||ce.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onOpenDisplayPreview)==null||ce.call(t,$)},"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:W,onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onShareDisplayNode)==null||ce.call(t,$)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:W?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:H,"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:V,onClick:()=>{var Z;return(Z=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Z.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:V,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?i.jsx(wM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):i.jsx(yM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),i.jsx(PJ,{nodeId:e,data:t})]})}function $J({id:e,data:t,selected:n,deleteNode:r}){var d,f,p;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d.has)==null?void 0:f.call(d,e))||((p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return 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":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:An(h.type)},title:`${b} · ${h.type}`})]},`in-${y}`)}),o.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:b}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:An(h.type)},title:`${b} · ${h.type}`})]},`out-${y}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var y,v;h.stopPropagation(),a?(y=t==null?void 0:t.onStopWorkspaceNode)==null||y.call(t,e):(v=t==null?void 0:t.onRunWorkspaceNode)==null||v.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"})]}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOptimizeWorkspaceRun)==null||y.call(t,e)},children:i.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||y.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:i.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function LJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Qe,_e,_t,Xt,Ft,at,Fn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=QJ(t),[d,f]=m.useState(u.task),p=m.useRef(!1),h=m.useRef(u.task),y=((_e=(Qe=t==null?void 0:t.runningRunNodeIds)==null?void 0:Qe.has)==null?void 0:_e.call(Qe,e))||((_t=t==null?void 0:t.runningRunNodeIds)==null?void 0:_t[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),g=Array.isArray(s)?s:[],k=Array.isArray(o)?o:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(ne=>({id:String((ne==null?void 0:ne.id)||""),label:String((ne==null?void 0:ne.label)||(ne==null?void 0:ne.name)||"知识库"),kind:(ne==null?void 0:ne.kind)==="git"?"git":"local",path:String((ne==null?void 0:ne.path)||""),repoUrl:String((ne==null?void 0:ne.repoUrl)||""),branch:String((ne==null?void 0:ne.branch)||""),mountPath:String((ne==null?void 0:ne.mountPath)||""),builtin:(ne==null?void 0:ne.builtin)===!0,exists:(ne==null?void 0:ne.exists)!==!1,type:String((ne==null?void 0:ne.type)||"")})).filter(ne=>ne.path),[a]),[j,S]=m.useState(!1),[C,P]=m.useState(""),[R,B]=m.useState(()=>new Set),[A,O]=m.useState(!1),[D,L]=m.useState(""),[M,V]=m.useState("config"),z=wg(t),F=!!z,$=_M(u.displayType),W=m.useMemo(()=>gJ(t,$),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,$]),E=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:$,displaySize:W,nodeSize:W,body:z,inputs:[{type:"text",name:$==="display_image"?"src":"content",value:z,default:z}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,$,e,z,c,W]),Q=Array.isArray((Xt=t==null?void 0:t.modelLists)==null?void 0:Xt.cursor)?t.modelLists.cursor:[],K=Array.isArray((Ft=t==null?void 0:t.modelLists)==null?void 0:Ft.opencode)?t.modelLists.opencode:[],H=Array.isArray((at=t==null?void 0:t.modelLists)==null?void 0:at.claudeCode)?t.modelLists.claudeCode:[],ee=Array.isArray((Fn=t==null?void 0:t.modelLists)==null?void 0:Fn.codex)?t.modelLists.codex:[],ue=m.useMemo(()=>new Set(Q.map(Es)),[Q]),G=m.useMemo(()=>new Set(K.map(Es)),[K]),te=m.useMemo(()=>new Set(H.map(Es)),[H]),se=m.useMemo(()=>new Set(ee.map(Es)),[ee]),ie=u.model,Z=m.useMemo(()=>ie?ie.startsWith("cursor:")||ie.startsWith("opencode:")||ie.startsWith("codex:")||ie.startsWith("claude-code:")?ie:te.has(ie)?`claude-code:${ie}`:se.has(ie)?`codex:${ie}`:G.has(ie)?`opencode:${ie}`:ue.has(ie)?`cursor:${ie}`:ie:"",[te,se,ue,G,ie]),ce=ie.startsWith("cursor:")?ie.slice(7):ie.startsWith("opencode:")?ie.slice(9):ie.startsWith("codex:")?ie.slice(6):ie.startsWith("claude-code:")?ie.slice(12):ie,de=ce,pe=!!ie&&!ue.has(de)&&!G.has(de)&&!te.has(de)&&!se.has(de),Me=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ne=m.useMemo(()=>new Map(g.map(ne=>[ne.key,ne])),[g]),Ce=m.useMemo(()=>{const ne=new Set,Pe=k.map(qe=>{const It=ia(qe,g).map(vt=>Ne.get(vt)).filter(Boolean);for(const vt of It)ne.add(vt.key);return{...qe,skills:It}}).filter(qe=>qe.skills.length>0),et=g.filter(qe=>!ne.has(qe.key));return{collectionGroups:Pe,ungrouped:et}},[k,Ne,g]);m.useEffect(()=>{B(ne=>{let Pe=!1;const et=new Set(ne);for(const qe of Ce.collectionGroups)et.has(qe.id)||(et.add(qe.id),Pe=!0);return Pe?et:ne})},[Ce.collectionGroups]);const We=m.useMemo(()=>{const ne=C.trim().toLowerCase();if(!ne)return Ce;const Pe=qe=>[qe==null?void 0:qe.key,qe==null?void 0:qe.name,qe==null?void 0:qe.description].map(It=>String(It||"").toLowerCase()).join(" ").includes(ne);return{collectionGroups:Ce.collectionGroups.map(qe=>{const It=[qe==null?void 0:qe.id,qe==null?void 0:qe.name,qe==null?void 0:qe.description].map(vt=>String(vt||"").toLowerCase()).join(" ").includes(ne);return{...qe,skills:It?qe.skills:qe.skills.filter(Pe)}}).filter(qe=>qe.skills.length>0),ungrouped:Ce.ungrouped.filter(Pe)}},[Ce,C]),ct=Eb(j,[We.collectionGroups.length,We.ungrouped.length,R.size,u.skillKeys.length,C]),yt=m.useMemo(()=>{const ne=D.trim().toLowerCase();return ne?x.filter(Pe=>[Pe.id,Pe.label,Pe.path,Pe.repoUrl,Pe.branch,Pe.mountPath,Pe.type].join(" ").toLowerCase().includes(ne)):x},[x,D]),Re=m.useMemo(()=>IM(u.knowledgeContext),[u.knowledgeContext]),ot=m.useMemo(()=>new Set(Re.map(ne=>ne.id||ne.path||ne.repoPath).filter(Boolean)),[Re]),kt=Eb(A,[yt.length,Re.length,D]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,p.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,z,y]),m.useEffect(()=>{var Pe,et;if(!(M==="result"&&F))return;(Pe=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Pe.call(t,e,W),(et=t==null?void 0:t.onRefreshNodeInternals)==null||et.call(t,e);const ne=window.setTimeout(()=>{var qe;return(qe=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:qe.call(t,e)},120);return()=>window.clearTimeout(ne)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,$,F,e,z,W,M]);const $t=ne=>{var Pe;(Pe=t==null?void 0:t.onChangeContextRunConfig)==null||Pe.call(t,e,{...u,task:d,...ne})},ye=(ne=d)=>{var et;const Pe=String(ne??"");Pe!==u.task&&(h.current=Pe,(et=t==null?void 0:t.onChangeContextRunConfig)==null||et.call(t,e,{...u,task:Pe}))},ze=(ne,Pe)=>{const et=new Set(u.skillKeys);for(const qe of ne){const It=String(qe||"").trim();It&&(Pe?et.add(It):et.delete(It))}$t({skillKeys:Array.from(et)})},re=ne=>{B(Pe=>{const et=new Set(Pe);return et.has(ne)?et.delete(ne):et.add(ne),et})},ke=(ne,Pe)=>{const et=(ne==null?void 0:ne.id)||(ne==null?void 0:ne.path)||"";if(!et)return;const qe=x.filter(It=>{const vt=It.id||It.path||"";return vt===et?Pe:ot.has(vt)});$t({knowledgeContext:xg(qe)})},Be=()=>{$t({knowledgeContext:null})};return M==="result"&&F?i.jsx(bM,{id:e,data:{...E,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):i.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(M==="result"&&F?" af-work-context-run-card--result":"")+(y?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(v?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((ne,Pe)=>{if(ne.showOnNode===!1)return null;const et=`${2.25+Pe*1.75}rem`,qe=ne.name||`#${Pe+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:et},children:qe}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${Pe}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:et,background:An(ne.type)},title:`${qe} · ${ne.type}`})]},`in-${Pe}`)}),c.map((ne,Pe)=>{if(ne.showOnNode===!1)return null;const et=`${2.25+Pe*1.75}rem`,qe=ne.name||`#${Pe+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:et},children:qe}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${Pe}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:et,background:An(ne.type)},title:`${qe} · ${ne.type}`})]},`out-${Pe}`)}),i.jsxs("div",{className:"af-work-context-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"automation"}),i.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),i.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>ne.stopPropagation(),children:[i.jsxs("select",{className:"af-work-context-run-card__model",value:Z,disabled:b,"aria-label":"模型",title:ce||"默认模型",onChange:ne=>$t({model:ne.target.value}),children:[i.jsx("option",{value:"",children:"默认"}),pe?i.jsx("option",{value:ie,children:ie}):null,Q.length?i.jsx("optgroup",{label:"Cursor",children:Q.map(ne=>i.jsx("option",{value:`cursor:${Es(ne)}`,children:Es(ne)},`context-cursor-${ne}`))}):null,K.length?i.jsx("optgroup",{label:"OpenCode",children:K.map(ne=>i.jsx("option",{value:`opencode:${Es(ne)}`,children:Es(ne)},`context-opencode-${ne}`))}):null,ee.length?i.jsx("optgroup",{label:"Codex",children:ee.map(ne=>i.jsx("option",{value:`codex:${Es(ne)}`,children:Es(ne)},`context-codex-${ne}`))}):null,H.length?i.jsx("optgroup",{label:"Claude Code",children:H.map(ne=>i.jsx("option",{value:`claude-code:${Es(ne)}`,children:Es(ne)},`context-claude-${ne}`))}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),i.jsx("span",{className:"af-work-context-run-card__kind",children:li(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),F?i.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:ne=>ne.stopPropagation(),children:[i.jsx("button",{type:"button",className:M==="config"?"is-active":"",onClick:()=>V("config"),"aria-label":"切换到任务配置",children:i.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),i.jsx("button",{type:"button",className:M==="result"?"is-active":"",onClick:()=>V("result"),"aria-label":"切换到展示结果",children:i.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,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-context-run-card__body nodrag",children:[i.jsxs(i.Fragment,{children:[i.jsx("textarea",{value:d,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{p.current=!0},onCompositionEnd:ne=>{p.current=!1,f(ne.currentTarget.value),ye(ne.currentTarget.value)},onChange:ne=>{f(ne.target.value)},onBlur:ne=>ye(ne.currentTarget.value)}),i.jsxs("div",{className:"af-work-context-run-card__grid",children:[i.jsxs("div",{className:"af-work-context-run-card__skills",children:[i.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ne=>{var Pe;ne.stopPropagation(),j||(Pe=t==null?void 0:t.onRefreshSkills)==null||Pe.call(t),S(et=>!et)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),j?i.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:ne=>ne.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:C,onChange:ne=>P(ne.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),C?i.jsx("button",{type:"button",onClick:()=>P(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:ct.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:ct.updateMenuScrollbar,children:[We.collectionGroups.map(ne=>{const Pe=ne.skills.map(vt=>vt.key),et=Pe.filter(vt=>Me.has(vt)).length,qe=Pe.length>0&&et===Pe.length,It=R.has(ne.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(It?" 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:qe,disabled:b,onChange:vt=>ze(Pe,vt.target.checked),"aria-label":`选择 ${ne.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>re(ne.id),"aria-expanded":!It,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:ne.name}),ne.description?i.jsx("em",{children:ne.description}):null]})}),i.jsxs("small",{children:[et,"/",Pe.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>re(ne.id),"aria-label":It?`展开 ${ne.name}`:`收起 ${ne.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:It?"chevron_right":"expand_more"})})]}),It?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:ne.skills.map(vt=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:Me.has(vt.key),disabled:b,onChange:tr=>ze([vt.key],tr.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:vt.name}),vt.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:vt.description}):null]})]},`${ne.id}:${vt.key}`))})]},ne.id)}),We.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:We.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:We.ungrouped.map(ne=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:Me.has(ne.key),disabled:b,onChange:Pe=>ze([ne.key],Pe.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:ne.name}),ne.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:ne.description}):null]})]},`ungrouped:${ne.key}`))})]}):null,We.collectionGroups.length===0&&We.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:()=>$t({skillKeys:[]}),children:"清空"})]}),i.jsx("div",{ref:ct.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(ct.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:ct.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${ct.scrollbar.height}%`,top:`${ct.scrollbar.top}%`}})})]}):null]}),i.jsxs("div",{className:"af-work-context-run-card__workspace",children:[i.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ne=>{var Pe;ne.stopPropagation(),A||(Pe=t==null?void 0:t.onRefreshWorkspaces)==null||Pe.call(t),O(et=>!et)},children:[i.jsx("span",{className:"material-symbols-outlined",children:Re.length?"folder_open":"folder_off"}),i.jsx("span",{children:Re.length?`${Re.length} 知识库`:"知识库"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),A?i.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:ne=>ne.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:D,onChange:ne=>L(ne.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?i.jsx("button",{type:"button",onClick:()=>L(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:kt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:kt.updateMenuScrollbar,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:"知识库"}),i.jsx("small",{children:yt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:yt.map(ne=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:ot.has(ne.id||ne.path),disabled:b,onChange:Pe=>ke(ne,Pe.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:ne.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[ne.kind==="git"&&ne.repoUrl?`${ne.repoUrl}${ne.branch?` · ${ne.branch}`:""}${ne.mountPath?` · ${ne.mountPath}`:""}`:ne.path,ne.exists?"":" · 路径未就绪"]})]})]},`${ne.id}:${ne.path}`))})]}),yt.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:Be,children:"清空知识库"})]}),i.jsx("div",{ref:kt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(kt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:kt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${kt.scrollbar.height}%`,top:`${kt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:b,onChange:ne=>$t({displayType:ne.target.value}),children:[i.jsx("option",{value:"markdown",children:"Markdown"}),i.jsx("option",{value:"html",children:"HTML"}),i.jsx("option",{value:"react",children:"React"}),i.jsx("option",{value:"table",children:"Table"}),i.jsx("option",{value:"chart",children:"Chart"}),i.jsx("option",{value:"ascii",children:"ASCII"}),i.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),z?i.jsx("pre",{className:"af-work-context-run-card__preview",children:z.slice(0,520)}):null]}),i.jsxs("div",{className:"af-work-context-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(y?" af-work-run-card__button--stop":""),disabled:b,onClick:ne=>{var Pe,et;ne.stopPropagation(),ye(),y?(Pe=t==null?void 0:t.onStopWorkspaceNode)==null||Pe.call(t,e):(et=t==null?void 0:t.onRunWorkspaceNode)==null||et.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:y?"stop_circle":"play_arrow"}),i.jsx("span",{children:y?"Stop":"Run"})]}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:ne=>{var Pe;ne.stopPropagation(),(Pe=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Pe.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:i.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function OJ({id:e,data:t,selected:n,deleteNode:r}){var P,R,B;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=Av((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},d=((R=(P=t==null?void 0:t.runningRunNodeIds)==null?void 0:P.has)==null?void 0:R.call(P,e))||((B=t==null?void 0:t.runningRunNodeIds)==null?void 0:B[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",f=(t==null?void 0:t.optimizingRun)===!0,p=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=A=>{var O;(O=t==null?void 0:t.onChangeScheduledRunConfig)==null||O.call(t,e,{...a,...A})},v=A=>{y({scheduleType:A,cron:td(A,a.time,a.weekday,a.monthDay,a.cron)})},b=A=>{y({time:A,cron:td(a.scheduleType,A,a.weekday,a.monthDay,a.cron)})},[g,k]=Ev(a.time).split(":"),x=(A,O)=>{b(`${Ko(A,9,0,23)}:${Ko(O,0,0,59)}`)},j=A=>{y({weekday:A,cron:td(a.scheduleType,a.time,A,a.monthDay,a.cron)})},S=A=>{y({monthDay:A,cron:td(a.scheduleType,a.time,a.weekday,A,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const C=()=>{h||l===a.cron||y({cron:l})};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":"")+(d?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(p?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((A,O)=>{if(A.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=A.name||`#${O+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:L}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${O}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:An(A.type)},title:`${L} · ${A.type}`})]},`in-${O}`)}),o.map((A,O)=>{if(A.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=A.name||`#${O+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:L}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${O}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:An(A.type)},title:`${L} · ${A.type}`})]},`out-${O}`)}),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:h,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:h,onChange:A=>y({enabled:A.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:h,onChange:A=>v(A.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:h,"aria-label":"小时",onChange:A=>x(A.target.value,k),children:Array.from({length:24},(A,O)=>Ko(O,0,0,23)).map(A=>i.jsxs("option",{value:A,children:[A," 时"]},A))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:A=>x(g,A.target.value),children:Array.from({length:12},(A,O)=>Ko(O*5,0,0,59)).map(A=>i.jsxs("option",{value:A,children:[A," 分"]},A))})]})]}):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:h,onChange:A=>j(A.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:h,onChange:A=>S(A.target.value),children:Array.from({length:31},(A,O)=>O+1).map(A=>i.jsxs("option",{value:A,children:[A," 日"]},A))})]}):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:l,disabled:h,spellCheck:!1,placeholder:nf,onChange:A=>c(A.target.value),onBlur:C,onKeyDown:A=>{A.key==="Enter"&&A.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[rJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",nJ(u.nextAt)]}),i.jsx("span",{children:d?"running":u.lastStatus||"idle"})]}),u.lastError?i.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,i.jsxs("div",{className:"af-work-schedule-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(d?" af-work-run-card__button--stop":""),disabled:h||f,onClick:A=>{var O,D;A.stopPropagation(),d?(O=t==null?void 0:t.onStopWorkspaceNode)==null||O.call(t,e):(D=t==null?void 0:t.onRunWorkspaceNode)==null||D.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:d?"stop_circle":"play_arrow"}),i.jsx("span",{children:d?"停止":"立即运行"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(f?" af-work-schedule-card__optimize--running":""),disabled:h||d||f,title:"为下游节点提前生成 implementation",onClick:A=>{var O;A.stopPropagation(),(O=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||O.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:f?"sync":"auto_fix_high"}),i.jsx("span",{children:f?"优化中":"优化"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:A=>{var O;A.stopPropagation(),(O=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||O.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:u.targetRunNodeId||e,lastRunId:u.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"article"}),i.jsx("span",{children:"日志"})]})]})]})]})}function DJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Gc(),o=!!(t!=null&&t.readOnly),a=jb(t==null?void 0:t.nodeSize)||{width:il,height:ol},l=m.useCallback(c=>{var u,d;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(d=(u=c.target)==null?void 0:u.closest)!=null&&d.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>SM(f,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(Zk,{className:"af-work-group-node__resize nodrag",minWidth:il,minHeight:ol,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 FJ(e){var y,v,b,g,k,x,j,S,C,P,R,B,A,O,D,L,M,V,z,F,$,W,E,Q,K,H,ee,ue;const{setEdges:t,setNodes:n}=Gc(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,s=!!((v=e.data)!=null&&v.readOnly),[o,a]=m.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(G=>{var ie,Z,ce;if(s)return;(Z=(ie=e.data)==null?void 0:ie.onCleanupWorkspaceNodeOutputs)==null||Z.call(ie,G,e.data);const te=li((ce=e.data)==null?void 0:ce.definitionId)?EM(G):"",se=new Set([G,te].filter(Boolean));n(de=>de.filter(pe=>!se.has(pe.id))),t(de=>de.filter(pe=>!se.has(pe.source)&&!se.has(pe.target)))},[e.data,s,t,n]),u=m.useCallback(G=>{var te,se;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(se=(te=G.target)==null?void 0:te.closest)!=null&&se.call(te,".react-flow__handle, .af-work-display-resize")||(n(ie=>SM(ie,e.id)),t(ie=>WJ(ie)))},[e.id,t,n]),d=m.useCallback((G,te)=>{s||(n(se=>se.map(ie=>ie.id===G?{...ie,data:{...ie.data,model:te}}:ie)),r==null||r(G,{model:te}))},[s,n,r]),f=m.useCallback((G,te)=>{s||(n(se=>se.map(ie=>{var ce;if(ie.id!==G)return ie;const Z=Array.isArray((ce=ie.data)==null?void 0:ce.outputs)&&ie.data.outputs.length?ie.data.outputs.map((de,pe)=>pe===0?{...de,default:te,value:te}:de):[{type:"bool",name:"value",default:te,value:te}];return{...ie,data:{...ie.data,body:"",outputs:Z}}})),r==null||r(G,se=>({body:"",outputs:Array.isArray(se==null?void 0:se.outputs)&&se.outputs.length?se.outputs.map((Z,ce)=>ce===0?{...Z,default:te,value:te}:Z):[{type:"bool",name:"value",default:te,value:te}]})))},[s,n,r]),p=m.useCallback((G,te)=>{s||(n(se=>se.map(ie=>ie.id===G?{...ie,data:{...ie.data,body:te}}:ie)),r==null||r(G,{body:te}))},[s,n,r]),h=m.useCallback((G,te)=>{if(s)return;const se=bo(te);n(ie=>ie.map(Z=>Z.id===G?{...Z,data:{...Z.data,images:se}}:Z)),r==null||r(G,{images:se})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(DJ,{...e,deleteNode:c}):ll((k=e.data)==null?void 0:k.definitionId)?i.jsx(bM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx($J,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((j=e.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"?i.jsx(OJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):li((S=e.data)==null?void 0:S.definitionId)?i.jsx(LJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(C=e.data)==null?void 0:C.skills,skillCollections:(P=e.data)==null?void 0:P.skillCollections,workspaces:(R=e.data)==null?void 0:R.workspaceTargets}):((B=e.data)==null?void 0:B.definitionId)==="control_load_skills"?i.jsx(iX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(A=e.data)==null?void 0:A.skills,skillCollections:(O=e.data)==null?void 0:O.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((L=e.data)==null?void 0:L.definitionId)==="control_load_mcp"?i.jsx(oX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(M=e.data)==null?void 0:M.mcpServers,onChangeMcpNames:(V=e.data)==null?void 0:V.onChangeLoadMcpNames}):((z=e.data)==null?void 0:z.definitionId)==="control_cd_workspace"?i.jsx(aX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(F=e.data)==null?void 0:F.workspaceTargets,onChangeWorkspace:($=e.data)==null?void 0:$.onChangeLoadWorkspace,onRefreshWorkspaces:(W=e.data)==null?void 0:W.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((E=e.data)!=null&&E.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((K=e.data)==null?void 0:K.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((H=e.data)==null?void 0:H.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((ee=e.data)==null?void 0:ee.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:i.jsx(Zk,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:JT,minHeight:ym,maxWidth:XT,maxHeight:QT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(vU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ue=e.data)==null?void 0:ue.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:h})]})}const zJ={[Sc]:m.memo(FJ)};function Pv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Pv(n.children,t);return t}function kM(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)?kM(r.children,n):null;if(s)return s}return null}function BJ(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function vM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&vM(n.children,t));return t}function Yp(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 HJ(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 SM(e,t){const n=String(t||""),r=(e||[]).find(o=>o.id===n),s=(e||[]).reduce((o,a)=>o+(a.selected?1:0),0);return r!=null&&r.selected&&s>1?e:HJ(e,n)}function WJ(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function VJ(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function KJ(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],u=l?`${l}/${c}`:c,d=a===r.length-1;let f=!1;const p=(Array.isArray(o)?o:[]).map(h=>h.name!==c?h:(f=!0,d?{...h,type:"file",name:c,path:u,icon:dc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:dc(c,!0),children:s(h.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:dc(c),size:n}:{type:"directory",name:c,path:u,icon:dc(c,!0),children:s([],a+1,u)}),VJ(p)};return s(e||[],0,"")}function qJ(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 jM({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const d=u.type==="directory",f=d&&(r==null?void 0:r.has(u.path)),p=n===u.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"af-work-file-row",children:[i.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+u.type+(p?" af-work-file--selected":""),draggable:!d,onDragStart:y=>{d||a==null||a(y,u)},onClick:()=>{o==null||o(u),d&&(s==null||s(u.path))},onDoubleClick:()=>{d||t(u)},title:u.path,children:[d?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:u.icon||dc(u.name,d)}),i.jsx("span",{children:u.name})]}),p?i.jsxs("div",{className:"af-work-file-actions",children:[d?null:i.jsx("button",{type:"button",className:"af-work-file-action",onClick:y=>{y.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),i.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:y=>{y.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),d&&!f&&((h=u.children)!=null&&h.length)?i.jsx(jM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function UJ({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>Pv(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.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:u=>u.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:u=>n(u.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(u=>i.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[i.jsx("span",{className:"material-symbols-outlined",children:u.icon||dc(u.name)}),i.jsxs("span",{className:"af-work-file-picker-modal__main",children:[i.jsx("strong",{children:u.name}),i.jsx("small",{children:u.path})]}),u.size?i.jsx("em",{children:qJ(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function r_({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 NM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function YJ(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!NM(o));if(r.length>0)return r;const s=[...n].reverse().find(o=>(o==null?void 0:o.kind)==="result"||(o==null?void 0:o.kind)==="assistant"||(o==null?void 0:o.error));return s?[s]:n.length>0||t?[{role:"assistant",kind:"assistant",text:t?"正在执行,可以在完成后继续追问或要求调整。":"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function GJ(e){return(Array.isArray(e)?e:[]).filter(NM)}function sf(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 JJ(e){const t=sf((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 sf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function XJ(e){const n=[...Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],...Array.isArray(e==null?void 0:e.outputs)?e.outputs:[]].find(r=>(r==null?void 0:r.name)==="skillKeys"||(r==null?void 0:r.name)==="skillsContext");return sf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function CM(e,t,n=1){const r=(Array.isArray(e)?e:[]).map(o=>String(o||"").trim()).filter(Boolean);return r.length?{head:r.slice(0,n).join("、"),extra:r.length>n?`等 ${r.length} 个`:"",title:r.join(", ")}:{head:t,extra:"",title:""}}function s_(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function la(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function Cm(e,t){const n=la(e,t,"");if(!n)return null;try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function Nf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Es(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function _M(e){const t=Nf(e);return t==="html"?"display_html":t==="react"?"display_react_app":t==="table"?"display_table":t==="chart"?"display_chart":t==="ascii"?"display_ascii":t==="mermaid"?"display_mermaid":"display_markdown"}function EM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function AM(e){return e==="display_image"?"src":"content"}function i_(e,t,n){const r=AM(t),s=nd(e);let o=!1;const a=s.map(l=>(l==null?void 0:l.name)===r?(o=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return o||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function o_(e,t,n=[],r=[]){const s=Array.isArray(e)?e:[],o=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=s.findIndex(u=>l(u)&&o.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=s.findIndex(u=>o.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function a_(e){return(Array.isArray(e)?e:[]).map(t=>(t==null?void 0:t.type)==="node"||(t==null?void 0:t.name)==="next"?t:{...t,default:"",value:""})}function wg(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=s=>String((s==null?void 0:s.value)??(s==null?void 0:s.default)??"").trim(),r=t.find(s=>((s==null?void 0:s.name)==="content"||(s==null?void 0:s.name)==="result")&&n(s))||t.find(s=>(s==null?void 0:s.name)==="resultFile"&&n(s))||t.find(s=>(s==null?void 0:s.type)!=="node"&&(s==null?void 0:s.name)!=="next"&&(s==null?void 0:s.name)!=="displayType"&&n(s));return r?n(r):""}function QJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=la(t,"includeWorkspaceContext","true").toLowerCase(),r=Cm(t,"knowledgeContext"),s=Cm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:XJ(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?xg([s]):null),workspaceContext:s,displayType:Nf(la(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function li(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function ZJ(e){const t=sf((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 sf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function eX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function PM(e={},t="context"){const n=String((e==null?void 0:e.cwd)||(e==null?void 0:e.workspaceRoot)||(e==null?void 0:e.path)||"").trim(),r=String((e==null?void 0:e.id)||"").trim(),s=String((e==null?void 0:e.label)||(e==null?void 0:e.name)||"").trim();if(!n&&!r&&!s)return null;const o=String(s||r||"知识库").trim();return{id:r,label:o,kind:(e==null?void 0:e.kind)==="git"?"git":"local",type:String((e==null?void 0:e.type)||""),repoPath:n,path:n,mountPath:String((e==null?void 0:e.mountPath)||r||o).trim(),repoUrl:String((e==null?void 0:e.repoUrl)||"").trim(),branch:String((e==null?void 0:e.branch)||"").trim(),readonly:!0,role:t}}function xg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>PM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function IM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>PM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function tX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Cm(t,"knowledgeContext"),r=Cm(t,"workspaceContext");return{sources:IM(n||(r?xg([r]):null)),path:la(t,"path",""),label:la(t,"label","")}}function l_(e){var r,s,o,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=$U(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:bo((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((d=e.data)==null?void 0:d.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function c_(e,t,n,r=""){var c,u;const s=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(d=>String((d==null?void 0:d.id)||"")===s),a=String(((c=o==null?void 0:o.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[s])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function u_(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 nX(e,t,n){var d,f;const r=String(((d=e==null?void 0:e.data)==null?void 0:d.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=Zd.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?[]:bo(t==null?void 0:t.images),inputs:u_(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:u_(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const p of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[p])??"").trim();h?c[p]=h:delete c[p]}return c}function d_({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(!sY.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(v=>v.id===c&&v.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=nX(r,s,c),d=r.data||{};if(!(c!==a||d.label!==u.label||d.role!==u.role||d.model!==u.model||d.body!==u.body||JSON.stringify(bo(d.images))!==JSON.stringify(u.images)||(d.script??void 0)!==(u.script??void 0)||(d.scriptRef??void 0)!==(u.scriptRef??void 0)||(d.implementationRef??void 0)!==(u.implementationRef??void 0)||(d.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(d.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(d.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let h=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,h=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:h,instances:y}}function rX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function sX(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"])rX(e[s],t[s])&&(r[s]=n[s]);return r}function Eb(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,S;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(S=(j=d.currentTarget).setPointerCapture)==null||S.call(j,g);const k=C=>{C.preventDefault(),l(c(C.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:s,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function iX({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:[],u=Array.isArray(s)?s:[],d=Array.isArray(o)?o:[],[f,p]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,j]=m.useState({visible:!1,top:0,height:100}),S=m.useMemo(()=>new Set(JJ(t)),[t]),C=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),P=m.useMemo(()=>Array.from(S).map(F=>{var $;return(($=C.get(F))==null?void 0:$.name)||F}),[C,S]),R=m.useMemo(()=>CM(P,"选择 Skills"),[P]),B=m.useMemo(()=>{const F=new Set,$=d.map(E=>{const Q=ia(E,u).map(K=>C.get(K)).filter(Boolean);for(const K of Q)F.add(K.key);return{...E,skills:Q}}).filter(E=>E.skills.length>0),W=u.filter(E=>!F.has(E.key));return{collectionGroups:$,ungrouped:W}},[C,d,u]);m.useEffect(()=>{b(F=>{let $=!1;const W=new Set(F);for(const E of B.collectionGroups)W.has(E.id)||(W.add(E.id),$=!0);return $?W:F})},[B.collectionGroups]);const A=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return B;const $=E=>[E==null?void 0:E.key,E==null?void 0:E.name,E==null?void 0:E.description].map(K=>String(K||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:B.collectionGroups.map(E=>{const K=[E==null?void 0:E.id,E==null?void 0:E.name,E==null?void 0:E.description].map(H=>String(H||"").toLowerCase()).join(" ").includes(F)?E.skills:E.skills.filter($);return{...E,skills:K}}).filter(E=>E.skills.length>0),ungrouped:B.ungrouped.filter($)}},[B,h]),O=m.useCallback((F,$)=>{const W=new Set(S);for(const E of F)$?W.add(E):W.delete(E);a==null||a(e,Array.from(W))},[e,S,a]),D=m.useCallback(F=>{b($=>{const W=new Set($);return W.has(F)?W.delete(F):W.add(F),W})},[]),L=m.useCallback(()=>{const F=g.current;if(!F)return;const $=Math.max(1,F.scrollHeight),W=Math.max(1,F.clientHeight),E=$>W+1,Q=E?Math.max(12,W/$*100):100,K=Math.max(0,100-Q),H=E?Math.min(K,F.scrollTop/Math.max(1,$-W)*K):0;j({visible:E,top:H,height:Q})},[]);m.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(L);return()=>cancelAnimationFrame(F)},[v,A,S.size,f,L]);const M=m.useCallback(F=>{const $=g.current;if(!$)return;const W=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,F))*W,L()},[L]),V=m.useCallback((F,$=0)=>{const W=k.current;if(!W)return 0;const E=W.getBoundingClientRect(),Q=x.height/100*E.height,K=Math.max(1,E.height-Q);return(F-E.top-$)/K},[x.height]),z=m.useCallback(F=>{var te,se;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const $=k.current;if(!$)return;const W=$.getBoundingClientRect(),E=x.top/100*W.height,Q=x.height/100*W.height,H=F.clientY>=W.top+E&&F.clientY<=W.top+E+Q?F.clientY-W.top-E:Q/2;M(V(F.clientY,H));const ee=F.pointerId;(se=(te=F.currentTarget).setPointerCapture)==null||se.call(te,ee);const ue=ie=>{ie.preventDefault(),M(V(ie.clientY,H))},G=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)},[V,M,x.height,x.top,x.visible]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((F,$)=>{if(F.showOnNode===!1)return null;const W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:W},children:E}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:W,background:An(F.type)},title:`${E} · ${F.type}`})]},`in-${$}`)}),c.map((F,$)=>{if(F.showOnNode===!1)return null;const W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:W},children:E}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:W,background:An(F.type)},title:`${E} · ${F.type}`})]},`out-${$}`)}),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:F=>{var $;F.stopPropagation(),f||($=t==null?void 0:t.onRefreshSkills)==null||$.call(t),p(W=>!W)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:R.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:R.head}),R.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:R.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:h,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?i.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:L,children:[A.collectionGroups.map(F=>{const $=F.skills.map(K=>K.key),W=$.filter(K=>S.has(K)).length,E=$.length>0&&W===$.length,Q=v.has(F.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Q?" 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:E,onChange:K=>O($,K.target.checked),"aria-label":`选择 ${F.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>D(F.id),"aria-expanded":!Q,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:F.name}),F.description?i.jsx("em",{children:F.description}):null]})}),i.jsxs("small",{children:[W,"/",$.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>D(F.id),"aria-label":Q?`展开 ${F.name}`:`收起 ${F.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Q?"chevron_right":"expand_more"})})]}),Q?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:F.skills.map(K=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:S.has(K.key),onChange:H=>O([K.key],H.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?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:K.description}):null]})]},`${F.id}:${K.key}`))})]},F.id)}),A.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:A.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:A.ungrouped.map(F=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:S.has(F.key),onChange:$=>O([F.key],$.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:F.name}),F.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:F.description}):null]})]},`ungrouped:${F.key}`))})]}):null,A.collectionGroups.length===0&&A.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:k,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:z,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function oX({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,u]=m.useState(!1),[d,f]=m.useState(""),p=m.useMemo(()=>new Set(ZJ(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[s]),y=m.useMemo(()=>{const b=d.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[d,h]),v=m.useCallback((b,g)=>{const k=new Set(p);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,p,o]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:An(b.type)},title:`${x} · ${b.type}`})]},`in-${g}`)}),l.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:x}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:An(b.type)},title:`${x} · ${b.type}`})]},`out-${g}`)}),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:b=>{var g;b.stopPropagation(),c||(g=t==null?void 0:t.onRefreshMcps)==null||g.call(t),u(k=>!k)},children:[i.jsx("span",{children:p.size>0?`${p.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:b=>b.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:d,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),d?i.jsx("button",{type:"button",onClick:()=>f(""),"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:y.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:y.map(b=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:p.has(b.name),onChange:g=>v([b.name],g.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:b.name}),b.description||b.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),y.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 aX({id:e,data:t,selected:n,deleteNode:r,workspaces:s=[],onChangeWorkspace:o,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,d]=m.useState(!1),[f,p]=m.useState(""),h=tX(t),y=m.useMemo(()=>(Array.isArray(s)?s:[]).map(S=>({id:String((S==null?void 0:S.id)||""),label:String((S==null?void 0:S.label)||(S==null?void 0:S.name)||"知识库"),kind:(S==null?void 0:S.kind)==="git"?"git":"local",path:String((S==null?void 0:S.path)||""),repoUrl:String((S==null?void 0:S.repoUrl)||""),branch:String((S==null?void 0:S.branch)||""),mountPath:String((S==null?void 0:S.mountPath)||""),builtin:(S==null?void 0:S.builtin)===!0,exists:(S==null?void 0:S.exists)!==!1})).filter(S=>S.path),[s]),v=m.useMemo(()=>{const S=f.trim().toLowerCase();return S?y.filter(C=>[C.id,C.label,C.path,C.repoUrl,C.branch,C.mountPath].join(" ").toLowerCase().includes(S)):y},[f,y]),b=m.useMemo(()=>new Set((h.sources||[]).map(S=>S.id||S.path||S.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(S=>S.label||S.id||S.mountPath||S.path),[h.sources]),k=m.useMemo(()=>CM(g,"选择知识库"),[g]),x=Eb(u,[v.length,g.length,f]),j=(S,C)=>{const P=(S==null?void 0:S.id)||(S==null?void 0:S.path)||"",R=y.filter(B=>{const A=B.id||B.path||"";return A===P?C:b.has(A)});o==null||o(e,R)};return i.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":"")+(u?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((S,C)=>{if(S.showOnNode===!1)return null;const P=`${2.6+C*1.7}rem`,R=S.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:P},children:R}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:P,background:An(S.type)},title:`${R} · ${S.type}`})]},`in-${C}`)}),c.map((S,C)=>{if(S.showOnNode===!1)return null;const P=`${2.6+C*1.7}rem`,R=S.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:P},children:R}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:P,background:An(S.type)},title:`${R} · ${S.type}`})]},`out-${C}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),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:S=>{S.stopPropagation(),u||a==null||a(),d(C=>!C)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:k.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:k.head}),k.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:k.extra}):null]}),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:S=>S.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:f,onChange:S=>p(S.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?i.jsx("button",{type:"button",onClick:()=>p(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,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:"知识库"}),i.jsx("small",{children:v.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:v.map(S=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:b.has(S.id||S.path),onChange:C=>j(S,C.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:S.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[S.kind==="git"&&S.repoUrl?`${S.repoUrl}${S.branch?` · ${S.branch}`:""}${S.mountPath?` · ${S.mountPath}`:""}`:S.path,S.exists?"":" · 路径未就绪"]})]})]},`${S.id}:${S.path}`))})]}),v.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空知识库"})]}),i.jsx("div",{ref:x.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(x.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:x.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function RM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=FT(r),o=mY(TG(r)),a=s?o.filter(p=>!["issue","mr"].includes(hm(p))):o,l=yY(r,o),c=Ti(r,t),u=s?"":za(r.platform),d=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,s&&d?`${d} 个端侧 Issue`:u,r.status].filter(Boolean);return i.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${s?" af-prd-workflow-issue--aggregate":""}`,children:[i.jsx("strong",{children:PG(r,t)}),i.jsx("small",{children:f.join(" · ")}),i.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[i.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?i.jsx("small",{children:l.detail}):null]}),a.length?i.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(p=>i.jsx("a",{href:p.href,target:"_blank",rel:"noreferrer",children:p.label},`${p.label}-${p.href}`))}):null,d?i.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((p,h)=>i.jsx(RM,{row:p,index:h,child:!0},Ti((p==null?void 0:p.issue)||{},h)))}):null]})}function TM(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e).trim():typeof e!="object"||Array.isArray(e)?"":String(e.label||e.name||e.value||e.key||e.code||e.username||e.userId||"").trim()}function MM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>TM(n)).filter(Boolean)}function lX({fieldKey:e,field:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=String(t.label||e||"").trim(),r=String(t.type||"text").trim().toLowerCase(),s=["text","user","chips","list","link"].includes(r)?r:"text",o=MM(t.value);if(!o.length)return null;if(s==="list")return i.jsxs("div",{className:"af-prd-overall-platform__rules",children:[i.jsx("small",{children:n}),i.jsx("ul",{children:o.map((a,l)=>i.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(s==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=String(t.href||t.url||a.href||a.url||"").trim();return i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[i.jsx("small",{children:n}),l?i.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:o[0]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o[0]})]})}return i.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${s}`,children:[i.jsx("small",{children:n}),i.jsx("div",{children:o.map((a,l)=>i.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function cX({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,o])=>o&&typeof o=="object"&&MM(o.value).length);if(!r.length)return null;const s=e==="progress";return i.jsxs("section",{className:`af-prd-overall-platform${s?" af-prd-overall-platform--compact":""}`,children:[i.jsx("div",{className:"af-prd-overall-platform__head",children:i.jsx("strong",{children:String(t.title||e||"").trim()})}),i.jsx("div",{className:"af-prd-overall-platform__fields",children:r.map(([o,a])=>i.jsx(lX,{fieldKey:o,field:a},o))})]})}function uX({globalState:e,tapdId:t}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n.workflow&&typeof n.workflow=="object"&&!Array.isArray(n.workflow)?n.workflow:{},s=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},o=String(n.title||"").trim(),a=String(n.url||"").trim(),l=TM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([f,p])=>f&&p&&typeof p=="object"&&!Array.isArray(p)),d=!!(o||a||l||u.length);return!c&&!d?null:i.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"需求概览"}),l?i.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),o||a||c?i.jsx("div",{className:"af-prd-overall__requirement",children:a?i.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[i.jsx("strong",{children:o||`${r.namespace||"Workflow"} ${c}`}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,d?i.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,p])=>i.jsx(cX,{sectionKey:f,section:p},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function dX({flowParams:e={},tapdId:t,setTapdId:n,snapshot:r,loading:s,error:o,actionRunning:a,actionOutput:l,pendingConfirm:c,conflict:u,reviewPublishing:d,onRefresh:f,onRunDryRun:p,onConfirmAction:h,onRetryConflict:y,onPublishReview:v}){const[b,g]=m.useState("all"),[k,x]=m.useState("all"),[j,S]=m.useState(!1),[C,P]=m.useState(!1),[R,B]=m.useState(!1),[A,O]=m.useState(""),[D,L]=m.useState(!1),[M,V]=m.useState(""),[z,F]=m.useState(null),$=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),W=Array.isArray(r==null?void 0:r.issues)?r.issues:[],E=MG(r),Q=E.reduce((ye,ze)=>ye+yb(ze.issues),0),K=Array.isArray(r==null?void 0:r.artifacts)?r.artifacts:[];Array.isArray(r==null?void 0:r.optionalGaps)&&r.optionalGaps;const H=r!=null&&r.nextAction&&typeof r.nextAction=="object"?r.nextAction:null,ee=DG(r,H),ue=EG(r,ee),G=K.filter(ye=>!BT({...ye,href:jc(ye)})),te=m.useMemo(()=>NG(ee),[ee]);m.useEffect(()=>{k!=="all"&&(te.some(ye=>ye.key===k)||x("all"))},[k,te]);const se=ee.filter(ye=>CG(ye,k)),ie=SG(se),Z=FG(r),ce=Z.filter(ye=>zG(ye,b)),de=se.filter(ye=>jv(ye)).length,pe=r!=null&&r.collaboration&&typeof r.collaboration=="object"?r.collaboration:{},Me=pe.activeAction&&typeof pe.activeAction=="object"?pe.activeAction:null;Array.isArray(r==null?void 0:r.clientObservations)&&r.clientObservations;const Ne=String((r==null?void 0:r.rawOutput)||""),Ce=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,We=mG($),ct=m.useCallback(async()=>{const ye=String(t||"").trim();if(!ye){F(null);return}P(!0),O(""),V("");try{const ze=new URLSearchParams({tapdId:ye});e.workflowShare&&ze.set("workflowShare",e.workflowShare);const re=await fetch(`/api/prd-workflow/share?${ze.toString()}`),ke=await re.json().catch(()=>({}));if(!re.ok)throw new Error(ke.error||"读取 Workflow 分享状态失败");let Be=ke.share||null;const Qe=ke.canCreate===!0&&!e.workflowShare;if(L(Qe),!Be&&Qe){const _e=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:ye})}),_t=await _e.json().catch(()=>({}));if(!_e.ok)throw new Error(_t.error||"生成 Workflow 分享链接失败");Be=_t.share||null}F(Be)}catch(ze){O(String(ze.message||ze))}finally{P(!1)}},[e,t]),yt=()=>{S(!0),ct()},Re=async()=>{if(!(!t||R||e.workflowShare)){B(!0),O(""),V("");try{const ye=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),ze=await ye.json().catch(()=>({}));if(!ye.ok)throw new Error(ze.error||"生成 Workflow 分享链接失败");F(ze.share||null),L(!0)}catch(ye){O(String(ye.message||ye))}finally{B(!1)}}},ot=async()=>{const ye=await Cb((z==null?void 0:z.shortUrl)||(z==null?void 0:z.url)||"");V(ye?"已复制":"复制失败")},kt=async()=>{if(!(!t||R||!(z!=null&&z.canManage))){B(!0),O(""),V("");try{const ye=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),ze=await ye.json().catch(()=>({}));if(!ye.ok)throw new Error(ze.error||"取消 Workflow 分享链接失败");F(null),L(!0)}catch(ye){O(String(ye.message||ye))}finally{B(!1)}}},$t=(z==null?void 0:z.shortUrl)||(z==null?void 0:z.url)||"";return i.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[i.jsxs("section",{className:"af-prd-workflow__statusbar",children:[i.jsxs("div",{className:"af-prd-workflow__status-main",children:[i.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${$.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:zC($)}),i.jsx("h1",{children:(r==null?void 0:r.pointer)||(t?"等待 prd-flow 返回状态":"选择 TAPD 需求后读取状态")}),i.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?i.jsxs(i.Fragment,{children:["TAPD ",i.jsx("strong",{children:t})," · 独立需求 Workflow"]}):i.jsx(i.Fragment,{children:"尚未选择 TAPD 需求"})}),o?i.jsx("p",{className:"af-prd-workflow-error",children:o}):null,Me||pe.subscribers?i.jsxs("div",{className:"af-prd-workflow-collab",children:[Me?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),Me.title||Me.action||"Workflow action"," 执行中",Me.userId?i.jsx("small",{children:Me.userId}):null]}):null,pe.subscribers?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),pe.subscribers," 个连接"]}):null]}):null]}),i.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:ye=>{ye.preventDefault(),f==null||f()},children:[i.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:We.map(ye=>i.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${ye.status}`,children:[i.jsx("span",{"aria-hidden":"true"}),i.jsx("small",{children:ye.label})]},ye.label))}),i.jsxs("div",{className:"af-prd-workflow__lookup-row",children:[i.jsxs("label",{children:[i.jsx("span",{children:"TAPD Workflow"}),i.jsx("input",{value:t,onChange:ye=>n(ye.target.value),placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),i.jsxs("button",{type:"submit",disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"hourglass_empty":"sync"}),s?"读取中":t?"刷新":"读取"]}),i.jsxs("button",{type:"button",disabled:!t,onClick:yt,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享"]})]})]})]}),u?i.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[i.jsxs("div",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),i.jsxs("div",{children:[i.jsx("strong",{children:"状态已变化,需要重新确认"}),i.jsx("p",{children:u.message||"当前 workflow 状态和执行前不一致。"})]})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"执行时 revision"}),i.jsx("dd",{children:u.expectedRevision||"空"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前 revision"}),i.jsx("dd",{children:u.currentRevision||"未知"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前状态"}),i.jsx("dd",{children:[zC(u.currentPhase),u.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),i.jsx("div",{className:"af-prd-workflow-conflict__actions",children:i.jsx("button",{type:"button",onClick:()=>f==null?void 0:f(),disabled:s||a,children:"刷新状态"})})]}):null,i.jsxs("section",{className:"af-prd-workflow__main",children:[i.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[i.jsxs("div",{className:"af-prd-workflow-actions__head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Action 时间线"}),i.jsx("p",{children:ee.length?`${de}/${se.length} 已完成${k!=="all"?` · 共 ${ee.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),H&&bm(H)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:H.command||ao(H,0)})]}):null]}),te.length?i.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[i.jsxs("button",{type:"button",className:k==="all"?"is-active":"","aria-pressed":k==="all",onClick:()=>x("all"),children:["全部 ",i.jsx("span",{children:ee.length})]}),te.map(ye=>i.jsxs("button",{type:"button",className:k===ye.key?"is-active":"","aria-pressed":k===ye.key,onClick:()=>x(ye.key),children:[ye.label," ",i.jsx("span",{children:ye.count})]},ye.key))]}):null,i.jsx("div",{className:"af-prd-workflow-action-list",children:se.length?ie.map(ye=>i.jsxs("section",{className:"af-prd-workflow-action-day",children:[i.jsxs("div",{className:"af-prd-workflow-action-day__label",children:[i.jsx("span",{children:ye.day}),i.jsx("small",{children:"北京时间"})]}),i.jsx("div",{className:"af-prd-workflow-action-day__items",children:ye.items.map(({item:ze,index:re})=>{const ke=ga(ze.status),Be=oa(ze)==="observation"&&ke==="done"?"observed":ke,Qe=Cv(ze),_e=vG(ze),_t=_G(ze),Xt=yG(ze,re),Ft=wG(ze);return i.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${Be}`,children:[i.jsx("div",{className:"af-prd-workflow-action__rail",children:i.jsx("span",{className:"af-prd-workflow-action__dot"})}),i.jsxs("div",{className:"af-prd-workflow-action__body",children:[i.jsxs("div",{className:"af-prd-workflow-action__top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-prd-workflow-action__title",children:[_e?i.jsx("time",{dateTime:xm(ze),children:_e}):null,i.jsx("strong",{children:Xt})]}),Ft?i.jsx("p",{children:Ft}):null,_t.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:_t.map(at=>i.jsxs("span",{children:[i.jsx("b",{children:at.label}),at.value]},`${at.label}-${at.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:jG(ze)})]}),Qe.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Qe.map(at=>i.jsxs("a",{href:at.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:at.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${at.label}-${at.href}`))}):null]})]},ze.id||ze.actionId||`${ao(ze,re)}-${re}`)})})]},ye.day)):i.jsxs("div",{className:"af-prd-workflow-action-empty",children:[i.jsx("strong",{children:t?ee.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),i.jsx("p",{children:t?ee.length?"切换到其它 tag 或查看全部。":"Workflow tab 不会生成默认步骤;需要 prd-flow snapshot 返回 actions/timeline/events/history 或 nextAction。":"选择后从 prd-flow 读取真实 action、产物和 URL。"})]})})]}),i.jsxs("aside",{className:"af-prd-workflow-side","aria-label":"Workflow related links",children:[i.jsx(uX,{globalState:Ce,tapdId:t}),G.length?i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:G.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:G.map((ye,ze)=>{const re=jc(ye),ke=String(ye.label||ye.title||ye.kind||re||`Artifact ${ze+1}`);return re?i.jsxs("a",{href:re,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:ke}),i.jsx("small",{children:ye.kind||re})]},`${re}-${ze}`):i.jsxs("div",{children:[i.jsx("span",{children:ke}),i.jsx("small",{children:ye.kind||""})]},`${ke}-${ze}`)})})]}):null,i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"AI Docs"}),i.jsx("span",{children:ue.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:ue.length?ue.map(ye=>{const ze=String(ye.title||ye.label||"ai-doc").trim(),re=[ye.label&&ye.label!==ze?ye.label:"",ye.platform,ye.issueKey].filter(Boolean);return i.jsxs("a",{className:"af-prd-ai-doc",href:ye.href,target:"_blank",rel:"noreferrer",title:ze,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:ze}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:re.join(" · ")||ye.kind||"ai-doc"})]},ye.href)}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"Issues"}),i.jsx("span",{children:Q||W.length})]}),i.jsx("div",{className:"af-prd-workflow-issues",children:E.length?E.map(ye=>i.jsxs("div",{className:"af-prd-workflow-epic",children:[i.jsxs("div",{className:"af-prd-workflow-epic__head",children:[i.jsx("strong",{children:ye.title||ye.key}),i.jsx("small",{children:yb(ye.issues)})]}),ye.issues.map((ze,re)=>i.jsx(RM,{row:ze,index:re},Ti((ze==null?void 0:ze.issue)||{},re)))]},ye.key)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"运行审计"}),i.jsxs("span",{children:[ce.length,"/",Z.length]})]}),i.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([ye,ze])=>i.jsx("button",{type:"button",className:b===ye?"is-active":"",onClick:()=>g(ye),children:ze},ye))}),i.jsx("div",{className:"af-prd-workflow-audit",children:ce.length?ce.map((ye,ze)=>i.jsxs("div",{children:[i.jsx("strong",{children:ao(ye,ze)}),i.jsx("small",{children:[ye.status,ye.type,xm(ye)].filter(Boolean).join(" · ")})]},ye.id||`${ye.type}-${ze}`)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Ne||l?i.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[i.jsx("div",{className:"af-prd-workflow-card__head",children:i.jsx("h2",{children:"Raw"})}),i.jsx("pre",{children:l||Ne})]}):null]})]}),j?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"分享需求 Workflow",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:"share"}),"分享需求 Workflow"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>S(!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("p",{className:"af-display-link-modal__empty",children:["通过只读链接分享 TAPD ",t," 的需求流程;不会分享当前 Project、画布或项目文件。"]}),C?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!C&&$t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:$t,readOnly:!0,onFocus:ye=>ye.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:R,onClick:()=>void ot(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),z.canManage?i.jsx("button",{type:"button",disabled:R,onClick:()=>void kt(),children:R?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!C&&!$t&&D?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:R,onClick:()=>void Re(),children:R?"生成中...":"生成分享链接"}):null,A?i.jsx("div",{className:"af-flow-snippet-error",children:A}):null]}),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:()=>S(!1),children:"完成"})})]})}),document.body):null]})}function f_(e,t){if(!(e!=null&&e[`has${t[0].toUpperCase()}${t.slice(1)}`]))return"(删除该字段)";const n=e==null?void 0:e[t];if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Hu(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function fX(e,t,n,r=!0){const s=JSON.parse(JSON.stringify(e||{})),o=Array.isArray(t)?t:[];if(!o.length)return r?n:{};let a=s;for(let c=0;c<o.length-1;c+=1){const u=o[c],d=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(d)?[]:{}),a=a[u]}const l=o[o.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],s}function pX(){var M0,$0,L0,O0;const{t:e,i18n:t}=Vr(),{navigate:n}=xs(),r=Gc(),s=dn(),o=n6(),a=m.useMemo(nG,[]),l=!!a.workflowShare,c=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=m.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[d,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=r6([]),[k,x]=s6([]),j=m.useRef([]),S=m.useRef([]),C=m.useRef(null),[P,R]=m.useState(()=>jh(null,[])),B=m.useRef(P),[A,O]=m.useState(null),D=m.useRef(null),L=m.useRef(!1),[M,V]=m.useState([]),z=m.useRef(new Map),F=m.useRef(new Map),$=m.useRef(new Set),W=m.useRef(new Set),E=m.useRef(null),Q=m.useRef(null),K=m.useRef([]),H=m.useRef(null),ee=m.useRef(null),ue=m.useRef(null),[G,te]=m.useState(null),[se,ie]=m.useState({}),Z=m.useRef({}),ce=m.useRef(!1),de=m.useRef(null),pe=m.useRef(""),Me=m.useRef(null),Ne=m.useRef(Promise.resolve()),Ce=m.useRef({running:!1,pending:null}),We=m.useRef(0),ct=m.useRef(!1),yt=m.useRef(0),Re=m.useRef(null),ot=m.useRef(!1),kt=m.useRef(!1),$t=m.useRef(""),ye=m.useRef(!1),ze=m.useRef(null),re=m.useRef(!1),ke=m.useRef(new Set),Be=m.useRef(!1),Qe=m.useRef(!1),_e=m.useCallback(()=>OY({nodeInteraction:re.current,pointerCount:ke.current.size,viewportInteraction:Be.current}),[]),_t=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Xt=m.useRef(!1),Ft=m.useRef(null),[at,Fn]=m.useState([]),ne=m.useRef([]),[Pe,et]=m.useState(""),[qe,It]=m.useState("nodes"),[vt,tr]=m.useState([]),[Yn,Tr]=m.useState(!1),[kn,nr]=m.useState(""),[pr,hr]=m.useState(!1),[fn,zn]=m.useState({name:"",id:"",description:""}),[ss,Ds]=m.useState(!1),[vn,Gn]=m.useState(""),[bs,Jn]=m.useState(""),Bn=m.useRef(null),[vr,Sr]=m.useState(!1),[Hn,Mr]=m.useState(!1),[$r,le]=m.useState(""),[me,tt]=m.useState(null),[rt,zt]=m.useState(()=>kw()),[Rn,jr]=m.useState(""),[Nr,mr]=m.useState(!1),[ut,Ut]=m.useState(""),[Yt,Xn]=m.useState(!1),[it,gr]=m.useState([]),[Fs,Bi]=m.useState(!1),[zs,oe]=m.useState(""),[ve,Te]=m.useState(""),[bt,Rt]=m.useState(""),[Qt,pn]=m.useState(!1),[$n,ks]=m.useState(""),[vs,q]=m.useState(""),[we,$e]=m.useState(!1),[Ee,Ze]=m.useState("nodes"),[wn,Lt]=m.useState(""),[Sn,rr]=m.useState(0),[yr,Zt]=m.useState(""),Kv=m.useRef(""),[gt,Ss]=m.useState(null),qv=m.useRef(null),[E$,hl]=m.useState(""),[ml,Uv]=m.useState([]),[Yv,A$]=m.useState(""),[Se,P$]=m.useState(!a.adminOwnerId),[If,I$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Tt,Rf]=m.useState(null),[R$,Cg]=m.useState(!1),[_g,Gv]=m.useState(!1),[Jv,vo]=m.useState(""),[su,Xv]=m.useState(""),[Qv,Zv]=m.useState(""),[Bs,T$]=m.useState(null),[Eg,eS]=m.useState("viewer"),[iu,tS]=m.useState(!1),[jn,gl]=m.useState(null),[M$,ya]=m.useState(!1),[Ag,yl]=m.useState({}),[Tf,nS]=m.useState(!1),[rS,ou]=m.useState(""),[Pg,$$]=m.useState(""),[L$,wl]=m.useState(()=>new Set),[Ig,Rg]=m.useState(""),[au,Tg]=m.useState({nodeId:"",query:""}),[sS,iS]=m.useState(!1),Mg=m.useRef(null),oS=m.useRef(null),aS=m.useRef(""),[$g,lS]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[O$,cS]=m.useState(!1),[wa,D$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Hi,F$]=m.useState(""),[Hs,z$]=m.useState([]),[uS,dS]=m.useState(!1),[Ws,lu]=m.useState([]),[xl,B$]=m.useState([]),[fS,H$]=m.useState(!1),[pS,hS]=m.useState([]),[mS,gS]=m.useState([]),[sr,W$]=m.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[sn,Mf]=m.useState(null),[V$,yS]=m.useState(!1),[K$,bl]=m.useState(""),[Lg,wS]=m.useState(!1),[Og,$f]=m.useState(""),[js,Lf]=m.useState(null),[Dg,xS]=m.useState(!1),[cu,uu]=m.useState(null),bS=m.useCallback(w=>{Bn.current&&window.clearTimeout(Bn.current),Jn(w),Bn.current=window.setTimeout(()=>{Jn(""),Bn.current=null},3800)},[]),Kr=m.useCallback(w=>{const N=Array.isArray(w)||w instanceof Set?w:[w];for(const _ of N){const I=String(_||"").trim();I&&($.current.add(I),W.current.add(I))}$.current.size!==0&&(E.current==null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const _=Array.from($.current);$.current.clear(),_.forEach(I=>o(I))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const _=Array.from(W.current);W.current.clear(),_.forEach(I=>o(I))},80))},[o]);m.useEffect(()=>()=>{E.current!=null&&window.cancelAnimationFrame(E.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),W.current.clear()},[]);const kS=m.useCallback((w,N)=>{const _=String(w||"").trim(),I=Nm(N);!_||!I||(g(T=>T.map(U=>{var ae;if(U.id!==_)return U;const X=Nm((ae=U.data)==null?void 0:ae.displaySize),J=X&&X.width===I.width&&X.height===I.height,Y=Math.round(Number(U.width||0))===I.width&&Math.round(Number(U.height||0))===I.height;return J&&Y?U:{...U,width:I.width,height:I.height,data:{...U.data,nodeSize:I,displaySize:I}}})),Kr(_))},[Kr,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round($g)))}catch{}},[$g]);const Fg=m.useCallback(w=>{const N=Mg.current;if(!N)return null;const _=N.getBoundingClientRect(),I=16,T=150,U=230,X=_.top+I,J=_.bottom-I,Y=Math.max(T,J-X-U);return Math.min(Math.max(w-X,T),Y)},[]),q$=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const N=Mg.current;if(!N)return;let _=Fg(w.clientY);if(!Number.isFinite(_))return;cS(!0),lS(_);const I=U=>{U.preventDefault();const X=Fg(U.clientY);Number.isFinite(X)&&(_=X,N.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},T=()=>{lS(_),cS(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",T,!0),window.removeEventListener("pointercancel",T,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",T,!0),window.addEventListener("pointercancel",T,!0)},[Fg]);m.useEffect(()=>()=>{Bn.current&&window.clearTimeout(Bn.current),Ft.current&&window.clearTimeout(Ft.current)},[]);const[U$,vS]=m.useState(()=>new Set),[Of,zg]=m.useState(!1),Bg=m.useRef(null),SS=m.useRef(null),jS=m.useRef(null),[Y$,G$]=m.useState({}),[xa,Hg]=m.useState(""),[is,NS]=m.useState(!1),[ba,kl]=m.useState([]),[Vs,Wn]=m.useState([]),[qr,Ns]=m.useState("workspace"),[du,vl]=m.useState(!1),CS=m.useRef(null),Wg=m.useRef(null),[fu,Sl]=m.useState(null),[J$,Vg]=m.useState(!0),[_S,ES]=m.useState(""),[ka,So]=m.useState({}),[Lr,Kg]=m.useState(null),[AS,qg]=m.useState(!1),jl=m.useMemo(()=>AS?aG(Lr):"",[AS,Lr]),[pu,Df]=m.useState(!0);m.useEffect(()=>{jl&&Df(lG(jl))},[jl]),m.useEffect(()=>{if(jl)try{window.localStorage.setItem(jl,pu?"true":"false")}catch{}},[pu,jl]);const[Ug,Ff]=m.useState(!1),[Yg,PS]=m.useState(!1),[Gg,IS]=m.useState("pan"),[RS,X$]=m.useState({}),hu=m.useRef({}),[TS,va]=m.useState({}),mu=m.useRef(new Map),gu=m.useRef(new Set),[MS,Nl]=m.useState(()=>new Set),[Jg,Cl]=m.useState({}),[$S,LS]=m.useState(""),[aue,ge]=m.useState(""),[OS,Ks]=m.useState("loading"),[DS,qs]=m.useState("正在载入 Project"),Wi=m.useMemo(()=>oG(a),[a]),[FS,zS]=m.useState(""),yu=a.flowSource||"user",BS=m.useMemo(()=>new Set(Object.values(RS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[RS]),Vi=m.useCallback(w=>{const N=hu.current||{},_=typeof w=="function"?w(N):w,I=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return hu.current=I,X$(I),I},[]),HS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Tt!=null&&Tt.role?Tt.role==="owner":yu==="user"||yu==="workspace")),wu=!!(!a.adminOwnerId&&yu==="workspace"&&(Tt!=null&&Tt.role)&&Tt.role!=="owner"),WS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[OS]||"同步状态",hi=m.useCallback(()=>{!ce.current||!Se||(ye.current=!1,We.current+=1,ct.current=!0,Ks("dirty"),qs("本地修改等待同步"))},[Se]);m.useEffect(()=>{a.flowId&&zF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{kl([]),Wn([]),Ns("workspace"),Vg(!0)},[a]);const Nn=m.useCallback(async()=>{const w=Fr(a),N=await fetch(`/api/workspace/files?${w.toString()}`),_=await N.json();if(!N.ok)throw new Error(_.error||"读取 workspace 失败");const I=_.files||[];Uv(I),wl(new Set(vM(I))),A$(_.root||"")},[a]),zf=m.useCallback(async()=>{Tr(!0),nr("");try{const w=await fetch("/api/marketplace/flow-snippets"),N=await w.json().catch(()=>({}));if(!w.ok)throw new Error(N.error||"读取流程片段失败");tr(Array.isArray(N.snippets)?N.snippets:[])}catch(w){nr(String(w.message||w)),tr([])}finally{Tr(!1)}},[]),VS=m.useCallback(async(w,N,_)=>{var Y,ae,he;if(!ce.current)return;if(!Se)throw ge("Readonly workspace"),Ks("readonly"),qs("只读 Project"),new Error("Readonly workspace");Ks("saving"),qs("正在同步修改");const I=Wl(w,N,Z.current);I.ui={...I.ui||{},displayPage:JC(B.current,w)};const T=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:I,baseRevision:pe.current,baseGraph:Me.current,clientId:_t.current})}),U=await T.json().catch(()=>({}));if(!T.ok){if(T.status===409||T.status===428){const je=Array.isArray(U.conflictItems)?U.conflictItems:[];gl({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:je,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),yl(Object.fromEntries(je.map((He,Le)=>[String(Le),{mode:"local",manual:Hu(He)}]))),ou(""),ya(je.length>0),Ks("conflict"),qs(U.error||"存在需要处理的字段冲突");const Ve=Array.isArray(U.conflictPaths)?U.conflictPaths:[],Fe=Ve.length?`${U.error||"Workspace 已被其他成员更新"}:${Ve.join("、")}`:U.error||"Workspace 已被其他成员更新",Ke=new Error(Fe);throw Ke.code="WORKSPACE_REVISION_CONFLICT",Ke.currentRevision=U.currentRevision||"",Ke}const fe=new Error(U.error||"保存 workspace graph 失败");throw Ks("error"),qs(fe.message),fe}const X=We.current!==_,J=LY({savedGraph:U.graph,sentGraph:I,savedRevision:U.revision,currentRevision:pe.current});if(pe.current=J.revision,Me.current=J.graph,!X){if(Z.current=((Y=U.graph)==null?void 0:Y.instances)||I.instances,ie(Z.current),U.merged&&U.graph){const fe=Bu(U.graph,at),je=jh((he=(ae=U.graph)==null?void 0:ae.ui)==null?void 0:he.displayPage,fe.nodes);Z.current=fe.instances,ie(fe.instances),g(fe.nodes),x(fe.edges),B.current=je,R(je)}ct.current=!1}return va(qp(U.workspaceSchedules||[])),gl(null),ya(!1),Ks(X?"dirty":"synced"),qs(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,at,x,g,Se]),en=m.useCallback((w=b,N=k)=>{const _=Ce.current,I={nextNodes:w,nextEdges:N,saveEditVersion:We.current,waiters:[]},T=new Promise((J,Y)=>{I.waiters.push({resolve:J,reject:Y})});if(_.running)return _.pending=LC(_.pending,I),T;_.running=!0;const U=async()=>{let J=I;for(;J;){_.pending&&(J=LC(J,_.pending),_.pending=null);try{const Y=await VS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ae})=>ae(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Ks("error"),qs(String(Y.message||Y))),J.waiters.forEach(({reject:ae})=>ae(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&_.pending&&(_.pending.waiters.forEach(({reject:ae})=>ae(Y)),_.pending=null)}J=_.pending,_.pending=null}_.running=!1},X=Ne.current.catch(()=>{}).then(U);return Ne.current=X,T},[k,b,VS]),Q$=m.useCallback(w=>{var _;const N=(_=w==null?void 0:w.extra)!=null&&_.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Z.current=N,ie(N),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Zt(""),te(null)},[x,g]),Z$=m.useMemo(()=>({instances:se}),[se]),eL=dY({nodes:b,edges:k,extra:Z$,enabled:ce.current,onRestore:Q$}),{resetHistory:xu,undo:KS,redo:qS}=eL,Cs=m.useCallback(async(w={})=>{var Oe,Ot;const N=(w==null?void 0:w.background)===!0,_=yt.current+1;yt.current=_;const I=We.current,T=pe.current;N||(ce.current=!1);const U=WY({background:N}),X=Fr(a);let J=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const De=Fr(a);De.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ft,Et]=await Promise.all([fetch(`/api/nodes?${De.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),Nn()]);if(J=await ft.json(),!ft.ok)throw new Error(J.error||"读取节点定义失败");Y=Et}const ae=await Y.json();if(!Y.ok)throw new Error(ae.error||"读取 workspace graph 失败");const he=$Y({background:N,requestId:_,currentRequestId:yt.current,dirty:ct.current,startedEditVersion:I,currentEditVersion:We.current,startedRevision:T,currentRevision:pe.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const fe=N?ne.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(De=>!qY.has(De.id)),QY,XY,GY,JY,UY,YY];N||(ne.current=fe,Fn(fe));const je=ae.graph||JSON.parse(localStorage.getItem(KY)||"null")||{},Ve=Bu(je,fe),Fe=jh((Oe=je==null?void 0:je.ui)==null?void 0:Oe.displayPage,Ve.nodes),Ke=!L.current;let He=D.current;if(Ke){let De=null;try{De=JSON.parse(window.localStorage.getItem(u)||"null")}catch{De=null}He=Nb(De)||Nb((Ot=je==null?void 0:je.ui)==null?void 0:Ot.viewport)}const Le=N?IY(Me.current,je):null;if(N&&(Le!=null&&Le.safe)){const De=Le.nodesChanged?RY(j.current,Ve.nodes,Le.changedNodeIds):j.current,ft=Le.edgesChanged?TY(S.current,Ve.edges):S.current,Et=Le.displayPageChanged||!oo(B.current,Fe),Ll=Le.nodesChanged||Le.edgesChanged||Et;if(Ll&&(ye.current=!0),Le.nodesChanged){const mi=MY(Z.current,Ve.instances,Le.changedNodeIds);Z.current=mi,j.current=De,ie(mi),g(De)}if(Le.edgesChanged&&(S.current=ft,x(ft)),Et&&(B.current=Fe,R(Fe)),Ll&&xu(De,ft,{instances:Le.nodesChanged?Z.current:Ve.instances}),Le.nodesChanged||Et){const mi=new Set(Fe.nodeIds);V(Na=>{const Ca=Na.filter(rp=>mi.has(rp));return Ca.length===Na.length?Na:Ca})}}else Z.current=Ve.instances,j.current=Ve.nodes,S.current=Ve.edges,B.current=Fe,ye.current=!0,ie(Ve.instances),g(Ve.nodes),x(Ve.edges),R(Fe),V([]),xu(Ve.nodes,Ve.edges,{instances:Ve.instances});const Ht=qp(ae.workspaceSchedules||[]);va(De=>oo(De,Ht)?De:Ht),pe.current=String(ae.revision||""),Me.current=je,ct.current=!1;const st=ae.collaboration||null;Rf(De=>oo(De,st)?De:st),I$(ae.adminReview||null),gl(null),Ke&&(O(He),D.current=He,L.current=!0);const Ye=ae.writable!==!1;return P$(Ye),ge(Ye?"Workspace ready":"Readonly workspace"),Ks(Ye?"synced":"readonly"),qs(Ye?"所有修改已同步":ae.adminReview?`管理员只读查看:${ae.adminReview.ownerUsername||ae.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ce.current=!0,{skipped:!1}},[a,t.language,Nn,xu,x,g,u]),_l=m.useCallback((w={})=>{if(!ce.current)return;const N=String(w.revision||""),_=w.type==="graph.committed",I=!!(Re.current||ot.current||kt.current);if(VY({eventType:w.type,revision:N,currentRevision:pe.current,targetRevision:$t.current,refreshPending:I}))return;if(_&&N&&($t.current=N),ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(kt.current=!0,Re.current||ot.current)return;const T=async()=>{if(Re.current=null,_e()){kt.current=!0;return}if(ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}kt.current=!1,ot.current=!0;try{await Cs({background:!0}),$t.current=pe.current}catch(U){$t.current="",ge(String(U.message||U))}finally{ot.current=!1,kt.current&&!ct.current&&(Re.current=window.setTimeout(T,40))}};Re.current=window.setTimeout(T,40)},[Cs,_e]),bu=m.useCallback(async(w=sr)=>{const N=String(w||"").trim();yS(!0),bl("");try{const _=Fr(a);_.set("tapdId",N),_.set("runtimeOnly","1");const I=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"读取 PRD Workflow 失败");Mf(T.snapshot||null),$f(""),Lf(null),uu(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;N?window.localStorage.setItem(U,N):window.localStorage.removeItem(U)}catch{}}catch(_){bl(String(_.message||_))}finally{yS(!1)}},[a,sr]),El=m.useCallback(async(w=null,N={})=>{const _=w&&typeof w=="object"?w:sn==null?void 0:sn.nextAction,I=bm(_);if(!I||Lg)return;const T=(N==null?void 0:N.confirm)===!0,U=String((N==null?void 0:N.expectedRevision)||(sn==null?void 0:sn.revision)||"");wS(!0),bl(""),T||($f(""),Lf(null),uu(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:sr,action:I,stage:al(_),title:ao(_,0),...AG(_),dryRun:!T,confirm:T,issueKey:_.issueKey||_.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&Mf(J.snapshot),J.conflict&&uu({...J.conflict,action:_}),new Error(J.error||"执行 PRD Workflow action 失败");$f(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),Mf(J.snapshot||sn),uu(null),Lf(T?null:{action:_,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){bl(String(X.message||X))}finally{wS(!1)}},[a,Lg,sn,sr]),tL=m.useCallback((w=null)=>El(w,{confirm:!1}),[El]),nL=m.useCallback(()=>{const w=(js==null?void 0:js.action)||(sn==null?void 0:sn.nextAction);return El(w,{confirm:!0,expectedRevision:(js==null?void 0:js.expectedRevision)||""})},[El,js,sn]),rL=m.useCallback(()=>{const w=(cu==null?void 0:cu.action)||(sn==null?void 0:sn.nextAction);return uu(null),El(w,{confirm:!1})},[El,cu,sn]),sL=m.useCallback(async()=>{var U,X;const w=String(Og||(sn==null?void 0:sn.rawOutput)||"").trim();if(!w||Dg)return;const N=(js==null?void 0:js.action)||(sn==null?void 0:sn.nextAction)||{},_=`Review: ${ao(N,0)||(sn==null?void 0:sn.pointer)||sr||"PRD Workflow"}`,I=/^[\[{]/.test(w),T=w.startsWith("#")?w:`# ${_}
247
-
248
- ${I?`\`\`\`json
249
- ${w}
250
- \`\`\``:w}`;xS(!0),bl("");try{const J=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:sr,title:_,markdown:T,action:bm(N),stage:al(N),issueKey:N.issueKey||N.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");Mf(Y.snapshot||sn);const ae=((U=Y.review)==null?void 0:U.shortUrl)||((X=Y.review)==null?void 0:X.url)||"";ae&&$f(he=>`${he||w}
251
-
252
- Review link: ${ae}`)}catch(J){bl(String(J.message||J))}finally{xS(!1)}},[a,Og,js,Dg,sn,sr]),iL=m.useCallback(async(w,N)=>{const _={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:N,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",scriptRef:(w==null?void 0:w.scriptRef)||"",implementationRef:(w==null?void 0:w.implementationRef)||"",implementationMode:(w==null?void 0:w.implementationMode)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:a.flowId,flowSource:a.flowSource||"user",archived:!!a.archived},I=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),T=await I.json().catch(()=>({}));if(!I.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||"Publish failed");return await Cs(),ge(`Published node ${T.definitionId||T.id||_.packageId}`),T},[a,Cs]),Sa=m.useCallback((w=Vs)=>{const N=Array.isArray(w)?w:[],I=[...N].reverse().find(T=>(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="stopping")||[...N].reverse().find(T=>T==null?void 0:T.id);return String((I==null?void 0:I.id)||"workspace")},[Vs]),oL=m.useCallback(w=>{const N=String(w||"").trim();!N||N==="workspace"||Wn(_=>{const I=(Array.isArray(_)?_:[]).filter(T=>T.id!==N);return Ns(T=>T===N?Sa(I):T),I})},[Sa]);m.useCallback((w="")=>{vl(!0),Sl(null),Ss(null),Ns(w||Sa())},[Sa]);const US=m.useCallback((w={})=>{Sl({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),vl(!1),Ss(null),Zt("")},[]),Xg=m.useCallback(async(w="")=>{const N=String(w||"").trim();if(!(!N||!Se)){LS(N),ge(`Optimizing run: ${N}`);try{await en(j.current,S.current);const _=Wl(j.current,S.current,Z.current),I=c_(j.current,Z.current,N,Hi),T=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:N,graph:_,model:I})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,J=Bu(X,at);Z.current=J.instances,ie(J.instances),g(J.nodes),x(J.edges),va(qp(U.workspaceSchedules||[])),xu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(U.optimized)?U.optimized.length:0;ge(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(_){ge(String(_.message||_))}finally{LS("")}}},[Hi,S,a,j,at,xu,en,x,g,Se]),YS=m.useCallback(async(w="")=>{const N=String(w||"").trim(),_=hu.current||{},I=Object.entries(_).find(([Y,ae])=>Y===N||String((ae==null?void 0:ae.runNodeId)||"")===N)||Object.entries(_)[0]||null,T=(I==null?void 0:I[0])||"",U=(I==null?void 0:I[1])||null,X=String((U==null?void 0:U.runNodeId)||N||"").trim();if((U==null?void 0:U.status)==="stopping")return;const J=new Set([X,...Array.isArray(U==null?void 0:U.plannedNodeIds)?U.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));T&&Vi(Y=>{const ae={...Y};return ae[T]&&(ae[T]={...ae[T],status:"stopping"}),ae}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Wn(Y=>Y.map(ae=>(T?ae.id===T:!X||ae.runNodeId===X)&&ae.status==="running"?{...ae,status:"stopping"}:ae));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:T,runNodeId:X})}),ae=await Y.json().catch(()=>({}));if(!Y.ok||(ae==null?void 0:ae.stopped)!==!0)throw new Error(ae.error||"Workspace run stop failed");const he=T?mu.current.get(T):null;he&&(he.abort(),mu.current.delete(T)),T&&Vi(fe=>{const je={...fe};return delete je[T],je}),Nl(fe=>{const je=new Set(fe);for(const Ve of J)je.delete(Ve);return je}),Cl(fe=>{var Ve;const je={...fe};for(const Fe of J)Fe&&(!je[Fe]||((Ve=je[Fe])==null?void 0:Ve.status)==="running")&&(je[Fe]={status:"stopped"});return je}),ge(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),Wn(fe=>fe.map(je=>(T?je.id===T:!X||je.runNodeId===X)?{...je,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(je.messages)?je.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:je))}catch(Y){T&&Vi(he=>{const fe={...he};return fe[T]&&(fe[T]={...fe[T],status:"running"}),fe});const ae=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${ae}`),Wn(he=>he.map(fe=>(T?fe.id===T:!X||fe.runNodeId===X)?{...fe,status:"running",messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${ae}`,at:Date.now()}].slice(-160)}:fe))}},[a,Vi]),Bf=m.useCallback(async()=>{if(a.flowId)try{const w=Fr(a),N=await fetch(`/api/workspace/run/status?${w.toString()}`),_=await N.json().catch(()=>({}));if(!N.ok||!_.running)return;const I=Array.isArray(_.runs)&&_.runs.length?_.runs:[{runId:`run-restored-${_.startedAt||Date.now()}`,runNodeId:_.runNodeId||"",startedAt:_.startedAt||Date.now(),plannedNodeIds:[]}],T={},U=[];for(const X of I){const J=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ae=String((X==null?void 0:X.label)||"").trim()||yw(j.current,Z.current,J,"Workspace Run");T[Y]={id:Y,runNodeId:J,label:ae,status:(X==null?void 0:X.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(X==null?void 0:X.plannedNodeIds)?X.plannedNodeIds:[],startedAt:(X==null?void 0:X.startedAt)||Date.now()},J&&U.push(J)}if(!Object.keys(T).length)return;Vi(X=>({...X,...T})),Nl(X=>{const J=new Set(X);for(const Y of U)J.add(Y);return J}),Cl(X=>{const J={...X};for(const Y of U)J[Y]={status:"running"};return J}),ge(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),Wn(X=>{const J=[...X];for(const[Y,ae]of Object.entries(T)){if(J.some(je=>je.id===Y||["running","stopping"].includes(je.status)&&je.runNodeId===ae.runNodeId))continue;const he=String(ae.runNodeId||""),fe=String(ae.label||"").trim()||yw(j.current,Z.current,he,"Workspace Run");J.push({id:Y,label:ww(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:ae.status,startedAt:ae.startedAt||Date.now(),steps:he?[{id:he,label:ww(fe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ae.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,j,Vi]),GS=m.useCallback(async w=>{if(!Se){ge("Readonly workspace");return}if(!w)return;if(Object.values(hu.current||{}).find(st=>String((st==null?void 0:st.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let _=j.current,I=S.current,T=Z.current;const U=qv.current;if(U!=null&&U.id){const st=_.find(Oe=>Oe.id===U.id),Ye=d_({nodes:_,edges:I,instances:T,selectedNode:st,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){hl(Ye.error),ge(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,I=Ye.edges,T=Ye.instances,Z.current=T,j.current=_,S.current=I,ie(T),g(_),x(I),Kr(Ye.nextId||U.id))}const X=Wl(_,I,T),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=yw(_,T,w,"Workspace Run"),ae=ww(Y,w,"Workspace Run");let he=[w];try{const st=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:w})}),Ye=await st.json().catch(()=>({}));if(!st.ok||(Ye==null?void 0:Ye.ok)===!1)throw new Error(Ye.error||"Workspace run plan failed");he=Array.isArray(Ye.plannedNodeIds)&&Ye.plannedNodeIds.length?Ye.plannedNodeIds.map(Ot=>String(Ot||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Oe=Ye.conflict||null;if(Oe!=null&&Oe.runNodeId||Oe!=null&&Oe.runId){const Ot=Array.isArray(Oe.conflictNodeIds)&&Oe.conflictNodeIds.length?`: ${Oe.conflictNodeIds.join(", ")}`:"";ge(`Run ${w} conflicts with running ${Oe.runNodeId||Oe.runId}${Ot}`);return}}catch(st){ge(String(st.message||st));return}const fe=new Set(he),je=Object.values(hu.current||{}).find(st=>(Array.isArray(st==null?void 0:st.plannedNodeIds)?st.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(je){const st=(Array.isArray(je.plannedNodeIds)?je.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));ge(`Run ${w} conflicts with running ${je.runNodeId||"workspace run"}${st.length?`: ${st.join(", ")}`:""}`);return}const Ve=new AbortController;mu.current.set(J,Ve),gu.current.delete(J),Vi(st=>({...st,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),Nl(st=>new Set([...st,w])),Cl(st=>({...st,[w]:{status:"running"}})),ge(`Running ${ae}...`),Ns(J),Wn(st=>[...st.slice(-7),{id:J,label:ae,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let Fe=w;const Ke=new Map,He=()=>gu.current.has(J),Le=st=>{const Ye=new Set((st||[]).map(Oe=>String(Oe||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),Nl(Oe=>{const Ot=new Set(Oe);for(const De of Ye)Ot.delete(De);return Ot})},Ht=(st,Ye)=>{const Oe=new Set((st||[]).map(Ot=>String(Ot||"").trim()).filter(Boolean));Oe.size||Oe.add(String(w||"")),Cl(Ot=>{var ft;const De={...Ot};for(const Et of Oe)Et&&(!De[Et]||((ft=De[Et])==null?void 0:ft.status)==="running")&&(De[Et]={status:Ye});return De})};try{await en(_,I);const st=c_(_,T,w,Hi),Ye=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:Ve.signal,body:JSON.stringify({...a,graph:X,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:pe.current,clientId:_t.current,model:st,selectedSkills:Ws,stream:!0})});if(!Ye.ok){const xe=await Ye.json().catch(()=>({}));throw new Error(xe.error||"Workspace run failed")}if(!Ye.body)throw new Error("Workspace run stream unavailable");const Oe=Ye.body.getReader(),Ot=new TextDecoder;let De="",ft=[],Et=[];const Ll=(xe,nt)=>{var lt,Ct;const Ge=b.find(Bt=>Bt.id===xe),ht=String(((lt=Ge==null?void 0:Ge.data)==null?void 0:lt.label)||xe||"").trim(),be=String(nt||((Ct=Ge==null?void 0:Ge.data)==null?void 0:Ct.definitionId)||"").trim();return be&&be!==ht?`${ht} (${be})`:ht},mi=(xe,nt,Ge)=>{const ht=String(xe||"").trim();ht&&Wn(be=>be.map(lt=>{if(lt.id!==J)return lt;const Bt=[...Array.isArray(lt.steps)?lt.steps:[]],mt=Bt.findIndex(an=>an.id===ht),St={id:ht,label:Ll(ht,nt),status:Ge};mt>=0?Bt[mt]={...Bt[mt],...St}:Bt.push(St);const on=Bt.map((an,_o)=>{const Ui=an.status==="done"?"[done]":an.status==="failed"?"[failed]":"[running]";return`${_o+1}. ${Ui} ${an.label}`}).join(`
253
- `),Gt=Array.isArray(lt.messages)?lt.messages:[],nn=Gt.findIndex(an=>an.kind==="run-summary"),hn={role:"assistant",kind:"run-summary",text:on||"准备运行...",at:Date.now()},Wt=[...Gt];return nn>=0?Wt[nn]=hn:Wt.unshift(hn),{...lt,steps:Bt,messages:Wt.slice(-160)}}))},Na=(xe,nt)=>{var H0,W0,V0,K0,q0,U0,Y0,G0,J0,X0;const Ge=String(xe||"").trim(),ht=String(nt||"").trim();if(!Ge||!ht)return;const be=(H0=Z.current)==null?void 0:H0[Ge];if(!li(be==null?void 0:be.definitionId))return;const lt=la(be==null?void 0:be.input,"displayType","markdown"),Ct=_M(lt),Bt=EM(Ge),mt=at.find(Or=>Or.id===Ct),St=i_(mt==null?void 0:mt.inputs,Ct,ht),on=i_(mt==null?void 0:mt.outputs,Ct,ht),Gt=String((be==null?void 0:be.label)||Ge||"一键任务").trim(),nn={...Z.current||{},[Ge]:{...be||{},output:a_(be==null?void 0:be.output)},[Bt]:{...((W0=Z.current)==null?void 0:W0[Bt])||{},definitionId:Ct,label:Gt,role:"normal",body:ht,input:St,output:on,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};Z.current=nn,ie(nn);const hn=j.current||[],Wt=hn.find(Or=>Or.id===Ge),an=hn.find(Or=>Or.id===Bt),_o=Number(((V0=Wt==null?void 0:Wt.measured)==null?void 0:V0.width)||(Wt==null?void 0:Wt.width)||((q0=(K0=Wt==null?void 0:Wt.data)==null?void 0:K0.nodeSize)==null?void 0:q0.width)||520),Ui=(an==null?void 0:an.position)||{x:Number(((U0=Wt==null?void 0:Wt.position)==null?void 0:U0.x)||0)+_o+120,y:Number(((Y0=Wt==null?void 0:Wt.position)==null?void 0:Y0.y)||0)},or=((G0=an==null?void 0:an.data)==null?void 0:G0.displaySize)||((J0=an==null?void 0:an.data)==null?void 0:J0.nodeSize)||{width:xb,height:bb},gi=gb({id:Bt,type:Sc,position:Ui,width:Number(or.width)||xb,height:Number(or.height)||bb,data:{label:Gt,definitionId:Ct,role:"normal",body:ht,inputs:St,outputs:on,sourceContextRunNodeId:Ge,displayReloadKey:nn[Bt].displayReloadKey,nodeSize:or,displaySize:or}},nn,at),Eo=hn.map(Or=>{if(Or.id===Ge){const{width:lue,height:cue,measured:uue,...a2}=Or,{nodeSize:due,displaySize:fue,...lp}=Or.data||{};return{...a2,data:{...lp,outputs:a_(lp==null?void 0:lp.outputs),contextRunResultNonce:Date.now()}}}return Or.id===Bt?{...gi,selected:Or.selected}:Or});an||Eo.push(gi),j.current=Eo,g(Eo);const Ao=S.current||[],ap=AM(Ct),fy=o_((be==null?void 0:be.output)||((X0=Wt==null?void 0:Wt.data)==null?void 0:X0.outputs),"output",["content","result"],["text"]),i2=o_(St,"input",[ap,"content"],["text"]),o2={id:`we-${Ge}-${Bt}`,source:Ge,target:Bt,sourceHandle:fy,targetHandle:i2,markerEnd:{type:Ci.ArrowClosed}},B0=[...Ao.filter(Or=>!(Or.source===Ge&&Or.target===Bt)),o2];S.current=B0,x(B0),window.requestAnimationFrame(()=>{o(Ge),o(Bt)})},Ca=(xe,nt=null)=>{const Ge=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},ht=nt instanceof Set?nt:null;for(const[be,lt]of Object.entries(Ge)){if(ht&&!ht.has(be)||!li(lt==null?void 0:lt.definitionId))continue;const Ct=wg({outputs:lt.output});Ct&&Na(be,Ct)}},rp=xe=>{const nt=String(xe||"").trim();if(!nt)return;const Ge=Fe;Fe=nt,Nl(ht=>{const be=new Set(ht);return Ge&&Ge!==nt&&Ge!==w&&be.delete(Ge),w&&be.add(w),be.add(nt),be}),Cl(ht=>{var be;return{...ht,...Ge&&Ge!==nt&&Ge!==w&&((be=ht[Ge])==null?void 0:be.status)==="running"?{[Ge]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},D0=xe=>{const nt=String(xe||"").trim();nt&&(Nl(Ge=>{const ht=new Set(Ge);return ht.delete(nt),ht}),Cl(Ge=>({...Ge,[nt]:{status:"success"}})))},F0=(xe,nt)=>{const Ge=String(nt||"");if(!Ge.trim())return;const ht=["assistant","thinking","result","error","prompt"].includes(xe)?xe:"assistant";Wn(be=>be.map(lt=>{if(lt.id!==J)return lt;let Ct=Array.isArray(lt.messages)?lt.messages:[];if(ht==="result"){const St=[...Ct].reverse().find(on=>on.kind==="assistant");if(String((St==null?void 0:St.text)||"").trim()===Ge.trim())return lt}if(ht==="assistant"){const St=Ct.findIndex(on=>on.kind==="result"&&String(on.text||"").trim()===Ge.trim());St>=0&&(Ct=Ct.filter((on,Gt)=>Gt!==St))}const Bt=[...Ct],mt=Bt[Bt.length-1];return mt&&mt.kind===ht&&!mt.error?Bt[Bt.length-1]={...mt,text:`${mt.text||""}${mt.text?`
254
- `:""}${Ge}`}:Bt.push({role:"assistant",kind:ht,text:Ge,...ht==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Bt.slice(-160)}}))},sp=xe=>{const nt=String(xe||"");nt.trim()&&Wn(Ge=>Ge.map(ht=>{var Bt;if(ht.id!==J)return ht;const be=Array.isArray(ht.messages)?ht.messages:[],lt=be.findIndex(mt=>mt.kind==="thinking"),Ct=[...be];if(lt>=0){const mt=String(((Bt=Ct[lt])==null?void 0:Bt.text)||"");Ct[lt]={...Ct[lt],text:`${mt}${mt&&!mt.endsWith(`
255
- `),""}${nt}`,at:Date.now()}}else{const mt=Ct.findIndex(St=>St.kind==="activity");Ct.splice(mt>=0?mt+1:Ct.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...ht,messages:Ct.slice(-160)}}))},Co=(xe,nt=null)=>{const Ge=dG(xe);Ge&&Wn(ht=>ht.map(be=>{if(be.id!==J)return be;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),Ct=Number(be.startedAt)||lt,Bt=Number(be.lastActivityAt)||Ct,mt=Math.max(0,lt-Bt),St=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,lt-Ct),on=Array.isArray(be.activities)?be.activities:[],Gt=on[on.length-1],hn=(typeof Gt=="string"?Gt:String((Gt==null?void 0:Gt.text)||""))===Ge?on:[...on,{text:Ge,kind:pG(Ge),stepMs:mt,totalMs:St,at:lt}].slice(-30),Wt=Array.isArray(be.timingEntries)?be.timingEntries:[],an=Array.isArray(be.messages)?be.messages:[],_o=an.findIndex(gi=>gi.kind==="activity"),Ui={role:"assistant",kind:"activity",text:HC(hn,Wt,Ct,lt),at:Date.now()},or=[...an];if(_o>=0)or[_o]=Ui;else{const gi=or.findIndex(Eo=>Eo.kind==="run-summary");or.splice(gi>=0?gi+1:0,0,Ui)}return{...be,activities:hn,lastActivityAt:lt,messages:or.slice(-160)}}))},z0=xe=>{const nt=String((xe==null?void 0:xe.source)||"runner"),Ge=String((xe==null?void 0:xe.stream)||""),ht=String((xe==null?void 0:xe.eventType)||"event"),be=String((xe==null?void 0:xe.text)||"").trim();if(!be)return;const lt=`[${nt}${Ge?`:${Ge}`:""}] ${ht}
256
- ${be}`,Ct=KG(xe);Wn(Bt=>Bt.map(mt=>{if(mt.id!==J)return mt;const on=[...Array.isArray(mt.rawTrace)?mt.rawTrace:[],lt].slice(-80),Gt=Array.isArray(mt.timingEntries)?mt.timingEntries:[],nn=Ct?[...Gt,Ct].slice(-80):Gt,hn=Array.isArray(mt.activities)?mt.activities:[],Wt=Number(mt.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),an=Number(Ct==null?void 0:Ct.at)||Number(xe==null?void 0:xe.ts)||Date.now(),_o=Array.isArray(mt.messages)?mt.messages:[],Ui={role:"assistant",kind:"raw",text:on.join(`
257
-
258
- ---
259
-
260
- `),at:Date.now()},or=[..._o],gi=or.findIndex(Ao=>Ao.kind==="activity");if(Ct){const Ao={role:"assistant",kind:"activity",text:HC(hn,nn,Wt,an),at:Date.now()};if(gi>=0)or[gi]=Ao;else{const ap=or.findIndex(fy=>fy.kind==="run-summary");or.splice(ap>=0?ap+1:0,0,Ao)}}const Eo=or.findIndex(Ao=>Ao.kind==="raw");return Eo>=0?or[Eo]=Ui:or.push(Ui),{...mt,rawTrace:on,timingEntries:nn,messages:or.slice(-160)}}))},s2=xe=>{Wn(nt=>nt.map(Ge=>Ge.id===J?{...Ge,status:xe,endedAt:Date.now()}:Ge))},ip=xe=>{const nt=new Set,Ge=String((xe==null?void 0:xe.nodeId)||"").trim();Ge&&nt.add(Ge);for(const ht of Array.isArray(xe==null?void 0:xe.displayNodeIds)?xe.displayNodeIds:[]){const be=String(ht||"").trim();be&&nt.add(be)}for(const ht of Array.isArray(xe==null?void 0:xe.touchedNodeIds)?xe.touchedNodeIds:[]){const be=String(ht||"").trim();be&&nt.add(be)}if(nt.size===0)for(const ht of Array.isArray(xe==null?void 0:xe.order)?xe.order:[]){const be=String(ht||"").trim();be&&nt.add(be)}return nt},op=(xe,nt=null)=>{const Ge=Bu(xe||X,at),ht=new Map(Ge.nodes.map(mt=>[mt.id,mt])),be=Ge.instances||{},lt=nt instanceof Set?nt:null,Ct=(mt,St)=>{const on={...mt||St};Array.isArray(St==null?void 0:St.output)&&(on.output=St.output);for(const Gt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Gt])!=null&&String(St[Gt]).trim()!==""&&(on[Gt]=St[Gt]);return on},Bt=(mt,St)=>{const on={...mt||{}};Array.isArray(St==null?void 0:St.outputs)&&(on.outputs=St.outputs);for(const Gt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Gt])!=null&&String(St[Gt]).trim()!==""&&(on[Gt]=St[Gt]);return on};g(mt=>{const St=new Set(mt.map(nn=>nn.id)),Gt={...Wl(mt,S.current,Z.current).instances||{}};for(const[nn,hn]of Object.entries(be)){if(lt&&!lt.has(nn)||!St.has(nn))continue;const Wt=Gt[nn];ll((hn==null?void 0:hn.definitionId)||(Wt==null?void 0:Wt.definitionId))?Gt[nn]=hn:Array.isArray(hn==null?void 0:hn.output)&&(Gt[nn]=Ct(Wt,hn))}return Z.current=Gt,ie(Gt),mt.map(nn=>{var Wt,an;if(lt&&!lt.has(nn.id))return nn;const hn=ht.get(nn.id);return hn?ll(((Wt=hn.data)==null?void 0:Wt.definitionId)||((an=nn.data)==null?void 0:an.definitionId))?{...nn,data:{...nn.data,...hn.data}}:{...nn,data:Bt(nn.data,hn.data)}:nn})})};for(;;){const{value:xe,done:nt}=await Oe.read();if(nt)break;De+=Ot.decode(xe,{stream:!0});const Ge=De.split(`
261
- `);De=Ge.pop()||"";for(const ht of Ge){if(!ht.trim())continue;const be=JSON.parse(ht);if(be.type==="error")throw new Error(be.error||"Workspace run failed");if(be.type==="stopped"){gu.current.add(J),ft=Array.isArray(be.order)?be.order:ft,Co("运行停止",be);continue}if(be.type==="node-start"&&(ge(`Running ${be.nodeId}...`),rp(be.nodeId),mi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const lt=Ke.get(String(be.nodeId||"").trim());lt&&Na(be.nodeId,lt),D0(be.nodeId),mi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Co(be.line||be.message||"",be),be.type==="paused"&&(Et=Array.isArray(be.nodeIds)?be.nodeIds:[],Co("运行暂停",be)),be.type==="natural"&&((be.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(be.text||"")))&&be.nodeId&&Ke.set(String(be.nodeId||"").trim(),String(be.text||"")),be.kind==="thinking"?sp(be.text||""):F0(be.kind,be.text||"")),be.type==="raw"){const lt=WC(be);lt&&sp(lt),z0(be)}if(be.type==="graph"&&be.graph){const lt=ip(be);op(be.graph,lt),Ca(be.graph,lt)}if(be.type==="done"){if(be.revision&&(pe.current=String(be.revision)),be.graph){Me.current=be.graph;const lt=ip(be);op(be.graph,lt),Ca(be.graph,lt)}ft=Array.isArray(be.order)?be.order:[],Et=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:Et,Co(Et.length?"运行暂停":"运行完成",be)}}}if(De.trim()){const xe=JSON.parse(De);if(xe.type==="error")throw new Error(xe.error||"Workspace run failed");if(xe.type==="stopped"&&(gu.current.add(J),Co("运行停止",xe)),xe.type==="node-start"&&(ge(`Running ${xe.nodeId}...`),rp(xe.nodeId),mi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const nt=Ke.get(String(xe.nodeId||"").trim());nt&&Na(xe.nodeId,nt),D0(xe.nodeId),mi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Co(xe.line||xe.message||"",xe),xe.type==="paused"&&(Et=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Co("运行暂停",xe)),xe.type==="natural"&&((xe.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(xe.text||"")))&&xe.nodeId&&Ke.set(String(xe.nodeId||"").trim(),String(xe.text||"")),xe.kind==="thinking"?sp(xe.text||""):F0(xe.kind,xe.text||"")),xe.type==="raw"){const nt=WC(xe);nt&&sp(nt),z0(xe)}if(xe.type==="graph"&&xe.graph){const nt=ip(xe);op(xe.graph,nt),Ca(xe.graph,nt)}if(xe.type==="done"){if(xe.revision&&(pe.current=String(xe.revision)),xe.graph){Me.current=xe.graph;const nt=ip(xe);op(xe.graph,nt),Ca(xe.graph,nt)}ft=Array.isArray(xe.order)?xe.order:[],Et=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:Et,Co(Et.length?"运行暂停":"运行完成",xe)}}He()&&(Le(he),Ht(he,"stopped"));const dy=He()?`Workspace run stopped: ${w}`:Et.length?`Workspace run paused at ${Et.join(", ")}`:`Workspace run done: ${ft.length?ft.join(" -> "):w}`;if(ge(dy),He()||Ht(he,Et.length?"paused":"success"),s2(He()?"stopped":Et.length?"paused":"done"),!He()){try{await en(j.current,S.current),ge(dy)}catch(xe){ge(`${dy},但保存结果失败:${String(xe.message||xe)}`)}await Nn()}}catch(st){if(He()||(st==null?void 0:st.name)==="AbortError"){Le(he),Ht(he,"stopped"),ge(`Workspace run stopped: ${w}`),Wn(Ye=>Ye.map(Oe=>Oe.id===J?{...Oe,status:"stopped",endedAt:Date.now()}:Oe));return}Le(he),Ht([w,Fe].filter(Boolean),"failed"),ge(String(st.message||st)),Wn(Ye=>Ye.map(Oe=>Oe.id===J?{...Oe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Oe.messages)?Oe.messages:[],{role:"assistant",error:!0,text:String(st.message||st),at:Date.now()}].slice(-160)}:Oe))}finally{mu.current.get(J)===Ve&&mu.current.delete(J),Vi(st=>{const Ye={...st};return delete Ye[J],Ye}),gu.current.delete(J),Le(he)}},[Hi,k,a,Nn,b,at,Kr,en,Ws,x,g,Vi,o,Se]),Hf=m.useCallback(async()=>{try{const N=await(await fetch("/api/skills")).json().catch(()=>({})),_=Array.isArray(N.skills)?N.skills.map(I=>({key:String(I.key),name:String(I.name||I.id||I.key),description:I.description?String(I.description):"",sourceLabel:I.sourceLabel?String(I.sourceLabel):""})):[];z$(_),dS(!0)}catch{dS(!0)}},[]),Wf=m.useCallback(async()=>{try{const N=await(await fetch("/api/mcps")).json().catch(()=>({})),_=Array.isArray(N.servers)?N.servers.map(I=>({name:String((I==null?void 0:I.name)||""),type:String((I==null?void 0:I.type)||""),url:String((I==null?void 0:I.url)||""),command:String((I==null?void 0:I.command)||""),args:Array.isArray(I==null?void 0:I.args)?I.args.map(String):[],description:String((I==null?void 0:I.description)||"")})).filter(I=>I.name):[];hS(_)}catch{hS([])}},[]),Vf=m.useCallback(async()=>{try{const w=Fr(a),_=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),I=Array.isArray(_.workspaces)?_.workspaces.map(T=>({id:String((T==null?void 0:T.id)||""),label:String((T==null?void 0:T.label)||(T==null?void 0:T.name)||"知识库"),path:String((T==null?void 0:T.path)||""),kind:(T==null?void 0:T.kind)==="git"?"git":"local",repoUrl:String((T==null?void 0:T.repoUrl)||""),branch:String((T==null?void 0:T.branch)||""),mountPath:String((T==null?void 0:T.mountPath)||""),type:String((T==null?void 0:T.type)||""),builtin:(T==null?void 0:T.builtin)===!0,exists:(T==null?void 0:T.exists)!==!1})).filter(T=>T.path):[];gS(I)}catch{gS([])}},[a]),JS=m.useCallback(async()=>{Xt.current=!1;try{const w=Fr(a),N=await fetch(`/api/workspace/conversations?${w.toString()}`),_=await N.json().catch(()=>({}));if(!N.ok)throw new Error(_.error||`HTTP ${N.status}`);const I=DC(_.conversations||{});kl(I.composer.messages),Wn(I.composer.runSessions),Ns(I.composer.activeSessionId||"workspace"),So(I.nodeChats)}catch{kl([]),Wn([]),Ns("workspace"),So({})}finally{Xt.current=!0}},[a]),XS=m.useCallback(async()=>{if(!Se||a.archived)return;const w=DC({composer:{activeSessionId:qr,messages:ba,runSessions:Vs},nodeChats:ka});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async N=>{if(!N.ok){const _=await N.json().catch(()=>({}));throw new Error(_.error||`HTTP ${N.status}`)}})},[qr,ba,Vs,a,ka,Se]);m.useEffect(()=>{let w=!1;return l?(Kg(null),qg(!0),()=>{w=!0}):((async()=>{const _=new URL(window.location.href),I=String(_.searchParams.get("invite")||"").trim();if(I){ge("正在加入共享 Workspace...");const T=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:I})}),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"加入共享 Workspace 失败");_.searchParams.delete("invite"),window.history.replaceState({},"",`${_.pathname}${_.search}${_.hash}`)}w||(await Cs(),w||await JS())})().catch(_=>{const I=String(_.message||_);ge(I),Ks("error"),qs(I)}),zf(),fetch("/api/model-lists").then(_=>_.json()).then(_=>D$({cursor:Array.isArray(_.cursor)?_.cursor.map(String):[],opencode:Array.isArray(_.opencode)?_.opencode.map(String):[],claudeCode:Array.isArray(_.claudeCode)?_.claudeCode.map(String):[],codex:Array.isArray(_.codex)?_.codex.map(String):[]})).catch(()=>{}),Hf(),Wf(),Vf(),Bf(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{B$(Va(_)),H$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{Kg(_.user||null),qg(!0)}).catch(()=>{Kg(null),qg(!0)}),()=>{w=!0})},[l,Cs,JS,zf,Wf,Hf,Bf,Vf,Wi]),m.useEffect(()=>{if(zS(""),!(!uS||!fS)){if(!Wi){lu([]);return}lu(QF(Wi,"workspace",Hs,xl)),zS(Wi)}},[xl,fS,Hs,uS,Wi]),m.useEffect(()=>{if(!(FS!==Wi||!Wi))try{localStorage.setItem(Wi,JSON.stringify(Ws))}catch{}},[Ws,Wi,FS]),m.useEffect(()=>{Z.current=se},[se]),m.useEffect(()=>{j.current=b},[b]),m.useEffect(()=>{if(re.current)return;const w=z.current,N=new Map,_=[];for(const I of b){const T=cM(I);N.set(I.id,T),w.get(I.id)!==T&&_.push(I.id)}z.current=N,_.length!==0&&Kr(_)},[b,Kr]),m.useEffect(()=>{S.current=k},[k]),m.useEffect(()=>{B.current=P},[P]),m.useEffect(()=>{D.current=A},[A]),m.useEffect(()=>{qv.current=gt},[gt]),m.useEffect(()=>{Kv.current=yr},[yr]),m.useEffect(()=>{ue.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=_=>{_.key==="Escape"&&te(null)},N=_=>{var I,T;(T=(I=_.target)==null?void 0:I.closest)!=null&&T.call(I,".af-connect-node-menu")||te(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",N)}},[G]),m.useEffect(()=>{if(!ce.current||!Se)return;if(re.current){de.current&&window.clearTimeout(de.current);return}const w=ze.current;if(ze.current=null,(w==null?void 0:w.nodes)===b&&w.edges===k&&w.displayPage===P)return;if(ye.current){ye.current=!1;return}hi(),de.current&&window.clearTimeout(de.current);const N=Qe.current?0:650;return Qe.current=!1,de.current=window.setTimeout(()=>{en().catch(_=>ge(String(_.message||_)))},N),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,P,hi,en,Se]),m.useEffect(()=>{if(Xt.current&&!(!Se||a.archived))return Ft.current&&window.clearTimeout(Ft.current),Ft.current=window.setTimeout(()=>{XS().catch(w=>ge(String(w.message||w)))},900),()=>{Ft.current&&window.clearTimeout(Ft.current)}},[qr,ba,Vs,a.archived,ka,XS,Se]);const ku=m.useMemo(()=>b.filter(w=>{var N;return((N=w==null?void 0:w.data)==null?void 0:N.definitionId)==="workspace_scheduled_run"}).map(w=>{var N;return{id:w.id,config:Av(((N=w.data)==null?void 0:N.body)||"")}}),[b]),aL=m.useMemo(()=>ku.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[ku]);m.useEffect(()=>{if(!ce.current||d!=="workspace"||!a.flowId){va({});return}if(!ku.length){va({});return}let w=!1;const N=async()=>{try{const I=Fr(a),T=await fetch(`/api/workspace/schedules?${I.toString()}`),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||va(qp(U.schedules||[]))}catch{w||va(I=>{var U;const T={};for(const X of ku)T[X.id]={...I[X.id]||{},lastStatus:((U=I[X.id])==null?void 0:U.lastStatus)||"unknown"};return T})}};N();const _=window.setInterval(N,5e3);return()=>{w=!0,window.clearInterval(_)}},[a,ku,aL,d]);const QS=m.useCallback((w,N)=>{if(!Se){ge("Readonly workspace");return}const _=s_(N),I=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="skillKeys"&&(ae==null?void 0:ae.name)!=="skillsContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:I((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:I(X.input)}};Z.current=J,g(T),ie(J),Ss(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:I(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,en,g,Se]),ZS=m.useCallback((w,N)=>{if(!Se){ge("Readonly workspace");return}const _=eX(N),I=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="serverNames"&&(ae==null?void 0:ae.name)!=="mcpContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:I((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:I(X.input)}};Z.current=J,g(T),ie(J),Ss(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:I(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,en,g,Se]),e0=m.useCallback((w,N)=>{if(!Se){ge("Readonly workspace");return}const _=(Array.isArray(N)?N:N?[N]:[]).filter(Fe=>String((Fe==null?void 0:Fe.path)||"").trim()),I=_[0]||null,T=String((I==null?void 0:I.path)||"").trim(),U=_.length===1?String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(xg(_)):"",J=I?JSON.stringify({version:1,id:(I==null?void 0:I.id)||"",label:String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim(),kind:(I==null?void 0:I.kind)||"local",cwd:T,workspaceRoot:T,repoUrl:(I==null?void 0:I.repoUrl)||"",branch:(I==null?void 0:I.branch)||"",mountPath:(I==null?void 0:I.mountPath)||"",type:(I==null?void 0:I.type)||""}):"",Y=Fe=>Array.isArray(Fe)?Fe.map(Ke=>(Ke==null?void 0:Ke.name)==="path"?{...Ke,default:T,value:T}:(Ke==null?void 0:Ke.name)==="label"?{...Ke,default:U,value:U}:(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:X,value:X}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J}:(Ke==null?void 0:Ke.name)==="mode"?{...Ke,default:"set",value:"set"}:Ke):[],ae=Fe=>Array.isArray(Fe)?Fe.map(Ke=>(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:X,value:X}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J,showOnNode:!1}:(Ke==null?void 0:Ke.name)==="cwd"?{...Ke,default:T,value:T,showOnNode:!1}:Ke):[],he=b.map(Fe=>{var Ke,He,Le;return Fe.id===w?{...Fe,data:{...Fe.data,label:((Ke=Fe.data)==null?void 0:Ke.label)||"加载知识库",inputs:Y((He=Fe.data)==null?void 0:He.inputs),outputs:ae((Le=Fe.data)==null?void 0:Le.outputs)}}:Fe}),fe=Z.current||{},je=fe[w]&&typeof fe[w]=="object"?fe[w]:{},Ve={...fe,[w]:{...je,label:je.label||"加载知识库",input:Y(je.input),output:ae(je.output)}};Z.current=Ve,g(he),ie(Ve),Ss(Fe=>(Fe==null?void 0:Fe.id)===w?{...Fe,inputs:Y(Fe.inputs),outputs:ae(Fe.outputs)}:Fe),en(he,k).catch(Fe=>ge(String(Fe.message||Fe)))},[k,b,en,g,Se]),t0=m.useCallback((w,N)=>{if(!Se){ge("Readonly workspace");return}const _=String(w||"");if(!_)return;const I=s_((N==null?void 0:N.skillKeys)||[]),T=Nf((N==null?void 0:N.displayType)||"markdown"),U=String((N==null?void 0:N.model)||"").trim(),X=(N==null?void 0:N.includeWorkspaceContext)===!1?"false":"true",J=N!=null&&N.workspaceContext&&typeof N.workspaceContext=="object"?JSON.stringify(N.workspaceContext):"",Y=N!=null&&N.knowledgeContext&&typeof N.knowledgeContext=="object"?JSON.stringify(N.knowledgeContext):"",ae=He=>Array.isArray(He)?He.map(Le=>(Le==null?void 0:Le.name)==="skillKeys"?{...Le,default:I,value:I}:(Le==null?void 0:Le.name)==="displayType"?{...Le,default:T,value:T}:(Le==null?void 0:Le.name)==="includeWorkspaceContext"?{...Le,default:X,value:X}:(Le==null?void 0:Le.name)==="knowledgeContext"?{...Le,default:Y,value:Y}:(Le==null?void 0:Le.name)==="workspaceContext"?{...Le,default:J,value:J}:Le):[],he=He=>Array.isArray(He)?He.map(Le=>(Le==null?void 0:Le.name)==="displayType"?{...Le,default:T,value:T}:Le):[],fe=String((N==null?void 0:N.task)??""),je=b.map(He=>{var Le,Ht;return He.id===_?{...He,data:{...He.data,body:fe,model:U,inputs:ae((Le=He.data)==null?void 0:Le.inputs),outputs:he((Ht=He.data)==null?void 0:Ht.outputs)}}:He}),Ve=Z.current||{},Fe=Ve[_]&&typeof Ve[_]=="object"?Ve[_]:{},Ke={...Ve,[_]:{...Fe,body:fe,model:U,input:ae(Fe.input),output:he(Fe.output)}};Z.current=Ke,g(je),ie(Ke),Ss(He=>(He==null?void 0:He.id)===_?{...He,body:fe,model:U,inputs:ae(He.inputs),outputs:he(He.outputs)}:He),en(je,k).catch(He=>ge(String(He.message||He)))},[k,b,en,g,Se]),n0=m.useCallback((w,N)=>{if(!Se){ge("Readonly workspace");return}const _=tJ(N),I=b.map(J=>J.id===w?{...J,data:{...J.data,body:_}}:J),T=Z.current||{},U=T[w]&&typeof T[w]=="object"?T[w]:{},X={...T,[w]:{...U,body:_}};Z.current=X,ye.current=!0,g(I),ie(X),Ss(J=>(J==null?void 0:J.id)===w?{...J,body:_}:J),en(I,k).catch(J=>ge(String(J.message||J)))},[k,b,en,g,Se]),r0=m.useCallback(w=>{const N=String(w||"").trim();N&&(ES(_=>_===N?"":N),So(_=>({..._,[N]:_[N]||{sessionId:`nodechat_${Date.now()}_${N.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),s0=m.useCallback(()=>ES(""),[]),i0=m.useCallback((w,N)=>{const _=String(w||"").trim();_&&So(I=>({...I,[_]:{...I[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(N||""),error:""}}))},[]),Us=m.useCallback((w,N,_="replace",I={})=>{var st,Ye;if(!Se){ge("Readonly workspace");return}const T=String(w||"").trim();if(!T)return;const U=j.current.find(Oe=>Oe.id===T),X=_n(U==null?void 0:U.data),J=li((st=U==null?void 0:U.data)==null?void 0:st.definitionId),Y=Mi(N),ae=X==="html"?Qc(Y):X==="react"?yg(Y):String(Y||""),he=U?lo(U.data):"",fe=_==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
262
-
263
- ${ae.trim()}`:ae,je=X==="image"?"src":"content",Ve=I!=null&&I.reloadDisplay?Date.now():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,Fe=Oe=>{let Ot=!1;return(Array.isArray(Oe)?Oe:[]).map(ft=>{const Et=String((ft==null?void 0:ft.name)||""),Ll=String((ft==null?void 0:ft.type)||"");return(J?Et===je||Et==="result"||Et==="filePath":Et===je||Et==="filePath"||Ll==="text")?Ot?{...ft,default:"",value:""}:(Ot=!0,{...ft,default:fe,value:fe}):ft})},Ke=j.current.map(Oe=>{var Ot,De;return Oe.id!==T?Oe:{...Oe,data:{...Oe.data,body:J?Oe.data.body:fe,...Ve?{displayReloadKey:Ve}:{},inputs:Fe((Ot=Oe.data)==null?void 0:Ot.inputs),outputs:Fe((De=Oe.data)==null?void 0:De.outputs)}}}),He=Z.current||{},Le=He[T]&&typeof He[T]=="object"?He[T]:{},Ht={...He,[T]:{...Le,body:J?Le.body:fe,input:Fe(Le.input),output:Fe(Le.output)}};Z.current=Ht,g(Ke),ie(Ht),Ss(Oe=>(Oe==null?void 0:Oe.id)===T?{...Oe,...J?{}:{body:fe}}:Oe),(I==null?void 0:I.logChat)!==!1&&So(Oe=>{var Ot;return{...Oe,[T]:{...Oe[T]||{},candidateContent:"",messages:[...(Ot=Oe[T])!=null&&Ot.messages&&Array.isArray(Oe[T].messages)?Oe[T].messages:[],{role:"assistant",text:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),en(Ke,S.current).catch(Oe=>ge(String(Oe.message||Oe))),ge(String((I==null?void 0:I.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[en,g,Se]),Kf=m.useCallback(async(w,N="")=>{if(!Se)return ge("Readonly workspace"),"";if(!w)return"";try{const _=new FormData;_.set("file",w),_.set("dir",String(N||"")),a.flowId&&_.set("flowId",a.flowId),a.flowSource&&_.set("flowSource",a.flowSource),a.adminOwnerId&&_.set("adminOwnerId",a.adminOwnerId),a.archived&&_.set("archived","1");const I=await fetch("/api/workspace/upload",{method:"POST",body:_}),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"上传文件失败");const U=String(T.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await Nn(),wl(X=>{const J=new Set(X);for(const Y of Yp(U))J.delete(Y);return J}),ge(`已上传 ${U}`),U}catch(_){return ge(String(_.message||_)),""}},[a,Nn,Se]),qf=m.useCallback(async w=>wm(w)?Kf(w,"img"):(ge("请选择图片文件"),""),[Kf]),o0=m.useCallback((w="")=>{var N;if(!Se){ge("Readonly workspace");return}aS.current=String(w||""),(N=oS.current)==null||N.click()},[Se]),lL=m.useCallback(async w=>{const N=Array.from(w.target.files||[]);if(w.target.value="",!N.length)return;const _=aS.current||"";iS(!0);try{let I="";for(const T of N){const U=await Kf(T,_);U&&(I=U)}N.length>1&&ge(`已上传 ${N.length} 个文件${I?`,最后一个:${I}`:""}`)}catch(I){ge(String(I.message||I))}finally{iS(!1)}},[Kf]),a0=m.useCallback(async(w,N)=>{const _=String(w||"").trim();if(!_)return;const I=await qf(N);I&&Us(_,I,"replace",{logChat:!1,statusMessage:`已上传图片 ${I}`})},[Us,qf]),l0=m.useCallback(async(w,N=void 0)=>{var Fe,Ke;if(!Se){ge("Readonly workspace");return}const _=String(w||"").trim();if(!_)return;const I=ka[_]||{},T=String(N!==void 0?N:I.draft||"").trim();if(!T||I.running)return;const U=j.current.find(He=>He.id===_);if(!U)return;const X=_n(U.data)||"markdown",J=lo(U.data);let Y=aa(J,X),ae=Mi(J);if(Y)try{ae=await cl(a,Y)}catch(He){ge(String(He.message||He))}else if(X!=="image"&&String(ae||"").trim()){const He=Ba(X,ae);if(He){ge(`${He} 未进入微调。`);return}try{const Le=await _b(a,n_(_,U.data),ae);await Nn(),Us(_,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),Y=Le,ae=""}catch(Le){ge(String(Le.message||Le));return}}const he=wJ(_,j.current,S.current),fe={role:"user",text:T,at:Date.now()},je=Array.isArray(I.messages)?I.messages:[],Ve=I.sessionId||`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;So(He=>({...He,[_]:{...I,sessionId:Ve,messages:[...je,fe],draft:"",running:!0,error:""}}));try{const He=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:Ve,node:{id:_,label:((Fe=U.data)==null?void 0:Fe.label)||_,definitionId:((Ke=U.data)==null?void 0:Ke.definitionId)||""},nodeKind:X,currentContent:Y?"":ae,sourceContext:he,targetFilePath:Y,messages:je,message:T,model:Hi})}),Le=await He.json().catch(()=>({}));if(!He.ok)throw new Error(Le.error||"节点微调失败");const Ht=String(Le.candidateContent||Le.reply||"").trim(),st=!!Le.directFileEdit,Ye=String(Le.artifactPath||Y||"").trim();if(st&&Ye){const Oe=Ba(X,Ht);if(Oe)throw new Error(`${Oe} 文件已由 agent 修改,请检查 ${Ye}。`);await Nn(),Us(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(Ht){const Oe=Ba(X,Ht);if(Oe)throw new Error(`${Oe} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Ot=await _b(a,Y,Ht);await Nn(),Us(_,Ot,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ot}`})}else Us(_,Ht,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}So(Oe=>{var Ot;return{...Oe,[_]:{...Oe[_]||{},sessionId:String(Le.sessionId||Ve),running:!1,candidateContent:"",messages:[...(Ot=Oe[_])!=null&&Ot.messages&&Array.isArray(Oe[_].messages)?Oe[_].messages:[...je,fe],{role:"assistant",text:Ht||st?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(He){const Le=String(He.message||He);So(Ht=>({...Ht,[_]:{...Ht[_]||{},running:!1,error:Le}})),ge(Le)}},[Hi,a,Nn,ka,Us,Se]),c0=m.useCallback(async(w,N)=>{if(!Se){ge("Readonly workspace");return}const _=_n(N)||"markdown",I=lo(N),T=aa(I,_);let U=Mi(I);if(T)try{U=await cl(a,T)}catch(ae){ge(String(ae.message||ae));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const X=Ba(_,U);if(X){ge(`${X} 未保存文件。`);return}const J=n_(w,N),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const ae=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:U})}),he=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||Y,je=Fr(a);je.set("path",fe);const Ve=await fetch(`/api/workspace/file?${je.toString()}`);if(!Ve.ok){const Fe=await Ve.json().catch(()=>({}));throw new Error(Fe.error||`保存后读取失败:${fe}`)}await Nn(),Uv(Fe=>KJ(Fe,fe,String(U||"").length)),wl(Fe=>{const Ke=new Set(Fe);for(const He of Yp(fe))Ke.delete(He);return Ke}),Us(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(ae){ge(String(ae.message||ae))}},[a,Nn,Us,Se]),u0=m.useCallback(w=>{var T,U;const N=String(w||"").trim();if(!N||Rn)return;const _=j.current.find(X=>X.id===N);if(!_||!_n(_==null?void 0:_.data)){ge("展示节点不可用");return}const I=String(((T=_.data)==null?void 0:T.label)||((U=_.data)==null?void 0:U.displayName)||N).trim()||"AgentFlow Display";zt(kw({title:I,layout:"single",nodeIds:[N],mode:"single-node",sourceNodeId:N})),le(""),tt(null),Sr(!0)},[Rn]),Uf=m.useCallback((w,N)=>{const _=String(w||"");_&&Ss(I=>{if(!I||I.id!==_)return I;const T=typeof N=="function"?N(I):N;return!T||typeof T!="object"?I:{...I,...T}})},[]),d0=m.useCallback((w,N)=>{const _=String(w||"");!_||!Se||(g(I=>I.map(T=>{var X;if(T.id!==_)return T;const U=Array.isArray((X=T.data)==null?void 0:X.outputs)&&T.data.outputs.length?T.data.outputs.map((J,Y)=>Y===0?{...J,default:N,value:N}:J):[{type:"file",name:"value",default:N,value:N}];return{...T,data:{...T.data,body:"",outputs:U}}})),Uf(_,I=>({body:"",outputs:Array.isArray(I==null?void 0:I.outputs)&&I.outputs.length?I.outputs.map((U,X)=>X===0?{...U,default:N,value:N}:U):[{type:"file",name:"value",default:N,value:N}]})),ge(`已选择文件 ${N}`))},[g,Uf,Se]),f0=m.useCallback(w=>{Tg({nodeId:String(w||""),query:""})},[]),Qg=m.useCallback(()=>{Tg({nodeId:"",query:""})},[]),cL=m.useCallback(w=>{const N=String((w==null?void 0:w.path)||"").trim();!N||!au.nodeId||(d0(au.nodeId,N),Qg())},[Qg,au.nodeId,d0]),p0=m.useCallback(async(w,N)=>{if(!Se)return;const _=MJ(w,N);if(_.length===0)return;const I=[];try{for(const T of _){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:T})});if(U.status===404)continue;const X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"清理节点输出失败");I.push(X.path||T)}if(I.length===0)return;ge(`已清理 ${I.join(", ")}`),await Nn(),Rg(T=>_.some(U=>T===U||T.startsWith(`${U}/`))?"":T)}catch(T){ge(String(T.message||T))}},[a,Nn,Se]),vu=m.useMemo(()=>({modelLists:wa,showBodyPreview:!0,flowParams:a,readOnly:!Se,onRunWorkspaceNode:GS,onStopWorkspaceNode:YS,onOpenWorkspaceRunLogs:US,onOptimizeWorkspaceRun:Xg,onOptimizeWorkspaceSchedule:Xg,runningRunNodeIds:BS,onChangeScheduledRunConfig:n0,onChangeContextRunConfig:t0,skills:Hs,skillCollections:xl,onChangeLoadSkillKeys:QS,onRefreshSkills:Hf,mcpServers:pS,onChangeLoadMcpNames:ZS,onRefreshMcps:Wf,workspaceTargets:mS,onChangeLoadWorkspace:e0,onRefreshWorkspaces:Vf,onSaveDisplayNodeToFile:c0,onShareDisplayNode:u0,onOpenDisplayPreview:q,onRefreshNodeInternals:Kr,onEnsureWorkspaceNodeDisplaySize:kS,sharingDisplayNodeId:Rn,onUploadWorkspaceImage:qf,onUploadImageToDisplayNode:a0,onOpenProvideFilePicker:f0,onStatus:ge,onSetDisplayNodeContent:Us,onToggleNodeChat:r0,onCloseNodeChat:s0,onUpdateNodeChatDraft:i0,onSendNodeChat:l0,onSyncNodePropDraft:Uf,onCleanupWorkspaceNodeOutputs:p0}),[t0,ZS,QS,e0,n0,p0,s0,kS,a,pS,wa,f0,US,Xg,Wf,Kr,Hf,Vf,GS,BS,c0,l0,Us,u0,Rn,xl,Hs,YS,Uf,r0,i0,a0,qf,mS,Se]),uL=m.useRef(new Map),os=m.useMemo(()=>{const w=uL.current,N=new Set,_=b.map(I=>{var Y,ae,he;const T={selected:I.selected===!0,isExecuting:MS.has(I.id),nodeStatus:((Y=Jg[I.id])==null?void 0:Y.status)??null,nodeElapsed:((ae=Jg[I.id])==null?void 0:ae.elapsed)??null,optimizingRun:$S===I.id,scheduledRunState:TS[I.id]||null,nodeChatActive:_S===I.id,nodeChat:ka[I.id]||null},U=w.get(I.id);if(U&&U.source===I&&U.commonData===vu&&YC(U.runtime,T))return N.add(I.id),U.node;const X=!!(U&&((he=U.source)==null?void 0:he.data)===I.data&&U.commonData===vu&&YC(U.runtime,T)),J={...I,data:X?U.node.data:{...I.data,...vu,...T}};return w.set(I.id,{source:I,commonData:vu,runtime:T,node:J}),N.add(I.id),J});for(const I of w.keys())N.has(I)||w.delete(I);return _},[_S,vu,ka,b,$S,TS,MS,Jg]),dt=d==="display",Cn=d==="workflow",h0=m.useMemo(()=>dt?new Map(os.map(w=>[w.id,w])):aJ,[os,dt]),m0=m.useMemo(()=>vs&&os.find(w=>w.id===vs)||null,[vs,os]),g0=m.useRef(new Map),Su=m.useMemo(()=>{if(!dt)return g0.current.clear(),lJ;const w=new Set(M),N=g0.current,_=new Set,I=P.nodeIds.map((T,U)=>{var Ve,Fe,Ke,He;const X=h0.get(T);if(!X||!_n(X.data))return null;const J=Yl(X)||{width:520,height:320},Y=Ua(P.nodeSizes[T]||J,{display:!0})||J,ae=P.nodePositions[T]||{x:180+U*36,y:120+U*28},he=w.has(T),fe=N.get(T);if(fe&&fe.source===X&&((Ve=fe.position)==null?void 0:Ve.x)===ae.x&&((Fe=fe.position)==null?void 0:Fe.y)===ae.y&&((Ke=fe.size)==null?void 0:Ke.width)===Y.width&&((He=fe.size)==null?void 0:He.height)===Y.height&&fe.selected===he)return _.add(T),fe.node;const je={...X,id:GC(T),position:ae,selected:he,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:T,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return N.set(T,{source:X,position:ae,size:Y,selected:he,node:je}),_.add(T),je}).filter(Boolean);for(const T of N.keys())_.has(T)||N.delete(T);return I},[P,h0,dt,M]),Al=m.useMemo(()=>os.filter(w=>_n(w==null?void 0:w.data)),[os]);m.useEffect(()=>{if(!dt||!P.viewport)return;const w=P.viewport,N=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(N));return()=>window.cancelAnimationFrame(_)},[P.viewport,dt,r]),m.useEffect(()=>{if(dt||Cn||!A)return;const w=A,N=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(N));return()=>window.cancelAnimationFrame(_)},[dt,Cn,r,A]),m.useEffect(()=>{Cn&&bu(sr)},[Cn]),m.useEffect(()=>{if(!Cn||!sr)return;const w=Fr(a);w.set("tapdId",sr);let N=null,_=null,I=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),N&&(N.onmessage=null,N.onerror=null,N.close(),N=null)},U=()=>{I||document.hidden||N||(N=new EventSource(`/api/prd-workflow/events?${w.toString()}`),N.onmessage=()=>{bu(sr)},N.onerror=()=>{T(),!I&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}bu(sr),U()};return U(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T()}},[a,Cn,bu,sr]),m.useEffect(()=>{if(!a.flowId||Cn)return;const w=Fr(a);w.set("clientId",_t.current);let N=null,_=null,I=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),N&&(N.onmessage=null,N.onerror=null,N.close(),N=null)},U=()=>{I||document.hidden||N||(N=new EventSource(`/api/workspace/events?${w.toString()}`),N.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===_t.current)){if(Y.type==="graph.committed"){_l(Y);return}if(Y.type==="runtime.committed"){_l(Y);return}if(String(Y.type||"").startsWith("file.")){Nn();return}String(Y.type||"").startsWith("run.")&&Bf()}},N.onerror=()=>{T(),!I&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}_l({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T(),Re.current&&(window.clearTimeout(Re.current),Re.current=null),kt.current=!1}},[a,Cn,Nn,Bf,_l]),m.useEffect(()=>{if(re.current)return;const w=F.current,N=new Map,_=[];for(const I of[...os,...Su]){const T=oJ(I);N.set(I.id,T),w.get(I.id)!==T&&_.push(I.id)}F.current=N,_.length!==0&&Kr(_)},[Su,os,Kr]);const Kt=m.useMemo(()=>b.find(w=>w.id===yr)||null,[b,yr]),Zg=m.useRef({id:"",draft:null}),dL=m.useMemo(()=>{const w=l_(Kt);return w?JSON.stringify(w):""},[Kt==null?void 0:Kt.data,Kt==null?void 0:Kt.id]);m.useEffect(()=>{if(!Kt){Zg.current={id:"",draft:null},Ss(null),hl("");return}const w=l_(Kt),N=Zg.current;Zg.current={id:Kt.id,draft:w},Ss(_=>!_||_.id!==Kt.id||N.id!==Kt.id||!N.draft?w:sX(_,N.draft,w)),hl("")},[Kt==null?void 0:Kt.id,dL]);const ey=m.useCallback((w=!1)=>{if(!gt||!Kt)return!1;if(!Se)return hl("Readonly workspace"),ge("Readonly workspace"),!1;hl("");const N=d_({nodes:b,edges:k,instances:Z.current,selectedNode:Kt,draft:gt,allowRename:w});return N!=null&&N.error?(hl(N.error),!1):(!(N!=null&&N.ok)||!N.changed||(Z.current=N.instances,ie(N.instances),g(N.nodes),x(N.edges),N.nextId!==Kt.id&&Zt(N.nextId),Kr(N.nextId)),!0)},[k,gt,b,Kt,x,g,Kr,Se]);m.useEffect(()=>{if(!Se||!gt||!Kt)return;const w=window.setTimeout(()=>{ey(!1)},350);return()=>window.clearTimeout(w)},[gt==null?void 0:gt.label,gt==null?void 0:gt.role,gt==null?void 0:gt.model,gt==null?void 0:gt.body,JSON.stringify((gt==null?void 0:gt.images)||[]),gt==null?void 0:gt.script,gt==null?void 0:gt.scriptRef,gt==null?void 0:gt.implementationRef,gt==null?void 0:gt.implementationMode,JSON.stringify((gt==null?void 0:gt.inputs)||[]),JSON.stringify((gt==null?void 0:gt.outputs)||[]),ey,Kt==null?void 0:Kt.id,Se]);const y0=m.useRef({refs:new Map,nodeDataById:new Map}),ty=m.useMemo(()=>{const w=y0.current;let N=w.refs.size!==b.length;const _=new Map;for(const T of b)_.set(T.id,T.data),(!w.refs.has(T.id)||w.refs.get(T.id)!==T.data)&&(N=!0);if(!N)return w.nodeDataById;const I=new Map(b.map(T=>[T.id,T.data]));return y0.current={refs:_,nodeDataById:I},I},[b]),fL=m.useMemo(()=>k.map(w=>{var Y,ae;const N=ty.get(w.source),_=ty.get(w.target),I=/^output-(\d+)$/.exec(w.sourceHandle||""),T=/^input-(\d+)$/.exec(w.targetHandle||""),U=N&&I?(Y=N.outputs)==null?void 0:Y[parseInt(I[1],10)]:null,X=_&&T?(ae=_.inputs)==null?void 0:ae[parseInt(T[1],10)]:null,J=U!=null&&U.type?An(U.type):X!=null&&X.type?An(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ci.ArrowClosed,color:J}}:w}),[ty,k]),Yf=dt?Su:os,pL=dt?[]:fL,w0=m.useRef(Yf),Pl=m.useRef([]);re.current||(w0.current=Yf);const hL=m.useMemo(()=>dt?Su.map(w=>({...w,id:Up(w.id)})):os,[Su,os,dt]),ny=m.useCallback(w=>{const N=String(w||"").trim();if(!N)return;const _=dt?GC(N):N;dt?V([N]):(g(T=>T.map(U=>({...U,selected:U.id===_}))),x(T=>T.map(U=>({...U,selected:!1}))),Zt(_));const I=()=>{var ae,he,fe;const T=r.getNode(_);if(!T)return;const U=(ae=r.getInternalNode)==null?void 0:ae.call(r,_),X=((he=U==null?void 0:U.measured)==null?void 0:he.width)??(U==null?void 0:U.width)??T.width??260,J=((fe=U==null?void 0:U.measured)==null?void 0:fe.height)??(U==null?void 0:U.height)??T.height??120,{zoom:Y}=r.getViewport();r.setCenter(T.position.x+X/2,T.position.y+J/2,{zoom:hJ(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(I))},[dt,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!ce.current||d!=="workspace"||os.some(N=>N.id===w)&&(c.current="",ye.current=!0,ny(w))},[os,ny,d]);const x0=m.useCallback(()=>{const w=r.getViewport(),N={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(dt){const _={...B.current,viewport:N};B.current=_,R(_),ge("已固定 Display 进入视角")}else{D.current=N,O(N);try{window.localStorage.setItem(u,JSON.stringify(N))}catch{}ge("已固定 Workspace 进入视角");return}en(j.current,S.current).catch(_=>ge(String(_.message||_)))},[dt,r,en,u]),ry=m.useMemo(()=>{const w=Pe.trim().toLowerCase(),N={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of at)w&&![_.id,_.label,_.displayName,_.description].some(I=>String(I||"").toLowerCase().includes(w))||N[Zu(_)].push(_);for(const _ of ql)N[_].sort((I,T)=>I.id.localeCompare(T.id));return N},[at,Pe]),ju=m.useMemo(()=>{const w=wn.trim().toLowerCase();return at.filter(N=>!w||[N.id,N.label,N.displayName,N.description].some(_=>String(_||"").toLowerCase().includes(w))).sort((N,_)=>{const I=ql.indexOf(Zu(N)),T=ql.indexOf(Zu(_));return I!==T?I-T:ed(N).localeCompare(ed(_))}).slice(0,30)},[at,wn]),Nu=m.useMemo(()=>{const w=wn.trim().toLowerCase();return vt.filter(N=>!w||[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].some(_=>String(_||"").toLowerCase().includes(w))).sort((N,_)=>String(N.displayName||N.name||N.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[vt,wn]);m.useEffect(()=>{rr(0)},[wn,we,Ee]),m.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var N;return(N=jS.current)==null?void 0:N.focus()},0);return()=>window.clearTimeout(w)},[we]);const mL=m.useMemo(()=>{const w=Pg.trim().toLowerCase();return w?Pv(ml).filter(N=>N.path.toLowerCase().includes(w)):ml},[Pg,ml]),ja=m.useMemo(()=>kM(ml,Ig),[ml,Ig]),Ki=(ja==null?void 0:ja.type)==="directory"?ja.path:BJ((ja==null?void 0:ja.path)||""),gL=m.useCallback(w=>{var N,_;(_=(N=w.target)==null?void 0:N.closest)!=null&&_.call(N,".af-work-file")||Rg("")},[]),yL=[...(wa.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(wa.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(wa.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(wa.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],sy=m.useMemo(()=>new Set(Ws),[Ws]),Il=m.useMemo(()=>{const w=new Map(Hs.map(U=>[U.key,U])),N=new Set,_=new Set,I=xl.map(U=>{const X=ia(U,Hs).map(J=>w.get(J)).filter(Boolean);for(const J of X)N.add(J.key),_.add(String(J.name||J.id||J.key||"").trim());return{...U,skills:X}}).filter(U=>U.skills.length>0),T=Hs.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!N.has(U.key)&&!_.has(X)});return{groups:I,ungrouped:T}},[xl,Hs]);m.useEffect(()=>{vS(w=>{let N=!1;const _=new Set(w);for(const I of Il.groups)_.has(I.id)||(_.add(I.id),N=!0);return N?_:w})},[Il.groups]);const Qn=m.useMemo(()=>{const w=b.filter(N=>N.selected);return w.length>0?w:yr?b.filter(N=>N.id===yr):[]},[b,yr]),Gf=m.useMemo(()=>Qn.map(w=>w.id),[Qn]),b0=m.useCallback(()=>{if(dt)return;if(!Se){ge("Readonly workspace");return}const w=(j.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Sm(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const N=w.reduce((J,Y)=>{var Ve,Fe,Ke,He,Le,Ht,st,Ye,Oe,Ot,De,ft;const ae=Number(((Ve=Y.position)==null?void 0:Ve.x)||0),he=Number(((Fe=Y.position)==null?void 0:Fe.y)||0),fe=Number(((Ke=Y.measured)==null?void 0:Ke.width)||Y.width||((Le=(He=Y.data)==null?void 0:He.nodeSize)==null?void 0:Le.width)||((st=(Ht=Y.data)==null?void 0:Ht.displaySize)==null?void 0:st.width)||GT),je=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||((Ot=(Oe=Y.data)==null?void 0:Oe.nodeSize)==null?void 0:Ot.height)||((ft=(De=Y.data)==null?void 0:De.displaySize)==null?void 0:ft.height)||ym);return{minX:Math.min(J.minX,ae),minY:Math.min(J.minY,he),maxX:Math.max(J.maxX,ae+fe),maxY:Math.max(J.maxY,he+je)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(N.minX)||!Number.isFinite(N.minY))return;const _=new Set((j.current||[]).map(J=>J.id));let I=1,T=`group_${I}`;for(;_.has(T);)I+=1,T=`group_${I}`;const U=jb({width:N.maxX-N.minX+Vp*2,height:N.maxY-N.minY+Vp*2})||{width:il,height:ol},X={id:T,type:Sc,position:{x:N.minX-Vp,y:N.minY-Vp},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:jm(I-1),title:jm(I-1),color:"purple",nodeSize:U}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),Zt(""),ge(`Created group for ${w.length} nodes`)},[dt,x,g,Se]),Cu=m.useMemo(()=>b.filter(w=>_n(w==null?void 0:w.data)),[b]),iy=m.useMemo(()=>Qn.filter(w=>_n(w==null?void 0:w.data)).map(w=>w.id),[Qn]),wL=m.useMemo(()=>{const w=String((Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Lr]),oy=m.useMemo(()=>new Set(Gf),[Gf]),Jf=m.useMemo(()=>k.filter(w=>oy.has(w.source)&&oy.has(w.target)),[k,oy]),ay=m.useCallback(w=>{const N=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(N),Zt(""),V([]),te(null),$e(!1),pn(!1);const _=Fr(a);N==="display"&&_.set("view","display"),N==="workflow"&&(_.set("view","workflow"),sr.trim()&&_.set("tapdId",sr.trim()));const I=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",I)},[a,sr]),k0=m.useCallback(w=>{const N=String(w||"").trim();if(!N)return;const _=j.current.find(I=>I.id===N);if(!_||!_n(_.data)){ge("展示节点不可用");return}R(I=>{if(I.nodeIds.includes(N))return I;const T=I.nodeIds.length,U=Yl(_);return{nodeIds:[...I.nodeIds,N],nodePositions:{...I.nodePositions,[N]:{x:180+T*36,y:120+T*28}},nodeSizes:{...I.nodeSizes,...U?{[N]:U}:{}}}}),V([N])},[]),v0=m.useCallback(w=>{const N=String(w||"").trim();N&&(R(_=>{const I=_.nodeIds.filter(X=>X!==N),T={..._.nodePositions},U={..._.nodeSizes};return delete T[N],delete U[N],{nodeIds:I,nodePositions:T,nodeSizes:U}}),V(_=>_.filter(I=>I!==N)))},[]),S0=m.useCallback(w=>{const N=String(w||"").trim();N&&(B.current.nodeIds.includes(N)?v0(N):k0(N))},[k0,v0]),Xf=m.useMemo(()=>{const w=$n.trim().toLowerCase();return w?Al.filter(N=>{var _,I;return[N.id,(_=N.data)==null?void 0:_.label,(I=N.data)==null?void 0:I.definitionId].filter(Boolean).some(T=>String(T).toLowerCase().includes(w))}):Al},[Al,$n]),j0=m.useMemo(()=>{const w=Xf.length,N=w<=1?1:w<=4?2:3,_=Array.from({length:N},()=>({height:0,nodes:[]}));for(const I of Xf){const T=Yl(I)||{width:420,height:260},U=Math.max(1,Number(T.width)||420),X=Math.max(1,Number(T.height)||260),J=Math.min(26,Math.max(5.5,X/U*16))+3.2;let Y=_[0];for(const ae of _)ae.height<Y.height&&(Y=ae);Y.nodes.push(I),Y.height+=J}return _.map(I=>I.nodes)},[Xf]),xL=m.useCallback(w=>{var U;const N=P.nodeIds.includes(w.id),_=Yl(w)||{width:420,height:260},I=Math.max(1,Math.round(Number(_.width)||420)),T=Math.max(1,Math.round(Number(_.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(N?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${I} / ${T}`},onClick:()=>S0(w.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:N,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(AJ,{node:w})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((U=w.data)==null?void 0:U.label)||w.id}),i.jsxs("small",{children:[_n(w.data)," · ",w.id]})]})]},w.id)},[P.nodeIds,S0]),N0=m.useMemo(()=>{const w=Pe.trim().toLowerCase();return w?vt.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(_=>String(_).toLowerCase().includes(w))):vt},[vt,Pe]),C0=m.useCallback((w,N)=>{const _=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let I=`${_}_${Date.now().toString(36)}`,T=2;for(;N.has(I);)I=`${_}_${Date.now().toString(36)}_${T}`,T+=1;return N.add(I),I},[]),_u=m.useCallback((w,N)=>{var Oe,Ot;if(!Se){ge("Readonly workspace");return}const _=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},I=_.instances&&typeof _.instances=="object"?_.instances:{},T=Object.keys(I);if(T.length===0)return;const U=new Set(j.current.map(De=>De.id)),X={};for(const De of T)X[De]=C0(De,U);const J=(Oe=_.ui)!=null&&Oe.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},Y=(Ot=_.ui)!=null&&Ot.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.ui.nodeSizes:{},ae=T.map(De=>{const ft=J[De];return{id:De,x:typeof(ft==null?void 0:ft.x)=="number"?ft.x:0,y:typeof(ft==null?void 0:ft.y)=="number"?ft.y:0}}),he=Math.min(...ae.map(De=>De.x)),fe=Math.min(...ae.map(De=>De.y));let je=N||{x:360+j.current.length*24,y:180+j.current.length*18};if(!N){const De=document.querySelector(".af-workspace-canvas .react-flow");if(De){const ft=De.getBoundingClientRect();je=r.screenToFlowPosition({x:ft.left+ft.width*.48,y:ft.top+ft.height*.32})}}const Ve={},Fe={},Ke={};for(const De of ae){const ft=X[De.id];Ve[ft]={...I[De.id]||{}},Fe[ft]={x:je.x+(De.x-he),y:je.y+(De.y-fe)};const Et=Y[De.id];typeof(Et==null?void 0:Et.width)=="number"&&typeof(Et==null?void 0:Et.height)=="number"&&(Ke[ft]={width:Et.width,height:Et.height})}const He=new Set(T),Le=(Array.isArray(_.edges)?_.edges:[]).filter(De=>He.has(De==null?void 0:De.source)&&He.has(De==null?void 0:De.target)).map(De=>({source:X[De.source],target:X[De.target],sourceHandle:De.sourceHandle??null,targetHandle:De.targetHandle??null})),Ht=Bu({instances:Ve,edges:Le,ui:{nodePositions:Fe,nodeSizes:Ke}},at),st=Ht.nodes.map(De=>De.id),Ye=Ht.nodes.map(De=>({...De,selected:!0}));Z.current={...Z.current,...Ht.instances},ie(Z.current),g(De=>[...De.map(ft=>({...ft,selected:!1})),...Ye]),x(De=>[...De.map(ft=>({...ft,selected:!1})),...Ht.edges.map(ft=>({...ft,selected:!1}))]),Zt(""),V([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${st.length} 个节点)`)},[C0,at,r,x,g,Se]),bL=m.useCallback(()=>{var _,I;if(Qn.length<2){nr("请先在 workspace 画布上选择至少两个节点。"),It("flows");return}const w=Qn[0],N=Qn.length===2?`${((_=w.data)==null?void 0:_.label)||w.id} 片段`:`${((I=w.data)==null?void 0:I.label)||w.id} 等 ${Qn.length} 个节点`;zn({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Gn(""),hr(!0),It("flows")},[Qn]),kL=m.useCallback(async()=>{var T,U;if(Qn.length<2)return;const w=fn.name.trim();if(!w){Gn("请填写片段名称。");return}const N={},_={};for(const X of Qn){N[X.id]={x:((T=X.position)==null?void 0:T.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const J=Yl(X);J&&(_[X.id]=J)}const I=Jf.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));Ds(!0),Gn("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:fn.id,name:w,displayName:w,version:"1.0.0",description:fn.description,snippet:{instances:bv(Qn,Z.current),edges:I,ui:{nodePositions:N,nodeSizes:_}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");hr(!1),ge(`流程片段已发布:${J.id||w}`),bS(`流程片段已发布:${J.id||w}`),await zf(),It("flows")}catch(X){Gn(String(X.message||X))}finally{Ds(!1)}},[zf,fn,Jf,Qn,bS]),_0=m.useCallback(async()=>{var N;const w=su.trim();if(w){Gv(!0),vo("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),I=await _.json().catch(()=>({}));if(!_.ok)throw new Error(I.error||"添加协作成员失败");Rf(I.workspace||null),Xv(""),ge(`已将 Workspace 分享给 ${((N=I.member)==null?void 0:N.username)||w}`)}catch(_){vo(String(_.message||_))}finally{Gv(!1)}}},[a,su]),vL=m.useCallback(()=>{vo(""),Cg(!0),fetch("/api/teams/me").then(w=>w.json().then(N=>({response:w,payload:N}))).then(({response:w,payload:N})=>{var T;if(!w.ok)throw new Error(N.error||"读取团队失败");const _=N.team||null;T$(_);const I=(T=Tt==null?void 0:Tt.teamShares)==null?void 0:T.find(U=>U.teamId===(_==null?void 0:_.id));eS((I==null?void 0:I.role)==="editor"?"editor":"viewer")}).catch(w=>vo(String(w.message||w)))},[Tt==null?void 0:Tt.teamShares]),ly=m.useCallback(async(w=!1)=>{if(Bs!=null&&Bs.id){tS(!0),vo("");try{const N=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Bs.id,role:Eg})}),_=await N.json().catch(()=>({}));if(!N.ok)throw new Error(_.error||(w?"取消团队分享失败":"分享到团队失败"));Rf(_.workspace||null),ge(w?`已取消对「${Bs.name}」的分享`:`已分享到「${Bs.name}」`)}catch(N){vo(String(N.message||N))}finally{tS(!1)}}},[a,Bs,Eg]),SL=m.useCallback(async w=>{const N=String((w==null?void 0:w.userId)||"").trim();if(!(!N||N===(Tt==null?void 0:Tt.ownerId))){Zv(N),vo("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:N})}),I=await _.json().catch(()=>({}));if(!_.ok)throw new Error(I.error||"取消成员分享失败");Rf(I.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||N} 的分享`)}catch(_){vo(String(_.message||_))}finally{Zv("")}}},[a,Tt==null?void 0:Tt.ownerId]),E0=m.useCallback(async()=>{const w=Wl(j.current,S.current,Z.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:JC(B.current,j.current)};const N=new Blob([`${JSON.stringify(w,null,2)}
264
- `],{type:"application/json"}),_=URL.createObjectURL(N),I=document.createElement("a");I.href=_,I.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(_),await Cs(),gl(null),ya(!1),ge("已备份本地草稿并载入远端最新版本")},[S,a.flowId,Cs,j]),jL=m.useCallback(async()=>{const w=Array.isArray(jn==null?void 0:jn.conflictItems)?jn.conflictItems:[];if(!w.length||!(jn!=null&&jn.mergeGraph)||!(jn!=null&&jn.currentGraph)){ou("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let N=jn.mergeGraph;try{w.forEach((I,T)=>{const U=Ag[String(T)]||{mode:"local"};let X,J=!0;U.mode==="remote"?(X=I.current,J=I.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=I.incoming,J=I.hasIncoming!==!1),N=fX(N,I.pathParts,X,J)})}catch(I){ou(`手动值不是有效 JSON:${String(I.message||I)}`);return}nS(!0),ou(""),Ks("saving"),qs("正在提交冲突解决结果");const _=Ne.current.catch(()=>{}).then(async()=>{const I=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:N,baseRevision:jn.currentRevision,baseGraph:jn.currentGraph,clientId:_t.current})}),T=await I.json().catch(()=>({}));if(!I.ok){if(I.status===409&&Array.isArray(T.conflictItems)){const U=T.conflictItems;gl({currentRevision:String(T.currentRevision||""),message:T.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(T.conflictPaths)?T.conflictPaths:[],conflictItems:U,mergeGraph:T.mergeGraph||null,currentGraph:T.currentGraph||null}),yl(Object.fromEntries(U.map((X,J)=>[String(J),{mode:"local",manual:Hu(X)}])))}throw new Error(T.error||"提交冲突解决结果失败")}await Cs(),gl(null),ya(!1),ge("冲突已解决并保存")});Ne.current=_;try{await _}catch(I){ou(String(I.message||I)),Ks("error"),qs(String(I.message||I))}finally{nS(!1)}},[a,Cs,jn,Ag]);m.useCallback(()=>{if(Cu.length===0){ge("当前 workspace 没有 display 节点");return}const w=iy.length>0?iy:Cu.map(_=>_.id),N=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";zt(kw({title:N,layout:"gallery",nodeIds:w,mode:"multi-node"})),le(""),tt(null),Sr(!0)},[a.flowId,iy,Cu]);const NL=m.useCallback(w=>{zt(N=>{const _=Array.isArray(N.nodeIds)?N.nodeIds:[];return _.includes(w)?{...N,nodeIds:_.filter(I=>I!==w)}:{...N,nodeIds:[..._,w]}})},[]),Ys=m.useCallback(async()=>{Bi(!0),oe("");try{const w=await fetch("/api/display/shares"),N=await w.json().catch(()=>({}));if(!w.ok)throw new Error(N.error||"读取分享列表失败");gr(Array.isArray(N.shares)?N.shares:[])}catch(w){oe(String(w.message||w)),gr([])}finally{Bi(!1)}},[]),CL=m.useCallback(()=>{Xn(!0),Rt(""),Ys()},[Ys]),_L=m.useCallback(async()=>{var _,I;const w=rt.title.trim(),N=Array.isArray(rt.nodeIds)?rt.nodeIds:[];if(N.length===0){le("请选择至少一个 display 节点。");return}Mr(!0),le(""),tt(null);try{await en(b,k);const T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:rt.layout,nodeIds:N,...QC(rt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const X=new URL(U.url||`/display/${((_=U.share)==null?void 0:_.id)||""}`,window.location.origin).href;tt({...U,absoluteUrl:X}),ge((I=U.share)!=null&&I.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Yt&&Ys()}catch(T){le(String(T.message||T))}finally{Mr(!1)}},[rt,Yt,k,a,Ys,b,en]),EL=m.useCallback(async()=>{var N,_;const w=Array.isArray(P.nodeIds)?P.nodeIds:[];if(w.length===0){le("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),pn(!0);return}Mr(!0),le("");try{await en(b,k);const I=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:I,layout:"canvas",nodeIds:w,...QC(rt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const X=new URL(U.url||`/display/${((N=U.share)==null?void 0:N.id)||""}`,window.location.origin).href;tt({...U,absoluteUrl:X}),mr(!0),ge((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Yt&&Ys()}catch(I){const T=String(I.message||I);le(T),ge(T)}finally{Mr(!1)}},[P.nodeIds,rt,Yt,k,a,Ys,b,en]),A0=m.useCallback(async()=>{const w=me==null?void 0:me.absoluteUrl;if(!w)return;const N=await Cb(w);Ut(N?"copied":"failed"),window.setTimeout(()=>Ut(""),1600)},[me==null?void 0:me.absoluteUrl]),AL=m.useCallback(async w=>{const N=ZC(w),_=await Cb(N);Rt(_?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>Rt(""),1600)},[]),PL=m.useCallback(async(w,N)=>{const _=String((w==null?void 0:w.id)||"");if(_){Te(_),oe("");try{const I=N==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(N||30)},T=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await Ys(),ge("分享有效期已更新")}catch(I){oe(String(I.message||I))}finally{Te("")}}},[Ys]),IL=m.useCallback(async w=>{const N=String((w==null?void 0:w.id)||"");if(N){Te(N),oe("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(N)}`,{method:"DELETE"}),I=await _.json().catch(()=>({}));if(!_.ok||I.ok===!1)throw new Error(I.error||"撤销分享失败");await Ys(),ge("分享已撤销")}catch(_){oe(String(_.message||_))}finally{Te("")}}},[Ys]),RL=m.useCallback(w=>{g(N=>N.map(_=>_.id===w?{..._,selected:!1}:_)),Zt(N=>N===w?"":N)},[g]),Rl=m.useCallback(()=>{const w=Bg.current;if(!w)return;const N=w.getBoundingClientRect(),_=Math.min(420,Math.max(320,N.width+160)),I=12,T=Math.max(180,N.top-I*2),U=Math.min(560,T);G$({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,N.left)),top:Math.max(I,N.top-U-I),width:_,maxHeight:U,zIndex:1e4})},[]);m.useEffect(()=>{if(!Of)return;Rl();const w=_=>{var T,U;const I=_.target;(T=Bg.current)!=null&&T.contains(I)||(U=SS.current)!=null&&U.contains(I)||zg(!1)},N=_=>{_.key==="Escape"&&zg(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",N),window.addEventListener("resize",Rl),window.addEventListener("scroll",Rl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",N),window.removeEventListener("resize",Rl),window.removeEventListener("scroll",Rl,!0)}},[Of,Rl]);const Qf=m.useCallback(w=>{const N=YT(w);if(N.active&&(re.current=!0),N.finished&&(re.current=!1,Qe.current=!0),DY(w)&&hi(),d==="display"){R(T=>{var Y,ae;let U=T.nodePositions,X=T.nodeSizes;for(const he of w||[]){const fe=Up(he==null?void 0:he.id);if(!(!fe||!T.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const je=U[fe];if((je==null?void 0:je.x)===he.position.x&&(je==null?void 0:je.y)===he.position.y)continue;U===T.nodePositions&&(U={...T.nodePositions}),U[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((ae=he.dimensions)!=null&&ae.height)){const je=Ua({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(je){const Ve=X[fe];if((Ve==null?void 0:Ve.width)===je.width&&(Ve==null?void 0:Ve.height)===je.height)continue;X===T.nodeSizes&&(X={...T.nodeSizes}),X[fe]=je}}}}if(U===T.nodePositions&&X===T.nodeSizes)return T;const J={...T,nodePositions:U,nodeSizes:X};return B.current=J,J});const I=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");I.length>0&&V(T=>{const U=new Set(T);for(const J of I){const Y=Up(J==null?void 0:J.id);Y&&(J.selected?U.add(Y):U.delete(Y))}const X=Array.from(U);return X.length===T.length&&X.every((J,Y)=>J===T[Y])?T:X});return}if(!Se){const I=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");I.length>0&&g(T=>yd(I,T));return}const _=(w||[]).filter(I=>{var T,U;return(I==null?void 0:I.type)==="dimensions"&&((T=I.dimensions)==null?void 0:T.width)&&((U=I.dimensions)==null?void 0:U.height)});g(I=>{const T=new Map;if(_.length>0){const J=new Map(I.map(Y=>[Y.id,Y]));for(const Y of _){const ae=J.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=Sm(ae)?jb(he):Ua(he,{display:!!_n(ae==null?void 0:ae.data)});fe&&T.set(Y.id,fe)}}const U=yd(w,I),X=T.size===0?U:U.map(J=>{const Y=T.get(J.id);if(!Y)return J;const ae={...J.data,nodeSize:Y};return _n(J.data)&&(ae.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ae}});return N.mutated||(ze.current={nodes:X,edges:S.current,displayPage:B.current}),j.current=X,X}),_.length>0&&Kr(_.map(I=>I.id))},[hi,Kr,g,d,Se]),Zf=m.useCallback((w=[],{finish:N=!1}={})=>{const _=N?HY([...K.current,...w]):wb(w);N&&(K.current=[]),_.length>0&&Qf(_)},[Qf]),TL=m.useCallback(w=>{const{transient:N,committed:_,finishesInteraction:I}=BY(w);if(N.length>0){de.current&&(window.clearTimeout(de.current),de.current=null),re.current||(re.current=!0,Pl.current=w0.current),K.current=wb([...K.current,...N]);const T=yd(N,Pl.current);Pl.current=T,s.getState().setNodes(T)}if(I){Pl.current=[],Zf(_,{finish:!0});return}_.length>0&&Qf(_)},[Qf,Zf,s]),Tl=m.useCallback(()=>{ke.current.size>0||Be.current||((re.current||K.current.length>0)&&(Zf([],{finish:!0}),Pl.current=[]),kt.current&&_l({type:"interaction.finished"}))},[Zf,_l]),ML=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),jo=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask(Tl)},[Tl]),$L=m.useCallback(()=>{Be.current=!0},[]),LL=m.useCallback(()=>{Be.current=!1,window.queueMicrotask(Tl)},[Tl]);m.useEffect(()=>{const w=()=>{ke.current.clear(),Be.current=!1,Tl()},N=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",jo,!0),window.addEventListener("pointercancel",jo,!0),window.addEventListener("lostpointercapture",jo,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",N),()=>{window.removeEventListener("pointerup",jo,!0),window.removeEventListener("pointercancel",jo,!0),window.removeEventListener("lostpointercapture",jo,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",N),ke.current.clear(),Be.current=!1,K.current=[],Pl.current=[]}},[jo,Tl]);const OL=m.useCallback(w=>{if(d!=="display"){if(!Se){const N=(w||[]).filter(_=>(_==null?void 0:_.type)==="select");N.length>0&&x(_=>{const I=lm(N,_);return S.current=I,I});return}(w||[]).some(N=>(N==null?void 0:N.type)!=="select")&&hi(),x(N=>{const _=lm(w,N);return S.current=_,_})}},[hi,x,d,Se]),Ml=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const N=w.getBoundingClientRect();return r.screenToFlowPosition({x:N.left+N.width*.48,y:N.top+N.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),ep=m.useCallback(()=>{var w,N,_;if(Kt){const I=Number(((w=Kt.measured)==null?void 0:w.width)||Kt.width||260);return{x:Number(((N=Kt.position)==null?void 0:N.x)||0)+I+140,y:Number(((_=Kt.position)==null?void 0:_.y)||0)}}return Ml()},[Ml,Kt]),qi=m.useCallback((w,N={})=>{if(!Se)return ge("Readonly workspace"),null;if(!w)return null;const _=_v(w)||w.id,I=oM(w),T=lM(w),U=N.id||XG(_,b),X=nd(w.inputs),J=nd(w.outputs),Y={definitionId:_,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:N.label||vm(w),role:"normal",body:N.body||"",...N.script||T?{script:N.script||T}:{},...N.scriptRef?{scriptRef:N.scriptRef}:{},...N.implementationRef?{implementationRef:N.implementationRef}:{},...N.implementationMode?{implementationMode:N.implementationMode}:{},input:N.inputs||X,output:N.outputs||J},ae={id:U,type:Sc,position:N.position||Ml(),data:{label:Y.label,definitionId:_,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:iM(_,w),role:"normal",body:Y.body,...Y.script?{script:Y.script}:{},...Y.scriptRef?{scriptRef:Y.scriptRef}:{},...Y.implementationRef?{implementationRef:Y.implementationRef}:{},...Y.implementationMode?{implementationMode:Y.implementationMode}:{},inputs:Y.input,outputs:Y.output}},he={...gb(ae,{...Z.current,[U]:Y},at),selected:!0};return hi(),g(fe=>[...fe.map(je=>({...je,selected:!1})),he]),N.openProperties&&Zt(U),U},[Ml,hi,b,at,g,Se]),DL=m.useCallback(w=>xw(w,j.current),[]),FL=m.useCallback(w=>{if(!Se){ge("Readonly workspace");return}if(!xw(w,j.current)){ge("端口类型不匹配,已取消连线");return}te(null),hi(),g(N=>pw(N,w)),x(N=>{const _=N.filter(T=>!(T.target===w.target&&T.targetHandle===w.targetHandle)),I=bh({...w,markerEnd:{type:Ci.ArrowClosed}},_);return S.current=I,I})},[hi,x,g,Se]),zL=m.useCallback((w,N)=>{if(!Se)return;const _=YG(N,j.current);ee.current=_?{..._,preferExisting:!!(w!=null&&w.shiftKey)}:null,te(null)},[Se]),BL=m.useCallback((w,N)=>{var He,Le,Ht,st;if(!Se)return;const _=ee.current;if(ee.current=null,!_||N!=null&&N.toNode)return;const I=GG(at,_),T=JG(j.current,S.current,_);if(I.length===0&&T.length===0){ge(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||_.preferExisting)?T.length>0?"existing":"create":I.length>0?"create":"existing",J=((Le=(He=w==null?void 0:w.changedTouches)==null?void 0:He[0])==null?void 0:Le.clientX)??(w==null?void 0:w.clientX),Y=((st=(Ht=w==null?void 0:w.changedTouches)==null?void 0:Ht[0])==null?void 0:st.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ae=document.querySelector(".af-workspace-canvas .react-flow");if(!ae)return;const he=ae.getBoundingClientRect(),fe=320,je=Math.max(I.length,T.length),Ve=Math.min(480,150+je*58),Fe=Math.max(12,Math.min(J-he.left,he.width-fe-12)),Ke=Math.max(12,Math.min(Y-he.top,he.height-Ve-12));te({left:Fe,top:Ke,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:_,candidates:I,existingCandidates:T,mode:X,query:""})},[at,r,Se]),HL=m.useCallback(w=>{if(!Se){ge("Readonly workspace"),te(null);return}const N=ue.current;if(!N||!(w!=null&&w.def))return;const _=qi(w.def,{position:N.flowPosition});if(!_)return;const I=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:_,targetHandle:`input-${w.slotIndex}`}:{source:_,sourceHandle:`output-${w.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};g(T=>pw(T,I)),x(T=>{const U=T.filter(J=>!(J.target===I.target&&J.targetHandle===I.targetHandle)),X=bh({...I,markerEnd:{type:Ci.ArrowClosed}},U);return S.current=X,X}),te(null)},[qi,x,Se]),WL=m.useCallback(w=>{if(!Se){ge("Readonly workspace"),te(null);return}const N=w==null?void 0:w.connection;if(!N||!xw(N,j.current)){ge("端口类型不匹配,已取消连线"),te(null);return}g(_=>pw(_,N)),x(_=>{const I=_.filter(U=>!(U.target===N.target&&U.targetHandle===N.targetHandle)),T=bh({...N,markerEnd:{type:Ci.ArrowClosed}},I);return S.current=T,T}),te(null)},[x,g,Se]),P0=m.useCallback(w=>{w&&(qi(w,{position:ep()}),$e(!1),Lt(""))},[qi,ep]),I0=m.useCallback(w=>{w&&(_u(w,ep()),$e(!1),Lt(""))},[_u,ep]),VL=m.useCallback(w=>{var _,I,T;if(dt||Cn)return;const N=w==null?void 0:w.target;FC(N)||(_=N==null?void 0:N.closest)!=null&&_.call(N,"button, a, [role='button'], .react-flow__handle")||(T=(I=C.current)==null?void 0:I.focus)==null||T.call(I,{preventScroll:!0})},[dt,Cn]);m.useEffect(()=>{const w=N=>{var ae;if(N.defaultPrevented)return;const _=OU(N.target)||FC(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){N.preventDefault(),en().catch(he=>ge(String(he.message||he)));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),PS(he=>!he);return}if(Yg)return;if(Ug){(N.key==="Escape"||xC(N))&&(N.preventDefault(),Ff(!1));return}const I=N.key.toLowerCase(),T=(N.metaKey||N.ctrlKey)&&I==="c",U=(N.metaKey||N.ctrlKey)&&I==="v",X=_&&T&&uG(N.target);if(_&&!X)return;const J=(N.metaKey||N.ctrlKey)&&!N.shiftKey&&I==="z",Y=(N.metaKey||N.ctrlKey)&&(N.shiftKey&&I==="z"||I==="y");if(J||Y){if(dt){N.preventDefault(),N.stopPropagation(),ge("展示页布局会自动保存");return}if(!Se){N.preventDefault(),ge("Readonly workspace");return}N.preventDefault(),N.stopPropagation();const he=J?KS():qS();ge(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(T){if(dt)return;const he=Kv.current,fe=(j.current||[]).some(Ve=>Ve==null?void 0:Ve.selected)?j.current:(j.current||[]).map(Ve=>he&&Ve.id===he?{...Ve,selected:!0}:Ve),je=oU(fe,S.current,Z.current);je&&(N.preventDefault(),N.stopPropagation(),H.current=je,fJ(je),X&&typeof((ae=N.target)==null?void 0:ae.blur)=="function"&&N.target.blur(),ge(`Copied ${je.nodes.length} node${je.nodes.length>1?"s":""}`));return}if(U){if(dt){N.preventDefault(),N.stopPropagation();return}if(!Se){N.preventDefault(),ge("Readonly workspace");return}const he=H.current||pJ();he&&!H.current&&(H.current=he);const fe=aU(he,j.current,S.current,Z.current);fe&&(N.preventDefault(),N.stopPropagation(),Z.current=fe.instances,ie(fe.instances),g(fe.nodes),x(fe.edges),ge(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(xC(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Ff(!0);return}if(I==="g"&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),b0();return}if(N.key==="a"||N.key==="A"){if(N.metaKey||N.ctrlKey){N.preventDefault(),dt?V(B.current.nodeIds):(g(he=>he.map(fe=>({...fe,selected:!0}))),x(he=>he.map(fe=>({...fe,selected:!1}))));return}if(N.altKey)return;if(dt){N.preventDefault(),pn(!0);return}if(!Se){N.preventDefault(),ge("Readonly workspace");return}N.preventDefault(),$e(!0);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),IS("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),IS("pan");return}(N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&(N.preventDefault(),x0())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[b0,dt,Yg,x0,qS,en,Ug,x,g,KS,Se]);const KL=m.useCallback(w=>{wl(N=>{const _=new Set(N);return _.has(w)?_.delete(w):_.add(w),_})},[]),qL=m.useCallback((w,N)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:N.path,name:N.name,type:N.type})),w.dataTransfer.setData("text/plain",N.path)},[]),UL=m.useCallback((w,N)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",N.id),w.dataTransfer.setData("text/plain",N.id)},[]),tp=m.useCallback(async(w,N)=>{const _=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),I=_.split(".").pop(),T=["jsx","tsx","js"].includes(I)?"display_react_app":I==="html"?"display_html":I==="csv"||I==="tsv"||I==="json"&&/\b(table|data|rows|report)\b/i.test(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(I)?"display_image":"display_markdown",U=at.find(fe=>fe.id===T);if(!U){ge("展示节点不可用");return}const X=T==="display_image";let J=String(w.path||"");if(!X){const fe=Fr(a);fe.set("path",w.path);const je=await fetch(`/api/workspace/file?${fe.toString()}`),Ve=await je.json();if(!je.ok)throw new Error(Ve.error||"读取文件失败");J=String(Ve.content||"")}const Y=T==="display_image"?"src":"content",ae=nd(U.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),he=nd(U.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);qi(U,{label:w.name||"Display",body:J,inputs:ae,outputs:he,position:N}),ge(`已创建展示:${w.path}`)},[qi,a,at]),YL=m.useCallback(w=>{if(!Se){ge("Readonly workspace");return}tp(w,Ml()).catch(N=>ge(String(N.message||N)))},[tp,Ml,Se]),GL=m.useCallback(w=>{if(!Se){w.preventDefault(),ge("Readonly workspace");return}const N=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(N){w.preventDefault();let X;try{X=JSON.parse(N)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});tp(X,J).catch(Y=>ge(String(Y.message||Y)));return}const _=w.dataTransfer.getData("application/agentflow-snippet");if(_){const X=vt.find(Y=>`${Y.id}@${Y.version}`===_);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});_u(X,J);return}const I=w.dataTransfer.getData("application/agentflow-node");if(!I)return;const T=at.find(X=>X.id===I);if(!T)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});qi(T,{position:U})},[tp,qi,vt,_u,at,r,Se]),JL=m.useCallback(w=>{if(!Se)return;const N=Array.from(w.dataTransfer.types||[]);!N.includes("application/x-agentflow-workspace-file")&&!N.includes("application/agentflow-node")&&!N.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=N.includes("application/agentflow-node")||N.includes("application/agentflow-snippet")?"move":"copy")},[Se]),XL=m.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const N=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!N)return;const _=w&&!N.includes("/")?`${w}/${N}`:N;try{const I=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_,content:""})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件失败");await Nn(),wl(U=>{const X=new Set(U);for(const J of Yp(T.path||_))X.delete(J);return X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),QL=m.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const N=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!N)return;const _=w&&!N.includes("/")?`${w}/${N}`:N;try{const I=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件夹失败");await Nn(),wl(U=>{const X=new Set(U);for(const J of Yp(T.path||_))X.delete(J);return T.path&&X.delete(T.path),X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),ZL=m.useCallback(async w=>{if(!Se){ge("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const N=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),_=await N.json();if(!N.ok)throw new Error(_.error||"删除失败");ge(`已删除 ${_.path}`),await Nn()}catch(N){ge(String(N.message||N))}},[a,Nn,Se]),e2=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const N=rf(w.path,a,{download:!0});if(!N)return;const _=document.createElement("a");_.href=N,_.download=w.name||w.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[a]),np=m.useCallback(async()=>{if(!Se){ge("Readonly workspace");return}const w=xa.trim(),N=qr,_=Vs.find(X=>X.id===N)||null;if(!w||is||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const I=_?Array.isArray(_.messages)?_.messages:[]:ba,T=Wl(b,k,Z.current);Hg(""),NS(!0),vl(!0),Sl(null);const U={role:"user",text:w,at:Date.now()};_?Wn(X=>X.map(J=>J.id===N?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(Ns("workspace"),kl(X=>[...X,U]));try{await en(b,k);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,prompt:w,outputKind:"markdown",workspaceGraph:T,allowFlowYaml:!1,model:Hi,selectedSkills:Ws,selectedNodeIds:Gf,messages:I})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const ae={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};_?Wn(he=>he.map(fe=>fe.id===N?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],ae].slice(-180)}:fe)):kl(he=>[...he,ae]),await Cs(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};_?Wn(ae=>ae.map(he=>he.id===N?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):kl(ae=>[...ae,Y]),ge(J)}finally{NS(!1)}},[qr,ba,Hi,Vs,is,xa,k,a,Cs,b,en,Gf,Ws,Se]),ir=Vs.find(w=>w.id===qr)||null,cy=ir?Array.isArray(ir.messages)?ir.messages:[]:ba,$l=ir&&(ir.status==="running"||ir.status==="stopping")||is,t2=YJ(cy,$l),uy=GJ(cy),R0=ir?ir.status==="stopping"?`${ir.label} stopping`:ir.status==="running"?`${ir.label} running`:ir.status==="paused"?`${ir.label} paused`:ir.status==="failed"?`${ir.label} failed`:`${ir.label} done`:is?"Workspace agent running":ba.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{qr!=="workspace"&&(Vs.some(w=>w.id===qr)||Ns(Sa()))},[qr,Vs,Sa]),m.useEffect(()=>{if(!du)return;const w=window.requestAnimationFrame(()=>{var _,I;const N=CS.current;N&&(N.scrollTop=N.scrollHeight),(I=(_=Wg.current)==null?void 0:_.scrollIntoView)==null||I.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[cy.length,qr,R0,uy.length,du]);const n2=String(a.flowId||"").trim()||"Workspace",No=(rt==null?void 0:rt.mode)==="single-node",T0=No&&Cu.find(w=>{var N;return w.id===rt.sourceNodeId||((N=rt.nodeIds)==null?void 0:N.includes(w.id))})||null,r2=No&&T0?[T0]:Cu;return i.jsxs("div",{className:"af-workspace-page",children:[l?null: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(a.adminOwnerId?"/admin/usage":"/projects"),"aria-label":"返回",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",title:a.flowId?`${a.flowId} · ${Yv}`:Yv||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:n2}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",tG,"-STABLE"]})]}),If?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",If.ownerUsername||If.ownerUserId]}):null,i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:d==="workspace"?"af-view-switch__active":"",onClick:()=>ay("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:d==="display"?"af-view-switch__active":"",onClick:()=>ay("display"),children:"Display"}),i.jsx("button",{type:"button",className:d==="workflow"?"af-view-switch__active":"",onClick:()=>ay("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${OS}`,title:`${WS} · ${DS}`,role:"status","aria-label":`${WS}:${DS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),jn?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=jn.conflictItems)!=null&&w.length?ya(!0):E0()},title:["先下载当前本地草稿,再载入远端最新版本",...jn.conflictPaths||[]].join(`
265
- `),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,dt?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||Hn||!(me!=null&&me.absoluteUrl)&&P.nodeIds.length===0,onClick:()=>{Ut(""),mr(!0)},title:me!=null&&me.absoluteUrl?"查看展示链接":P.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Hn?"hourglass_empty":"ios_share"}),Hn?"生成中":me!=null&&me.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||Al.length===0,onClick:()=>pn(!0),title:Al.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||!!(Tt!=null&&Tt.role&&Tt.role!=="owner"),onClick:vL,title:Tt!=null&&Tt.role&&Tt.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),If?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:CL,title:"查看我的展示分享",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!HS,onClick:()=>h(!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:!HS&&!wu,onClick:()=>v(!0),"aria-label":wu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:wu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:wu?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ff(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(du?" af-composer-topbar-btn--active":"")+(is?" af-composer-topbar-btn--running":""),disabled:!Se||dt||Cn,onClick:()=>{Sl(null),vl(w=>(w||Ns(Sa()),!w))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Se,onClick:()=>en().catch(w=>ge(String(w.message||w))),children:"Save"})]})]}),bs?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:bs}),i.jsx("button",{type:"button",onClick:()=>Jn(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!dt&&!Cn&&(du||gt)?" af-workspace-body--drawer":"")+(!dt&&!Cn&&pu?" af-workspace-body--sidebar-collapsed":"")+(dt?" af-workspace-body--display-mode":"")+(Cn?" af-workspace-body--workflow-mode":""),children:[!dt&&!Cn&&pu?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:()=>$e(!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:()=>Df(!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:()=>Df(!1),"aria-label":"展开侧边栏",title:(Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"展开侧边栏",children:wL})]})}):null,!dt&&!Cn?i.jsxs("aside",{ref:Mg,className:"af-workspace-sidebar"+(O$?" af-workspace-sidebar--resizing":""),"aria-hidden":pu,style:{"--af-work-files-pane-height":`${Math.round($g)}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:()=>Df(!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:!Se,onClick:()=>XL(Ki),"aria-label":"新增文件",title:Ki?`在 ${Ki} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>QL(Ki),"aria-label":"新增文件夹",title:Ki?`在 ${Ki} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se||sS,onClick:()=>o0(Ki),"aria-label":"上传文件",title:Ki?`上传到 ${Ki}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:sS?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Nn(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:oS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:lL})]})]}),i.jsx("input",{className:"af-workspace-search",value:Pg,onChange:w=>$$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:gL,children:i.jsx(jM,{items:mL,onOpen:YL,selectedPath:Ig,collapsedDirs:L$,onToggleDir:KL,onSelect:w=>Rg(w.path||""),onFileDragStart:qL,onDelete:ZL,onDownload:e2})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:q$,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:qe==="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:Pe,onChange:w=>et(w.target.value),placeholder:qe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":qe==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":qe==="nodes",className:"af-palette-tab"+(qe==="nodes"?" af-palette-tab--active":""),onClick:()=>It("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":qe==="flows",className:"af-palette-tab"+(qe==="flows"?" af-palette-tab--active":""),onClick:()=>It("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:qe==="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:bL,disabled:Qn.length<2,title:Qn.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:["已选 ",Qn.length," 节点 / ",Jf.length," 连线"]})]})}),kn?i.jsx("p",{className:"af-err af-palette-list-err",children:kn}):null,Yn?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):N0.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:N0.map(w=>{const N=`${w.id}@${w.version}`,_=w.displayName||w.name||w.id,I=w.description||`${w.nodeCount||0} 个节点,${w.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:T=>{T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("application/agentflow-snippet",N),T.dataTransfer.setData("text/plain",N)},onClick:()=>_u(w),title:I,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:_}),i.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),I?i.jsx("span",{className:"af-palette-card-desc",children:I}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[w.nodeCount||0," nodes"]}),i.jsxs("span",{children:[w.edgeCount||0," edges"]})]})]},N)})})]}):i.jsx("p",{className:"af-palette-empty",children:Pe.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[ql.map(w=>{var N;return(N=ry[w])!=null&&N.length?i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${w}`,children:[i.jsx("h3",{className:"af-palette-cat",children:w}),i.jsx("div",{className:"af-palette-cards",children:ry[w].map(_=>{const I=qC(_.inputs,"input"),T=qC(_.outputs,"output"),U=Sb(_),X=ed(_);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>UL(J,_),onClick:()=>qi(_),title:U||_.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:VC(w)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:X}),X!==_.id?i.jsx("span",{className:"af-palette-card-id",children:_.id}):null]})]}),U?i.jsx("span",{className:"af-palette-card-desc",children:U}):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:[I.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[I.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:KC("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:An(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Kp(J,Y)})]},`in-${Y}`)),I.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",I.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:[T.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[T.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:KC("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Kp(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:An(J==null?void 0:J.type)}})]},`out-${Y}`)),T.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",T.hidden]}):null]})]})]})]},_.id)})})]},w):null}),at.length>0&&Pe.trim()&&ql.every(w=>{var N;return!((N=ry[w])!=null&&N.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,Cn?i.jsx(dX,{flowParams:a,tapdId:sr,setTapdId:W$,snapshot:sn,loading:V$,error:K$,actionRunning:Lg,actionOutput:Og,pendingConfirm:js,conflict:cu,reviewPublishing:Dg,onRefresh:()=>bu(sr),onRunDryRun:tL,onConfirmAction:nL,onRetryConflict:rL,onPublishReview:sL}):i.jsxs("main",{ref:C,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{VL(w),ML(w)},onLostPointerCaptureCapture:jo,children:[i.jsx(TR,{className:"af-flow-canvas af-workspace-flow"+(Gg==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(dt?" af-workspace-flow--display-mode":""),nodes:Yf,edges:pL,nodeTypes:zJ,onNodesChange:TL,onEdgesChange:OL,onMoveStart:$L,onMoveEnd:LL,onConnect:dt?void 0:FL,onConnectStart:dt?void 0:zL,onConnectEnd:dt?void 0:BL,isValidConnection:dt?void 0:DL,onNodeClick:(w,N)=>{var _;if(dt){V([Up(N.id)]);return}if((_=N==null?void 0:N.data)!=null&&_.isWorkspaceGroup){Zt("");return}if(w.detail>=3){vl(!1),g(I=>I.map(T=>({...T,selected:T.id===N.id}))),x(I=>I.map(T=>({...T,selected:!1}))),Zt(N.id);return}yr&&Zt(N.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{dt?V([]):Zt("")},onDrop:dt?void 0:GL,onDragOver:dt?void 0:JL,nodesDraggable:Se,nodesConnectable:dt?!1:Se,edgesReconnectable:dt?!1:Se,onlyRenderVisibleElements:Yf.length>=80,deleteKeyCode:dt?null:Se?["Backspace","Delete"]:null,selectionOnDrag:Gg==="select",panOnDrag:Gg==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx($R,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!dt&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),N=G.mode==="create"?"create":"existing",_=Array.isArray(G.candidates)?G.candidates:[],I=Array.isArray(G.existingCandidates)?G.existingCandidates:[],T=w?_.filter(Y=>{var ae,he,fe;return[(ae=Y.def)==null?void 0:ae.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(je=>String(je).toLowerCase().includes(w))}):_,U=w?I.filter(Y=>{var ae,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ae=Y.slot)==null?void 0:ae.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):I,X=G.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.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:An((J=G.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",G.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>te(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:N==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:I.length===0,onClick:()=>te(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:I.length})]}),i.jsxs("button",{type:"button",className:N==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:_.length===0,onClick:()=>te(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:_.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:G.query,onChange:Y=>te(ae=>ae&&{...ae,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[N==="create"?T.map(Y=>{var fe,je;const ae=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),he=Kp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>HL(Y),title:Y.description||Y.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:ae}),ae!==Y.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:An((je=Y.slot)==null?void 0:je.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${Y.def.id}-${Y.slotIndex}`)}):U.map(Y=>{var fe;const ae=Y.nodeLabel||Y.nodeId,he=Kp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>WL(Y),title:`${Y.definitionId||Y.nodeId} · ${he}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:An((fe=Y.slot)==null?void 0:fe.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he}),Y.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(N==="create"?T.length:U.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!dt&&!Cn&&!J$?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:()=>Vg(!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:Qn.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Qn.map(w=>{var T,U;const N=String(((T=w.data)==null?void 0:T.label)??w.id),_=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",I=_&&_!==N?`${N} · ${w.id} · ${_}`:`${N} · ${w.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:I,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:_||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:N}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>RL(w.id),"aria-label":`取消选择 ${w.id}`,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.jsx("div",{className:"af-composer-input-wrap",children:i.jsx("textarea",{className:"af-composer-textarea",value:xa,rows:2,onChange:w=>Hg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),np())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Se})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Bg,type:"button",className:"af-composer-skills-button"+(Ws.length>0?" af-composer-skills-button--active":""),disabled:is||!Se,"aria-haspopup":"listbox","aria-expanded":Of,onClick:()=>zg(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Ws.length>0?`Skills ${Ws.length}`:"Skills"})]}),Of&&!is?lr.createPortal(i.jsx("div",{ref:SS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:Y$,children:Hs.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Il.groups.map(w=>{const N=ia(w,Hs),_=JF(w,sy,Hs),I=U$.has(w.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(I?" 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:_==="all",disabled:N.length===0,onChange:T=>{const U=T.target.checked;lu(X=>U?YF(X,N):GF(X,N))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:w.name}),w.builtin?i.jsx("em",{children:"built-in"}):null,_==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":I?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{vS(T=>{const U=new Set(T);return U.has(w.id)?U.delete(w.id):U.add(w.id),U})},children:[i.jsx("span",{children:w.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:I?"expand_more":"expand_less"})]})]}),I?null:i.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(T=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:sy.has(T.key),onChange:U=>{const X=U.target.checked;lu(J=>X?J.includes(T.key)?J:[...J,T.key]:J.filter(Y=>Y!==T.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:T.name}),T.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:T.description}):null]})]},`${w.id}:${T.key}`))})]},w.id)}),Il.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:Il.ungrouped.length})]}),Il.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:sy.has(w.key),onChange:N=>{const _=N.target.checked;lu(I=>_?I.includes(w.key)?I:[...I,w.key]:I.filter(T=>T!==w.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:w.name}),w.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:w.description}):null]})]},`ungrouped:${w.key}`))]}):null]})}),document.body):null]}),i.jsx("label",{className:"af-composer-model-field",children:i.jsxs("select",{className:"af-composer-model-select",value:Hi,onChange:w=>F$(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),yL.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(xa.trim()&&!is?" af-composer-send--active":"")+(is?" af-composer-send--stop":""),disabled:is||!xa.trim()||!Se,"aria-label":is?"Running":"Send",onClick:()=>void np(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:is?"sync":"arrow_upward"})})]})]})]})}):!dt&&!Cn?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Vg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!dt&&!Cn&&du?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:()=>vl(!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"+(qr==="workspace"?" af-composer-session-tab--active":""),ref:qr==="workspace"?Wg:null,onClick:()=>Ns("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Vs.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:qr===w.id?Wg:null,className:"af-composer-session-tab"+(qr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>Ns(w.id),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),Ns(w.id))},title:w.runNodeId||w.label,children:[i.jsx("span",{className:"af-composer-session-label",children:w.label}),i.jsx("button",{type:"button",className:"af-composer-session-close",onClick:N=>{N.preventDefault(),N.stopPropagation(),oL(w.id)},"aria-label":`关闭 ${w.label}`,title:"关闭 tab",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},w.id))]}),i.jsx("div",{className:"af-composer-sidebar-status"+($l?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:R0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:CS,children:[i.jsx(r_,{messages:t2,running:$l,showRunningIndicator:!ir}),uy.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",...$l?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(r_,{messages:uy,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:xa,rows:3,onChange:w=>Hg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),np())},placeholder:ir?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!Se||$l}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!Se||$l||!xa.trim(),onClick:()=>void np(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!dt&&!Cn&&gt&&Kt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(iY,{draft:gt,setDraft:Ss,definitionId:String(((M0=Kt.data)==null?void 0:M0.definitionId)||Kt.id),systemPromptReadonly:String((($0=Kt.data)==null?void 0:$0.description)||""),modelLists:wa,disabled:!Se,onIdBlur:()=>ey(!0),onClose:()=>Zt(""),onPublishToMarketplace:iL,error:E$,ioSlots:{inputs:Array.isArray(gt==null?void 0:gt.inputs)?gt.inputs:[],outputs:Array.isArray(gt==null?void 0:gt.outputs)?gt.outputs:[]}})}):null,!dt&&!Cn&&fu?lr.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>Sl(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(VU,{flowParams:a,scheduleNodeId:fu.scheduleNodeId,runNodeId:fu.runNodeId,lastRunId:fu.lastRunId,label:fu.label,onClose:()=>Sl(null)})})}),document.body):null,i.jsx(zU,{open:Ug,onClose:()=>Ff(!1)}),i.jsx(HU,{open:Yg,onClose:()=>PS(!1),onJump:ny,nodes:hL}),i.jsx(oY,{open:p,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:yu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(aY,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:yu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:wu,onDeleted:async()=>{v(!1),n("/projects")}}),M$&&jn?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-workspace-conflict-modal",role:"dialog","aria-modal":"true","aria-label":"解决 Workspace 冲突",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:"difference"}),"解决 ",((L0=jn.conflictItems)==null?void 0:L0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ya(!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("div",{className:"af-workspace-conflict-summary",children:["未冲突的改动已经自动合并。这里只需要决定双方同时修改的字段。",i.jsxs("div",{className:"af-workspace-conflict-bulk",children:[i.jsx("button",{type:"button",onClick:()=>yl(Object.fromEntries((jn.conflictItems||[]).map((w,N)=>[String(N),{mode:"local",manual:Hu(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>yl(Object.fromEntries((jn.conflictItems||[]).map((w,N)=>[String(N),{mode:"remote",manual:Hu(w)}]))),children:"全部使用远端"})]})]}),(jn.conflictItems||[]).map((w,N)=>{const _=Ag[String(N)]||{mode:"local",manual:Hu(w)};return i.jsxs("section",{className:"af-workspace-conflict-item",children:[i.jsx("code",{className:"af-workspace-conflict-path",children:w.path}),i.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([I,T])=>i.jsx("button",{type:"button",className:_.mode===I?"is-active":"",onClick:()=>yl(U=>({...U,[String(N)]:{..._,mode:I}})),children:T},I))}),i.jsxs("div",{className:"af-workspace-conflict-values",children:[i.jsxs("div",{className:_.mode==="local"?"is-selected":"",children:[i.jsx("span",{children:"我的修改"}),i.jsx("pre",{children:f_(w,"incoming")})]}),i.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:f_(w,"current")})]})]}),_.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:_.manual,onChange:I=>yl(T=>({...T,[String(N)]:{..._,manual:I.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${N}`)}),rS?i.jsx("div",{className:"af-flow-snippet-error",children:rS}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot af-workspace-conflict-foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Tf,onClick:()=>void E0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Tf,onClick:()=>ya(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Tf||!(jn.conflictItems||[]).length,onClick:()=>void jL(),children:Tf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,pr?lr.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:()=>hr(!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:fn.name,onChange:w=>{const N=w.target.value;zn(_=>({..._,name:N,id:_.id?_.id:N.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:fn.id,onChange:w=>zn(N=>({...N,id:w.target.value})),placeholder:"content-cleanup-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:fn.description,onChange:w=>zn(N=>({...N,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Qn.length," 个节点和 ",Jf.length," 条内部连线。"]}),vn?i.jsx("div",{className:"af-flow-snippet-error",children:vn}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>hr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ss||!fn.name.trim(),onClick:()=>void kL(),children:ss?"发布中...":"发布"})]})]})}),document.body):null,m0?i.jsx(EJ,{node:m0,onClose:()=>q("")}):null,vr?lr.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":No?"新建分享":"发布展示页",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"}),No?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Sr(!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:rt.title,onChange:w=>zt(N=>({...N,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),No?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:rt.layout,onChange:w=>zt(N=>({...N,layout:w.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.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"有效期"}),i.jsx("select",{className:"af-display-share-select",value:XC(rt),onChange:w=>{const N=w.target.value;zt(_=>({..._,permanent:N==="permanent",expiresInDays:N==="permanent"?_.expiresInDays||30:Number(N)}))},children:bw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),i.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":No?"分享内容":"选择展示节点",children:[No?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,r2.map(w=>{var _;const N=Array.isArray(rt.nodeIds)&&rt.nodeIds.includes(w.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:N,disabled:No,onChange:()=>NL(w.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((_=w.data)==null?void 0:_.label)||w.id}),i.jsxs("small",{children:[_n(w.data)," · ",w.id]})]})]},w.id)})]}),me!=null&&me.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:me.absoluteUrl,onFocus:w=>w.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(me.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void A0(),children:ut==="copied"?"已复制":ut==="failed"?"复制失败":"复制"})]}):null,$r?i.jsx("div",{className:"af-flow-snippet-error",children:$r}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Sr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Hn||!Array.isArray(rt.nodeIds)||rt.nodeIds.length===0,onClick:()=>void _L(),children:Hn?"生成中...":"生成链接"})]})]})}),document.body):null,Nr?lr.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:()=>{Ut(""),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:[me!=null&&me.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:me.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(me.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 A0(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ut==="copied"?"check":"content_copy"}),ut==="copied"?"已复制":ut==="failed"?"复制失败":"复制"]})]}):i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"新链接有效期"}),i.jsx("select",{className:"af-display-share-select",value:XC(rt),onChange:w=>{const N=w.target.value;zt(_=>({..._,permanent:N==="permanent",expiresInDays:N==="permanent"?_.expiresInDays||30:Number(N)}))},children:bw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),$r?i.jsx("div",{className:"af-flow-snippet-error",children:$r}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Ut(""),mr(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Hn||P.nodeIds.length===0,onClick:()=>void EL(),children:Hn?"生成中...":me!=null&&me.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,R$?lr.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:"group_add"}),"协作分享"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Cg(!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("div",{className:"af-workspace-team-share",children:[i.jsxs("div",{className:"af-workspace-team-share__head",children:[i.jsx("strong",{children:"分享到团队"}),i.jsx("span",{children:Bs?Bs.name:"尚未加入团队"})]}),Bs?i.jsxs("div",{className:"af-workspace-team-share__actions",children:[i.jsxs("select",{value:Eg,onChange:w=>eS(w.target.value),"aria-label":"团队权限",children:[i.jsx("option",{value:"viewer",children:"只读"}),i.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(O0=Tt==null?void 0:Tt.teamShares)!=null&&O0.some(w=>w.teamId===Bs.id)?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:iu,onClick:()=>void ly(!1),children:iu?"处理中...":"更新权限"}),i.jsx("button",{type:"button",disabled:iu,onClick:()=>void ly(!0),children:"取消分享"})]}):i.jsx("button",{type:"button",disabled:iu,onClick:()=>void ly(!1),children:iu?"分享中...":"分享到团队"})]}):i.jsx("p",{className:"af-display-link-modal__empty",children:"联系超级管理员将你加入团队后,即可在这里分享。"})]}),i.jsx("p",{className:"af-display-link-modal__empty",children:"输入已注册用户名。添加后,这个 Workspace 会直接出现在对方的项目列表中。"}),i.jsxs("div",{className:"af-workspace-member-add",children:[i.jsx("input",{type:"text",value:su,onChange:w=>Xv(w.target.value),onKeyDown:w=>{w.key==="Enter"&&su.trim()&&!_g&&(w.preventDefault(),_0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:_g||!su.trim(),onClick:()=>void _0(),children:_g?"添加中...":"添加成员"})]}),Jv?i.jsx("div",{className:"af-flow-snippet-error",children:Jv}):null,i.jsx("div",{className:"af-workspace-member-list",children:((Tt==null?void 0:Tt.members)||[]).map(w=>{const N=w.userId===(Tt==null?void 0:Tt.ownerId)||w.role==="owner";return i.jsxs("div",{className:"af-workspace-member-row",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:N?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:w.username||w.userId}),i.jsx("small",{children:N?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),N?null:i.jsx("button",{type:"button",disabled:Qv===w.userId,onClick:()=>void SL(w),children:Qv===w.userId?"移除中...":"取消分享"})]},w.userId)})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Cg(!1),children:"完成"})})]})}),document.body):null,Yt?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-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:"folder_shared"}),"我的分享"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Xn(!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("div",{className:"af-display-shares-toolbar",children:[i.jsx("span",{children:it.length?`${it.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Ys(),disabled:Fs,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),zs?i.jsx("div",{className:"af-flow-snippet-error",children:zs}):null,Fs?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!Fs&&it.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:it.map(w=>{const N=ZC(w),_=ve===w.id,I=w.expiresAt?String(w.expiresInDays||30):"permanent";return i.jsxs("article",{className:"af-display-share-item",children:[i.jsxs("div",{className:"af-display-share-item__main",children:[i.jsx("strong",{children:w.title||"AgentFlow Display"}),i.jsxs("span",{children:[w.flowId||"-"," · ",w.layout||"gallery"," · ",Array.isArray(w.nodeIds)?w.nodeIds.length:0," nodes"]}),i.jsx("small",{children:cJ(w)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:N,onFocus:T=>T.target.select()}),i.jsx("select",{className:"af-display-share-select",value:I,disabled:_,onChange:T=>void PL(w,T.target.value),"aria-label":"修改分享有效期",children:bw.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsxs("div",{className:"af-display-share-item__actions",children:[i.jsxs("button",{type:"button",onClick:()=>window.open(N,"_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 AL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:bt===w.id?"check":"content_copy"}),bt===w.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:_,onClick:()=>void IL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,Qt?lr.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:()=>pn(!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:$n,onChange:w=>ks(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":j0.length||1},children:Xf.length>0?j0.map((w,N)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(xL)},`display-picker-column-${N}`)):i.jsx("div",{className:"af-display-picker-empty",children:Al.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:()=>pn(!1),children:"完成"})})]})}),document.body):null,au.nodeId?lr.createPortal(i.jsx(UJ,{files:ml,query:au.query,onQueryChange:w=>Tg(N=>({...N,query:w})),onSelect:cL,onUpload:o0,onClose:Qg}),document.body):null,!dt&&!Cn&&we?lr.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>$e(!1),children:i.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:w=>w.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":Ee==="nodes",className:"af-workspace-quick-add__tab"+(Ee==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ze("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":Ee==="flows",className:"af-workspace-quick-add__tab"+(Ee==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ze("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:jS,value:wn,onChange:w=>Lt(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),$e(!1);else if(w.key==="ArrowDown"){w.preventDefault();const N=Ee==="flows"?Nu.length:ju.length;rr(_=>Math.min(Math.max(0,N-1),_+1))}else w.key==="ArrowUp"?(w.preventDefault(),rr(N=>Math.max(0,N-1))):w.key==="Tab"?(w.preventDefault(),Ze(N=>N==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),Ee==="flows"?I0(Nu[Sn]||Nu[0]):P0(ju[Sn]||ju[0]))},placeholder:Ee==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ee==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:Ee==="flows"?Nu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Yn?"正在加载流程片段...":kn||"没有匹配的流程片段"}):Nu.map((w,N)=>{const _=w.displayName||w.name||w.id,I=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,T=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,U=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(I||{}).length,X=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(T)?T.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(N===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>rr(N),onClick:()=>I0(w),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:_}),i.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${U} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):ju.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):ju.map((w,N)=>{const _=Zu(w),I=ed(w),T=Sb(w);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(N===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>rr(N),onClick:()=>P0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:VC(_)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:I}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),T?i.jsx("span",{className:"af-workspace-quick-add__desc",children:T}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:_})]},w.id)})})]})}),document.body):null]})]})}function $M(){return i.jsx(Qk,{children:i.jsx(pX,{})})}function hX(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 mX(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function gX(e){let t=String(e||"").replace(/\r\n/g,`
266
- `).trim();return t.includes(`
267
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
268
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
269
- $2`)),t}function LM(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=gX(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 d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
270
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
271
- `).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),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 Iv(e){let t=LM(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 yX(e){const t=Iv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function wX(e){const t=Iv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
272
- (() => {
273
- document.addEventListener("click", (event) => {
274
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
275
- if (!link) return;
276
- const rawHref = String(link.getAttribute("href") || "").trim();
277
- if (!rawHref || rawHref.startsWith("#")) return;
278
- if (/^javascript:/i.test(rawHref)) {
279
- event.preventDefault();
280
- return;
281
- }
282
- event.preventDefault();
283
- window.open(link.href, "_blank", "noopener,noreferrer");
284
- }, true);
285
- })();
286
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function OM(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 xX(e,t,n={}){const r=String(e||"").trim();return r?OM(r,t,n):""}function bX({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=x=>{x.preventDefault(),l(c(x.clientY,b))},k=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[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:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function Ab({node:e,shareId:t,style:n,bare:r=!1}){const s=hX(e),o=e.kind==="html"?Iv(s):e.kind==="react"?yg(s):LM(s),a=e.kind==="html"?yX(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:mX(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(bX,{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 allow-popups allow-popups-to-escape-sandbox",srcDoc:wX(o)}):null,e.kind==="react"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:kv(o)}):null,e.kind==="image"?i.jsx("img",{src:OM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(mv,{content:o,resolveSrc:(c,u)=>xX(c,t,u)})}):null,e.kind==="chart"?i.jsx(yv,{content:o}):null,e.kind==="table"?i.jsx(gv,{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 kX({data:e}){return i.jsx(Ab,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const vX={publicDisplay:kX};function SX(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 DM(){var l,c,u,d;const{path:e}=xs(),t=m.useMemo(()=>SX(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function p(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return p(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((p,h)=>{const y=p.position&&typeof p.position.x=="number"&&typeof p.position.y=="number"?p.position:{x:120+h*40,y:100+h*32},v=p.size&&typeof p.size.width=="number"&&typeof p.size.height=="number"?p.size:{width:520,height:320};return{id:p.id,type:"publicDisplay",position:y,data:{node:p,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(v.width)||520),height:Math.max(1,Number(v.height)||320)}}}),[t,n.nodes]),o=m.useMemo(()=>{var v;const f=(v=n.share)==null?void 0:v.viewport;if(!f||typeof f!="object")return null;const p=Number(f.x),h=Number(f.y),y=Number(f.zoom);return!Number.isFinite(p)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:p,y:h,zoom:Math.min(Math.max(y,.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(p=>i.jsx(Ab,{node:p,shareId:t,bare:!0},p.id))})});const f=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 ${f}`,children:[i.jsxs("header",{className:"af-public-display-hero",children:[i.jsxs("div",{children:[i.jsx("p",{children:"AgentFlow Display"}),i.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),i.jsx("span",{children:(d=n.share)!=null&&d.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>i.jsx(Ab,{node:p,shareId:t},p.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(Qk,{children:i.jsx(TR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:vX,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($R,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=e=>typeof e=="string",Wu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},p_=e=>e==null?"":""+e,jX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},NX=/###/g,h_=e=>e&&e.indexOf("###")>-1?e.replace(NX,"."):e,m_=e=>!e||xt(e),Sd=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(m_(e))return{};const o=h_(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return m_(e)?{}:{obj:e,k:h_(r[s])}},g_=(e,t,n)=>{const{obj:r,k:s}=Sd(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=Sd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Sd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},CX=(e,t,n,r)=>{const{obj:s,k:o}=Sd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},_m=(e,t)=>{const{obj:n,k:r}=Sd(e,t);if(n)return n[r]},_X=(e,t,n)=>{const r=_m(e,n);return r!==void 0?r:_m(t,n)},FM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?xt(e[r])||e[r]instanceof String||xt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):FM(e[r],t[r],n):e[r]=t[r]);return e},Vl=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var EX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const AX=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>EX[t]):e;class PX{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 IX=[" ",",","?","!",";"],RX=new PX(20),TX=(e,t,n)=>{t=t||"",n=n||"";const r=IX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=RX.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},Pb=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},Em=e=>e&&e.replace("_","-"),MX={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 Am{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||MX,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:(xt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Am(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Am(this.logger,t)}}var Ai=new Am;class bg{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l.apply(l,[t,...r])})}}class y_ extends bg{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):xt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=_m(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!xt(r)?c:Pb(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),g_(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)(xt(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=_m(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?FM(c,r,o):c={...c,...r},g_(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 zM={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 w_={};class Pm extends bg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),jX(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ai.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&&!TX(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:xt(o)?[o]:o};const u=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(s)}return{key:t,namespaces:xt(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],u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(d){const j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${j}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(p),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!xt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&x&&b.indexOf(v)<0&&!(xt(g)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const j=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=j,f.usedParams=this.getUsedParamsDetails(n),f):j}if(o){const j=Array.isArray(p),S=j?[]:{},C=j?y:h;for(const P in p)if(Object.prototype.hasOwnProperty.call(p,P)){const R=`${C}${o}${P}`;S[P]=this.translate(R,{...n,joinArrays:!1,ns:l}),S[P]===R&&(S[P]=p[P])}p=S}}else if(k&&xt(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,S=!1;const C=n.count!==void 0&&!xt(n.count),P=Pm.hasDefaultValue(n),R=C?this.pluralResolver.getSuffix(u,n.count,n):"",B=n.ordinal&&C?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",A=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),O=A&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${R}`]||n[`defaultValue${B}`]||n.defaultValue;!this.isValidLookup(p)&&P&&(j=!0,p=O),this.isValidLookup(p)||(S=!0,p=a);const L=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&S?void 0:p,M=P&&O!==p&&this.options.updateMissing;if(S||j||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?O:p),o){const $=this.resolve(a,{...n,keySeparator:!1});$&&$.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 V=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let $=0;$<z.length;$++)V.push(z[$]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(n.lng||this.language):V.push(n.lng||this.language);const F=($,W,E)=>{const Q=P&&E!==p?E:L;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,W,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing($,c,W,Q,M,n),this.emit("missingKey",$,c,W,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?V.forEach($=>{const W=this.pluralResolver.getSuffixes($,n);A&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(E=>{F([$],a+E,n[`defaultValue${E}`]||O)})}):F(V,a,O))}p=this.extendTranslation(p,t,n,f,r),S&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(S||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}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 u=xt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(u){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=r.replace&&!xt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),y=0;y<p;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=xt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=zM.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 xt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;s=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!xt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(xt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!w_[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(w_[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(g=>{if(this.isValidLookup(r))return;a=g;const k=[d];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,d,g,b,n);else{let j;p&&(j=this.pluralResolver.getSuffix(g,n.count,n));const S=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(d+j),n.ordinal&&j.indexOf(C)===0&&k.push(d+j.replace(C,this.options.pluralSeparator)),h&&k.push(d+S)),y){const P=`${d}${this.options.contextSeparator}${n.context}`;k.push(P),p&&(k.push(P+j),n.ordinal&&j.indexOf(C)===0&&k.push(P+j.replace(C,this.options.pluralSeparator)),h&&k.push(P+S))}}let x;for(;x=k.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(g,b,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&&!xt(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 Sw=e=>e.charAt(0).toUpperCase()+e.slice(1);class x_{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ai.create("languageUtils")}getScriptPartFromCode(t){if(t=Em(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=Em(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(xt(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]=Sw(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]=Sw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Sw(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)),xt(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 xt(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))):xt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let $X=[{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}],LX={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 OX=["v1","v2","v3"],DX=["v4"],b_={zero:0,one:1,two:2,few:3,many:4,other:5},FX=()=>{const e={};return $X.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:LX[t.fc]}})}),e};class zX{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Ai.create("pluralResolver"),(!this.options.compatibilityJSON||DX.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=FX(),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=Em(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)=>b_[s]-b_[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!OX.includes(this.options.compatibilityJSON)}}const k_=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=_X(e,t,n);return!o&&s&&xt(n)&&(o=Pb(e,n,r),o===void 0&&(o=Pb(t,n,r))),o},jw=e=>e.replace(/\$/g,"$$$$");class BX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ai.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:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:AX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Vl(o):a||"{{",this.suffix=l?Vl(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Vl(p):h||Vl("$t("),this.nestingSuffix=y?Vl(y):v||Vl(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=g||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=k_(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...s,...n,interpolationkey:h}):g}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(k_(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>jw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?jw(this.escape(h)):jw(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof d=="function"){const b=d(t,o,s);a=xt(b)?b:""}else if(s&&Object.prototype.hasOwnProperty.call(s,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!xt(a)&&!this.useRawValueToEscape&&(a=p_(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,o,a;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),y=p.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!xt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const d=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=d.shift(),c=d,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!xt(o))return o;xt(o)||(o=p_(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const HX=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Kl=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(Em(r),s),t[a]=l),l(n)}};class WX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ai.create("formatter"),this.options=t,this.formats={number:Kl((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Kl((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Kl((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Kl((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Kl((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()]=Kl(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:u,formatOptions:d}=HX(c);if(this.formats[u]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...d,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const VX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class KX extends bg{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=Ai.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(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,d=!1,a[p]===void 0&&(a[p]=!0),o[p]===void 0&&(o[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!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=>{CX(c.loaded,[o],a),VX(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,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=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();xt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),xt(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},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(t,n,r,s,c):d=u(t,n,r,s),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const v_=()=>({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]),xt(e[1])&&(t.defaultValue=e[1]),xt(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}}),S_=e=>(xt(e.ns)&&(e.ns=[e.ns]),xt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),xt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Gp=()=>{},qX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class of extends bg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=S_(t),this.services={},this.logger=Ai,this.modules={external:[]},qX(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&&(xt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=v_();this.options={...s,...this.options,...S_(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=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Ai.init(o(this.modules.logger),this.options):Ai.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=WX);const f=new x_(this.options);this.store=new y_(this.options.resources,this.options);const p=this.services;p.logger=Ai,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new zX(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=o(d),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new BX(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new KX(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=o(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=o(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Pm(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Gp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[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(d=>{this[d]=function(){return t.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return t.store[d](...arguments),t}});const c=Wu(),u=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Gp;const s=xt(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(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(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=Wu();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=Gp),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"&&zM.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=Wu();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,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=xt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,d=>{a(d,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,d=new Array(u>2?u-2:0),f=2;f<u;f++)d[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(d))}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 p=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${p}${y}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return xt(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 u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(o,t)))}loadNamespaces(t,n){const r=Wu();return this.options.ns?(xt(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=Wu();xt(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 x_(v_());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 of(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Gp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new of(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 y_(this.store.data,s),o.services.resourceStore=o.store),o.translator=new Pm(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];o.emit(l,...u)}),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 kr=of.createInstance();kr.createInstance=of.createInstance;kr.createInstance;kr.dir;kr.init;kr.loadResources;kr.reloadResources;kr.use;kr.changeLanguage;kr.getFixedT;kr.t;kr.exists;kr.setDefaultNamespace;kr.hasLoadedNamespace;kr.loadNamespaces;kr.loadLanguages;function UX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function af(e){"@babel/helpers - typeof";return af=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},af(e)}function YX(e,t){if(af(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(af(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function GX(e){var t=YX(e,"string");return af(t)=="symbol"?t:t+""}function JX(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,GX(r.key),r)}}function XX(e,t,n){return t&&JX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var BM=[],QX=BM.forEach,ZX=BM.slice;function eQ(e){return QX.call(ZX.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var j_=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,tQ=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(!j_.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!j_.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},N_={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=tQ(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)}},nQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=N_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&N_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},rQ={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}},Vu=null,C_=function(){if(Vu!==null)return Vu;try{Vu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Vu=!1}return Vu},sQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&C_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&C_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ku=null,__=function(){if(Ku!==null)return Ku;try{Ku=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ku=!1}return Ku},iQ={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&__()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&__()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},oQ={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}},aQ={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}},lQ={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}},cQ={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]}},HM=!1;try{document.cookie,HM=!0}catch{}var WM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];HM||WM.splice(1,1);function uQ(){return{order:WM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var VM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};UX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return XX(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=eQ(r,this.options||{},uQ()),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(nQ),this.addDetector(rQ),this.addDetector(sQ),this.addDetector(iQ),this.addDetector(oQ),this.addDetector(aQ),this.addDetector(lQ),this.addDetector(cQ)}},{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)}))}}])}();VM.type="languageDetector";const dQ={name:"AgentFlow",tagline:"AI Workflow Orchestration"},fQ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},pQ={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"},hQ={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},mQ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},gQ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},yQ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},wQ={app:dQ,nav:fQ,common:pQ,status:hQ,nodeTypes:mQ,engine:gQ,links:yQ},xQ="Flow Editor",bQ="Nodes",kQ="Edges",vQ="Properties",SQ={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"},jQ={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}}"},NQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},CQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},_Q={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"},EQ={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)"},AQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},PQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},IQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},RQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},TQ={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"},MQ={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"},$Q={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},LQ={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."},OQ={mainNav:"Main Navigation"},DQ={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'},FQ={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):
287
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
288
- 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}}"},zQ={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"},BQ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},HQ={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}}"},WQ={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"},VQ={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"},KQ={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"},qQ={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"},UQ={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"},YQ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},GQ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},JQ={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"},XQ={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."},QQ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},ZQ={save:"Save",cancel:"Cancel"},eZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},tZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},nZ={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"},rZ={title:xQ,nodes:bQ,edges:kQ,properties:vQ,node:SQ,nodeProps:jQ,actions:NQ,panel:CQ,palette:_Q,pipeline:EQ,status:AQ,roles:PQ,phases:IQ,types:RQ,runContext:TQ,shortcuts:MQ,jumpPalette:$Q,emptyCanvas:LQ,sidebar:OQ,validation:DQ,composer:FQ,topbar:zQ,palette2:BQ,run:HQ,fileEdit:WQ,settings:VQ,schedule:KQ,history:qQ,nodePropsError:UQ,placeholder:YQ,time:GQ,userCheck:JQ,userAsk:XQ,toolPrint:QQ,provideEdit:ZQ,runParams:eZ,runPreset:tZ,runConfig:nZ},sZ="Settings",iZ={engine:"Engine Settings",preferences:"Global Preferences"},oZ={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)."},aZ={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..."}},lZ={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."},cZ={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."},uZ={title:"Codex CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Codex model id list",description:"Model list comes from codex debug models --bundled. Run 'codex login' first."},dZ={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)"},fZ={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"},pZ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},hZ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},mZ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},gZ={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."},yZ={title:sZ,crumb:iZ,workspace:oZ,cursor:aZ,opencode:lZ,claudeCode:cZ,codex:uZ,env:dZ,allowlist:fZ,system:pZ,shortcuts:hZ,language:mZ,onboarding:gZ},wZ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},xZ={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)"},bZ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},kZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},vZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},SZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},jZ={aiLabels:wZ,placeholders:xZ,actions:bZ,labels:kZ,tooltips:vZ,rightPanel:SZ},NZ="Projects",CZ="All",_Z="Archived",EZ="Nodes",AZ="My Nodes",PZ="My Flows",IZ="Skills",RZ="Active Projects",TZ="Archived Pipelines",MZ="Global Nodes",$Z="All Nodes",LZ="My Nodes",OZ="Manage node versions published to the current workspace marketplace, {{count}} total.",DZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",FZ="Global Skills",zZ="Create New Project",BZ="New Pipeline",HZ="SEARCH PIPELINES...",WZ="SEARCH NODES...",VZ="SEARCH FLOW SNIPPETS...",KZ="SEARCH SKILLS...",qZ="Refresh Resources",UZ="Loading pipelines...",YZ="Loading global resources...",GZ="Filter result: {{count}} items (matching title, description, path and tags)",JZ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",XZ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",QZ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",ZZ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",eee="Executable building blocks for pipeline runtime",tee="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.",nee="Published local node packages",ree="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",see="Published flow snippets",iee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",oee="Operating guides for Composer and agents",aee="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",lee="No archived projects.",cee="No active pipelines; archived items are in the Archived tab.",uee="No global nodes available.",dee="No marketplace nodes have been published.",fee="No flow snippets have been published. Select multiple canvas nodes and publish them first.",pee="No skills available.",hee="No description.",mee='No node matches "{{query}}".',gee='No flow snippet matches "{{query}}".',yee='No skill matches "{{query}}".',wee="{{inputs}} in / {{outputs}} out",xee="Flow Snippet",bee="{{nodes}} nodes / {{edges}} edges",kee="Skill",vee="Node detail",See="Flow snippet detail",jee="Skill detail",Nee="Type",Cee="Source",_ee="Package",Eee="Version",Aee="Path",Pee="Editable",Iee="Read only",Ree="Editable",Tee="Schema",Mee="Inputs",$ee="Outputs",Lee="Runtime",Oee="Node Body",Dee="Files",Fee="Usage",zee="No runtime manifest.",Bee="No node body or README.",Hee="No previewable files.",Wee="Select a file to preview.",Vee="Binary file preview is not supported.",Kee="Large file; showing the first 256KB only.",qee="No pipelines using this node were found.",Uee="Node Management",Yee="Delete Node Version",Gee="Deleting...",Jee="AgentFlow checks all flow references before deleting; installed or used versions are kept.",Xee="Delete {{id}}@{{version}}? This cannot be undone.",Qee="Deleted {{id}}@{{version}}.",Zee="{{count}} flow(s) still use it.",ete="Flow Snippet Management",tte="Delete Flow Snippet",nte="Deleting...",rte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",ste="Delete {{id}}@{{version}}? This cannot be undone.",ite="Deleted {{id}}@{{version}}.",ote="No slots",ate="Purpose",lte="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",cte="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.",ute="Scale",dte="Flow Preview",fte="Edges",pte="Snippet JSON",hte="{{count}} more edge(s)",mte="No previewable nodes.",gte="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",yte="SKILL.md Preview",wte="No preview content available.",xte="Select a resource to inspect details.",bte="Failed to load pipeline list.",kte="No pipelines in current workspace.",vte="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.",Ste='No pipelines found matching "{{query}}". Try different keywords or clear the search.',jte="Recent Activity",Nte="No recent activity",Cte="No recent activity matching the keyword",_te="Recent Run",Ete="Recent Open",Ate={builtin:"Built-in",workspace:"Workspace",user:"User"},Pte={flow:"Flow",global:"Global",marketplace:"Marketplace"},Ite={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Rte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Tte="Open to edit this pipeline in the node canvas.",Mte={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>"},$te={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"},Lte={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"},Ote={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"},Dte={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"},Fte={title:NZ,all:CZ,archived:_Z,nodes:EZ,myNodes:AZ,myFlows:PZ,skills:IZ,activeProjects:RZ,archivedPipelines:TZ,globalNodes:MZ,nodeScopeAll:$Z,nodeScopeMine:LZ,myNodesHint:OZ,myFlowsHint:DZ,globalSkills:FZ,createNew:zZ,newPipeline:BZ,searchPipelines:HZ,searchNodes:WZ,searchFlows:VZ,searchSkills:KZ,refreshResources:qZ,loadingPipelines:UZ,loadingResources:YZ,filterResult:GZ,archivedHint:JZ,activeHint:XZ,nodesHint:QZ,skillsHint:ZZ,nodesPurposeTitle:eee,nodesPurposeDesc:tee,myNodesPurposeTitle:nee,myNodesPurposeDesc:ree,myFlowsPurposeTitle:see,myFlowsPurposeDesc:iee,skillsPurposeTitle:oee,skillsPurposeDesc:aee,noArchived:lee,noActive:cee,noNodes:uee,noMyNodes:dee,noMyFlows:fee,noSkills:pee,noDescription:hee,noNodeMatch:mee,noFlowSnippetMatch:gee,noSkillMatch:yee,nodeSlots:wee,flowSnippet:xee,flowSnippetNodes:bee,skill:kee,nodeDetail:vee,flowDetail:See,skillDetail:jee,detailType:Nee,detailSource:Cee,detailPackage:_ee,detailVersion:Eee,detailPath:Aee,detailEditable:Pee,readOnly:Iee,editable:Ree,nodeSchema:Tee,nodeInputs:Mee,nodeOutputs:$ee,nodeRuntime:Lee,nodeBody:Oee,nodeFiles:Dee,nodeUsage:Fee,noRuntimeManifest:zee,noNodeBody:Bee,noNodeFiles:Hee,selectNodeFile:Wee,binaryFile:Vee,fileTruncated:Kee,noNodeUsage:qee,myNodeManagement:Uee,deleteMyNode:Yee,deletingMyNode:Gee,deleteMyNodeHint:Jee,deleteMyNodeConfirm:Xee,deleteMyNodeSuccess:Qee,deleteMyNodeUsedBy:Zee,myFlowManagement:ete,deleteMyFlow:tte,deletingMyFlow:nte,deleteMyFlowHint:rte,deleteMyFlowConfirm:ste,deleteMyFlowSuccess:ite,noSlots:ote,resourceMeaning:ate,nodesMeaning:lte,myFlowsMeaning:cte,flowSnippetScale:ute,flowSnippetPreview:dte,flowSnippetEdges:fte,flowSnippetJson:pte,flowSnippetMoreEdges:hte,noFlowSnippetPreview:mte,skillsMeaning:gte,skillPreview:yte,skillPreviewEmpty:wte,selectResource:xte,loadFailed:bte,noPipelines:kte,emptyHint:vte,noMatch:Ste,recentActivity:jte,noRecentActivity:Nte,noMatchRecent:Cte,recentRun:_te,recentOpen:Ete,sourceBadge:Ate,resourceSource:Pte,resourceFilter:Ite,nodeDetailTabs:Rte,defaultCardDesc:Tte,hubCard:Mte,newPipelineModal:$te,importModal:Lte,deleteModal:Ote,archiveModal:Dte},zte="Back",Bte="Next",Hte="Skip",Wte="Done",Vte="Start Creating",Kte={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
289
-
290
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
291
-
292
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},qte={intro:`Now you're in the flow editor.
293
-
294
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
295
-
296
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
297
-
298
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
299
-
300
- The left node panel allows you to freely drag, delete, and adjust connections.`},Ute={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"},Yte={back:zte,next:Bte,skip:Hte,done:Wte,startCreate:Vte,projects:Kte,flow:qte,newPipeline:Ute},Gte={name:"AgentFlow",tagline:"AI 工作流编排"},Jte={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},Xte={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},Qte={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},Zte={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},ene={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},tne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},nne={app:Gte,nav:Jte,common:Xte,status:Qte,nodeTypes:Zte,engine:ene,links:tne},rne="流程编辑器",sne="节点",ine="连线",one="属性",ane={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:"编辑内容"},lne={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}}"},cne={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},une={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},dne={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},fne={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},pne={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},hne={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},mne={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},gne={node:"节点",text:"文本",file:"文件",bool:"布尔"},yne={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:"等待"},wne={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},xne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},bne={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},kne={mainNav:"主导航"},vne={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Sne={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}} 步):
301
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
302
- 当前:{{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}}"},jne={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},Nne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Cne={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}} 的分支"},_ne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Ene={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:"已复制"},Ane={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:"定时配置已保存"},Pne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Ine={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Rne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Tne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Mne={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},$ne={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Lne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},One={save:"保存",cancel:"取消"},Dne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},Fne={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},zne={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},Bne={title:rne,nodes:sne,edges:ine,properties:one,node:ane,nodeProps:lne,actions:cne,panel:une,palette:dne,pipeline:fne,status:pne,roles:hne,phases:mne,types:gne,runContext:yne,shortcuts:wne,jumpPalette:xne,emptyCanvas:bne,sidebar:kne,validation:vne,composer:Sne,topbar:jne,palette2:Nne,run:Cne,fileEdit:_ne,settings:Ene,schedule:Ane,history:Pne,nodePropsError:Ine,placeholder:Rne,time:Tne,userCheck:Mne,userAsk:$ne,toolPrint:Lne,provideEdit:One,runParams:Dne,runPreset:Fne,runConfig:zne},Hne="设置",Wne={engine:"引擎设置",preferences:"全局首选项"},Vne={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},Kne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},qne={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},Une={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},Yne={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},Gne={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},Jne={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:"添加"},Xne={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},Qne={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},Zne={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},ere={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},tre={title:Hne,crumb:Wne,workspace:Vne,cursor:Kne,opencode:qne,claudeCode:Une,codex:Yne,env:Gne,allowlist:Jne,system:Xne,shortcuts:Qne,language:Zne,onboarding:ere},nre={thinking:"思考",result:"结果",reply:"回复",error:"错误"},rre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},sre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},ire={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},ore={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},are={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},lre={aiLabels:nre,placeholders:rre,actions:sre,labels:ire,tooltips:ore,rightPanel:are},cre="项目",ure="全部",dre="已归档",fre="Nodes",pre="我的 Nodes",hre="我的流程",mre="Skills",gre="活跃项目",yre="已归档流水线",wre="全局 Nodes",xre="全部 Nodes",bre="我的 Nodes",kre="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",vre="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Sre="全局 Skills",jre="创建新项目",Nre="新建流水线",Cre="搜索流水线…",_re="搜索 nodes…",Ere="搜索流程片段…",Are="搜索 skills…",Pre="刷新资源",Ire="加载流水线列表…",Rre="加载全局资源…",Tre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Mre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",$re="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Lre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Ore="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",Dre="流程运行时的可执行积木",Fre="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",zre="已发布的本地节点包",Bre="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Hre="已发布的流程片段",Wre="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Vre="Composer/Agent 的操作指南",Kre="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",qre="暂无归档项目。",Ure="暂无未归档流水线;已归档项在 Archived 标签中查看。",Yre="暂无可用全局 nodes。",Gre="暂无已发布的 marketplace nodes。",Jre="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Xre="暂无可用 skills。",Qre="暂无描述。",Zre="未找到与「{{query}}」匹配的 node。",ese="未找到与「{{query}}」匹配的流程片段。",tse="未找到与「{{query}}」匹配的 skill。",nse="{{inputs}} in / {{outputs}} out",rse="流程片段",sse="{{nodes}} 节点 / {{edges}} 连线",ise="Skill",ose="Node 详情",ase="流程片段详情",lse="Skill 详情",cse="类型",use="来源",dse="包",fse="版本",pse="路径",hse="可编辑",mse="只读",gse="可编辑",yse="Schema",wse="输入",xse="输出",bse="Runtime",kse="节点内容",vse="Files",Sse="Usage",jse="暂无 runtime manifest。",Nse="暂无节点正文或 README。",Cse="暂无可预览文件。",_se="请选择文件查看内容。",Ese="二进制文件暂不支持预览。",Ase="文件较大,仅显示前 256KB。",Pse="暂未发现使用此 node 的流水线。",Ise="节点管理",Rse="删除节点版本",Tse="删除中…",Mse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",$se="确定删除 {{id}}@{{version}}?此操作不可撤销。",Lse="已删除 {{id}}@{{version}}。",Ose="仍有 {{count}} 个 Flow 使用它。",Dse="流程片段管理",Fse="删除流程片段",zse="删除中…",Bse="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Hse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Wse="已删除 {{id}}@{{version}}。",Vse="无槽位",Kse="作用",qse="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Use="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Yse="规模",Gse="流程预览",Jse="连线",Xse="片段 JSON",Qse="还有 {{count}} 条连线",Zse="暂无可预览节点。",eie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",tie="SKILL.md 预览",nie="暂无可预览内容。",rie="请选择一个资源查看详情。",sie="未能加载流水线列表。",iie="当前工作区暂无流水线。",oie="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",aie="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",lie="最近打开或最近运行",cie="暂无打开或运行记录",uie="暂无与关键词匹配的最近记录",die="最近运行",fie="最近打开",pie={builtin:"内置",workspace:"工作区",user:"用户"},hie={flow:"Flow",global:"Global",marketplace:"Marketplace"},mie={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},gie={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},yie="打开以在节点画布中编辑此流水线。",wie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},xie={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:"关闭"},bie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},kie={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},vie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Sie={title:cre,all:ure,archived:dre,nodes:fre,myNodes:pre,myFlows:hre,skills:mre,activeProjects:gre,archivedPipelines:yre,globalNodes:wre,nodeScopeAll:xre,nodeScopeMine:bre,myNodesHint:kre,myFlowsHint:vre,globalSkills:Sre,createNew:jre,newPipeline:Nre,searchPipelines:Cre,searchNodes:_re,searchFlows:Ere,searchSkills:Are,refreshResources:Pre,loadingPipelines:Ire,loadingResources:Rre,filterResult:Tre,archivedHint:Mre,activeHint:$re,nodesHint:Lre,skillsHint:Ore,nodesPurposeTitle:Dre,nodesPurposeDesc:Fre,myNodesPurposeTitle:zre,myNodesPurposeDesc:Bre,myFlowsPurposeTitle:Hre,myFlowsPurposeDesc:Wre,skillsPurposeTitle:Vre,skillsPurposeDesc:Kre,noArchived:qre,noActive:Ure,noNodes:Yre,noMyNodes:Gre,noMyFlows:Jre,noSkills:Xre,noDescription:Qre,noNodeMatch:Zre,noFlowSnippetMatch:ese,noSkillMatch:tse,nodeSlots:nse,flowSnippet:rse,flowSnippetNodes:sse,skill:ise,nodeDetail:ose,flowDetail:ase,skillDetail:lse,detailType:cse,detailSource:use,detailPackage:dse,detailVersion:fse,detailPath:pse,detailEditable:hse,readOnly:mse,editable:gse,nodeSchema:yse,nodeInputs:wse,nodeOutputs:xse,nodeRuntime:bse,nodeBody:kse,nodeFiles:vse,nodeUsage:Sse,noRuntimeManifest:jse,noNodeBody:Nse,noNodeFiles:Cse,selectNodeFile:_se,binaryFile:Ese,fileTruncated:Ase,noNodeUsage:Pse,myNodeManagement:Ise,deleteMyNode:Rse,deletingMyNode:Tse,deleteMyNodeHint:Mse,deleteMyNodeConfirm:$se,deleteMyNodeSuccess:Lse,deleteMyNodeUsedBy:Ose,myFlowManagement:Dse,deleteMyFlow:Fse,deletingMyFlow:zse,deleteMyFlowHint:Bse,deleteMyFlowConfirm:Hse,deleteMyFlowSuccess:Wse,noSlots:Vse,resourceMeaning:Kse,nodesMeaning:qse,myFlowsMeaning:Use,flowSnippetScale:Yse,flowSnippetPreview:Gse,flowSnippetEdges:Jse,flowSnippetJson:Xse,flowSnippetMoreEdges:Qse,noFlowSnippetPreview:Zse,skillsMeaning:eie,skillPreview:tie,skillPreviewEmpty:nie,selectResource:rie,loadFailed:sie,noPipelines:iie,emptyHint:oie,noMatch:aie,recentActivity:lie,noRecentActivity:cie,noMatchRecent:uie,recentRun:die,recentOpen:fie,sourceBadge:pie,resourceSource:hie,resourceFilter:mie,nodeDetailTabs:gie,defaultCardDesc:yie,hubCard:wie,newPipelineModal:xie,importModal:bie,deleteModal:kie,archiveModal:vie},jie="返回",Nie="下一步",Cie="跳过",_ie="完成",Eie="开始创建",Aie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
303
-
304
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
305
-
306
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Pie={intro:`现在进入流程编辑器。
307
-
308
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
309
-
310
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
311
-
312
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
313
-
314
- 左侧节点面板可以自由拖拽、删除和调整连接。`},Iie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Rie={back:jie,next:Nie,skip:Cie,done:_ie,startCreate:Eie,projects:Aie,flow:Pie,newPipeline:Iie},Tie={en:{common:wQ,flow:rZ,settings:yZ,composer:jZ,project:Fte,onboarding:Yte},zh:{common:nne,flow:Bne,settings:tre,composer:lre,project:Sie,onboarding:Rie}};kr.use(VM).use(YD).init({resources:Tie,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 Mie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function $ie(e){return kr.changeLanguage(e)}const Ib="agentflow-settings-opencode-plan-v1",rd="CURSOR_API_KEYS",sd="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Nw=new Set([rd,sd,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),KM=["cursor","opencode","claudeCode","codex"];function qM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function Rb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function _a(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of KM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(Rb).filter(Boolean))]:[];return n}function Gi(e){if(!e||typeof e!="object")return qM();const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],codex:Array.isArray(t.codex)?t.codex.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null,codexFetchedAt:t.codexFetchedAt??null}}function Nc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Lie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ra(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()||Nc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function E_(e){return Ra(e).map(({key:t,value:n})=>({key:t,value:n}))}function A_(){try{return localStorage.getItem(Ib)??""}catch{return""}}function UM(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Oie(e){const t=String(e||"").trim();if(!t)return[];const n=(r,s)=>{if(typeof r=="string"){const a=r.trim();return a?{id:`legacy_${s}_${a.slice(-6)}`,name:`Key ${s+1}`,key:a,createdAt:""}:null}if(!r||typeof r!="object")return null;const o=String(r.key??"").trim();return o?{id:String(r.id??"").trim()||Nc(),name:String(r.name??"").trim()||`Key ${s+1}`,key:o,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,s)=>n(r,s)).filter(Boolean)}function P_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||Nc(),name:String((n==null?void 0:n.name)||"").trim()||`Key ${r+1}`,key:String((n==null?void 0:n.key)||"").trim(),createdAt:String((n==null?void 0:n.createdAt)||"").trim()||new Date().toISOString()})).filter(n=>n.key):[];return JSON.stringify(t)}function Die(e){const t=String(e||"").trim();return t?t.length<=10?UM(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function Fie(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 zie({authUser:e}){const{t,i18n:n}=Vr(["common","settings"]),r=n.language||"zh",[s,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[d,f]=m.useState(qM()),[p,h]=m.useState(()=>_a({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,S]=m.useState(!1),[C,P]=m.useState(!1),[R,B]=m.useState(""),[A,O]=m.useState([]),[D,L]=m.useState(""),[M,V]=m.useState(!1),[z,F]=m.useState(""),[$,W]=m.useState(""),[E,Q]=m.useState(!1),[K,H]=m.useState(()=>new Set),[ee,ue]=m.useState(""),[G,te]=m.useState(""),[se,ie]=m.useState(!!(e!=null&&e.isAdmin)),[Z,ce]=m.useState(""),[de,pe]=m.useState([]),[Me,Ne]=m.useState([]),[Ce,We]=m.useState(""),[ct,yt]=m.useState(""),[Re,ot]=m.useState(!1),[kt,$t]=m.useState(!1),[ye,ze]=m.useState(""),[re,ke]=m.useState(""),[Be,Qe]=m.useState(""),[_e,_t]=m.useState(null),[Xt,Ft]=m.useState(!1),[at,Fn]=m.useState(!1),[ne,Pe]=m.useState(""),et=m.useRef(null),qe=m.useRef(!1),It=m.useRef(!1),vt=m.useRef(""),tr=m.useCallback(async()=>{l("");try{const oe=await fetch("/api/ui-context");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();o(typeof ve.workspaceRoot=="string"?ve.workspaceRoot:"")}catch(oe){l(String(oe.message||oe)),o("")}},[]),Yn=m.useCallback(async()=>{x(""),S(!0),g("");try{const oe=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();if(e!=null&&e.isAdmin)u(Gi(ve.modelLists)),f(Gi(ve.allModelLists)),h(_a(ve.hiddenModels));else{const Te=Gi(ve);u(Te),f(Te),h(_a({}))}}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin]),Tr=m.useCallback(async()=>{L("");try{const oe=await fetch("/api/user-env"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Te=Ra(Array.isArray(ve.env)?ve.env:[],"user").map(Qt=>({...Qt,scope:"user"})),Rt=[...e!=null&&e.isAdmin?Ra(Array.isArray(ve.globalEnv)?ve.globalEnv:[],"global").map(Qt=>({...Qt,scope:"global"})):[],...Te];vt.current=JSON.stringify(Rt),O(Rt)}catch(oe){O([]),L(String(oe.message||oe))}finally{It.current=!0}},[e==null?void 0:e.isAdmin]),kn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){ot(!0),ze("");try{const oe=await fetch("/api/admin/user-allowlist"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Te=ve.allowlist&&typeof ve.allowlist=="object"?ve.allowlist:{};pe(Array.isArray(Te.fileUsers)?Te.fileUsers.map(String):[]),Ne(Array.isArray(Te.envUsers)?Te.envUsers.map(String):[]),We(typeof Te.path=="string"?Te.path:"")}catch(oe){ze(String(oe.message||oe))}finally{ot(!1)}}},[e==null?void 0:e.isAdmin]),nr=m.useCallback(async oe=>{if(e!=null&&e.isAdmin){$t(!0),ze("");try{const ve=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Te=await ve.json().catch(()=>({}));if(!ve.ok)throw new Error(typeof Te.error=="string"?Te.error:"HTTP "+ve.status);const bt=Te.allowlist&&typeof Te.allowlist=="object"?Te.allowlist:{};pe(Array.isArray(bt.fileUsers)?bt.fileUsers.map(String):[]),Ne(Array.isArray(bt.envUsers)?bt.envUsers.map(String):[]),We(typeof bt.path=="string"?bt.path:"")}catch(ve){ze(String(ve.message||ve))}finally{$t(!1)}}},[e==null?void 0:e.isAdmin]),pr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Ft(!0),Pe("");try{const oe=await fetch("/api/admin/storage-config"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Te=ve.config&&typeof ve.config=="object"?ve.config:{};_t(Te),ke(typeof Te.dataRoot=="string"?Te.dataRoot:""),Qe(typeof Te.skillsRoot=="string"?Te.skillsRoot:"")}catch(oe){Pe(String(oe.message||oe))}finally{Ft(!1)}}},[e==null?void 0:e.isAdmin]),hr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Fn(!0),Pe("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:re.trim(),skillsRoot:Be.trim(),migrateLegacySkills:!0})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Te=ve.config&&typeof ve.config=="object"?ve.config:{};_t(Te),ke(typeof Te.dataRoot=="string"?Te.dataRoot:""),Qe(typeof Te.skillsRoot=="string"?Te.skillsRoot:"")}catch(oe){Pe(String(oe.message||oe))}finally{Fn(!1)}}},[e==null?void 0:e.isAdmin,re,Be]),fn=m.useCallback(async oe=>{const ve=Ra(oe),Te=ve.filter(Rt=>Rt.scope!=="global"),bt=ve.filter(Rt=>Rt.scope==="global");V(!0),L("");try{const Rt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:E_(Te),...e!=null&&e.isAdmin?{globalEnv:E_(bt)}:{}})}),Qt=await Rt.json().catch(()=>({}));if(!Rt.ok)throw new Error(typeof Qt.error=="string"?Qt.error:"HTTP "+Rt.status);const pn=Ra(Array.isArray(Qt.env)?Qt.env:[],"user").map(vs=>({...vs,scope:"user"})),ks=[...e!=null&&e.isAdmin?Ra(Array.isArray(Qt.globalEnv)?Qt.globalEnv:[],"global").map(vs=>({...vs,scope:"global"})):[],...pn];vt.current=JSON.stringify(ks),O(ks)}catch(Rt){L(String(Rt.message||Rt))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),zn=m.useCallback(async()=>{x(""),S(!0);try{const oe=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);u(Gi(ve.modelLists)),e!=null&&e.isAdmin?await Yn():f(Gi(ve.modelLists))}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin,Yn,Z]),ss=m.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const ve=_a(oe);h(ve),v(!0),g("");try{const Te=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:ve})}),bt=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(typeof bt.error=="string"?bt.error:"HTTP "+Te.status);u(Gi(bt.modelLists)),f(Gi(bt.allModelLists)),h(_a(bt.hiddenModels))}catch(Te){g(String(Te.message||Te)),Yn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,Yn]),Ds=m.useCallback((oe,ve,Te)=>{const bt=KM.includes(oe)?oe:"cursor",Rt=Rb(ve);if(!Rt)return;const Qt=_a(p),pn=new Set(Qt[bt]);Te?pn.delete(Rt):pn.add(Rt),ss({...Qt,[bt]:Array.from(pn)})},[p,ss]);m.useEffect(()=>{Tr(),e!=null&&e.isAdmin?(tr(),Yn(),kn(),pr(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const ve=await oe.json(),Te=typeof ve.opencodeProvider=="string"?ve.opencodeProvider:"";ce(Te),et.current=Te;try{localStorage.setItem(Ib,Te)}catch{}}else{const ve=A_();ce(ve),et.current=ve}}catch{const oe=A_();ce(oe),et.current=oe}finally{qe.current=!0}})()):(o(""),qe.current=!1)},[e==null?void 0:e.isAdmin,tr,Yn,pr,kn,Tr]),m.useEffect(()=>{if(!It.current||JSON.stringify(Ra(A))===vt.current)return;const ve=setTimeout(()=>{fn(A)},350);return()=>clearTimeout(ve)},[A,fn]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!qe.current)return;const oe=Z.trim();if(oe===et.current)return;const ve=setTimeout(()=>{(async()=>{P(!0),B("");try{const Te=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),bt=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(typeof bt.error=="string"?bt.error:"HTTP "+Te.status);et.current=oe;try{localStorage.setItem(Ib,oe)}catch{}bt.modelLists&&(u(Gi(bt.modelLists)),e!=null&&e.isAdmin?Yn():f(Gi(bt.modelLists)))}catch(Te){B(String(Te.message||Te))}finally{P(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,Yn,Z]);const vn=e!=null&&e.isAdmin?d:c,Gn=vn.cursor.length>0,bs=vn.opencode.length>0,Jn=vn.claudeCode.length>0,Bn=vn.codex.length>0,vr=_a(p),Sr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Hn=m.useCallback((oe,ve,Te)=>{const bt=Array.isArray(ve)?ve:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Te,children:bt.join(`
315
- `)});const Rt=new Set(vr[oe]||[]);return i.jsxs("div",{className:"af-set-model-visibility","aria-label":Te,children:[i.jsxs("div",{className:"af-set-model-visibility-head",children:[i.jsxs("span",{children:["展示 ",Sr[oe]||0," / ",bt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:bt.map(Qt=>{const pn=Rb(Qt),$n=!Rt.has(pn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:$n,disabled:y,onChange:ks=>Ds(oe,Qt,ks.target.checked)}),i.jsx("span",{children:Qt})]},`${oe}-${Qt}`)})})]})},[e==null?void 0:e.isAdmin,vr,y,Sr,Ds]),Mr=de.length>0||Me.length>0,$r=e!=null&&e.isAdmin?A:A.filter(oe=>!Nw.has(String((oe==null?void 0:oe.key)||"").trim())),le=e!=null&&e.isAdmin&&se?"global":"user",me=m.useMemo(()=>A.find(oe=>oe.key===rd&&(oe.scope||"user")===le)||null,[le,A]),tt=m.useMemo(()=>Oie((me==null?void 0:me.value)||""),[me==null?void 0:me.value]),rt=m.useMemo(()=>A.find(oe=>oe.key===sd&&(oe.scope||"user")===le)||null,[le,A]),zt=rt!=null&&rt.value?String(rt.value):"30",Rn=m.useCallback((oe,ve,Te)=>{const bt=String(oe||"").trim();if(!bt)return;const Rt=String(ve??"");O(Qt=>{const pn=Qt.find($n=>$n.key===bt&&($n.scope||"user")===Te);return Rt?pn?Qt.map($n=>$n.id===pn.id?{...$n,value:Rt,scope:Te}:$n):[{id:Nc(),key:bt,value:Rt,scope:Te},...Qt]:Qt.filter($n=>!($n.key===bt&&($n.scope||"user")===Te))})},[]),jr=m.useCallback(()=>{const oe=G.trim();if(!oe)return;const ve=[...tt,{id:Nc(),name:ee.trim()||`Key ${tt.length+1}`,key:oe,createdAt:new Date().toISOString()}];Rn(rd,P_(ve),le),ue(""),te("")},[ee,tt,le,G,Rn]),Nr=m.useCallback(oe=>{const ve=tt.filter(Te=>Te.id!==oe);Rn(rd,ve.length?P_(ve):"",le)},[tt,le,Rn]),mr=m.useCallback(oe=>{const ve=String(oe||"").replace(/[^\d]/g,"");if(!ve){Rn(sd,"",le);return}const Te=Math.min(1440,Math.max(1,Number(ve)||30));Rn(sd,String(Te),le)},[le,Rn]),ut=m.useCallback(()=>{var oe;s&&((oe=navigator.clipboard)==null||oe.writeText(s))},[s]),Ut=m.useCallback(()=>{const oe=z.trim(),ve=$;if(oe){if(!Lie(oe)){L(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Nw.has(oe)){L("该运行基础设施变量仅管理员可配置。");return}O(Te=>[{id:Nc(),key:oe,value:ve,scope:e!=null&&e.isAdmin&&E?"global":"user"},...Te]),F(""),W("")}},[e==null?void 0:e.isAdmin,E,z,$,t]),Yt=m.useCallback(oe=>{O(ve=>ve.filter(Te=>Te.id!==oe))},[]),Xn=m.useCallback((oe,ve)=>{const Te=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Te&&Nw.has(Te)){L("该运行基础设施变量仅管理员可配置。");return}O(bt=>bt.map(Rt=>Rt.id===oe?{...Rt,...ve}:Rt))},[e==null?void 0:e.isAdmin]),it=m.useCallback(oe=>{H(ve=>{const Te=new Set(ve);return Te.has(oe)?Te.delete(oe):Te.add(oe),Te})},[]),gr=m.useCallback(()=>{const oe=ct.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){ze("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Te=>String(Te||"").trim().toLowerCase())).has(oe.toLowerCase())){yt("");return}yt(""),nr([...de,oe])},[ct,de,nr]),Fs=m.useCallback(oe=>{const ve=String(oe||"").trim().toLowerCase();ve&&nr(de.filter(Te=>String(Te||"").trim().toLowerCase()!==ve))},[de,nr]),Bi=m.useCallback(oe=>{const ve=oe.target.value;$ie(ve)},[]),zs=oe=>{const ve=Fie(oe,r);return ve?t("settings:cursor.modelList.fetchedAt",{time:ve}):t("settings:cursor.modelList.never")};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:e!=null&&e.isAdmin?t("settings:workspace.description"):t("settings:env.note")}),e!=null&&e.isAdmin&&a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,e!=null&&e.isAdmin&&k?i.jsx("p",{className:"af-err af-settings-api-hint",children:k}):null,D?i.jsx("p",{className:"af-err af-settings-api-hint",children:D}):null,ne?i.jsx("p",{className:"af-err af-settings-api-hint",children:ne}):null]}),i.jsx("div",{className:"af-settings-layout",children:i.jsxs("div",{className:"af-settings-bento",children:[e!=null&&e.isAdmin?i.jsxs(i.Fragment,{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:ut,"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:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“知识库”里维护。"})]}),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"+(Gn?" af-set-badge--ok":" af-set-badge--muted"),children:t(Gn?"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:Gn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Gn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Gn?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${vn.cursor.length}`:"")+" · "+zs(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Gn?Hn("cursor",vn.cursor,t("settings:cursor.modelPreviewLabel")):null,b?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:j,children:t(j?"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-cursor-pool",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:"key"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),i.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),i.jsxs("span",{className:"af-set-badge"+(tt.length?" af-set-badge--ok":" af-set-badge--muted"),children:[tt.length," keys"]})]}),i.jsxs("div",{className:"af-set-cursor-pool-controls",children:[e!=null&&e.isAdmin?i.jsxs("div",{className:"af-set-env-scope-switch af-set-cursor-scope",role:"group","aria-label":"Cursor API Key scope",children:[i.jsx("button",{type:"button",className:se?"":"is-active",onClick:()=>ie(!1),children:"个人"}),i.jsx("button",{type:"button",className:se?"is-active":"",onClick:()=>ie(!0),children:"全局"})]}):null,i.jsxs("label",{className:"af-set-cursor-cooldown",children:[i.jsx("span",{children:"限额冷却"}),i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",inputMode:"numeric",value:zt,onChange:oe=>mr(oe.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":le==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:tt.length?tt.map(oe=>i.jsxs("div",{className:"af-set-cursor-key-row",children:[i.jsxs("div",{className:"af-set-cursor-key-main",children:[i.jsx("strong",{children:oe.name}),i.jsx("code",{children:Die(oe.key)})]}),i.jsx("span",{className:"af-set-cursor-key-meta",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"历史 Key"}),i.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${oe.name}`,onClick:()=>Nr(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe.id)):i.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),i.jsxs("div",{className:"af-set-cursor-key-add",children:[i.jsx("input",{className:"af-set-input",value:ee,onChange:oe=>ue(oe.target.value),placeholder:"名称,例如 Team Key 1"}),i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:oe=>te(oe.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:jr,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",rd,";冷却时间保存到 ",sd,"。个人配置会覆盖全局配置。"]})]}),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"+(bs?" af-set-badge--ok":" af-set-badge--err"),children:t(bs?"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:Z,onChange:oe=>ce(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),C?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,R?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:R}):null]}),bs?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})+(e!=null&&e.isAdmin?` / ${vn.opencode.length}`:"")+" · "+zs(c.opencodeFetchedAt)}),Hn("opencode",vn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:j,children:t(j?"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"+(Jn?" af-set-badge--ok":" af-set-badge--err"),children:t(Jn?"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:Jn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Jn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Jn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${vn.claudeCode.length}`:"")+" · "+zs(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),Jn?Hn("claudeCode",vn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:j,children:t(j?"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:codex.title")}),i.jsx("span",{className:"af-set-badge"+(Bn?" af-set-badge--ok":" af-set-badge--err"),children:t(Bn?"settings:codex.status.ready":"settings:codex.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:Bn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Bn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Bn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${vn.codex.length}`:"")+" · "+zs(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Bn?Hn("codex",vn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:j,children:t(j?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,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:M?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:z,onChange:oe=>F(oe.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:E?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:E?"is-active":"",onClick:()=>Q(!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:$,onChange:oe=>W(oe.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:Ut,disabled:!z.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),$r.map(oe=>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:oe.key,onChange:ve=>Xn(oe.id,{key:ve.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:oe.scope!=="global"?"is-active":"",onClick:()=>Xn(oe.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>Xn(oe.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:K.has(oe.id)?"text":"password",value:oe.value,onChange:ve=>Xn(oe.id,{value:ve.target.value}),placeholder:UM(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>it(oe.id),"aria-label":K.has(oe.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:K.has(oe.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:oe.key}),onClick:()=>Yt(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},oe.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"+(_e!=null&&_e.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:_e!=null&&_e.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void pr(),disabled:Xt||at,children:Xt?"刷新中...":"刷新"})]}),ne?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ne}):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:re,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(_e!=null&&_e.envLocked)||at}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Data Root",disabled:at||!!(_e!=null&&_e.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:at?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(_e==null?void 0:_e.dataRoot)||re||"-"}),_e!=null&&_e.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:_e.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 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",_e!=null&&_e.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:Be,onChange:oe=>Qe(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(_e!=null&&_e.skillsEnvLocked)||at}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Skills Root",disabled:at||!!(_e!=null&&_e.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:at?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(_e==null?void 0:_e.skillsRoot)||Be||"-"}),_e!=null&&_e.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:_e.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",_e!=null&&_e.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?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"+(Mr?" af-set-badge--ok":" af-set-badge--muted"),children:t(Mr?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void kn(),disabled:Re,children:t(Re?"settings:allowlist.refreshing":"common:common.refresh")})]}),ye?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ye}):null,Ce?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:Ce})]}):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:kt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(oe=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:oe}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>Fs(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:kt,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe)):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:ct,onChange:oe=>yt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&gr()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:gr,disabled:kt||!ct.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:Me.length>0?Me.map(oe=>i.jsx("code",{children:oe},oe)):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,i.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?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&&!k?"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.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.codexModels")}),i.jsx("span",{children:c.codex.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.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"})})]}):null,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:Bi,"aria-label":t("settings:language.description"),children:Mie.map(oe=>i.jsxs("option",{value:oe.code,children:[oe.flag," ",oe.name]},oe.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function Bie(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t))}function Hie(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function Wie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function Vie({run:e,onClose:t}){const[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),d=m.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const b=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${b.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(b){l(String((b==null?void 0:b.message)||b))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);m.useEffect(()=>{r(null),u("timeline"),d()},[d]),m.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||d({quiet:!0})},5e3);return()=>window.clearInterval(v)},[d,e==null?void 0:e.status]);const f=Array.isArray(n==null?void 0:n.events)?n.events:[],p=m.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?p:f;return i.jsx("div",{className:"af-admin-run-detail-overlay",role:"presentation",onMouseDown:t,children:i.jsxs("aside",{className:"af-admin-run-detail",role:"dialog","aria-modal":"true","aria-label":"Run 详情",onMouseDown:v=>v.stopPropagation(),children:[i.jsxs("header",{className:"af-admin-run-detail__head",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"af-admin-run-detail__eyebrow",children:[e.runType==="workspace"?"Workspace Run":"Pipeline Run"," · ",Wie(e.status)]}),i.jsx("h2",{children:e.flowId||"Run 详情"}),i.jsxs("p",{children:[e.username||e.userId," · ",i.jsx("code",{children:e.runId})]})]}),i.jsxs("div",{className:"af-admin-run-detail__actions",children:[i.jsx("button",{type:"button",onClick:()=>void d(),disabled:s,title:"刷新详情",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),i.jsx("button",{type:"button",onClick:t,title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),i.jsxs("div",{className:"af-admin-run-detail__tabs",role:"tablist","aria-label":"Run 详情分类",children:[i.jsxs("button",{type:"button",className:c==="timeline"?"is-active":"",onClick:()=>u("timeline"),children:["过程 ",i.jsx("span",{children:f.length})]}),i.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",i.jsx("span",{children:p.length})]}),i.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",i.jsx("span",{children:h.length})]})]}),n!=null&&n.truncated?i.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?i.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,s&&!n?i.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,i.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?h.length>0?i.jsx("pre",{className:"af-admin-run-detail__raw",children:h.join(`
316
- `)}):i.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?i.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,b)=>i.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[i.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[i.jsx("time",{children:Bie(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:Hie(v.kind)}),i.jsx("span",{children:v.type||"event"}),v.nodeId?i.jsx("code",{children:v.nodeId}):null]}),i.jsx("pre",{children:v.text||"-"})]},v.id||`${v.ts||0}-${b}`))}):i.jsx("div",{className:"af-admin-run-detail__empty",children:c==="thinking"?"该模型或 CLI 没有为这个 Run 输出可记录的 Thinking。":"这个 Run 暂无过程事件。"})})]})})}function Dr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Jp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Cw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function Kie(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function _w(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 qie(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Uie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function Yie({authUser:e}){const{navigate:t}=xs(),[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=m.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const A=await fetch("/api/admin/usage-dashboard"),O=await A.json().catch(()=>({}));if(!A.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+A.status);r(O)}catch(A){r(null),l(String((A==null?void 0:A.message)||A))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=m.useCallback(async A=>{const O=String((A==null?void 0:A.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!O)){f({userId:O,username:String((A==null?void 0:A.username)||O)}),h([]),g(""),v(!0);try{const D=new URLSearchParams({userId:O}),L=await fetch(`/api/admin/user-workspaces?${D.toString()}`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(M.error||"读取用户 Workspace 失败");f(M.owner||{userId:O,username:String((A==null?void 0:A.username)||O)}),h(Array.isArray(M.workspaces)?M.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),j=m.useCallback(A=>{const O=String((A==null?void 0:A.ownerUserId)||(d==null?void 0:d.userId)||"").trim(),D=String((A==null?void 0:A.id)||"").trim();if(!O||!D)return;const L=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:O});A!=null&&A.archived&&L.set("archived","1"),t(`/workspace?${L.toString()}`)},[t,d==null?void 0:d.userId]);m.useEffect(()=>{k()},[k]);const S=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],C=m.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},L=980-D.left-D.right,M=250-D.top-D.bottom,V=S.length>0?S:[],z=Math.max(1,...V.map(K=>Number(K.runs||0))),F=Math.max(1,...V.flatMap(K=>[Number(K.users||0),Number(K.pipelines||0)])),$=K=>D.left+(V.length<=1?L/2:K*L/(V.length-1)),W=K=>D.top+M-Math.max(0,Number(K||0))/z*M,E=K=>D.top+M-Math.max(0,Number(K||0))/F*M,Q=K=>V.map((H,ee)=>`${ee===0?"M":"L"} ${$(ee)} ${E(H[K])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:M,rows:V,x:$,yRuns:W,yLine:E,lineUsers:Q("users"),linePipelines:Q("pipelines"),barWidth:Math.min(34,Math.max(12,L/Math.max(1,V.length)*.44))}},[S]),P=(n==null?void 0:n.usage)||{},R=(n==null?void 0:n.totals)||{},B=Array.isArray(n==null?void 0:n.recentRuns)?n.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 k(),disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),s?"刷新中":"刷新"]})]}),a?i.jsx("div",{className:"af-project-admin-usage__error",children:a}):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:Jp(P.activeUserRate)}),i.jsxs("em",{children:[Dr(P.activeUsers)," / ",Dr(R.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:Jp(P.activePipelineRate)}),i.jsxs("em",{children:[Dr(P.activePipelines)," / ",Dr(R.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Dr(P.runs)}),i.jsxs("em",{children:[Dr(P.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:Jp(P.successRate)}),i.jsxs("em",{children:["失败率 ",Jp(P.failureRate)," · avg ",Cw(P.avgDurationMs)]})]})]}),i.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"每日趋势"}),i.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),i.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[i.jsxs("div",{className:"af-admin-usage-chart__legend",children:[i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),i.jsx("div",{className:"af-admin-usage-chart__canvas",children:i.jsxs("svg",{viewBox:`0 0 ${C.width} ${C.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:C.margin.left,y1:C.margin.top+C.innerHeight,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight}),[.25,.5,.75,1].map(A=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:C.margin.left,y1:C.margin.top+C.innerHeight-C.innerHeight*A,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight-C.innerHeight*A},A)),C.rows.map((A,O)=>{const D=C.x(O),L=C.yRuns(A.runs),M=C.margin.top+C.innerHeight,V=Math.max(2,M-L);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-C.barWidth/2,y:M-V,width:C.barWidth,height:V,rx:"5",children:i.jsx("title",{children:`${A.date}: ${A.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:M+22,children:Dr(A.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:M+42,children:Kie(A.date)})]},A.date)}),C.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:C.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:C.linePipelines}),C.rows.map((A,O)=>{const D=C.x(O);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:C.yLine(A.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:C.yLine(A.pipelines),r:"3.5"})]},`${A.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:B.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):B.map(A=>i.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(A),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),u(A))},children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId||"-"}),i.jsx("span",{children:A.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:A.flowId||"-"}),i.jsxs("span",{children:[A.runType==="workspace"?"Workspace Run":"Pipeline"," · ",A.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:_w(A.at)}),A.endedAt?i.jsxs("span",{children:["结束 ",_w(A.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:Uie(A.status)})})}),i.jsx("td",{children:Cw(A.durationMs)}),i.jsx("td",{children:i.jsxs("span",{className:"af-admin-usage-run-link",children:[i.jsx("code",{className:"af-admin-usage-run-id",title:A.runId,children:qie(A.runId)}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${A.userId}:${A.flowSource}:${A.flowId}:${A.runId}:${A.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("th",{children:"Workspace"})]})}),i.jsx("tbody",{children:s&&!n?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"正在加载..."})}):((n==null?void 0:n.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无用户数据"})}):((n==null?void 0:n.users)||[]).map(A=>{var O,D,L,M,V,z,F,$,W,E,Q,K,H;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId}),i.jsxs("span",{children:[A.userId,A.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Dr((O=A.pipelines)==null?void 0:O.total)}),i.jsxs("span",{children:[Dr((D=A.pipelines)==null?void 0:D.active)," active / ",Dr((L=A.pipelines)==null?void 0:L.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Dr((M=A.runs)==null?void 0:M.total)}),i.jsxs("span",{children:["avg ",Cw((V=A.runs)==null?void 0:V.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Dr((z=A.runs)==null?void 0:z.success)]}),i.jsxs("em",{children:["失败 ",Dr((F=A.runs)==null?void 0:F.failed)]}),i.jsxs("em",{children:["运行中 ",Dr(($=A.runs)==null?void 0:$.running)]})]})}),i.jsx("td",{children:(W=A.runs)!=null&&W.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((E=A.runs)==null?void 0:E.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((Q=A.runs)==null?void 0:Q.lastRunStatus)||"unknown"," · ",_w(A.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})}),i.jsx("td",{children:i.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((K=A.pipelines)!=null&&K.total)||y&&(d==null?void 0:d.userId)===A.userId,onClick:()=>void x(A),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(d==null?void 0:d.userId)===A.userId?"读取中":`查看 ${Dr((H=A.pipelines)==null?void 0:H.total)}`]})})]},A.userId)})})]})})]}),d?i.jsxs("section",{className:"af-project-admin-usage af-admin-user-workspaces",children:[i.jsxs("div",{className:"af-project-admin-usage__head",children:[i.jsxs("div",{children:[i.jsxs("strong",{children:[d.username||d.userId," 的 Workspace"]}),i.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),i.jsx("button",{type:"button",onClick:()=>{f(null),h([]),g("")},children:"关闭"})]}),b?i.jsx("div",{className:"af-project-admin-usage__error",children:b}):null,i.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?i.jsx("p",{children:"正在读取 Workspace..."}):p.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):p.map(A=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>j(A),children:[i.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:A.archived?"inventory_2":"account_tree"}),i.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[i.jsx("strong",{children:A.id}),i.jsx("small",{children:A.description||(A.archived?"已归档 Workspace":"用户 Workspace")})]}),i.jsx("span",{className:"af-admin-user-workspace-card__status",children:A.archived?"已归档":"只读打开"})]},`${A.id}:${A.archived?"archived":"active"}`))})]}):null,c?i.jsx(Vie,{run:c,onClose:()=>u(null)}):null]}):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 Gie({authUser:e}){const[t,n]=m.useState([]),[r,s]=m.useState([]),[o,a]=m.useState(""),[l,c]=m.useState({name:"",description:"",status:"active",members:[]}),[u,d]=m.useState(""),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState(""),g=m.useCallback(async()=>{b("");try{const S=await fetch("/api/admin/teams"),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||"读取团队失败");const P=Array.isArray(C.teams)?C.teams:[];n(P),s(Array.isArray(C.users)?C.users:[]),a(R=>{var B;return R&&P.some(A=>A.id===R)?R:((B=P[0])==null?void 0:B.id)||""})}catch(S){b(String(S.message||S))}},[]);m.useEffect(()=>{g()},[g]);const k=m.useMemo(()=>t.find(S=>S.id===o)||null,[o,t]);m.useEffect(()=>{if(!k){c({name:"",description:"",status:"active",members:[]});return}c({name:k.name||"",description:k.description||"",status:k.status||"active",members:(k.members||[]).map(S=>S.userId||S)})},[k]);const x=async(S,C)=>{y(!0),b("");try{const P=await fetch("/api/admin/teams",{method:S,headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"更新团队失败");return await g(),R}catch(P){return b(String(P.message||P)),null}finally{y(!1)}};if(!(e!=null&&e.isAdmin))return i.jsx("main",{className:"af-team-admin-page",children:i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:"仅超级管理员可以管理团队。"})});const j=r.filter(S=>{const C=f.trim().toLowerCase();return!C||`${S.username} ${S.userId}`.toLowerCase().includes(C)});return i.jsxs("main",{className:"af-team-admin-page",children:[i.jsxs("header",{className:"af-team-admin-hero",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Admin / Organization"}),i.jsx("h1",{children:"团队管理"}),i.jsx("p",{children:"划分团队成员,并为团队迭代汇总与 Project 分享提供权限边界。"})]}),i.jsxs("button",{type:"button",onClick:()=>void g(),disabled:h,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),v?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,i.jsxs("div",{className:"af-team-admin-layout",children:[i.jsxs("aside",{className:"af-team-admin-list",children:[i.jsxs("form",{onSubmit:S=>{S.preventDefault(),u.trim()&&x("POST",{name:u.trim()}).then(C=>{var P;(P=C==null?void 0:C.team)!=null&&P.id&&a(C.team.id),C&&d("")})},children:[i.jsx("input",{value:u,onChange:S=>d(S.target.value),placeholder:"新团队名称"}),i.jsx("button",{type:"submit",disabled:h||!u.trim(),children:i.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),t.map(S=>i.jsxs("button",{type:"button",className:S.id===o?"is-active":"",onClick:()=>a(S.id),children:[i.jsxs("span",{children:[i.jsx("strong",{children:S.name}),i.jsxs("small",{children:[S.memberCount||0," 位成员"]})]}),S.status==="inactive"?i.jsx("em",{children:"已停用"}):null]},S.id)),t.length?null:i.jsx("p",{children:"还没有团队。"})]}),i.jsx("section",{className:"af-team-admin-detail",children:k?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-team-admin-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"团队名称"}),i.jsx("input",{value:l.name,onChange:S=>c(C=>({...C,name:S.target.value}))})]}),i.jsxs("label",{children:[i.jsx("span",{children:"状态"}),i.jsxs("select",{value:l.status,onChange:S=>c(C=>({...C,status:S.target.value})),children:[i.jsx("option",{value:"active",children:"启用"}),i.jsx("option",{value:"inactive",children:"停用"})]})]}),i.jsxs("label",{className:"is-wide",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:l.description,onChange:S=>c(C=>({...C,description:S.target.value})),placeholder:"团队职责或范围"})]})]}),i.jsxs("div",{className:"af-team-admin-members-head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"团队成员"}),i.jsx("span",{children:"一个用户只能属于一个团队,保存后会自动从原团队移出。"})]}),i.jsx("input",{type:"search",value:f,onChange:S=>p(S.target.value),placeholder:"搜索用户"})]}),i.jsx("div",{className:"af-team-admin-members",children:j.map(S=>{var P;const C=l.members.includes(S.userId);return i.jsxs("label",{className:C?"is-selected":"",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>c(B=>({...B,members:R.target.checked?[...B.members,S.userId]:B.members.filter(A=>A!==S.userId)}))}),i.jsx("span",{className:"material-symbols-outlined",children:"person"}),i.jsxs("span",{children:[i.jsx("strong",{children:S.username}),i.jsxs("small",{children:[S.userId,S.isAdmin?" · Admin":""]})]}),S.teamId&&S.teamId!==k.id?i.jsx("em",{children:((P=t.find(R=>R.id===S.teamId))==null?void 0:P.name)||"其他团队"}):null]},S.userId)})}),i.jsxs("footer",{className:"af-team-admin-actions",children:[i.jsx("button",{type:"button",className:"is-danger",disabled:h||l.members.length>0,onClick:()=>{window.confirm(`删除团队「${k.name}」?`)&&x("DELETE",{teamId:k.id})},children:"删除团队"}),i.jsxs("div",{children:[i.jsx("button",{type:"button",disabled:h,onClick:()=>c({name:k.name,description:k.description||"",status:k.status,members:(k.members||[]).map(S=>S.userId||S)}),children:"重置"}),i.jsx("button",{type:"button",className:"is-primary",disabled:h||!l.name.trim(),onClick:async()=>{await x("PATCH",{teamId:k.id,name:l.name,description:l.description,status:l.status})&&await x("PUT",{teamId:k.id,members:l.members})},children:h?"保存中...":"保存团队"})]})]})]}):i.jsx("div",{className:"af-workflows-message",children:"创建或选择一个团队。"})})]})]})}function Jie(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);try{return new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}).format(new Date(t))}catch{return String(e)}}function Xie({authUser:e}){const{navigate:t}=xs(),[n,r]=m.useState(""),[s,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(k){v(!0),g("");try{const S=await fetch("/api/feedback"),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||"加载失败");h(Array.isArray(C.feedback)?C.feedback:[])}catch(S){g(String(S.message||S)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const j=async S=>{if(S.preventDefault(),!a){l(!0),u("");try{const C=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"提交失败");f(!0),r(""),o("")}catch(C){u(String(C.message||C))}finally{l(!1)}}};return k?i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",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("div",{className:"af-feedback-admin-actions",children:[i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:y,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":"refresh"}),y?"刷新中...":"刷新"]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?i.jsx("p",{className:"af-err af-feedback-error",children:b}):null,i.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:p.length>0?p.map(S=>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:S.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:S.username||S.userId||"unknown"}),i.jsx("span",{children:Jie(S.createdAt)})]})]}),S.contact?i.jsx("span",{className:"af-feedback-item__contact",children:S.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:S.content}),S.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:S.pageUrl}):null]},S.id)):i.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):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:()=>t("/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:j,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:n,onChange:S=>r(S.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"反馈内容"}),i.jsx("textarea",{value:s,onChange:S=>o(S.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?i.jsx("p",{className:"af-err af-feedback-error",children:c}):null,i.jsx("div",{className:"af-feedback-actions",children:i.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!s.trim(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function YM(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function I_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:YM(),key:r,value:String(s??""),private:n.has(r)}))}function R_(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 Nh(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(`
317
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:I_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:I_(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 Ew(){return Nh({name:"",raw:{command:""}})}function Qie(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=R_(e.envRows),s=R_(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 T_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function M_(e){return e?e.ok?"ok":"error":"unknown"}function Tb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function Zie(e,t){return e&&e.label||t}async function Aw(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)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.top="-9999px",r.style.left="-9999px",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return r.remove(),s}catch{return!1}}function Rv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function GM({baseUrl:e="",token:t=""}){return JSON.stringify({mcpServers:{agentflow:{command:"agentflow",args:["mcp"],env:{AGENTFLOW_BASE_URL:String(e||"http://127.0.0.1:8875"),AGENTFLOW_TOKEN:Rv(t)}}}},null,2)}function JM({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(Rv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
318
- `)}function eoe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=GM({baseUrl:n,token:t}),s=JM({baseUrl:n,token:t});return["你是一个 AI Coding Agent。请帮我把 AgentFlow 配置成当前开发环境可用的 MCP server。","","这是一项配置任务,不是调用任务:请修改 Cursor 或 Codex 的 MCP 配置文件,让它们能连接本机 AgentFlow。","","AgentFlow MCP server 信息:","- server name: agentflow","- command: agentflow",'- args: ["mcp"]',`- env.AGENTFLOW_BASE_URL: ${n}`,`- env.AGENTFLOW_TOKEN: ${Rv(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",s,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
319
- `)}function toe({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return i.jsx("div",{className:"af-mcp-backends",children:n.map(([r,s])=>i.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${Tb(s==null?void 0:s.status)}`,children:[i.jsxs("div",{className:"af-mcp-backend-head",children:[i.jsx("strong",{children:r}),i.jsx("span",{children:Zie(s,"Unknown")})]}),Array.isArray(s==null?void 0:s.reasons)&&s.reasons.length?i.jsx("ul",{children:s.reasons.map(o=>i.jsx("li",{children:o},o))}):i.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function $_({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const o=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));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:YM(),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 noe(){var ue;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(Ew),[a,l]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,S]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[C,P]=m.useState(""),[R,B]=m.useState(""),A=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),O=A&&y[A.name]||null,D=m.useMemo(()=>GM({baseUrl:j,token:C}),[j,C]),L=m.useMemo(()=>JM({baseUrl:j,token:C}),[j,C]),M=m.useMemo(()=>eoe({baseUrl:j,token:C}),[j,C]),V=m.useCallback(async()=>{u(!0),g("");try{const G=await fetch("/api/mcps"),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(te.error||"MCP HTTP "+G.status);const se=Array.isArray(te.servers)?te.servers:[];t(String(te.path||"")),r(se),a&&se.some(ie=>ie.name===a)&&o(Nh(se.find(ie=>ie.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{V()},[V]);const z=()=>{l(""),o(Ew()),x(""),g("")},F=G=>{l(G.name),o(Nh(G)),x(""),g("")},$=m.useCallback(async()=>{if(!M)return;const G=await Aw(M);B(G?"prompt":"copy-failed"),window.setTimeout(()=>B(""),1200)},[M]),W=m.useCallback(async()=>{const G=await Aw(D);B(G?"cursor":"copy-failed"),window.setTimeout(()=>B(""),1200)},[D]),E=m.useCallback(async()=>{const G=await Aw(L);B(G?"codex":"copy-failed"),window.setTimeout(()=>B(""),1200)},[L]),Q=m.useCallback(async()=>{try{const G=await fetch("/api/auth/session-token"),te=await G.json().catch(()=>({}));if(!G.ok)throw new Error(typeof te.error=="string"?te.error:"HTTP "+G.status);P(String(te.token||"")),B("token"),window.setTimeout(()=>B(""),1200)}catch(G){B(""),g(String(G.message||G))}},[]),K=async(G="")=>{h(!0),g(""),x("");try{const te=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G?{name:G}:{})}),se=await te.json().catch(()=>({}));if(!te.ok)throw new Error(se.error||"检测 MCP 失败");const ie=Array.isArray(se.results)?se.results:[];v(Z=>{const ce={...Z};for(const de of ie)de!=null&&de.name&&(ce[de.name]=de);return ce}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(te){g(String(te.message||te))}finally{h(!1)}},H=async()=>{f(!0),g(""),x("");try{const G=Qie(s);if(!G.nextName)throw new Error("请填写 MCP 名称");const te=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),se=await te.json().catch(()=>({}));if(!te.ok)throw new Error(se.error||"保存 MCP 失败");const ie=Array.isArray(se.servers)?se.servers:[];r(ie),t(String(se.path||e)),l(G.nextName),o(Nh(ie.find(Z=>Z.name===G.nextName)||null)),v(Z=>{const ce={...Z};return s.originalName&&s.originalName!==G.nextName&&delete ce[s.originalName],delete ce[G.nextName],ce}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{f(!1)}},ee=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){f(!0),g(""),x("");try{const te=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),se=await te.json().catch(()=>({}));if(!te.ok)throw new Error(se.error||"删除 MCP 失败");r(Array.isArray(se.servers)?se.servers:[]),l(""),o(Ew()),v(ie=>{const Z={...ie};return delete Z[G.name],Z}),x("已删除。")}catch(te){g(String(te.message||te))}finally{f(!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:V,disabled:c||d,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(),disabled:p||c||d||n.length===0,children:p?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:d,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.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",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:"lan"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),i.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),i.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),i.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),i.jsxs("div",{className:"af-set-mcp-connect-grid",children:[i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Base URL"}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:j,onChange:G=>S(G.target.value),placeholder:"http://127.0.0.1:8875"})]}),i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Token"}),i.jsxs("div",{className:"af-set-mcp-token-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:C,onChange:G=>P(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:R==="token"?"已填入":"使用当前登录 Token"})]})]})]}),i.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Cursor mcp.json"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:W,children:R==="cursor"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:D})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Codex config.toml"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:E,children:R==="codex"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:L})]})]}),i.jsx("div",{className:"af-set-mcp-copy-row",children:i.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:$,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),R==="prompt"?"已复制 Prompt":R==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),R==="copy-failed"?i.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),i.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:M})]}),i.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[i.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),i.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 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:z,disabled:d,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:z,disabled:d,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var te,se,ie,Z;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>F(G),children:[i.jsx("span",{className:"material-symbols-outlined",children:G.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:G.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${M_(y[G.name])}`,children:T_(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Tb((se=(te=G.backends)==null?void 0:te.cursor)==null?void 0:se.status)}`,children:"Cursor"}),i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Tb((Z=(ie=G.backends)==null?void 0:ie.codex)==null?void 0:Z.status)}`,children:"Codex"})]}),i.jsx("em",{children:G.url||[G.command,...G.args||[]].filter(Boolean).join(" ")})]})]},G.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:A?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),A?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(A.name),disabled:p||d,children:p?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>ee(A),disabled:d,children:"删除"})]}):null]}),b?i.jsx("p",{className:"af-mcp-error",children:b}):null,k?i.jsx("p",{className:"af-mcp-status",children:k}):null,A?i.jsx(toe,{server:A}):null,O?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${M_(O)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:T_(O)}),i.jsxs("span",{children:[O.elapsedMs||0,"ms"]})]}),O.error?i.jsx("p",{children:O.error}):null,(ue=O.tools)!=null&&ue.length?i.jsx("div",{className:"af-mcp-tools-list",children:O.tools.map(G=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:G.name}),G.description?i.jsx("span",{children:G.description}):null]},G.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:G=>o(te=>({...te,name:G.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:G=>o(te=>({...te,type:G.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:G=>o(te=>({...te,url:G.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:G=>o(te=>({...te,command:G.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:G=>o(te=>({...te,argsText:G.target.value})),placeholder:`mcp-server-example
320
- --flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:G=>o(te=>({...te,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx($_,{title:"Headers",rows:s.headerRows,onChange:G=>o(te=>({...te,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx($_,{title:"Env",rows:s.envRows,onChange:G=>o(te=>({...te,envRows:G})),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:G=>o(te=>({...te,extraJson:G.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:z,disabled:d,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:H,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function roe(e={}){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=new URLSearchParams({flowId:t,flowSource:String((e==null?void 0:e.flowSource)||"user").trim()||"user"}),r=String((e==null?void 0:e.workspaceId)||"").trim();if(r&&n.set("workspaceId",r),(e==null?void 0:e.kind)==="workspace"){const s=String((e==null?void 0:e.scheduleNodeId)||"").trim();s&&n.set("focusNodeId",s)}return`/workspace?${n.toString()}`}function L_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function O_(e){if(!e)return"-";const t=typeof e=="number"?e:Date.parse(String(e));return Number.isFinite(t)?new Date(t).toLocaleString():String(e)}function soe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function ioe(e){if(e!=null&&e.running)return"运行中";if(!(e!=null&&e.enabled))return"已停用";const t=String((e==null?void 0:e.lastStatus)||"").trim();return!t||t==="armed"||t==="enabled"?"已启用":t==="success"?"上次成功":t==="failed"?"上次失败":t==="invalid"?"配置异常":t.startsWith("skipped")?"已跳过":t}function ooe(){const{navigate:e}=xs(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{s(!0),a("");try{const p=await fetch("/api/schedules"),h=await p.json().catch(()=>({}));if(!p.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(p){a(String(p.message||p)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`;c(h),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:p.kind,flowId:p.flowId,flowSource:p.flowSource||"user",scheduleNodeId:p.scheduleNodeId||"",enabled:!p.enabled})}),v=await y.json().catch(()=>({}));if(!y.ok||v.success===!1)throw new Error(v.error||"更新定时任务失败");await u()}catch(y){a(String(y.message||y))}finally{c("")}},[u]),f=m.useMemo(()=>{const p=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:p,workspace:h,pipeline:t.length-h}},[t]);return i.jsxs("div",{className:"af-settings-page af-schedules-page",children:[i.jsxs("div",{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:"定时任务"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),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:"定时任务"}),i.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),i.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部"}),i.jsx("strong",{children:f.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"启用中"}),i.jsx("strong",{children:f.enabled})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("strong",{children:f.workspace})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Pipeline"}),i.jsx("strong",{children:f.pipeline})]})]}),o?i.jsx("div",{className:"af-schedules-error",children:o}):null,r?i.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?i.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,i.jsx("div",{className:"af-schedules-list",children:t.map(p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`,y=l===h,v=roe(p);return i.jsxs("article",{className:"af-schedule-card",children:[i.jsxs("div",{className:"af-schedule-card__main",children:[i.jsxs("div",{className:"af-schedule-card__title-row",children:[i.jsx("strong",{children:p.label||p.flowId||"-"}),i.jsx("span",{className:`af-schedule-badge af-schedule-badge--${p.kind||"pipeline"}`,children:soe(p)}),i.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:ioe(p)})]}),i.jsxs("div",{className:"af-schedule-card__meta",children:[i.jsx("span",{children:p.flowId||"-"}),i.jsx("span",{children:p.flowSource||"user"}),p.scheduleNodeId?i.jsx("span",{children:p.scheduleNodeId}):null]}),i.jsxs("div",{className:"af-schedule-card__grid",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Cron"}),i.jsx("strong",{children:p.cron||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"时区"}),i.jsx("strong",{children:p.timezone||"Asia/Shanghai"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"下次执行"}),i.jsx("strong",{children:O_(p.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:O_(p.lastTriggeredAt)})]})]}),p.lastError?i.jsx("p",{className:"af-schedule-card__error",children:p.lastError}):null]}),i.jsxs("div",{className:"af-schedule-card__actions",children:[v?i.jsxs("button",{type:"button",className:"af-schedule-open",title:L_(p),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),L_(p)]}):null,i.jsxs("button",{type:"button",className:p.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":p.enabled,title:p.enabled?"点击停用":"点击启用",onClick:()=>void d(p),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":p.enabled?"toggle_on":"toggle_off"}),p.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const D_={id:"",title:"Untitled Node",definitionId:"",agentMessages:[],promptDraft:"",manifest:{id:"",version:"1.0.0",name:"",runtime:{type:"agent_subAgent"},inputs:[],outputs:[],configSchema:{fields:[]},ui:{card:{icon:"extension",variant:"default",actions:[]}}},config:{},files:{},test:{inputs:{},log:[],status:"not run"}};function F_(e){const t=(e==null?void 0:e.manifest)||{};return(e==null?void 0:e.definitionId)||`marketplace:${t.id||(e==null?void 0:e.id)||"node"}@${t.version||"1.0.0"}`}function aoe(e){var c,u,d,f,p,h,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((d=(u=t.ui)==null?void 0:u.card)==null?void 0:d.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(j=>[`input.${j.name||"-"}`,`${j.type||"text"}${j.required?" · required":""}${j.default?` · default: ${j.default}`:""}`]),...s.map(j=>[`output.${j.name||"-"}`,j.type||"text"]),...o.map(j=>[`config.${j.key||"-"}`,j.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((p=t.runtime)==null?void 0:p.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(j=>[`action.${j.id||j.label||"-"}`,j.variant||j.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([j,S])=>[`sample.${j}`,String(S)]),["last run",`${((k=e==null?void 0:e.test)==null?void 0:k.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function loe(){var L,M,V,z,F,$,W;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState(""),y=e||D_,v=m.useMemo(()=>aoe(y),[y]),b=m.useMemo(()=>v.find(E=>E.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((L=y==null?void 0:y.test)==null?void 0:L.inputs)||{},j=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],S=((z=(V=g.ui)==null?void 0:V.card)==null?void 0:z.icon)||"event_repeat",C=(($=(F=g.ui)==null?void 0:F.card)==null?void 0:$.variant)||"default",P=k.enabled===!0,R=m.useCallback(async()=>{var E;l(!0),u("");try{const Q=await fetch("/api/node-studio/drafts"),K=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(K.error||"读取节点草稿失败");const H=Array.isArray(K.drafts)?K.drafts[0]:null;if(!(H!=null&&H.id)){t(null),h("");return}const ee=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(H.id)}`),ue=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(ue.error||"读取节点草稿失败");t(ue.draft||null),h(String(((E=ue.draft)==null?void 0:E.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{R()},[R]);const B=m.useCallback(async(E={})=>{var Q;f(!0),u("");try{const K=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",...E})}),H=await K.json().catch(()=>({}));if(!K.ok||H.ok===!1)throw new Error(H.error||"保存节点草稿失败");t(H.draft||e),h(String(((Q=H.draft||e)==null?void 0:Q.promptDraft)||""))}catch(K){u(String(K.message||K))}finally{f(!1)}},[e]),A=()=>{o(!0),window.setTimeout(()=>o(!1),900)},O=E=>{const Q={...k,enabled:E};t(K=>({...K||D_,config:Q})),B({config:{enabled:E}})},D=()=>{B({promptDraft:p,appendUserMessage:!0})};return i.jsxs("div",{className:"af-node-studio-page",children:[i.jsxs("header",{className:"af-node-studio-top",children:[i.jsxs("div",{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:"Node Studio"})]}),i.jsx("h1",{children:"节点编辑器"})]}),i.jsxs("div",{className:"af-node-studio-actions",children:[i.jsxs("button",{type:"button",onClick:()=>void R(),disabled:a,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),i.jsxs("button",{type:"button",onClick:A,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),i.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),i.jsxs("main",{className:"af-node-studio-shell",children:[i.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),i.jsx("strong",{children:"AI Agent"})]}),c?i.jsx("div",{className:"af-node-studio-error",children:c}):null,i.jsxs("div",{className:"af-node-studio-thread",children:[e?null:i.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((E,Q)=>i.jsx("div",{className:E.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:E.text||""},`${E.role||"message"}-${Q}`)),i.jsxs("div",{className:"af-node-studio-agent-tools",children:[i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),i.jsxs("label",{className:"af-node-studio-prompt",children:[i.jsx("span",{children:"需求"}),i.jsx("textarea",{value:p,onChange:E=>h(E.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:d?"sync":"send"}),d?"Saving":"Send"]})]}),i.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),i.jsx("strong",{children:"Preview / Test"})]}),i.jsxs("div",{className:"af-node-studio-preview-grid",children:[i.jsx("div",{className:"af-node-studio-preview-stage",children:e?C==="schedule"?i.jsxs("div",{className:"af-node-preview-card",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:F_(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:P,onChange:E=>O(E.target.checked)}),i.jsx("span",{children:P?"定时开启":"定时关闭"})]}),i.jsxs("div",{className:"af-node-preview-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:k.scheduleType||"daily",onChange:E=>B({config:{scheduleType:E.target.value}}),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{children:[i.jsxs("select",{value:k.hour||"09",onChange:E=>B({config:{hour:E.target.value}}),children:[i.jsx("option",{children:"09"}),i.jsx("option",{children:"10"})]}),i.jsxs("select",{value:k.minute||"00",onChange:E=>B({config:{minute:E.target.value}}),children:[i.jsx("option",{children:"00"}),i.jsx("option",{children:"30"})]})]})]})]}),i.jsxs("div",{className:"af-node-preview-meta",children:[i.jsxs("span",{children:[k.scheduleType==="weekly"?"每周":"每天"," ",k.hour||"09",":",k.minute||"00"]}),i.jsx("span",{children:"Next -"}),i.jsx("span",{children:P?"enabled":"disabled"})]}),i.jsxs("div",{className:"af-node-preview-actions",children:[i.jsxs("button",{type:"button",className:"af-node-preview-run",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):i.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:F_(y)})]}),i.jsxs("div",{className:"af-node-preview-default-body",children:[i.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),i.jsxs("div",{children:[i.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),i.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),i.jsx("span",{children:((W=g.runtime)==null?void 0:W.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):i.jsxs("div",{className:"af-node-preview-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),i.jsx("strong",{children:"暂无预览"}),i.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),i.jsxs("div",{className:"af-node-studio-test",children:[i.jsxs("div",{className:"af-node-studio-subhead",children:[i.jsx("strong",{children:"Test Inputs"}),i.jsxs("button",{type:"button",onClick:A,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"play_arrow"}),"Run"]})]}),i.jsxs("div",{className:"af-node-studio-inputs",children:[i.jsxs("label",{children:[i.jsx("span",{children:"project"}),i.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"date"}),i.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),i.jsx("div",{className:"af-node-studio-log",children:(s?["running..."]:j.length?j:["No test run yet."]).map((E,Q)=>i.jsx("span",{children:E},`${E}-${Q}`))})]})]})]}),i.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),i.jsx("strong",{children:"Internals"})]}),i.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(E=>i.jsxs("button",{type:"button",className:E.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(E.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:E.icon}),E.label]},E.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([E,Q])=>i.jsxs("div",{className:"af-node-studio-internal-row",children:[i.jsx("span",{children:E}),i.jsx("strong",{children:Q})]},E))}),i.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(g.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((y==null?void 0:y.test)||{},null,2):JSON.stringify({runtime:g.runtime||{},files:(y==null?void 0:y.files)||{}},null,2)})]})]})]})}function coe(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function uoe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ch(e){const t=String(e||"").trim();if(!t)return"";let n=t;try{n=new URL(t).pathname}catch{n=t.split("?")[0].split("#")[0]}return(n.replace(/\/+$/,"").split("/").filter(Boolean).pop()||"").replace(/\.git$/i,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")}function doe(e={},t={}){return`${String(e.mountPath||t.mountPath||e.label||t.label||e.id||t.id||"workspace").trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"WORKSPACE"}_GIT_TOKEN`}function Pw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function Xp(e={}){return{id:String((e==null?void 0:e.id)||""),label:String((e==null?void 0:e.label)||(e==null?void 0:e.name)||""),kind:(e==null?void 0:e.kind)==="local"?"local":"git",path:String((e==null?void 0:e.path)||""),repoUrl:String((e==null?void 0:e.repoUrl)||""),branch:String((e==null?void 0:e.branch)||"master"),mountPath:String((e==null?void 0:e.mountPath)||""),credentialRef:String((e==null?void 0:e.credentialRef)||""),type:String((e==null?void 0:e.type)||((e==null?void 0:e.kind)==="local"?"local":"code")),description:String((e==null?void 0:e.description)||""),enabled:(e==null?void 0:e.enabled)!==!1}}function foe(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Ch(n)||"").trim():"";return{id:String(e.id||"").trim(),label:String(e.label||"").trim(),kind:t,path:String(e.path||"").trim(),repoUrl:n,branch:t==="git"?String(e.branch||"master").trim()||"master":"",mountPath:r,credentialRef:t==="git"?String(e.credentialRef||"").trim():"",type:String(e.type||(t==="local"?"local":"code")).trim(),description:String(e.description||"").trim(),enabled:e.enabled!==!1}}function Ji(e,t=0){return(e==null?void 0:e.id)||(e==null?void 0:e.path)||(e==null?void 0:e.repoUrl)||`workspace-${t}`}function poe({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function z_({item:e,selected:t,onClick:n,readOnly:r}){return i.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[i.jsxs("div",{className:"af-workspaces-card__head",children:[i.jsx("strong",{children:e.label||"知识库"}),i.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),i.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),i.jsxs("div",{className:"af-workspaces-card__meta",children:[i.jsx(poe,{ok:e.exists!==!1}),i.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?i.jsx("em",{children:"内置"}):e.enabled===!1?i.jsx("em",{children:"disabled"}):null]})]})}function hoe(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState(Pw),[k,x]=m.useState(""),[j,S]=m.useState([]),[C,P]=m.useState(""),R=m.useMemo(()=>y.findIndex((K,H)=>Ji(K,H)===C),[y,C]),A=!!m.useMemo(()=>p.find((K,H)=>Ji(K,H)===C)||null,[p,C]),O=m.useMemo(()=>{const K=String(b.credentialRef||"").trim();return K?j.some(H=>String((H==null?void 0:H.key)||"").trim()===K&&String((H==null?void 0:H.value)??"")!==""):!1},[b.credentialRef,j]),D=m.useCallback(async()=>{t(!0),l("");try{const[K,H]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),ee=await K.json().catch(()=>({})),ue=await H.json().catch(()=>({}));if(!H.ok)throw new Error(typeof ue.error=="string"?ue.error:"ENV HTTP "+H.status);if(!K.ok)throw new Error(typeof ee.error=="string"?ee.error:"HTTP "+K.status);const G=Array.isArray(ee.workspaces)?ee.workspaces:[],te=Array.isArray(ee.customWorkspaces)?ee.customWorkspaces:[];f(String(ee.path||"")),h(G.filter(se=>se==null?void 0:se.builtin)),v(te),S(Array.isArray(ue.env)?ue.env.map(se=>({key:String((se==null?void 0:se.key)||""),value:String((se==null?void 0:se.value)??"")})):[])}catch(K){l(String(K.message||K))}finally{t(!1)}},[]);m.useEffect(()=>{D()},[D]);const L=m.useCallback(async(K,H="")=>{r(!0),l(""),u("");try{const ee=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:K})}),ue=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof ue.error=="string"?ue.error:"HTTP "+ee.status);const G=Array.isArray(ue.customWorkspaces)?ue.customWorkspaces:K;v(G),h((Array.isArray(ue.workspaces)?ue.workspaces:[]).filter(te=>te==null?void 0:te.builtin)),f(String(ue.path||d)),H&&P(H),u("已保存")}catch(ee){l(String(ee.message||ee))}finally{r(!1)}},[d]),M=m.useCallback(()=>{P(""),g(Pw()),x(""),u(""),l("")},[]),V=m.useCallback((K,H)=>{P(Ji(K,H)),g(Xp(K)),x(""),u("")},[]),z=m.useCallback((K,H)=>{P(Ji(K,H)),g(Xp(K)),x(""),u("")},[]),F=m.useCallback(async(K,H)=>{const ee=String(K||"").trim(),ue=String(H??"");if(!ee||!ue)return;const G=j.filter(ie=>String((ie==null?void 0:ie.key)||"").trim()!==ee);G.push({key:ee,value:ue});const te=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),se=await te.json().catch(()=>({}));if(!te.ok)throw new Error(typeof se.error=="string"?se.error:"ENV HTTP "+te.status);S(Array.isArray(se.env)?se.env.map(ie=>({key:String((ie==null?void 0:ie.key)||""),value:String((ie==null?void 0:ie.value)??"")})):G)},[j]),$=m.useCallback(()=>{const K=foe({...b,id:b.id||coe()}),H=k.trim();if(K.kind==="git"&&H&&!K.credentialRef&&(K.credentialRef=doe(b,K)),K.kind==="local"&&!K.path){l("本地知识库需要填写路径");return}if(K.kind==="git"&&!K.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!K.label){l("请填写名称");return}if(K.kind==="git"&&K.credentialRef&&!uoe(K.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const ee=R>=0?y.map((ue,G)=>G===R?K:ue):[K,...y];g(Xp(K)),(async()=>{r(!0);try{H&&await F(K.credentialRef,H),x(""),await L(ee,Ji(K))}catch(ue){l(String(ue.message||ue)),r(!1)}})()},[y,b,L,F,R,k]),W=m.useCallback(()=>{if(R<0)return;const K=y.filter((H,ee)=>ee!==R);g(Pw()),P(""),L(K)},[y,L,R]),E=m.useCallback(async()=>{if(!A){if(R<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const K=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),H=await K.json().catch(()=>({}));if(!K.ok)throw new Error(typeof H.error=="string"?H.error:"HTTP "+K.status);const ee=Array.isArray(H.customWorkspaces)?H.customWorkspaces:y;v(ee),h((Array.isArray(H.workspaces)?H.workspaces:[]).filter(te=>te==null?void 0:te.builtin));const ue=ee.find(te=>String((te==null?void 0:te.id)||"")===String(b.id||""));ue&&g(Xp(ue));const G=String(H.commit||"").trim();u(H.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(K){l(String(K.message||K))}finally{o(!1)}}},[y,b,A,R]),Q=m.useCallback(K=>{g(H=>({...H,...K}))},[]);return i.jsxs("div",{className:"af-workspaces-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb","aria-label":"知识库",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"知识库"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:D,disabled:e,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),i.jsx("main",{className:"af-settings-body",children:i.jsxs("div",{className:"af-workspaces-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"知识库"}),i.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),d?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",d]}):null,a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?i.jsx("p",{className:"af-workspaces-status",children:c}):null]}),i.jsxs("section",{className:"af-workspaces-summary",children:[i.jsxs("div",{children:[i.jsx("span",{children:"内置"}),i.jsx("strong",{children:p.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"自定义"}),i.jsx("strong",{children:y.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Git"}),i.jsx("strong",{children:y.filter(K=>K.kind==="git").length})]})]}),i.jsxs("div",{className:"af-workspaces-layout",children:[i.jsxs("section",{className:"af-workspaces-list",children:[i.jsxs("div",{className:"af-workspaces-section-head",children:[i.jsx("h2",{children:"自定义知识库"}),i.jsxs("button",{type:"button",onClick:M,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),y.length?y.map((K,H)=>i.jsx(z_,{item:K,selected:Ji(K,H)===C,onClick:()=>V(K,H)},Ji(K,H))):i.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),i.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:i.jsx("h2",{children:"内置知识库"})}),p.map((K,H)=>i.jsx(z_,{item:K,selected:Ji(K,H)===C,onClick:()=>z(K,H),readOnly:!0},Ji(K,H)))]}),i.jsxs("section",{className:"af-workspaces-editor",children:[i.jsxs("div",{className:"af-workspaces-editor__head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:A?"查看内置知识库":R>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:A?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:A,onChange:K=>Q({enabled:K.target.checked})}),i.jsx("span",{children:"启用"})]})]}),i.jsxs("div",{className:"af-workspaces-kind",children:[i.jsxs("button",{type:"button",className:b.kind==="git"?"active":"",disabled:A,onClick:()=>Q({kind:"git",type:b.type==="local"?"code":b.type}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),i.jsxs("button",{type:"button",className:b.kind==="local"?"active":"",disabled:A,onClick:()=>Q({kind:"local",type:"local"}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),i.jsxs("div",{className:"af-workspaces-form",children:[i.jsxs("label",{children:[i.jsx("span",{children:"名称"}),i.jsx("input",{value:b.label,disabled:A,onChange:K=>Q({label:K.target.value}),placeholder:"Likee Android"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"类型"}),i.jsxs("select",{value:b.type,disabled:A,onChange:K=>Q({type:K.target.value}),children:[i.jsx("option",{value:"code",children:"code"}),i.jsx("option",{value:"docs",children:"docs"}),i.jsx("option",{value:"analytics",children:"analytics"}),i.jsx("option",{value:"config",children:"config"}),i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"other",children:"other"})]})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"本地路径"}),i.jsx("input",{value:b.path,disabled:A,onChange:K=>Q({path:K.target.value}),placeholder:b.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),b.kind==="git"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"Git URL"}),i.jsx("input",{value:b.repoUrl,disabled:A,onChange:K=>{const H=K.target.value,ee=Ch(b.repoUrl),ue=String(b.mountPath||"").trim();Q({repoUrl:H,...!ue||ue===ee?{mountPath:Ch(H)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:b.branch,disabled:A,onChange:K=>Q({branch:K.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:b.mountPath,disabled:A,onChange:K=>Q({mountPath:K.target.value}),placeholder:Ch(b.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:b.credentialRef,disabled:A,onChange:K=>Q({credentialRef:K.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"Token"}),i.jsx("input",{type:"password",value:k,disabled:A,onChange:K=>x(K.target.value),placeholder:O?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),i.jsx("small",{children:"保存后只在知识库配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:b.description,disabled:A,onChange:K=>Q({description:K.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!A&&R>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:W,disabled:n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):i.jsx("span",{}),i.jsxs("div",{children:[b.kind==="git"&&R>=0?i.jsxs("button",{type:"button",onClick:E,disabled:A||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:s?"sync":"download"}),s?"拉取中":"拉取更新"]}):null,i.jsx("button",{type:"button",onClick:M,disabled:n||s,children:"重置"}),i.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:$,disabled:A||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}function moe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}function goe(e){return e==="owner"?"我创建的":e==="editor"?"协作编辑":e==="viewer"?"只读协作":"可访问"}function yoe(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function woe(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function xoe(e){return`/workspace?${new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||"")}).toString()}`}function boe(){const{navigate:e}=xs(),[t,n]=m.useState([]),[r,s]=m.useState("personal"),[o,a]=m.useState(null),[l,c]=m.useState(!1),[u,d]=m.useState(""),[f,p]=m.useState(""),[h,y]=m.useState("all"),[v,b]=m.useState("all"),g=m.useCallback(async()=>{c(!0),d("");try{const j=await fetch(`/api/prd-workflows?view=${encodeURIComponent(r)}`),S=await j.json().catch(()=>({}));if(!j.ok)throw new Error(S.error||"读取迭代列表失败");n(Array.isArray(S.workflows)?S.workflows:[]),a(S.team||null)}catch(j){d(String(j.message||j)),n([]),a(null)}finally{c(!1)}},[r]);m.useEffect(()=>{g()},[g]);const k=m.useMemo(()=>({total:t.length,owned:t.filter(j=>j.role==="owner").length,collaborating:t.filter(j=>j.role!=="owner").length,attention:t.filter(j=>j.state==="blocked").length}),[t]),x=m.useMemo(()=>{const j=f.trim().toLowerCase();return t.filter(S=>{var C;return h==="owned"&&S.role!=="owner"||h==="collaborating"&&S.role==="owner"||v!=="all"&&S.state!==v?!1:j?[S.tapdId,S.title,S.pointer,S.phase,S.ownerUsername,(C=S.latestAction)==null?void 0:C.title].some(P=>String(P||"").toLowerCase().includes(j)):!0})},[f,h,v,t]);return i.jsxs("div",{className:"af-settings-page af-workflows-page",children:[i.jsxs("div",{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:"迭代"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void g(),disabled:l,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:l?"hourglass_empty":"refresh"}),"刷新"]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner af-workflows-inner",children:[i.jsxs("section",{className:"af-settings-hero af-workflows-hero",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-workflows-eyebrow",children:"Workflow Dashboard"}),i.jsx("h1",{className:"af-settings-h1",children:"迭代"}),i.jsx("p",{className:"af-settings-lead",children:r==="team"?`汇总${o!=null&&o.name?`「${o.name}」`:"当前团队"}的需求 Workflow,按负责人追踪进度与风险。`:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]}),i.jsxs("div",{className:"af-scope-switch","aria-label":"迭代视图",children:[i.jsx("button",{type:"button",className:r==="personal"?"is-active":"",onClick:()=>s("personal"),children:"个人迭代"}),i.jsx("button",{type:"button",className:r==="team"?"is-active":"",onClick:()=>s("team"),children:"团队迭代"})]})]}),i.jsxs("div",{className:"af-workflows-summary","aria-label":"迭代汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部迭代"}),i.jsx("strong",{children:k.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"我创建的"}),i.jsx("strong",{children:k.owned})]}),i.jsxs("div",{children:[i.jsx("span",{children:"参与协作"}),i.jsx("strong",{children:k.collaborating})]}),i.jsxs("div",{className:k.attention?"is-attention":"",children:[i.jsx("span",{children:"需关注"}),i.jsx("strong",{children:k.attention})]})]}),i.jsxs("section",{className:"af-workflows-toolbar","aria-label":"迭代筛选",children:[i.jsxs("label",{className:"af-workflows-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:f,onChange:j=>p(j.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),i.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([j,S])=>i.jsx("button",{type:"button",className:h===j?"is-active":"","aria-pressed":h===j,onClick:()=>y(j),children:S},j))}),i.jsxs("select",{value:v,onChange:j=>b(j.target.value),"aria-label":"迭代状态",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"active",children:"进行中"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"blocked",children:"需关注"})]})]}),u?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:u}):null,l?i.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!l&&!u&&t.length===0?i.jsxs("div",{className:"af-workflows-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timeline"}),i.jsx("strong",{children:r==="team"&&!o?"尚未加入团队":"暂无迭代"}),i.jsx("p",{children:r==="team"&&!o?"请联系超级管理员完成团队划分。":"当 prd-flow 上报 Workflow 后,它会出现在这里。"})]}):null,!l&&t.length>0&&x.length===0?i.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,i.jsx("div",{className:"af-workflows-list",children:x.map(j=>{var C,P;const S=j.actionCount>0?Math.round(j.completedActionCount/j.actionCount*100):0;return i.jsxs("article",{className:"af-workflow-card",children:[i.jsxs("div",{className:"af-workflow-card__identity",children:[i.jsxs("div",{className:"af-workflow-card__title-row",children:[i.jsxs("span",{className:"af-workflow-tapd",children:["TAPD ",j.tapdId]}),i.jsx("span",{className:`af-workflow-state af-workflow-state--${j.state||"active"}`,children:yoe(j.state)}),i.jsx("span",{className:"af-workflow-role",children:goe(j.role)}),j.shareActive?i.jsxs("span",{className:"af-workflow-shared",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"已分享"]}):null]}),i.jsx("h2",{children:j.title||j.pointer||`需求 ${j.tapdId}`}),i.jsx("p",{children:j.pointer||"等待 Workflow 上报当前状态"}),i.jsxs("div",{className:"af-workflow-card__meta",children:[i.jsx("span",{children:j.phase||"未识别阶段"}),i.jsxs("span",{children:[j.issueCount||0," Issues"]}),(j.platforms||[]).map(R=>i.jsx("span",{children:woe(R)},R)),i.jsxs("span",{children:["Owner · ",j.ownerUsername||j.ownerId||"-"]}),r==="team"&&j.teamName?i.jsxs("span",{children:["团队 · ",j.teamName]}):null]})]}),i.jsxs("div",{className:"af-workflow-card__progress",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Action 进度"}),i.jsxs("strong",{children:[j.completedActionCount||0,"/",j.actionCount||0]})]}),i.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${S}%`,children:i.jsx("span",{style:{width:`${S}%`}})}),i.jsxs("small",{children:[S,"%"]})]}),i.jsxs("div",{className:"af-workflow-card__latest",children:[i.jsx("span",{children:"最新动态"}),i.jsx("strong",{children:((C=j.latestAction)==null?void 0:C.title)||"暂无 Action 记录"}),i.jsx("small",{children:moe(((P=j.latestAction)==null?void 0:P.at)||j.updatedAt)})]}),i.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>e(xoe(j)),children:["打开 Workflow",i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_forward"})]})]},j.id||j.tapdId)})})]})})]})}const koe=[{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"}],voe=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Soe=[{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"}],joe=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Qp({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 Noe(){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(Qp,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(Qp,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(Qp,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(Qp,{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 _h({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 Coe(){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(_h,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:Soe.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 XM(){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(Noe,{}),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(_h,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:koe.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(_h,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:voe.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(Coe,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(_h,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:joe.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 QM(e){return t=>typeof t===e}var _oe=QM("function"),Eoe=e=>e===null,B_=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",H_=e=>!Aoe(e)&&!Eoe(e)&&(_oe(e)||typeof e=="object"),Aoe=QM("undefined");function Poe(e,t,n){return Ooe(n,e,t)?!0:(Doe(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Ioe(e,t,n):e instanceof Map&&t instanceof Map?Moe(e,t,n):e instanceof Set&&t instanceof Set?Loe(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Roe(e,t):B_(e)&&B_(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Toe(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():$oe(e,t,n))}function Cf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!H_(e)||!t||!H_(t)?!1:Poe(e,t,n)}function Ioe(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!Cf(e[s],t[s],n))return!1;return!0}function Roe(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 Toe(e,t,n){return e.message===t.message&&e.name===t.name&&Cf(e.cause,t.cause,n)}function Moe(e,t,n){if(e.size!==t.size)return!1;for(const r of e.entries())if(!t.has(r[0]))return!1;for(const r of e.entries())if(!Cf(r[1],t.get(r[0]),n))return!1;return!0}function $oe(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)&&!Cf(e[o],t[o],n))return!1}return!0}function Loe(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 Ooe(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Doe(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function Tv(e,t){return Cf(e,t,new WeakMap)}function Iw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Foe(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function zoe(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Boe(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Hoe(e,t){const n=Boe();m.useEffect(()=>{if(!n)return e()},t)}function ZM(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function Woe(e,t){const n=m.useRef(t);return Tv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Voe(e){m.useEffect(()=>{e()},[])}function Koe(e=0){const[t,n]=m.useState({height:Iw()?window.innerHeight:0,width:Iw()?window.innerWidth:0}),r=m.useRef(0),s=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!Iw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),zoe(window,"resize",o),()=>{Foe(window,"resize",o)}},[]),t}var qoe=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Uoe=["bigint","boolean","null","number","string","symbol","undefined"];function _f(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Yoe(t))return t}function pi(e){return t=>_f(t)===e}function Yoe(e){return qoe.includes(e)}function Zc(e){return t=>typeof t===e}function Goe(e){return Uoe.includes(e)}var Joe=["innerHTML","ownerDocument","style","attributes","nodeValue"],Ef=e=>Array.isArray(e),Xoe=e=>_f(e)==="AsyncGeneratorFunction",Qoe=pi("AsyncFunction"),Zoe=Zc("bigint"),eae=e=>e===!0||e===!1,tae=pi("Date"),nae=pi("Error"),ca=Zc("function"),rae=pi("GeneratorFunction"),sae=e=>typeof e=="number"&&Number.isInteger(e),Mb=pi("Map"),e$=e=>Number.isNaN(e),Mv=e=>e===null,t$=pi("Function"),iae=pi("Promise"),oae=pi("RegExp"),$b=pi("Set"),Af=Zc("string"),aae=Zc("symbol"),$v=Zc("undefined"),lae=pi("WeakMap"),cae=pi("WeakSet"),Lv=e=>Mv(e)||$v(e),n$=e=>!$v(e),uae=e=>Zc("number")(e)&&!e$(e),dae=e=>Af(e)&&e.trim().length>0,fae=e=>{if(!Af(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},kg=e=>!Lv(e)&&(ca(e)||typeof e=="object"),r$=e=>{if(_f(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},pae=e=>Mv(e)||Goe(typeof e),hae=e=>_f(e)==="URL",s$=e=>!Lv(e)&&ca(e[Symbol.iterator]),mae=e=>s$(e)&&ca(e.next)&&ca(e.throw),gae=e=>ca(e)&&/^class\s/.test(e.toString()),yae=(e,t)=>!Ef(e)||!ca(t)?!1:e.every(n=>t(n)),wae=e=>kg(e)&&!r$(e)&&e.nodeType===1&&Af(e.nodeName)&&Joe.every(t=>t in e),xae=e=>Af(e)&&e.length===0||Ef(e)&&e.length===0||kg(e)&&!Mb(e)&&!$b(e)&&Object.keys(e).length===0||$b(e)&&e.size===0||Mb(e)&&e.size===0,bae=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,kae=(e,t)=>Ef(e)?e.indexOf(t)>-1:!1,vae=(e,t,n)=>{if(!kg(e)||!t)return!1;const r=e[t];return ca(n)?n(r):n$(r)};function Nt(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(Ef(e))return"Array";if(t$(e))return"Function";const t=_f(e);return t||"Object"}Nt.array=Ef;Nt.arrayOf=yae;Nt.asyncGeneratorFunction=Xoe;Nt.asyncFunction=Qoe;Nt.bigint=Zoe;Nt.boolean=eae;Nt.class=gae;Nt.date=tae;Nt.defined=n$;Nt.domElement=wae;Nt.empty=xae;Nt.error=nae;Nt.function=ca;Nt.generator=mae;Nt.generatorFunction=rae;Nt.instanceOf=bae;Nt.integer=sae;Nt.iterable=s$;Nt.map=Mb;Nt.nan=e$;Nt.null=Mv;Nt.nullOrUndefined=Lv;Nt.nonEmptyString=dae;Nt.number=uae;Nt.numericString=fae;Nt.object=kg;Nt.oneOf=kae;Nt.plainFunction=t$;Nt.plainObject=r$;Nt.primitive=pae;Nt.promise=iae;Nt.propertyOf=vae;Nt.regexp=oae;Nt.set=$b;Nt.string=Af;Nt.symbol=aae;Nt.undefined=$v;Nt.url=hae;Nt.weakMap=lae;Nt.weakSet=cae;var Pr=Nt;/* v8 ignore next -- @preserve */var Sae=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},jae=function(e,t){return e+lf(t)},lf=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(jae,""):Sae(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?lf(e.props.children):""};lf.default=lf;var Nae=lf;const Rw=da(Nae);var i$={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(S){return S!=="constructor"&&S!=="prototype"&&S!=="__proto__"}function a(S){let C=0;const P=S.length,R=new Array(P);for(C;C<P;++C)R[C]=g(S[C]);return R}function l(S){const C={};if(p&&Object.getPrototypeOf(S)!==t)return p(S);const P=f(S);let R,B,A;for(R=0,B=P.length;R<B;++R)o(A=P[R])&&(C[A]=g(S[A]));return C}function c(S,C){const P=S.length,R=C.length;let B=0;const A=new Array(P+R);for(B;B<P;++B)A[B]=g(S[B]);for(B=0;B<R;++B)A[B+P]=g(C[B]);return A}const u=Object.prototype.propertyIsEnumerable;function d(S){const C=Object.keys(S),P=Object.getOwnPropertySymbols(S);for(let R=0,B=P.length;R<B;++R)u.call(S,P[R])&&C.push(P[R]);return C}const f=s!=null&&s.symbols?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),y=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(S){return typeof S!="object"||S===null}const b=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:g,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function g(S){return h(S)?Array.isArray(S)?a(S):l(S):S}function k(S,C){const P={},R=f(S),B=f(C);let A,O,D;for(A=0,O=R.length;A<O;++A)o(D=R[A])&&B.indexOf(D)===-1&&(P[D]=g(S[D]));for(A=0,O=B.length;A<O;++A)if(o(D=B[A]))if(D in S)R.indexOf(D)!==-1&&(p&&h(C[D])&&Object.getPrototypeOf(C[D])!==t?P[D]=p(C[D]):P[D]=x(S[D],C[D]));else{if(y&&typeof C[D]>"u")continue;P[D]=g(C[D])}return P}function x(S,C){if(y&&typeof C>"u")return g(S);const P=Array.isArray(C),R=Array.isArray(S);return v(C)?C:h(S)?P&&R?b(S,C):P!==R?g(C):k(S,C):g(C)}function j(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let S;for(let C=0,P=arguments.length;C<P;++C)S=x(S,arguments[C]);return S}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})})(i$);var Cae=i$.exports;const _ae=da(Cae);var Eae=new Error("Element already at target scroll position"),Aae=new Error("Scroll cancelled"),Pae=Math.min,W_=Date.now,Iae={left:V_("scrollLeft"),top:V_("scrollTop")};function V_(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=Tae);var a=W_(),l=n[e],c=s.ease||Rae,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?o(Eae,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(h){if(d)return o(Aae,n[e]);var y=W_(),v=Pae(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){o(null,n[e])})}}}function Rae(e){return .5*(1-Math.cos(Math.PI*e))}function Tae(){}const Mae=da(Iae);var o$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(jd,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})})(o$);var $ae=o$.exports;const a$=da($ae),Lae=["top","right","bottom","left"],K_=["start","end"],q_=Lae.reduce((e,t)=>e.concat(t,t+"-"+K_[0],t+"-"+K_[1]),[]),Wc=Math.min,Ya=Math.max,Im=Math.round,Zp=Math.floor,$i=e=>({x:e,y:e}),Oae={left:"right",right:"left",bottom:"top",top:"bottom"};function Lb(e,t,n){return Ya(e,Wc(t,n))}function eu(e,t){return typeof e=="function"?e(t):e}function yo(e){return e.split("-")[0]}function Li(e){return e.split("-")[1]}function l$(e){return e==="x"?"y":"x"}function Ov(e){return e==="y"?"height":"width"}function qo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Dv(e){return l$(qo(e))}function c$(e,t,n){n===void 0&&(n=!1);const r=Li(e),s=Dv(e),o=Ov(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Tm(a)),[a,Tm(a)]}function Dae(e){const t=Tm(e);return[Rm(e),t,Rm(t)]}function Rm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const U_=["left","right"],Y_=["right","left"],Fae=["top","bottom"],zae=["bottom","top"];function Bae(e,t,n){switch(e){case"top":case"bottom":return n?t?Y_:U_:t?U_:Y_;case"left":case"right":return t?Fae:zae;default:return[]}}function Hae(e,t,n,r){const s=Li(e);let o=Bae(yo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(Rm)))),o}function Tm(e){const t=yo(e);return Oae[t]+e.slice(t.length)}function Wae(e){return{top:0,right:0,bottom:0,left:0,...e}}function u$(e){return typeof e!="number"?Wae(e):{top:e,right:e,bottom:e,left:e}}function Mm(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 G_(e,t,n){let{reference:r,floating:s}=e;const o=qo(t),a=Dv(t),l=Ov(a),c=yo(t),u=o==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Li(t)){case"start":h[a]-=p*(n&&u?-1:1);break;case"end":h[a]+=p*(n&&u?-1:1);break}return h}async function Vae(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=eu(t,e),y=u$(h),b=l[p?f==="floating"?"reference":"floating":f],g=Mm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),k=f==="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},S=Mm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-S.top+y.top)/j.y,bottom:(S.bottom-g.bottom+y.bottom)/j.y,left:(g.left-S.left+y.left)/j.x,right:(S.right-g.right+y.right)/j.x}}const Kae=50,qae=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Vae},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=G_(u,r,c),p=r,h=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:j,data:S,reset:C}=await k({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});d=x??d,f=j??f,y[g]={...y[g],...S},C&&h<Kae&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:d,y:f}=G_(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:y}},Uae=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:u,padding:d=0}=eu(e,t)||{};if(u==null)return{};const f=u$(d),p={x:n,y:r},h=Dv(s),y=Ov(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",j=o.reference[y]+o.reference[h]-p[h]-o.floating[y],S=p[h]-o.reference[h],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=C?C[x]:0;(!P||!await(a.isElement==null?void 0:a.isElement(C)))&&(P=l.floating[x]||o.floating[y]);const R=j/2-S/2,B=P/2-v[y]/2-1,A=Wc(f[g],B),O=Wc(f[k],B),D=A,L=P-v[y]-O,M=P/2-v[y]/2+R,V=Lb(D,M,L),z=!c.arrow&&Li(s)!=null&&M!==V&&o.reference[y]/2-(M<D?A:O)-v[y]/2<0,F=z?M<D?M-D:M-L:0;return{[h]:p[h]+F,data:{[h]:V,centerOffset:M-V-F,...z&&{alignmentOffset:F}},reset:z}}});function Yae(e,t,n){return(e?[...n.filter(s=>Li(s)===e),...n.filter(s=>Li(s)!==e)]:n.filter(s=>yo(s)===s)).filter(s=>e?Li(s)===e||(t?Rm(s)!==s:!1):!0)}const Gae=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:u}=t,{crossAxis:d=!1,alignment:f,allowedPlacements:p=q_,autoAlignment:h=!0,...y}=eu(e,t),v=f!==void 0||p===q_?Yae(f||null,h,p):p,b=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const x=c$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const j=[b[yo(k)],b[x[0]],b[x[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:j}],C=v[g+1];if(C)return{data:{index:g+1,overflows:S},reset:{placement:C}};const P=S.map(A=>{const O=Li(A.placement);return[A.placement,O&&d?A.overflows.slice(0,2).reduce((D,L)=>D+L,0):A.overflows[0],A.overflows]}).sort((A,O)=>A[1]-O[1]),B=((s=P.filter(A=>A[2].slice(0,Li(A[0])?2:3).every(O=>O<=0))[0])==null?void 0:s[0])||P[0][0];return B!==l?{data:{index:g+1,overflows:S},reset:{placement:B}}:{}}}},Jae=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:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=eu(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=yo(s),k=qo(l),x=yo(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(x||!v?[Tm(l)]:Dae(l)),C=y!=="none";!p&&C&&S.push(...Hae(l,v,y,j));const P=[l,...S],R=await c.detectOverflow(t,b),B=[];let A=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&B.push(R[g]),f){const M=c$(s,a,j);B.push(R[M[0]],R[M[1]])}if(A=[...A,{placement:s,overflows:B}],!B.every(M=>M<=0)){var O,D;const M=(((O=o.flip)==null?void 0:O.index)||0)+1,V=P[M];if(V&&(!(f==="alignment"?k!==qo(V):!1)||A.every($=>qo($.placement)===k?$.overflows[0]>0:!0)))return{data:{index:M,overflows:A},reset:{placement:V}};let z=(D=A.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:D.placement;if(!z)switch(h){case"bestFit":{var L;const F=(L=A.filter($=>{if(C){const W=qo($.placement);return W===k||W==="y"}return!0}).map($=>[$.placement,$.overflows.filter(W=>W>0).reduce((W,E)=>W+E,0)]).sort(($,W)=>$[1]-W[1])[0])==null?void 0:L[0];F&&(z=F);break}case"initialPlacement":z=l;break}if(s!==z)return{reset:{placement:z}}}return{}}}},Xae=new Set(["left","top"]);async function Qae(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=yo(n),l=Li(n),c=qo(n)==="y",u=Xae.has(a)?-1:1,d=o&&c?-1:1,f=eu(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}const Zae=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 Qae(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}}}}},ele=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:g=>{let{x:k,y:x}=g;return{x:k,y:x}}},...u}=eu(e,t),d={x:n,y:r},f=await o.detectOverflow(t,u),p=qo(yo(s)),h=l$(p);let y=d[h],v=d[p];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+f[g],j=y-f[k];y=Lb(x,y,j)}if(l){const g=p==="y"?"top":"left",k=p==="y"?"bottom":"right",x=v+f[g],j=v-f[k];v=Lb(x,v,j)}const b=c.fn({...t,[h]:y,[p]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[p]:l}}}}}};function vg(){return typeof window<"u"}function tu(e){return d$(e)?(e.nodeName||"").toLowerCase():"#document"}function hs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zi(e){var t;return(t=(d$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function d$(e){return vg()?e instanceof Node||e instanceof hs(e).Node:!1}function ui(e){return vg()?e instanceof Element||e instanceof hs(e).Element:!1}function ko(e){return vg()?e instanceof HTMLElement||e instanceof hs(e).HTMLElement:!1}function J_(e){return!vg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof hs(e).ShadowRoot}function Pf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=di(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function tle(e){return/^(table|td|th)$/.test(tu(e))}function Sg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const nle=/transform|translate|scale|rotate|perspective|filter/,rle=/paint|layout|strict|content/,Ea=e=>!!e&&e!=="none";let Tw;function Fv(e){const t=ui(e)?di(e):e;return Ea(t.transform)||Ea(t.translate)||Ea(t.scale)||Ea(t.rotate)||Ea(t.perspective)||!zv()&&(Ea(t.backdropFilter)||Ea(t.filter))||nle.test(t.willChange||"")||rle.test(t.contain||"")}function sle(e){let t=ua(e);for(;ko(t)&&!Vc(t);){if(Fv(t))return t;if(Sg(t))return null;t=ua(t)}return null}function zv(){return Tw==null&&(Tw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Tw}function Vc(e){return/^(html|body|#document)$/.test(tu(e))}function di(e){return hs(e).getComputedStyle(e)}function jg(e){return ui(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ua(e){if(tu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||J_(e)&&e.host||zi(e);return J_(t)?t.host:t}function f$(e){const t=ua(e);return Vc(t)?e.ownerDocument?e.ownerDocument.body:e.body:ko(t)&&Pf(t)?t:f$(t)}function cf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=f$(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=hs(s);if(o){const l=Ob(a);return t.concat(a,a.visualViewport||[],Pf(s)?s:[],l&&n?cf(l):[])}else return t.concat(s,cf(s,[],n))}function Ob(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function p$(e){const t=di(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ko(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Im(n)!==o||Im(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Bv(e){return ui(e)?e:e.contextElement}function Cc(e){const t=Bv(e);if(!ko(t))return $i(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=p$(t);let a=(o?Im(n.width):n.width)/r,l=(o?Im(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const ile=$i(0);function h$(e){const t=hs(e);return!zv()||!t.visualViewport?ile:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ole(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==hs(e)?!1:t}function ul(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Bv(e);let a=$i(1);t&&(r?ui(r)&&(a=Cc(r)):a=Cc(e));const l=ole(o,n,r)?h$(o):$i(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,d=s.width/a.x,f=s.height/a.y;if(o){const p=hs(o),h=r&&ui(r)?hs(r):r;let y=p,v=Ob(y);for(;v&&r&&h!==y;){const b=Cc(v),g=v.getBoundingClientRect(),k=di(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,j=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=x,u+=j,y=hs(v),v=Ob(y)}}return Mm({width:d,height:f,x:c,y:u})}function Ng(e,t){const n=jg(e).scrollLeft;return t?t.left+n:ul(zi(e)).left+n}function m$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ng(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function ale(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=zi(r),l=t?Sg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=$i(1);const d=$i(0),f=ko(r);if((f||!f&&!o)&&((tu(r)!=="body"||Pf(a))&&(c=jg(r)),f)){const h=ul(r);u=Cc(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=a&&!f&&!o?m$(a,c):$i(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function lle(e){return Array.from(e.getClientRects())}function cle(e){const t=zi(e),n=jg(e),r=e.ownerDocument.body,s=Ya(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ya(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Ng(e);const l=-n.scrollTop;return di(r).direction==="rtl"&&(a+=Ya(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const X_=25;function ule(e,t){const n=hs(e),r=zi(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const d=zv();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Ng(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-h);y<=X_&&(o-=y)}else u<=X_&&(o+=u);return{width:o,height:a,x:l,y:c}}function dle(e,t){const n=ul(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=ko(e)?Cc(e):$i(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,u=r*o.y;return{width:a,height:l,x:c,y:u}}function Q_(e,t,n){let r;if(t==="viewport")r=ule(e,n);else if(t==="document")r=cle(zi(e));else if(ui(t))r=dle(t,n);else{const s=h$(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Mm(r)}function g$(e,t){const n=ua(e);return n===t||!ui(n)||Vc(n)?!1:di(n).position==="fixed"||g$(n,t)}function fle(e,t){const n=t.get(e);if(n)return n;let r=cf(e,[],!1).filter(l=>ui(l)&&tu(l)!=="body"),s=null;const o=di(e).position==="fixed";let a=o?ua(e):e;for(;ui(a)&&!Vc(a);){const l=di(a),c=Fv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Pf(a)&&!c&&g$(e,a))?r=r.filter(d=>d!==a):s=l,a=ua(a)}return t.set(e,r),r}function ple(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Sg(t)?[]:fle(t,this._c):[].concat(n),r],l=Q_(t,a[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const h=Q_(t,a[p],s);c=Ya(h.top,c),u=Wc(h.right,u),d=Wc(h.bottom,d),f=Ya(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function hle(e){const{width:t,height:n}=p$(e);return{width:t,height:n}}function mle(e,t,n){const r=ko(t),s=zi(t),o=n==="fixed",a=ul(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=$i(0);function u(){c.x=Ng(s)}if(r||!r&&!o)if((tu(t)!=="body"||Pf(s))&&(l=jg(t)),r){const h=ul(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?m$(s,l):$i(0),f=a.left+l.scrollLeft-c.x-d.x,p=a.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:a.width,height:a.height}}function Mw(e){return di(e).position==="static"}function Z_(e,t){if(!ko(e)||di(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zi(e)===n&&(n=n.ownerDocument.body),n}function y$(e,t){const n=hs(e);if(Sg(e))return n;if(!ko(e)){let s=ua(e);for(;s&&!Vc(s);){if(ui(s)&&!Mw(s))return s;s=ua(s)}return n}let r=Z_(e,t);for(;r&&tle(r)&&Mw(r);)r=Z_(r,t);return r&&Vc(r)&&Mw(r)&&!Fv(r)?n:r||sle(e)||n}const gle=async function(e){const t=this.getOffsetParent||y$,n=this.getDimensions,r=await n(e.floating);return{reference:mle(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yle(e){return di(e).direction==="rtl"}const wle={convertOffsetParentRelativeRectToViewportRelativeRect:ale,getDocumentElement:zi,getClippingRect:ple,getOffsetParent:y$,getElementRects:gle,getClientRects:lle,getDimensions:hle,getScale:Cc,isElement:ui,isRTL:yle};function w$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xle(e,t){let n=null,r;const s=zi(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 u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=u;if(l||t(),!p||!h)return;const y=Zp(f),v=Zp(s.clientWidth-(d+p)),b=Zp(s.clientHeight-(f+h)),g=Zp(d),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Ya(0,Wc(1,c))||1};let j=!0;function S(C){const P=C[0].intersectionRatio;if(P!==c){if(!j)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!w$(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(S,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),o}function eE(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,u=Bv(e),d=s||o?[...u?cf(u):[],...t?cf(t):[]]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?xle(u,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?ul(e):null;c&&b();function b(){const g=ul(e);v&&!w$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;d.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const ble=Zae,kle=Gae,vle=ele,Sle=Jae,tE=Uae,jle=(e,t,n)=>{const r=new Map,s={platform:wle,...n},o={...s.platform,_c:r};return qae(e,t,{...s,platform:o})};var Nle=typeof document<"u",Cle=function(){},Eh=Nle?m.useLayoutEffect:Cle;function $m(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(!$m(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)&&!$m(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function x$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nE(e,t){const n=x$(e);return Math.round(t*n)/n}function $w(e){const t=m.useRef(e);return Eh(()=>{t.current=e}),t}function rE(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:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);$m(p,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback($=>{$!==C.current&&(C.current=$,v($))},[]),x=m.useCallback($=>{$!==P.current&&(P.current=$,g($))},[]),j=o||y,S=a||b,C=m.useRef(null),P=m.useRef(null),R=m.useRef(d),B=c!=null,A=$w(c),O=$w(s),D=$w(u),L=m.useCallback(()=>{if(!C.current||!P.current)return;const $={placement:t,strategy:n,middleware:p};O.current&&($.platform=O.current),jle(C.current,P.current,$).then(W=>{const E={...W,isPositioned:D.current!==!1};M.current&&!$m(R.current,E)&&(R.current=E,lr.flushSync(()=>{f(E)}))})},[p,t,n,O,D]);Eh(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);Eh(()=>(M.current=!0,()=>{M.current=!1}),[]),Eh(()=>{if(j&&(C.current=j),S&&(P.current=S),j&&S){if(A.current)return A.current(j,S,L);L()}},[j,S,L,A,B]);const V=m.useMemo(()=>({reference:C,floating:P,setReference:k,setFloating:x}),[k,x]),z=m.useMemo(()=>({reference:j,floating:S}),[j,S]),F=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!z.floating)return $;const W=nE(z.floating,d.x),E=nE(z.floating,d.y);return l?{...$,transform:"translate("+W+"px, "+E+"px)",...x$(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:E}},[n,l,z.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:V,elements:z,floatingStyles:F}),[d,L,V,z,F])}const _le=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?tE({element:r.current,padding:s}).fn(n):{}:r?tE({element:r,padding:s}).fn(n):{}}}},sE=(e,t)=>{const n=ble(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ele=(e,t)=>{const n=vle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ale=(e,t)=>{const n=Sle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ple=(e,t)=>{const n=kle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ile=(e,t)=>{const n=_le(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rle={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},Tle={beaconOptions:{offset:-18}},b$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Mle={isFixed:!1,locale:b$,placement:"bottom"},$le={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Dt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},ar={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Je={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Si={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},At={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Lle="react-joyride-portal";function Ole(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function fc(...e){return _ae({all:!0,isMergeableObject:t=>!(!Pr.plainObject(t)||m.isValidElement(t))})(...e)}function k$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Zi(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=Rw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&k$(e.type)==="function")try{o=Zi(e.type({}),t)}catch{o=Rw(n)}else o=Rw(n);return o}function dr(e,t,n,...r){if(!e)return;const s=new Date,o=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}.${String(s.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Dle(e,t){const n=Ole(t);return{...e,...n}}function uf(){}function Fle(e){return Object.keys(e)}function Lm(e,...t){if(!Pr.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 iE(e,...t){if(!Pr.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 Db(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(k$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Pr.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):Db(o,t,n))});if(Pr.function(e.type)&&!Object.values(e.props).length)try{return Db(e.type({}),t,n)}catch{return e}return e}function oE(e){return Fle(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Hv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function aE(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 Wv(e){return e?e.getBoundingClientRect():null}function zle(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 Ts(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 Ble(e,t,n){const r=Wv(e),s=nu(e),o=s?!s.isSameNode(Qr()):!1,a=n??ru(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(Qr())||(c+=Qr().scrollTop)),Math.floor(c-t)}function nu(e,t){if(!e)return Qr();const n=a$(e);if(n){if(n.isSameNode(Qr()))return t?document:Qr();if(!(n.scrollHeight>n.offsetHeight))return Qr()}return n}function Hle(e){const t=e.getBoundingClientRect(),n=Qr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Wle(e,t){if(!e)return 0;const n=a$(e)??Qr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Wv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(v$(e)||Vle(e))){const d=e.getBoundingClientRect(),f=d.top-((s==null?void 0:s.top)??0),p=f+d.height,h=n.clientHeight,y=h*.2;f>=y&&p<=h-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function Vle(e){return e.offsetParent!==document.body}function v$(e){if(!e)return!1;const t=nu(e);return t?!t.isSameNode(Qr()):!1}function ru(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?ru(e.parentNode,t):!1}function eh(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 lE(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Je.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?nu(s):Qr(),l=a?!a.isSameNode(Qr()):!1;return(r.isFixed||ru(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Qr(){return document.scrollingElement??document.documentElement}function cE(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=Mae.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function Kle(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 S$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},th={...S$,borderRadius:4,padding:8};function qle(e,t){const{styles:n}=e,r=fc(n??{},t.styles??{});let{width:s}=t;Hv()&&(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 fc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...S$,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(${Kle(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:{...th,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...th,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...th,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...th,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 Ule=["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 Vv(e,t){if(!t)return null;const n=fc(Mle,iE(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=fc(Rle,e.options??{},iE(t,...Ule)),s=qle(e,{...n,...r}),o=fc(Tle,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:fc(b$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Yle(r.spotlightPadding),styles:s}}function Yle(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 Gle(e,t,n){const{action:r}=t,s=n&&[Dt.PREV,Dt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function j$(e,t=!1){return Pr.plainObject(e)?e.target?!0:(dr(t,"tour","target is missing from the step"),!1):(dr(t,"tour","step must be an object"),!1)}function N$(e,t=!1){return Pr.array(e)?e.every(n=>j$(n,t)):(dr(t,"tour","steps must be an array"),!1)}var Jle=class{constructor(e){Tn(this,"beaconPosition",null);Tn(this,"debug");Tn(this,"eventListeners",new Map);Tn(this,"listeners",new Set);Tn(this,"props");Tn(this,"snapshot");Tn(this,"state");Tn(this,"steps");Tn(this,"tooltipPosition",null);Tn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Tn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Tn(this,"getServerSnapshot",()=>this.snapshot);Tn(this,"getSnapshot",()=>this.snapshot);Tn(this,"getEventState",()=>Lm(this.snapshot,"positioned"));Tn(this,"getState",()=>Lm(this.snapshot,"positioned"));Tn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&dr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Je.BEACON_BEFORE||this.state.lifecycle===Je.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)});Tn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Tn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Tn(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)}});Tn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Tn(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,!Tv(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=Pr.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,Pr.number(t)&&dr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Pr.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&dr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Dt.INIT,controlled:s,index:o,lifecycle:Je.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?At.READY:At.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===At.WAITING&&e.size>0?{...e,status:At.RUNNING}:e}getStep(e){return Vv(this.props,this.steps[e??this.state.index])}};function Xle(e){return new Jle(e)}function uE(e,t){return Math.min(Math.max(e,0),t)}function Qle(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(b=null)=>{const{index:g,status:k}=o();k===At.RUNNING&&e.current.updateState({action:Dt.CLOSE,index:g+1,origin:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){dr(r.current,"tour","go() is not supported in controlled mode");return}x===At.RUNNING&&e.current.updateState({action:Dt.GO,index:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:At.FINISHED,waiting:!1})},info:()=>Lm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===At.RUNNING&&e.current.updateState({action:Dt.NEXT,index:uE(g+1,k),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===At.RUNNING&&e.current.updateState({action:Dt.UPDATE,lifecycle:Je.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===At.RUNNING&&e.current.updateState({action:Dt.PREV,index:uE(g-1,k),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){dr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Dt.RESET,index:0,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:b?At.RUNNING:At.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===At.RUNNING&&e.current.updateState({action:Dt.SKIP,lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:At.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:Dt.START,index:Pr.number(b)?b:g,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:k?At.RUNNING:At.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[At.FINISHED,At.SKIPPED].includes(k)||e.current.updateState({action:Dt.STOP,index:g+(b?1:0),lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:At.PAUSED,waiting:!1})}}},[e])}const Zle=new Set(["origin","positioned"]);function ece(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return dr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const o=n.current;if(n.current=s,!o)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==o[c]&&!Zle.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||dr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function tce(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.useCallback((o,a,l)=>{var u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(u=r.current)==null||u.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Do(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 nce(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:u,index:d,lifecycle:f,positioned:p,scrolling:h,size:y,status:v}=a,b=ZM(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),j=m.useRef(s),S=m.useRef(l),C=m.useRef(b),P=m.useRef(n),R=m.useRef(null),B=m.useRef(null),A=m.useRef(null);k.current=o,x.current=a,j.current=s,S.current=l,C.current=b,P.current=n;const O=()=>{R.current&&(clearInterval(R.current),R.current=null),B.current=null,A.current&&(A.current.cancel(),A.current=null)};m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D}=Do(x.current,j.current);(D("action",[Dt.NEXT,Dt.PREV,Dt.SKIP,Dt.CLOSE])||g.current===Dt.CLOSE&&u===Dt.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!j.current)return()=>{O()};const{hasChanged:D}=Do(x.current,j.current),L=S.current;if(D("index")&&O(),v!==At.RUNNING||!L||f!==Je.INIT)return()=>{O()};const{hasChangedTo:M}=Do(x.current,j.current);M("status",At.RUNNING)&&[At.IDLE,At.READY,At.PAUSED].includes(j.current.status)&&r(ar.TOUR_START,L),c.current.cleanupPositionData();const{debug:V}=k.current;if(L.before&&!A.current){dr(V,`step:${d}`,"before()",L),A.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(ar.STEP_BEFORE_HOOK,L,{action:g.current??x.current.action});const z=()=>{A.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Je.READY})},F=new AbortController,$=L.beforeTimeout;A.current={cancel:()=>F.abort()};const W=$?setTimeout(()=>{F.signal.aborted||(dr(V,`step:${d}`,"before()","timed out",`${$}ms`),F.abort(),t(L,"before_hook"),r(ar.ERROR,L,{error:new Error("Step before hook timed out")}),z())},$):null;L.before({...c.current.getState(),action:g.current??c.current.getState().action,step:L}).then(()=>{F.signal.aborted||(W&&clearTimeout(W),z())}).catch(E=>{F.signal.aborted||(W&&clearTimeout(W),t(L,"before_hook"),r(ar.ERROR,L,{error:E instanceof Error?E:new Error(String(E))}),z())})}else if(!A.current){R.current&&B.current!==L.target&&O();const z=Ts(L.target);if(z&&eh(z))O(),c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1});else if(L.targetWaitTimeout===0)c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1});else if(!R.current){const{targetWaitTimeout:F}=L,$=Date.now();B.current=L.target,dr(V,`step:${d}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const W=Ts(L.target),E=Date.now()-$,Q=E>=F;(W&&eh(W)||Q)&&(dr(V,`step:${d}`,"polling",W&&eh(W)?"found":"timed out",`${E}ms`),O(),c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1}))},100)}}return()=>{O()}},[t,r,d,f,v,c]),m.useEffect(()=>{if(!j.current)return;const{hasChanged:D,hasChangedTo:L,previous:M}=Do(x.current,j.current),V=S.current;if(!V)return;const z=Ts(V.target),F=!!z;if(F&&eh(z)){if(L("lifecycle",Je.READY)&&M.lifecycle===Je.INIT&&r(ar.STEP_BEFORE,V,{action:g.current??x.current.action}),L("lifecycle",Je.READY)){const $=x.current,W=Gle(V,$,k.current.continuous)?Je.TOOLTIP:Je.BEACON,E=Ts(V.scrollTarget??V.spotlightTarget??V.target),Q=lE({isFirstStep:$.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:V,target:E,targetLifecycle:W}),K=W===Je.TOOLTIP?Je.TOOLTIP_BEFORE:Je.BEACON_BEFORE;dr(k.current.debug,`step:${d}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:Dt.UPDATE,lifecycle:K,scrolling:Q})}}else if(x.current.status===At.RUNNING&&f!==Je.INIT&&f!==Je.COMPLETE&&D("lifecycle")){dr(k.current.debug,`step:${d}`,F?"Target not visible":"Target not mounted",V),t(V,"target_not_found"),r(ar.TARGET_NOT_FOUND,V);const $=x.current;$.controlled||c.current.updateState({action:Dt.UPDATE,index:$.index+($.action===Dt.PREV?-1:1),lifecycle:Je.INIT})}},[t,r,d,f,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:L}=Do(x.current,j.current),M=S.current,V=C.current;if(M&&D("lifecycle",Je.TOOLTIP_BEFORE)&&L.lifecycle===Je.BEACON){const $=Ts(M.scrollTarget??M.spotlightTarget??M.target);if(lE({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:$,targetLifecycle:Je.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const z=f===Je.BEACON_BEFORE||f===Je.TOOLTIP_BEFORE;if(M&&z&&!h){const $=f===Je.TOOLTIP_BEFORE?Je.TOOLTIP:Je.BEACON;c.current.updateState({action:Dt.UPDATE,lifecycle:$})}M&&D("lifecycle",Je.BEACON)&&r(ar.BEACON,M),M&&D("lifecycle",Je.TOOLTIP)&&r(ar.TOOLTIP,M);const F=x.current;if((F.status===At.RUNNING||F.controlled&&F.status===At.PAUSED&&M)&&V&&D("lifecycle",Je.COMPLETE)&&L.lifecycle===Je.TOOLTIP&&(r(ar.STEP_AFTER,V,{action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle}),V.after)){r(ar.STEP_AFTER_HOOK,V,{action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle});try{V.after({...c.current.getState(),action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle,step:V})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:L}=Do(x.current,j.current),M=S.current,V=C.current;y&&!M&&f===Je.INIT&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.COMPLETE,status:At.FINISHED}),!x.current.controlled&&v===At.RUNNING&&D("lifecycle",Je.COMPLETE)&&d<y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.INIT}),D("lifecycle",Je.COMPLETE)&&d>=y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.COMPLETE,status:At.FINISHED});const z=M??V??Vv(k.current,k.current.steps[d-1]);if(z&&D("status",[At.FINISHED,At.SKIPPED])){let F;M?F=d:V?F=L.index??d:F=d-1,r(ar.TOUR_END,z,{index:F}),x.current.controlled||P.current.reset(),g.current=null}M&&D("action",Dt.STOP)&&(g.current=null,r(ar.TOUR_STATUS,M)),M&&D("action",Dt.RESET)&&(r(ar.TOUR_STATUS,M),g.current=null)},[u,r,d,f,y,v,c])}function rce({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,d=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=d.current;if(d.current=n,!h||n===h)return;const{hasChanged:y}=Do(n,h);if(Tv(h.steps,u)||(N$(u,o)?s.current.setSteps(u):(dr(o,"tour","Steps are not valid",u),t(ar.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?s.current.getState().size&&p.current.start(c??a):p.current.stop();else if(Pr.number(c)&&y("stepIndex")){const v=Pr.number(h.stepIndex)&&h.stepIndex<c?Dt.NEXT:Dt.PREV;[At.FINISHED,At.SKIPPED].includes(f.current.status)||s.current.updateState({action:v,index:c,lifecycle:Je.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,s])}function sce(e,t){var l,c,u,d;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===Je.BEACON_BEFORE&&(n!=null&&n.placement)){const f=ice(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Je.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+h;a-=p+y}else if(f==="left"||f==="right"){const p=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((d=Ts(o.target))==null?void 0:d.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+h/2-p/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function ice(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 oce({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:d}=r,f=m.useRef(null),p=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(s);p.current=r,h.current=t,y.current=n,v.current=s,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var S;if(!h.current||!v.current)return;const{hasChangedTo:b}=Do(p.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,j=l===Je.BEACON_BEFORE||l===Je.TOOLTIP_BEFORE;if(d===At.RUNNING&&j&&u&&b("positioned",!0)){const C=Ts(g.scrollTarget??g.spotlightTarget??g.target),P=o.current.getPositionData("beacon"),R=nu(C),B=R?!R.isSameNode(Qr()):!1;(S=f.current)==null||S.call(f),(async()=>{if(B&&!ru(R)){const F=Qr(),$=Hle(R),W={initial:F.scrollTop,target:$,element:F,duration:x};e(ar.SCROLL_START,g,{scroll:W});const{cancel:E,promise:Q}=cE($,{element:F,duration:x});f.current=E,await Q,e(ar.SCROLL_END,g,{scroll:W})}const O=Math.floor(Wle(C,g.scrollOffset))||0,D=B?O:sce(O,{beaconPosition:P,lifecycle:l,scrollOffset:g.scrollOffset,step:g});dr(k,`step:${a}`,"scroll",B?"custom":"document",`${O} → ${D}`);const L=R,M={initial:L.scrollTop,target:D,element:L,duration:x};e(ar.SCROLL_START,g,{scroll:M});const{cancel:V,promise:z}=cE(D,{element:L,duration:x});f.current=V,await z,e(ar.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,d,o])}function ace(e){const t=Woe(()=>Dle($le,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(Xle(t)),u=nR.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=m.useState([]),p=m.useCallback((S,C)=>{f(P=>[...P,{reason:C,step:S}])},[]),h=m.useCallback(()=>{f([])},[]);ece(c,n);const y=Qle(c,n,h),v=tce(s,y,c),{index:b,size:g,status:k}=u,x=ZM(u),j=m.useMemo(()=>Vv(t,l[b]),[b,t,l]);return Voe(()=>{o&&g&&N$(l,n)&&y.start(a??r)}),Hoe(()=>{o&&g&&k===At.IDLE&&c.current.updateState({status:At.READY})},[o,g,k]),rce({controls:y,emitEvent:v,props:t,state:u,store:c}),nce({addFailure:p,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:j,store:c}),oce({emitEvent:v,previousState:x,props:t,state:u,step:j,store:c}),{controls:y,failures:d,mergedProps:t,state:u,step:j,store:c}}function lce(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Pr.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=Lle,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const cce={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function uce({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return uf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
321
- @keyframes joyride-loader-spin {
322
- to { transform: rotate(360deg); }
323
- }
324
- `)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:s,width:o,...a}=t.styles.loader;let l;if(n){const c=n;l=pt.createElement(c,{step:t})}else l=pt.createElement("div",{style:{...cce,height:s,width:o,borderTopColor:t.primaryColor}});return pt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const dce={height:0,isFixed:!1,left:0,top:0,width:0};function qu(e,t){const n=Ts(e);if(!n)return dce;const r=Wv(n),s=ru(n),o=Ble(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 fce(e,t,n){const[r,s]=m.useState(()=>qu(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(f=>{const p=qu(e,t);return f.top===p.top&&f.left===p.left&&f.width===p.width&&f.height===p.height&&f.isFixed===p.isFixed?f:p})},100)},[e,t]);m.useEffect(()=>{let f=null;const p=y=>{a.current=nu(y,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(y)),s(qu(e,t))},h=Ts(e);return h?p(h):(f=new MutationObserver(()=>{const y=Ts(e);y&&(f==null||f.disconnect(),f=null,p(y))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(y=c.current)==null||y.disconnect(),clearTimeout(o.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&s(qu(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=qu(e,t)),d}function pce(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function dE(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 hce=[Je.BEACON_BEFORE,Je.BEACON];function mce(e){var z,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:d,spotlightRadius:f,spotlightTarget:p,styles:h,target:y,waiting:v}=e,b=Koe(),g=fce(p??y,d,u||v),k=m.useRef(null),x=(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE)&&l!=="center",[j,S]=m.useState(!1),C=c?(z=k.current)==null?void 0:z.offsetParent:null,P=(C==null?void 0:C.clientWidth)??b.width,R=(C==null?void 0:C.clientHeight)??zle()??b.height,B=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",A=m.useMemo(()=>{const{backgroundColor:$,mixBlendMode:W,...E}=h.overlay;return{height:R,pointerEvents:"none",...E}},[R,h.overlay]),O=x&&!u&&!v;m.useEffect(()=>{O?requestAnimationFrame(()=>S(!0)):S(!1)},[O]);const D=n&&hce.includes(s),L=!n&&s!==Je.TOOLTIP;if(r||!v&&(D||L))return null;let M="";if(O)if(c&&C){const $=Ts(p??y);if($){const W=aE($),E=aE(C);M=dE(W.left-E.left-d.left,W.top-E.top-d.top,$.offsetWidth+d.left+d.right,$.offsetHeight+d.top+d.bottom,f)}}else M=dE(g.left,g.top,g.width,g.height,f);const V=pce(P,R,M);return pt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:A},pt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:R,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:P}},pt.createElement("path",{d:V,fill:B,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&pt.createElement("path",{d:M,fill:B,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&pt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function C$(e){const{children:t,element:n}=e;return n?lr.createPortal(t,n):null}const gce='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function yce(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return uf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(gce)],{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 so(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 wce(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...so(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...so(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...so(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...so(e,t,n)};default:return null}}function xce(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...so(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...so(e,r,n)};case"left":return{right:-n,top:t.y??0,...so(e,r,n)};case"right":return{left:-n,top:t.y??0,...so(e,r,n)};default:return{}}}function bce({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!so(r,n,o))return null;c=pt.createElement("span",{style:{flexShrink:0}},pt.createElement(l,{base:n,placement:r,size:o}))}else{const u=wce(r,n,o);if(!u)return null;c=pt.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},pt.createElement("polygon",{fill:"currentColor",points:u.points}))}return pt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...xce(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function kce(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:d,styles:f}=e,p=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return uf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
325
- @keyframes joyride-beacon-inner {
326
- 20% {
327
- opacity: 0.9;
328
- }
329
-
330
- 90% {
331
- opacity: 0.7;
332
- }
333
- }
334
-
335
- @keyframes joyride-beacon-outer {
336
- 0% {
337
- transform: scale(1);
338
- }
339
-
340
- 45% {
341
- opacity: 0.7;
342
- transform: scale(0.75);
343
- }
344
-
345
- 100% {
346
- opacity: 0.9;
347
- transform: scale(1);
348
- }
349
- }
350
- `)),document.head.appendChild(b);const g=setTimeout(()=>{Pr.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=Zi(o.open);let v;if(t){const b=t;v=pt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=pt.createElement("span",{style:f.beacon},pt.createElement("span",{style:f.beaconOuter}),pt.createElement("span",{style:f.beaconInner}));return pt.createElement("button",{ref:p,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function vce({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return pt.createElement("button",{style:o,type:"button",...t},pt.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"},pt.createElement("g",null,pt.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 Sce(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=pt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=pt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=pt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&pt.createElement(vce,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Zi(d),"aria-describedby":"joyride-tooltip-content"};return pt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},pt.createElement("div",{style:f.tooltipContainer},p&&pt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),pt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&pt.createElement("div",{style:f.tooltipFooter},pt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function jce(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Si.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Si.BUTTON_CLOSE):n.close(Si.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Si.BUTTON_PRIMARY);return}n.next(Si.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(Si.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:j,nextWithProgress:S,skip:C}=a.locale,P=Zi(g),R=Zi(k),B=Zi(x),A=Zi(j),O=Zi(C);let D=k,L=R;if(t){if(D=j,L=A,a.showProgress&&!s){const M=Zi(S,{step:r+1,steps:o});D=Db(S,r+1,o),L=M}s&&(D=x,L=B)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:l,role:"button",title:P},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":L,children:D,"data-action":"primary",onClick:u,role:"button",title:L},skipProps:{"aria-label":O,children:C,"data-action":"skip",onClick:d,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=pt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=pt.createElement(Sce,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Nce(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Cce(e,t,n){var r,s;return e?[Ple()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Ale({crossAxis:!1,fallbackPlacements:Nce(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function _ce(e){var W,E,Q,K,H;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:d,size:f,step:p,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=p.placement==="center",x=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),S=m.useMemo(()=>v$(h)?nu(h):void 0,[h]),C=m.useMemo(()=>ru(h),[h]),P=m.useMemo(()=>S?{boundary:S,rootBoundary:"viewport"}:{},[S]),R=k||x?"bottom":p.placement,B=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),A=m.useMemo(()=>{var ee,ue,G,te;return k?[{name:"center",fn:({rects:se})=>({x:(window.innerWidth-se.floating.width)/2,y:(window.innerHeight-se.floating.height)/2})}]:[sE(({placement:se})=>{var ce;let ie="right";se.startsWith("top")?ie="top":se.startsWith("bottom")?ie="bottom":se.startsWith("left")&&(ie="left");const Z=p.spotlightTarget?0:p.spotlightPadding[ie];return p.offset+Z+((ce=p.floatingOptions)!=null&&ce.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(ee=p.floatingOptions)==null?void 0:ee.hideArrow]),...Cce(x,p,R),Ele({padding:10,...P,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[Ile({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((te=p.floatingOptions)==null?void 0:te.middleware)??[]]},[k,p,x,R,P]),O=rE({...k?{elements:{reference:j}}:{},placement:R,strategy:B,middleware:A}),D=rE({strategy:B,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:m.useMemo(()=>{var ee,ue;return[sE(((ue=(ee=p.floatingOptions)==null?void 0:ee.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:eE});g.current=O.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:ee,reference:ue}=O.elements;if(!(!ue||!ee||s!==Je.TOOLTIP))return eE(ue,ee,O.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,O.update,(K=p.floatingOptions)==null?void 0:K.autoUpdate,p.target,O.elements]),m.useEffect(()=>{!k&&h&&O.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,O.refs]),m.useEffect(()=>{O.isPositioned&&c("tooltip",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:g.current})},[c,O.isPositioned,O.placement,O.x,O.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const L=p.zIndex+100,M=m.useCallback(ee=>{ee.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Je.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),V=m.useCallback(ee=>{ee&&(O.refs.setFloating(ee),u(ee))},[O.refs,u]),{arrow:z,floater:F}=p.styles;let $=null;if(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE){const ee=oE({...F,...O.floatingStyles,zIndex:L,opacity:a&&O.isPositioned?1:0,...!a&&{transition:"none"}});$=pt.createElement("div",{ref:V,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:ee},pt.createElement(jce,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((H=p.floatingOptions)!=null&&H.hideArrow)&&pt.createElement(bce,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:p.arrowSize,styles:z}))}else(s===Je.BEACON||s===Je.BEACON_BEFORE)&&($=pt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:oE({...D.floatingStyles,zIndex:L})},pt.createElement(kce,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:o,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return pt.createElement(C$,{element:l},$)}function Ece(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,h]=m.useState(null);yce(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Ts(d.target),v=s===Je.TOOLTIP;return!j$(d)||!Pr.domElement(y)?null:pt.createElement(_ce,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function Ace({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=lce(c),{index:f,lifecycle:p,status:h}=n,y=h===At.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const S=C=>{!r||p!==Je.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Si.KEYBOARD):e.close(Si.KEYBOARD))};return document.body.addEventListener("keydown",S,{passive:!0}),()=>{document.body.removeEventListener("keydown",S)}},[e,y,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Si.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Si.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const j=n.action===Dt.START&&!r.skipBeacon&&r.placement!=="center";return pt.createElement(pt.Fragment,null,p!==Je.INIT&&pt.createElement(Ece,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),pt.createElement(C$,{element:d},pt.createElement(pt.Fragment,null,v&&pt.createElement(uce,{nonce:l,step:r}),!j&&pt.createElement(mce,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Pce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=ace(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Lm(s,"positioned"),[s]),step:o,Tour:Hv()?pt.createElement(Ace,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function Ice(e){const{Tour:t}=Pce(e);return t}function Rce(e){return Hv()?pt.createElement(Ice,e):null}function Tce(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 Mce(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function $ce(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const nh="af:onboarding";function Lce({page:e,hasNodes:t=!1}){const{t:n}=Vr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Tce(n):t?Mce(n):$ce(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(nh),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(nh,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(nh)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(nh,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(Rce,{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})}const Oce="agentflow:recent-runs:v1",Dce="agentflow:recent-runs:poller",Fce=3e3,zce=8e3,Bce=2e3,fE=5e3,Hce=16e3,pE=[1e4,3e4,6e4];function Wce(e){return pE[Math.min(Math.max(e-1,0),pE.length-1)]}function Vce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Kce(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function qce(){const{navigate:e,path:t}=xs(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let j=!1,S=!1,C=!1,P=null,R=0,B=0,A=0,O=0,D=null,L=0,M=0;const V=Vce(),z=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(Oce):null,$=Ne=>{try{F==null||F.postMessage({...Ne,tabId:V,sentAt:Date.now()})}catch{}},W=()=>{const Ne=Date.now()-Hce;for(const[Ce,We]of z)We<Ne&&z.delete(Ce);l(1+z.size)},E=(Ne="presence")=>{$({type:Ne,visible:!document.hidden})},Q=Ne=>{if(!j&&(Array.isArray(Ne.runs)&&r(Ne.runs),Ne.syncHealth&&typeof Ne.syncHealth=="object")){const Ce=Ne.syncHealth;L=Number(Ce.failureCount)||0,M=Number(Ce.lastSuccessAt)||0,u(Ce)}},K=Ne=>{Q(Ne),$({type:"state",...Ne})},H=()=>{R&&(window.clearTimeout(R),R=0)},ee=Ne=>{H(),!(j||!S||document.hidden)&&(R=window.setTimeout(()=>{R=0,ue()},Math.max(0,Ne)))},ue=async()=>{if(j||!S||document.hidden||D)return;const Ne=new AbortController;D=Ne;let Ce=!1;const We=window.setTimeout(()=>{Ce=!0,Ne.abort()},zce);try{const ct=await fetch("/api/pipeline-recent-runs",{signal:Ne.signal});if(!ct.ok)throw new Error(`HTTP ${ct.status}`);const yt=await ct.json();if(j||!S||document.hidden)return;L=0,M=Date.now();const Re=Array.isArray(yt.runs)?yt.runs:[];K({runs:Re.filter(ot=>ot&&ot.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),ee(Fce)}catch(ct){const yt=Ne.signal.aborted&&!Ce;if(j||!S||document.hidden||yt)return;L+=1,K({syncHealth:{status:"delayed",failureCount:L,lastSuccessAt:M,message:Ce?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ct==null?void 0:ct.message)||ct)}`}}),ee(Wce(L))}finally{window.clearTimeout(We),D===Ne&&(D=null)}},G=()=>{H(),D&&(D.abort(),D=null)},te=()=>{if(G(),P){const Ne=P;P=null,Ne()}S=!1},se=(Ne=Bce)=>{B&&window.clearTimeout(B),!(j||document.hidden||S||C)&&(B=window.setTimeout(()=>{B=0,Z()},Ne))},ie=()=>{j||document.hidden||S||(S=!0,ee(0))},Z=async()=>{var Ne;if(!(j||document.hidden||S||C)){if(!((Ne=navigator.locks)!=null&&Ne.request)){ie();return}C=!0;try{await navigator.locks.request(Dce,{mode:"exclusive",ifAvailable:!0},async Ce=>{if(C=!1,!Ce||j||document.hidden){se();return}S=!0,ee(0),await new Promise(We=>{P=We}),P=null,S=!1})}catch{C=!1}finally{se()}}},ce=()=>{if(!j){if(S){L=0,ee(0);return}$({type:"retry"}),se(0)}};d.current=ce,F&&(F.onmessage=Ne=>{const Ce=Ne.data;if(!(!Ce||Ce.tabId===V)){if(Ce.type==="hello"||Ce.type==="presence"){z.set(Ce.tabId,Date.now()),W(),Ce.type==="hello"&&E();return}if(Ce.type==="bye"){z.delete(Ce.tabId),W(),se(0);return}if(Ce.type==="state"){z.set(Ce.tabId,Date.now()),W(),Q(Ce);return}Ce.type==="retry"&&S&&(L=0,ee(0))}});const de=()=>{E(),document.hidden?te():se(0)},pe=()=>{E("bye"),te()},Me=()=>{E("hello"),se(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",pe),window.addEventListener("pageshow",Me),E("hello"),A=window.setInterval(E,fE),O=window.setInterval(W,fE),se(0),()=>{j=!0,d.current=()=>{},E("bye"),te(),B&&window.clearTimeout(B),A&&window.clearInterval(A),O&&window.clearInterval(O),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",pe),window.removeEventListener("pageshow",Me),F==null||F.close()}},[]);const f=j=>{const S=new URLSearchParams({flowId:j.flowId,flowSource:j.flowSource||"workspace"});e(`/flow?${S.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,h=(p==null?void 0:p.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(j=>!j)};return i.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[s&&i.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&i.jsxs("div",{className:"af-run-indicator__sync",children:[i.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),i.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&i.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",Kce(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:j=>{j.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(j=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(j.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(j),title:`${j.flowId} · ${j.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:j.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:j.runId.slice(0,12)})]},`${j.flowId}:${j.runId}`))]}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const Lw="0.1.134",Uce=6e4,Yce=30*6e4;function Kc(e){return String(e||"").trim().replace(/^v/i,"")}function Gce(e,t){const n=Kc(e),r=Kc(t);return!!(n&&r&&n!==r)}function Jce(e,t){return`agentflow.app-version.snooze:${Kc(e)}:${Kc(t)}`}function Xce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Qce(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=Kc(u.version);if(!Gce(Lw,d)){t(null);return}const f=Jce(Lw,d);if(Xce(f)>Date.now())return;t({clientVersion:Kc(Lw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Uce);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Yce))}catch{}t(null)};return i.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),i.jsxs("div",{className:"af-app-version-notice__copy",children:[i.jsx("strong",{children:"AgentFlow 已更新"}),i.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),i.jsxs("div",{className:"af-app-version-notice__actions",children:[i.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),i.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function _$(e){return e==="/likee-context"||e==="/likee_context"}function Zce(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function eue(){const{navigate:e}=xs();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class tue extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function nue({authUser:e}){const{path:t}=xs();return t==="/projects"||t==="/"?i.jsx(Fl,{authUser:e}):t==="/nodes"?i.jsx(Fl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Fl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Fl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Fl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(hoe,{authUser:e}):t==="/workflows"?i.jsx(boe,{}):t==="/mcps"?i.jsx(noe,{}):t==="/schedules"?i.jsx(ooe,{}):t==="/node-studio"?i.jsx(loe,{}):t==="/flow"?i.jsx(eue,{}):t==="/workspace"?i.jsx($M,{}):t.startsWith("/display")?i.jsx(DM,{}):t==="/settings"?i.jsx(zie,{authUser:e}):t==="/admin/usage"?i.jsx(Yie,{authUser:e}):t==="/admin/teams"?i.jsx(Gie,{authUser:e}):t==="/feedback"?i.jsx(Xie,{authUser:e}):_$(t)?i.jsx(XM,{}):i.jsx(Fl,{})}function rue({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,d]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),d(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),d("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(y){d(String(y.message||y))}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:p,autoComplete:"on",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",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function sue({authUser:e,onLogout:t}){const{path:n}=xs(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(Lce,{page:r?"flow":"projects"}):null,r?null:i.jsx(tF,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(nue,{authUser:e})}),i.jsx(qce,{})]})}function iue(){return i.jsx(tue,{children:i.jsxs(LD,{children:[i.jsx(oue,{}),i.jsx(Qce,{})]})})}function oue(){const{path:e}=xs();return e.startsWith("/display")?i.jsx(DM,{}):_$(e)?i.jsx(XM,{}):Zce(e)?i.jsx($M,{}):i.jsx(rue,{children:({user:t,onLogout:n})=>i.jsx(sue,{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 hE=document.querySelector('link[rel="icon"]');hE&&(hE.href=PP);Ow.createRoot(document.getElementById("root")).render(i.jsx(pt.StrictMode,{children:i.jsx(iue,{})}));