@fieldwangai/agentflow 0.1.137 → 0.1.138

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,590 +0,0 @@
1
- var S2=Object.defineProperty;var j2=(e,t,n)=>t in e?S2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bn=(e,t,n)=>j2(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 Td=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ma(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var NA={exports:{}},Vm={},_A={exports:{}},Ot={};/**
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 bf=Symbol.for("react.element"),N2=Symbol.for("react.portal"),_2=Symbol.for("react.fragment"),C2=Symbol.for("react.strict_mode"),A2=Symbol.for("react.profiler"),E2=Symbol.for("react.provider"),I2=Symbol.for("react.context"),P2=Symbol.for("react.forward_ref"),T2=Symbol.for("react.suspense"),R2=Symbol.for("react.memo"),M2=Symbol.for("react.lazy"),i0=Symbol.iterator;function $2(e){return e===null||typeof e!="object"?null:(e=i0&&e[i0]||e["@@iterator"],typeof e=="function"?e:null)}var CA={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},AA=Object.assign,EA={};function Qc(e,t,n){this.props=e,this.context=t,this.refs=EA,this.updater=n||CA}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 IA(){}IA.prototype=Qc.prototype;function qb(e,t,n){this.props=e,this.context=t,this.refs=EA,this.updater=n||CA}var Ub=qb.prototype=new IA;Ub.constructor=qb;AA(Ub,Qc.prototype);Ub.isPureReactComponent=!0;var o0=Array.isArray,PA=Object.prototype.hasOwnProperty,Gb={current:null},TA={key:!0,ref:!0,__self:!0,__source:!0};function RA(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)PA.call(t,r)&&!TA.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:bf,type:e,key:o,ref:a,props:s,_owner:Gb.current}}function L2(e,t){return{$$typeof:bf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Yb(e){return typeof e=="object"&&e!==null&&e.$$typeof===bf}function O2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var a0=/\/+/g;function by(e,t){return typeof e=="object"&&e!==null&&e.key!=null?O2(""+e.key):t.toString(36)}function uh(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 bf:case N2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+by(a,0):r,o0(s)?(n="",e!=null&&(n=e.replace(a0,"$&/")+"/"),uh(s,t,n,"",function(u){return u})):s!=null&&(Yb(s)&&(s=L2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(a0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",o0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+by(o,l);a+=uh(o,t,n,c,s)}else if(c=$2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+by(o,l++),a+=uh(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 mp(e,t,n){if(e==null)return e;var r=[],s=0;return uh(e,r,"","",function(o){return t.call(n,o,s++)}),r}function D2(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 Vr={current:null},dh={transition:null},F2={ReactCurrentDispatcher:Vr,ReactCurrentBatchConfig:dh,ReactCurrentOwner:Gb};function MA(){throw Error("act(...) is not supported in production builds of React.")}Ot.Children={map:mp,forEach:function(e,t,n){mp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return mp(e,function(){t++}),t},toArray:function(e){return mp(e,function(t){return t})||[]},only:function(e){if(!Yb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ot.Component=Qc;Ot.Fragment=_2;Ot.Profiler=A2;Ot.PureComponent=qb;Ot.StrictMode=C2;Ot.Suspense=T2;Ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F2;Ot.act=MA;Ot.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=AA({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Gb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)PA.call(t,c)&&!TA.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:bf,type:e.type,key:s,ref:o,props:r,_owner:a}};Ot.createContext=function(e){return e={$$typeof:I2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:E2,_context:e},e.Consumer=e};Ot.createElement=RA;Ot.createFactory=function(e){var t=RA.bind(null,e);return t.type=e,t};Ot.createRef=function(){return{current:null}};Ot.forwardRef=function(e){return{$$typeof:P2,render:e}};Ot.isValidElement=Yb;Ot.lazy=function(e){return{$$typeof:M2,_payload:{_status:-1,_result:e},_init:D2}};Ot.memo=function(e,t){return{$$typeof:R2,type:e,compare:t===void 0?null:t}};Ot.startTransition=function(e){var t=dh.transition;dh.transition={};try{e()}finally{dh.transition=t}};Ot.unstable_act=MA;Ot.useCallback=function(e,t){return Vr.current.useCallback(e,t)};Ot.useContext=function(e){return Vr.current.useContext(e)};Ot.useDebugValue=function(){};Ot.useDeferredValue=function(e){return Vr.current.useDeferredValue(e)};Ot.useEffect=function(e,t){return Vr.current.useEffect(e,t)};Ot.useId=function(){return Vr.current.useId()};Ot.useImperativeHandle=function(e,t,n){return Vr.current.useImperativeHandle(e,t,n)};Ot.useInsertionEffect=function(e,t){return Vr.current.useInsertionEffect(e,t)};Ot.useLayoutEffect=function(e,t){return Vr.current.useLayoutEffect(e,t)};Ot.useMemo=function(e,t){return Vr.current.useMemo(e,t)};Ot.useReducer=function(e,t,n){return Vr.current.useReducer(e,t,n)};Ot.useRef=function(e){return Vr.current.useRef(e)};Ot.useState=function(e){return Vr.current.useState(e)};Ot.useSyncExternalStore=function(e,t,n){return Vr.current.useSyncExternalStore(e,t,n)};Ot.useTransition=function(){return Vr.current.useTransition()};Ot.version="18.3.1";_A.exports=Ot;var m=_A.exports;const ft=ma(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 z2=m,W2=Symbol.for("react.element"),B2=Symbol.for("react.fragment"),H2=Object.prototype.hasOwnProperty,V2=z2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,K2={key:!0,ref:!0,__self:!0,__source:!0};function $A(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)H2.call(t,r)&&!K2.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:W2,type:e,key:o,ref:a,props:s,_owner:V2.current}}Vm.Fragment=B2;Vm.jsx=$A;Vm.jsxs=$A;NA.exports=Vm;var i=NA.exports,Vw={},LA={exports:{}},bs={},OA={exports:{}},DA={};/**
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($,H){var A=$.length;$.push(H);e:for(;0<A;){var Q=A-1>>>1,K=$[Q];if(0<s(K,H))$[Q]=H,$[A]=K,A=Q;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var H=$[0],A=$.pop();if(A!==H){$[0]=A;e:for(var Q=0,K=$.length,W=K>>>1;Q<W;){var ne=2*(Q+1)-1,Z=$[ne],G=ne+1,te=$[G];if(0>s(Z,A))G<K&&0>s(te,Z)?($[Q]=te,$[G]=A,Q=G):($[Q]=Z,$[ne]=A,Q=ne);else if(G<K&&0>s(te,A))$[Q]=te,$[G]=A,Q=G;else break e}}return H}function s($,H){var A=$.sortIndex-H.sortIndex;return A!==0?A:$.id-H.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=[],f=1,p=null,d=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 H=n(u);H!==null;){if(H.callback===null)r(u);else if(H.startTime<=$)r(u),H.sortIndex=H.expirationTime,t(c,H);else break;H=n(u)}}function _($){if(v=!1,x($),!y)if(n(c)!==null)y=!0,B(S);else{var H=n(u);H!==null&&F(_,H.startTime-$)}}function S($,H){y=!1,v&&(v=!1,g(T),T=-1),h=!0;var A=d;try{for(x(H),p=n(c);p!==null&&(!(p.expirationTime>H)||$&&!D());){var Q=p.callback;if(typeof Q=="function"){p.callback=null,d=p.priorityLevel;var K=Q(p.expirationTime<=H);H=e.unstable_now(),typeof K=="function"?p.callback=K:p===n(c)&&r(c),x(H)}else r(c);p=n(c)}if(p!==null)var W=!0;else{var ne=n(u);ne!==null&&F(_,ne.startTime-H),W=!1}return W}finally{p=null,d=A,h=!1}}var N=!1,I=null,T=-1,z=5,E=-1;function D(){return!(e.unstable_now()-E<z)}function L(){if(I!==null){var $=e.unstable_now();E=$;var H=!0;try{H=I(!0,$)}finally{H?O():(N=!1,I=null)}}else N=!1}var O;if(typeof k=="function")O=function(){k(L)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,V=M.port2;M.port1.onmessage=L,O=function(){V.postMessage(null)}}else O=function(){b(L,0)};function B($){I=$,N||(N=!0,O())}function F($,H){T=b(function(){$(e.unstable_now())},H)}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,B(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"):z=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(d){case 1:case 2:case 3:var H=3;break;default:H=d}var A=d;d=H;try{return $()}finally{d=A}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,H){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var A=d;d=$;try{return H()}finally{d=A}},e.unstable_scheduleCallback=function($,H,A){var Q=e.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?Q+A:Q):A=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=A+K,$={id:f++,callback:H,priorityLevel:$,startTime:A,expirationTime:K,sortIndex:-1},A>Q?($.sortIndex=A,t(u,$),n(c)===null&&$===n(u)&&(v?(g(T),T=-1):v=!0,F(_,A-Q))):($.sortIndex=K,t(c,$),y||h||(y=!0,B(S))),$},e.unstable_shouldYield=D,e.unstable_wrapCallback=function($){var H=d;return function(){var A=d;d=H;try{return $.apply(this,arguments)}finally{d=A}}}})(DA);OA.exports=DA;var q2=OA.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 U2=m,ws=q2;function Ie(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 FA=new Set,Rd={};function gl(e,t){Rc(e,t),Rc(e+"Capture",t)}function Rc(e,t){for(Rd[e]=t,e=0;e<t.length;e++)FA.add(t[e])}var fo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kw=Object.prototype.hasOwnProperty,G2=/^[: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]*$/,l0={},c0={};function Y2(e){return Kw.call(c0,e)?!0:Kw.call(l0,e)?!1:G2.test(e)?c0[e]=!0:(l0[e]=!0,!1)}function J2(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 X2(e,t,n,r){if(t===null||typeof t>"u"||J2(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 Kr(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 Sr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Sr[e]=new Kr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Sr[t]=new Kr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Sr[e]=new Kr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Sr[e]=new Kr(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){Sr[e]=new Kr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Sr[e]=new Kr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Sr[e]=new Kr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Sr[e]=new Kr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Sr[e]=new Kr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jb=/[\-:]([a-z])/g;function Xb(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Jb,Xb);Sr[t]=new Kr(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Jb,Xb);Sr[t]=new Kr(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Jb,Xb);Sr[t]=new Kr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Sr[e]=new Kr(e,1,!1,e.toLowerCase(),null,!1,!1)});Sr.xlinkHref=new Kr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Sr[e]=new Kr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Qb(e,t,n,r){var s=Sr.hasOwnProperty(t)?Sr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(X2(t,n,s,r)&&(n=null),r||s===null?Y2(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 bo=U2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,gp=Symbol.for("react.element"),tc=Symbol.for("react.portal"),nc=Symbol.for("react.fragment"),Zb=Symbol.for("react.strict_mode"),qw=Symbol.for("react.profiler"),zA=Symbol.for("react.provider"),WA=Symbol.for("react.context"),ek=Symbol.for("react.forward_ref"),Uw=Symbol.for("react.suspense"),Gw=Symbol.for("react.suspense_list"),tk=Symbol.for("react.memo"),Fo=Symbol.for("react.lazy"),BA=Symbol.for("react.offscreen"),u0=Symbol.iterator;function Lu(e){return e===null||typeof e!="object"?null:(e=u0&&e[u0]||e["@@iterator"],typeof e=="function"?e:null)}var zn=Object.assign,ky;function td(e){if(ky===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ky=t&&t[1]||""}return`
34
- `+ky+e}var vy=!1;function Sy(e,t){if(!e||vy)return"";vy=!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{vy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?td(e):""}function Q2(e){switch(e.tag){case 5:return td(e.type);case 16:return td("Lazy");case 13:return td("Suspense");case 19:return td("SuspenseList");case 0:case 2:case 15:return e=Sy(e.type,!1),e;case 11:return e=Sy(e.type.render,!1),e;case 1:return e=Sy(e.type,!0),e;default:return""}}function Yw(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 nc:return"Fragment";case tc:return"Portal";case qw:return"Profiler";case Zb:return"StrictMode";case Uw:return"Suspense";case Gw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case WA:return(e.displayName||"Context")+".Consumer";case zA:return(e._context.displayName||"Context")+".Provider";case ek:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tk:return t=e.displayName||null,t!==null?t:Yw(e.type)||"Memo";case Fo:t=e._payload,e=e._init;try{return Yw(e(t))}catch{}}return null}function Z2(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 Yw(t);case 8:return t===Zb?"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 aa(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function HA(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function eO(e){var t=HA(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 yp(e){e._valueTracker||(e._valueTracker=eO(e))}function VA(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=HA(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Lh(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 Jw(e,t){var n=t.checked;return zn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function d0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=aa(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 KA(e,t){t=t.checked,t!=null&&Qb(e,"checked",t,!1)}function Xw(e,t){KA(e,t);var n=aa(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")?Qw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Qw(e,t.type,aa(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function f0(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 Qw(e,t,n){(t!=="number"||Lh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var nd=Array.isArray;function xc(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=""+aa(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 Zw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ie(91));return zn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function p0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ie(92));if(nd(n)){if(1<n.length)throw Error(Ie(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:aa(n)}}function qA(e,t){var n=aa(t.value),r=aa(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 h0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function UA(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 ex(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?UA(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var wp,GA=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(wp=wp||document.createElement("div"),wp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=wp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Md(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pd={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},tO=["Webkit","ms","Moz","O"];Object.keys(pd).forEach(function(e){tO.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pd[t]=pd[e]})});function YA(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||pd.hasOwnProperty(e)&&pd[e]?(""+t).trim():t+"px"}function JA(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=YA(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var nO=zn({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 tx(e,t){if(t){if(nO[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ie(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ie(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ie(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ie(62))}}function nx(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 rx=null;function nk(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sx=null,bc=null,kc=null;function m0(e){if(e=Sf(e)){if(typeof sx!="function")throw Error(Ie(280));var t=e.stateNode;t&&(t=Ym(t),sx(e.stateNode,e.type,t))}}function XA(e){bc?kc?kc.push(e):kc=[e]:bc=e}function QA(){if(bc){var e=bc,t=kc;if(kc=bc=null,m0(e),t)for(e=0;e<t.length;e++)m0(t[e])}}function ZA(e,t){return e(t)}function eE(){}var jy=!1;function tE(e,t,n){if(jy)return e(t,n);jy=!0;try{return ZA(e,t,n)}finally{jy=!1,(bc!==null||kc!==null)&&(eE(),QA())}}function $d(e,t){var n=e.stateNode;if(n===null)return null;var r=Ym(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(Ie(231,t,typeof n));return n}var ix=!1;if(fo)try{var Ou={};Object.defineProperty(Ou,"passive",{get:function(){ix=!0}}),window.addEventListener("test",Ou,Ou),window.removeEventListener("test",Ou,Ou)}catch{ix=!1}function rO(e,t,n,r,s,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var hd=!1,Oh=null,Dh=!1,ox=null,sO={onError:function(e){hd=!0,Oh=e}};function iO(e,t,n,r,s,o,a,l,c){hd=!1,Oh=null,rO.apply(sO,arguments)}function oO(e,t,n,r,s,o,a,l,c){if(iO.apply(this,arguments),hd){if(hd){var u=Oh;hd=!1,Oh=null}else throw Error(Ie(198));Dh||(Dh=!0,ox=u)}}function yl(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 nE(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 g0(e){if(yl(e)!==e)throw Error(Ie(188))}function aO(e){var t=e.alternate;if(!t){if(t=yl(e),t===null)throw Error(Ie(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 g0(s),e;if(o===r)return g0(s),t;o=o.sibling}throw Error(Ie(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(Ie(189))}}if(n.alternate!==r)throw Error(Ie(190))}if(n.tag!==3)throw Error(Ie(188));return n.stateNode.current===n?e:t}function rE(e){return e=aO(e),e!==null?sE(e):null}function sE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=sE(e);if(t!==null)return t;e=e.sibling}return null}var iE=ws.unstable_scheduleCallback,y0=ws.unstable_cancelCallback,lO=ws.unstable_shouldYield,cO=ws.unstable_requestPaint,Un=ws.unstable_now,uO=ws.unstable_getCurrentPriorityLevel,rk=ws.unstable_ImmediatePriority,oE=ws.unstable_UserBlockingPriority,Fh=ws.unstable_NormalPriority,dO=ws.unstable_LowPriority,aE=ws.unstable_IdlePriority,Km=null,Ti=null;function fO(e){if(Ti&&typeof Ti.onCommitFiberRoot=="function")try{Ti.onCommitFiberRoot(Km,e,void 0,(e.current.flags&128)===128)}catch{}}var li=Math.clz32?Math.clz32:mO,pO=Math.log,hO=Math.LN2;function mO(e){return e>>>=0,e===0?32:31-(pO(e)/hO|0)|0}var xp=64,bp=4194304;function rd(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 zh(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=rd(l):(o&=a,o!==0&&(r=rd(o)))}else a=n&~s,a!==0?r=rd(a):o!==0&&(r=rd(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-li(t),s=1<<n,r|=e[n],t&=~s;return r}function gO(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 yO(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-li(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=gO(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function ax(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function lE(){var e=xp;return xp<<=1,!(xp&4194240)&&(xp=64),e}function Ny(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function kf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-li(t),e[t]=n}function wO(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-li(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function sk(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-li(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var un=0;function cE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var uE,ik,dE,fE,pE,lx=!1,kp=[],Xo=null,Qo=null,Zo=null,Ld=new Map,Od=new Map,Bo=[],xO="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 w0(e,t){switch(e){case"focusin":case"focusout":Xo=null;break;case"dragenter":case"dragleave":Qo=null;break;case"mouseover":case"mouseout":Zo=null;break;case"pointerover":case"pointerout":Ld.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Od.delete(t.pointerId)}}function Du(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=Sf(t),t!==null&&ik(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function bO(e,t,n,r,s){switch(t){case"focusin":return Xo=Du(Xo,e,t,n,r,s),!0;case"dragenter":return Qo=Du(Qo,e,t,n,r,s),!0;case"mouseover":return Zo=Du(Zo,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Ld.set(o,Du(Ld.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Od.set(o,Du(Od.get(o)||null,e,t,n,r,s)),!0}return!1}function hE(e){var t=Wa(e.target);if(t!==null){var n=yl(t);if(n!==null){if(t=n.tag,t===13){if(t=nE(n),t!==null){e.blockedOn=t,pE(e.priority,function(){dE(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function fh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=cx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rx=r,n.target.dispatchEvent(r),rx=null}else return t=Sf(n),t!==null&&ik(t),e.blockedOn=n,!1;t.shift()}return!0}function x0(e,t,n){fh(e)&&n.delete(t)}function kO(){lx=!1,Xo!==null&&fh(Xo)&&(Xo=null),Qo!==null&&fh(Qo)&&(Qo=null),Zo!==null&&fh(Zo)&&(Zo=null),Ld.forEach(x0),Od.forEach(x0)}function Fu(e,t){e.blockedOn===t&&(e.blockedOn=null,lx||(lx=!0,ws.unstable_scheduleCallback(ws.unstable_NormalPriority,kO)))}function Dd(e){function t(s){return Fu(s,e)}if(0<kp.length){Fu(kp[0],e);for(var n=1;n<kp.length;n++){var r=kp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Xo!==null&&Fu(Xo,e),Qo!==null&&Fu(Qo,e),Zo!==null&&Fu(Zo,e),Ld.forEach(t),Od.forEach(t),n=0;n<Bo.length;n++)r=Bo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Bo.length&&(n=Bo[0],n.blockedOn===null);)hE(n),n.blockedOn===null&&Bo.shift()}var vc=bo.ReactCurrentBatchConfig,Wh=!0;function vO(e,t,n,r){var s=un,o=vc.transition;vc.transition=null;try{un=1,ok(e,t,n,r)}finally{un=s,vc.transition=o}}function SO(e,t,n,r){var s=un,o=vc.transition;vc.transition=null;try{un=4,ok(e,t,n,r)}finally{un=s,vc.transition=o}}function ok(e,t,n,r){if(Wh){var s=cx(e,t,n,r);if(s===null)$y(e,t,r,Bh,n),w0(e,r);else if(bO(s,e,t,n,r))r.stopPropagation();else if(w0(e,r),t&4&&-1<xO.indexOf(e)){for(;s!==null;){var o=Sf(s);if(o!==null&&uE(o),o=cx(e,t,n,r),o===null&&$y(e,t,r,Bh,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else $y(e,t,r,null,n)}}var Bh=null;function cx(e,t,n,r){if(Bh=null,e=nk(r),e=Wa(e),e!==null)if(t=yl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=nE(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 Bh=e,null}function mE(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(uO()){case rk:return 1;case oE:return 4;case Fh:case dO:return 16;case aE:return 536870912;default:return 16}default:return 16}}var Uo=null,ak=null,ph=null;function gE(){if(ph)return ph;var e,t=ak,n=t.length,r,s="value"in Uo?Uo.value:Uo.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 ph=s.slice(e,1<r?1-r:void 0)}function hh(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 vp(){return!0}function b0(){return!1}function ks(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)?vp:b0,this.isPropagationStopped=b0,this}return zn(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=vp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=vp)},persist:function(){},isPersistent:vp}),t}var Zc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lk=ks(Zc),vf=zn({},Zc,{view:0,detail:0}),jO=ks(vf),_y,Cy,zu,qm=zn({},vf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ck,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!==zu&&(zu&&e.type==="mousemove"?(_y=e.screenX-zu.screenX,Cy=e.screenY-zu.screenY):Cy=_y=0,zu=e),_y)},movementY:function(e){return"movementY"in e?e.movementY:Cy}}),k0=ks(qm),NO=zn({},qm,{dataTransfer:0}),_O=ks(NO),CO=zn({},vf,{relatedTarget:0}),Ay=ks(CO),AO=zn({},Zc,{animationName:0,elapsedTime:0,pseudoElement:0}),EO=ks(AO),IO=zn({},Zc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),PO=ks(IO),TO=zn({},Zc,{data:0}),v0=ks(TO),RO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},MO={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"},$O={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function LO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=$O[e])?!!t[e]:!1}function ck(){return LO}var OO=zn({},vf,{key:function(e){if(e.key){var t=RO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=hh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?MO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ck,charCode:function(e){return e.type==="keypress"?hh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?hh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),DO=ks(OO),FO=zn({},qm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),S0=ks(FO),zO=zn({},vf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ck}),WO=ks(zO),BO=zn({},Zc,{propertyName:0,elapsedTime:0,pseudoElement:0}),HO=ks(BO),VO=zn({},qm,{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}),KO=ks(VO),qO=[9,13,27,32],uk=fo&&"CompositionEvent"in window,md=null;fo&&"documentMode"in document&&(md=document.documentMode);var UO=fo&&"TextEvent"in window&&!md,yE=fo&&(!uk||md&&8<md&&11>=md),j0=" ",N0=!1;function wE(e,t){switch(e){case"keyup":return qO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rc=!1;function GO(e,t){switch(e){case"compositionend":return xE(t);case"keypress":return t.which!==32?null:(N0=!0,j0);case"textInput":return e=t.data,e===j0&&N0?null:e;default:return null}}function YO(e,t){if(rc)return e==="compositionend"||!uk&&wE(e,t)?(e=gE(),ph=ak=Uo=null,rc=!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 yE&&t.locale!=="ko"?null:t.data;default:return null}}var JO={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 _0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!JO[e.type]:t==="textarea"}function bE(e,t,n,r){XA(r),t=Hh(t,"onChange"),0<t.length&&(n=new lk("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var gd=null,Fd=null;function XO(e){PE(e,0)}function Um(e){var t=oc(e);if(VA(t))return e}function QO(e,t){if(e==="change")return t}var kE=!1;if(fo){var Ey;if(fo){var Iy="oninput"in document;if(!Iy){var C0=document.createElement("div");C0.setAttribute("oninput","return;"),Iy=typeof C0.oninput=="function"}Ey=Iy}else Ey=!1;kE=Ey&&(!document.documentMode||9<document.documentMode)}function A0(){gd&&(gd.detachEvent("onpropertychange",vE),Fd=gd=null)}function vE(e){if(e.propertyName==="value"&&Um(Fd)){var t=[];bE(t,Fd,e,nk(e)),tE(XO,t)}}function ZO(e,t,n){e==="focusin"?(A0(),gd=t,Fd=n,gd.attachEvent("onpropertychange",vE)):e==="focusout"&&A0()}function eD(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Um(Fd)}function tD(e,t){if(e==="click")return Um(t)}function nD(e,t){if(e==="input"||e==="change")return Um(t)}function rD(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var di=typeof Object.is=="function"?Object.is:rD;function zd(e,t){if(di(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(!Kw.call(t,s)||!di(e[s],t[s]))return!1}return!0}function E0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function I0(e,t){var n=E0(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=E0(n)}}function SE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?SE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jE(){for(var e=window,t=Lh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lh(e.document)}return t}function dk(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 sD(e){var t=jE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&SE(n.ownerDocument.documentElement,n)){if(r!==null&&dk(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=I0(n,o);var a=I0(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 iD=fo&&"documentMode"in document&&11>=document.documentMode,sc=null,ux=null,yd=null,dx=!1;function P0(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;dx||sc==null||sc!==Lh(r)||(r=sc,"selectionStart"in r&&dk(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}),yd&&zd(yd,r)||(yd=r,r=Hh(ux,"onSelect"),0<r.length&&(t=new lk("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sc)))}function Sp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ic={animationend:Sp("Animation","AnimationEnd"),animationiteration:Sp("Animation","AnimationIteration"),animationstart:Sp("Animation","AnimationStart"),transitionend:Sp("Transition","TransitionEnd")},Py={},NE={};fo&&(NE=document.createElement("div").style,"AnimationEvent"in window||(delete ic.animationend.animation,delete ic.animationiteration.animation,delete ic.animationstart.animation),"TransitionEvent"in window||delete ic.transitionend.transition);function Gm(e){if(Py[e])return Py[e];if(!ic[e])return e;var t=ic[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in NE)return Py[e]=t[n];return e}var _E=Gm("animationend"),CE=Gm("animationiteration"),AE=Gm("animationstart"),EE=Gm("transitionend"),IE=new Map,T0="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 ga(e,t){IE.set(e,t),gl(t,[e])}for(var Ty=0;Ty<T0.length;Ty++){var Ry=T0[Ty],oD=Ry.toLowerCase(),aD=Ry[0].toUpperCase()+Ry.slice(1);ga(oD,"on"+aD)}ga(_E,"onAnimationEnd");ga(CE,"onAnimationIteration");ga(AE,"onAnimationStart");ga("dblclick","onDoubleClick");ga("focusin","onFocus");ga("focusout","onBlur");ga(EE,"onTransitionEnd");Rc("onMouseEnter",["mouseout","mouseover"]);Rc("onMouseLeave",["mouseout","mouseover"]);Rc("onPointerEnter",["pointerout","pointerover"]);Rc("onPointerLeave",["pointerout","pointerover"]);gl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));gl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));gl("onBeforeInput",["compositionend","keypress","textInput","paste"]);gl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sd="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(" "),lD=new Set("cancel close invalid load scroll toggle".split(" ").concat(sd));function R0(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,oO(r,t,void 0,e),e.currentTarget=null}function PE(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;R0(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;R0(s,l,u),o=c}}}if(Dh)throw e=ox,Dh=!1,ox=null,e}function jn(e,t){var n=t[gx];n===void 0&&(n=t[gx]=new Set);var r=e+"__bubble";n.has(r)||(TE(t,e,2,!1),n.add(r))}function My(e,t,n){var r=0;t&&(r|=4),TE(n,e,r,t)}var jp="_reactListening"+Math.random().toString(36).slice(2);function Wd(e){if(!e[jp]){e[jp]=!0,FA.forEach(function(n){n!=="selectionchange"&&(lD.has(n)||My(n,!1,e),My(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[jp]||(t[jp]=!0,My("selectionchange",!1,t))}}function TE(e,t,n,r){switch(mE(t)){case 1:var s=vO;break;case 4:s=SO;break;default:s=ok}n=s.bind(null,t,n,e),s=void 0,!ix||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 $y(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=Wa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}tE(function(){var u=o,f=nk(n),p=[];e:{var d=IE.get(e);if(d!==void 0){var h=lk,y=e;switch(e){case"keypress":if(hh(n)===0)break e;case"keydown":case"keyup":h=DO;break;case"focusin":y="focus",h=Ay;break;case"focusout":y="blur",h=Ay;break;case"beforeblur":case"afterblur":h=Ay;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=k0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=_O;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=WO;break;case _E:case CE:case AE:h=EO;break;case EE:h=HO;break;case"scroll":h=jO;break;case"wheel":h=KO;break;case"copy":case"cut":case"paste":h=PO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=S0}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var k=u,x;k!==null;){x=k;var _=x.stateNode;if(x.tag===5&&_!==null&&(x=_,g!==null&&(_=$d(k,g),_!=null&&v.push(Bd(k,_,x)))),b)break;k=k.return}0<v.length&&(d=new h(d,y,null,n,f),p.push({event:d,listeners:v}))}}if(!(t&7)){e:{if(d=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",d&&n!==rx&&(y=n.relatedTarget||n.fromElement)&&(Wa(y)||y[po]))break e;if((h||d)&&(d=f.window===f?f:(d=f.ownerDocument)?d.defaultView||d.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?Wa(y):null,y!==null&&(b=yl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=k0,_="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=S0,_="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?d:oc(h),x=y==null?d:oc(y),d=new v(_,k+"leave",h,n,f),d.target=b,d.relatedTarget=x,_=null,Wa(f)===u&&(v=new v(g,k+"enter",y,n,f),v.target=x,v.relatedTarget=b,_=v),b=_,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=Hl(x))k++;for(x=0,_=g;_;_=Hl(_))x++;for(;0<k-x;)v=Hl(v),k--;for(;0<x-k;)g=Hl(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Hl(v),g=Hl(g)}v=null}else v=null;h!==null&&M0(p,d,h,v,!1),y!==null&&b!==null&&M0(p,b,y,v,!0)}}e:{if(d=u?oc(u):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var S=QO;else if(_0(d))if(kE)S=nD;else{S=eD;var N=ZO}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(S=tD);if(S&&(S=S(e,u))){bE(p,S,n,f);break e}N&&N(e,d,u),e==="focusout"&&(N=d._wrapperState)&&N.controlled&&d.type==="number"&&Qw(d,"number",d.value)}switch(N=u?oc(u):window,e){case"focusin":(_0(N)||N.contentEditable==="true")&&(sc=N,ux=u,yd=null);break;case"focusout":yd=ux=sc=null;break;case"mousedown":dx=!0;break;case"contextmenu":case"mouseup":case"dragend":dx=!1,P0(p,n,f);break;case"selectionchange":if(iD)break;case"keydown":case"keyup":P0(p,n,f)}var I;if(uk)e:{switch(e){case"compositionstart":var T="onCompositionStart";break e;case"compositionend":T="onCompositionEnd";break e;case"compositionupdate":T="onCompositionUpdate";break e}T=void 0}else rc?wE(e,n)&&(T="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(T="onCompositionStart");T&&(yE&&n.locale!=="ko"&&(rc||T!=="onCompositionStart"?T==="onCompositionEnd"&&rc&&(I=gE()):(Uo=f,ak="value"in Uo?Uo.value:Uo.textContent,rc=!0)),N=Hh(u,T),0<N.length&&(T=new v0(T,e,null,n,f),p.push({event:T,listeners:N}),I?T.data=I:(I=xE(n),I!==null&&(T.data=I)))),(I=UO?GO(e,n):YO(e,n))&&(u=Hh(u,"onBeforeInput"),0<u.length&&(f=new v0("onBeforeInput","beforeinput",null,n,f),p.push({event:f,listeners:u}),f.data=I))}PE(p,t)})}function Bd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Hh(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(Bd(e,o,s)),o=$d(e,t),o!=null&&r.push(Bd(e,o,s))),e=e.return}return r}function Hl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function M0(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(Bd(n,c,l))):s||(c=$d(n,o),c!=null&&a.push(Bd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var cD=/\r\n?/g,uD=/\u0000|\uFFFD/g;function $0(e){return(typeof e=="string"?e:""+e).replace(cD,`
38
- `).replace(uD,"")}function Np(e,t,n){if(t=$0(t),$0(e)!==t&&n)throw Error(Ie(425))}function Vh(){}var fx=null,px=null;function hx(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 mx=typeof setTimeout=="function"?setTimeout:void 0,dD=typeof clearTimeout=="function"?clearTimeout:void 0,L0=typeof Promise=="function"?Promise:void 0,fD=typeof queueMicrotask=="function"?queueMicrotask:typeof L0<"u"?function(e){return L0.resolve(null).then(e).catch(pD)}:mx;function pD(e){setTimeout(function(){throw e})}function Ly(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),Dd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Dd(t)}function ea(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 O0(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 eu=Math.random().toString(36).slice(2),_i="__reactFiber$"+eu,Hd="__reactProps$"+eu,po="__reactContainer$"+eu,gx="__reactEvents$"+eu,hD="__reactListeners$"+eu,mD="__reactHandles$"+eu;function Wa(e){var t=e[_i];if(t)return t;for(var n=e.parentNode;n;){if(t=n[po]||n[_i]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=O0(e);e!==null;){if(n=e[_i])return n;e=O0(e)}return t}e=n,n=e.parentNode}return null}function Sf(e){return e=e[_i]||e[po],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function oc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ie(33))}function Ym(e){return e[Hd]||null}var yx=[],ac=-1;function ya(e){return{current:e}}function _n(e){0>ac||(e.current=yx[ac],yx[ac]=null,ac--)}function yn(e,t){ac++,yx[ac]=e.current,e.current=t}var la={},Mr=ya(la),ns=ya(!1),el=la;function Mc(e,t){var n=e.type.contextTypes;if(!n)return la;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 rs(e){return e=e.childContextTypes,e!=null}function Kh(){_n(ns),_n(Mr)}function D0(e,t,n){if(Mr.current!==la)throw Error(Ie(168));yn(Mr,t),yn(ns,n)}function RE(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(Ie(108,Z2(e)||"Unknown",s));return zn({},n,r)}function qh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||la,el=Mr.current,yn(Mr,e),yn(ns,ns.current),!0}function F0(e,t,n){var r=e.stateNode;if(!r)throw Error(Ie(169));n?(e=RE(e,t,el),r.__reactInternalMemoizedMergedChildContext=e,_n(ns),_n(Mr),yn(Mr,e)):_n(ns),yn(ns,n)}var eo=null,Jm=!1,Oy=!1;function ME(e){eo===null?eo=[e]:eo.push(e)}function gD(e){Jm=!0,ME(e)}function wa(){if(!Oy&&eo!==null){Oy=!0;var e=0,t=un;try{var n=eo;for(un=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}eo=null,Jm=!1}catch(s){throw eo!==null&&(eo=eo.slice(e+1)),iE(rk,wa),s}finally{un=t,Oy=!1}}return null}var lc=[],cc=0,Uh=null,Gh=0,Rs=[],Ms=0,tl=null,no=1,ro="";function Ma(e,t){lc[cc++]=Gh,lc[cc++]=Uh,Uh=e,Gh=t}function $E(e,t,n){Rs[Ms++]=no,Rs[Ms++]=ro,Rs[Ms++]=tl,tl=e;var r=no;e=ro;var s=32-li(r)-1;r&=~(1<<s),n+=1;var o=32-li(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,no=1<<32-li(t)+s|n<<s|r,ro=o+e}else no=1<<o|n<<s|r,ro=e}function fk(e){e.return!==null&&(Ma(e,1),$E(e,1,0))}function pk(e){for(;e===Uh;)Uh=lc[--cc],lc[cc]=null,Gh=lc[--cc],lc[cc]=null;for(;e===tl;)tl=Rs[--Ms],Rs[Ms]=null,ro=Rs[--Ms],Rs[Ms]=null,no=Rs[--Ms],Rs[Ms]=null}var gs=null,hs=null,In=!1,ri=null;function LE(e,t){var n=Os(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 z0(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,gs=e,hs=ea(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,gs=e,hs=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=tl!==null?{id:no,overflow:ro}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Os(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,gs=e,hs=null,!0):!1;default:return!1}}function wx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function xx(e){if(In){var t=hs;if(t){var n=t;if(!z0(e,t)){if(wx(e))throw Error(Ie(418));t=ea(n.nextSibling);var r=gs;t&&z0(e,t)?LE(r,n):(e.flags=e.flags&-4097|2,In=!1,gs=e)}}else{if(wx(e))throw Error(Ie(418));e.flags=e.flags&-4097|2,In=!1,gs=e}}}function W0(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;gs=e}function _p(e){if(e!==gs)return!1;if(!In)return W0(e),In=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!hx(e.type,e.memoizedProps)),t&&(t=hs)){if(wx(e))throw OE(),Error(Ie(418));for(;t;)LE(e,t),t=ea(t.nextSibling)}if(W0(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ie(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){hs=ea(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}hs=null}}else hs=gs?ea(e.stateNode.nextSibling):null;return!0}function OE(){for(var e=hs;e;)e=ea(e.nextSibling)}function $c(){hs=gs=null,In=!1}function hk(e){ri===null?ri=[e]:ri.push(e)}var yD=bo.ReactCurrentBatchConfig;function Wu(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(Ie(309));var r=n.stateNode}if(!r)throw Error(Ie(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(Ie(284));if(!n._owner)throw Error(Ie(290,e))}return e}function Cp(e,t){throw e=Object.prototype.toString.call(t),Error(Ie(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function B0(e){var t=e._init;return t(e._payload)}function DE(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=sa(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,_){return k===null||k.tag!==6?(k=Vy(x,g.mode,_),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,_){var S=x.type;return S===nc?f(g,k,x.props.children,_,x.key):k!==null&&(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&B0(S)===k.type)?(_=s(k,x.props),_.ref=Wu(g,k,x),_.return=g,_):(_=kh(x.type,x.key,x.props,null,g.mode,_),_.ref=Wu(g,k,x),_.return=g,_)}function u(g,k,x,_){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=Ky(x,g.mode,_),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function f(g,k,x,_,S){return k===null||k.tag!==7?(k=Ga(x,g.mode,_,S),k.return=g,k):(k=s(k,x),k.return=g,k)}function p(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Vy(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case gp:return x=kh(k.type,k.key,k.props,null,g.mode,x),x.ref=Wu(g,null,k),x.return=g,x;case tc:return k=Ky(k,g.mode,x),k.return=g,k;case Fo:var _=k._init;return p(g,_(k._payload),x)}if(nd(k)||Lu(k))return k=Ga(k,g.mode,x,null),k.return=g,k;Cp(g,k)}return null}function d(g,k,x,_){var S=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:l(g,k,""+x,_);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case gp:return x.key===S?c(g,k,x,_):null;case tc:return x.key===S?u(g,k,x,_):null;case Fo:return S=x._init,d(g,k,S(x._payload),_)}if(nd(x)||Lu(x))return S!==null?null:f(g,k,x,_,null);Cp(g,x)}return null}function h(g,k,x,_,S){if(typeof _=="string"&&_!==""||typeof _=="number")return g=g.get(x)||null,l(k,g,""+_,S);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case gp:return g=g.get(_.key===null?x:_.key)||null,c(k,g,_,S);case tc:return g=g.get(_.key===null?x:_.key)||null,u(k,g,_,S);case Fo:var N=_._init;return h(g,k,x,N(_._payload),S)}if(nd(_)||Lu(_))return g=g.get(x)||null,f(k,g,_,S,null);Cp(k,_)}return null}function y(g,k,x,_){for(var S=null,N=null,I=k,T=k=0,z=null;I!==null&&T<x.length;T++){I.index>T?(z=I,I=null):z=I.sibling;var E=d(g,I,x[T],_);if(E===null){I===null&&(I=z);break}e&&I&&E.alternate===null&&t(g,I),k=o(E,k,T),N===null?S=E:N.sibling=E,N=E,I=z}if(T===x.length)return n(g,I),In&&Ma(g,T),S;if(I===null){for(;T<x.length;T++)I=p(g,x[T],_),I!==null&&(k=o(I,k,T),N===null?S=I:N.sibling=I,N=I);return In&&Ma(g,T),S}for(I=r(g,I);T<x.length;T++)z=h(I,g,T,x[T],_),z!==null&&(e&&z.alternate!==null&&I.delete(z.key===null?T:z.key),k=o(z,k,T),N===null?S=z:N.sibling=z,N=z);return e&&I.forEach(function(D){return t(g,D)}),In&&Ma(g,T),S}function v(g,k,x,_){var S=Lu(x);if(typeof S!="function")throw Error(Ie(150));if(x=S.call(x),x==null)throw Error(Ie(151));for(var N=S=null,I=k,T=k=0,z=null,E=x.next();I!==null&&!E.done;T++,E=x.next()){I.index>T?(z=I,I=null):z=I.sibling;var D=d(g,I,E.value,_);if(D===null){I===null&&(I=z);break}e&&I&&D.alternate===null&&t(g,I),k=o(D,k,T),N===null?S=D:N.sibling=D,N=D,I=z}if(E.done)return n(g,I),In&&Ma(g,T),S;if(I===null){for(;!E.done;T++,E=x.next())E=p(g,E.value,_),E!==null&&(k=o(E,k,T),N===null?S=E:N.sibling=E,N=E);return In&&Ma(g,T),S}for(I=r(g,I);!E.done;T++,E=x.next())E=h(I,g,T,E.value,_),E!==null&&(e&&E.alternate!==null&&I.delete(E.key===null?T:E.key),k=o(E,k,T),N===null?S=E:N.sibling=E,N=E);return e&&I.forEach(function(L){return t(g,L)}),In&&Ma(g,T),S}function b(g,k,x,_){if(typeof x=="object"&&x!==null&&x.type===nc&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case gp:e:{for(var S=x.key,N=k;N!==null;){if(N.key===S){if(S=x.type,S===nc){if(N.tag===7){n(g,N.sibling),k=s(N,x.props.children),k.return=g,g=k;break e}}else if(N.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&B0(S)===N.type){n(g,N.sibling),k=s(N,x.props),k.ref=Wu(g,N,x),k.return=g,g=k;break e}n(g,N);break}else t(g,N);N=N.sibling}x.type===nc?(k=Ga(x.props.children,g.mode,_,x.key),k.return=g,g=k):(_=kh(x.type,x.key,x.props,null,g.mode,_),_.ref=Wu(g,k,x),_.return=g,g=_)}return a(g);case tc:e:{for(N=x.key;k!==null;){if(k.key===N)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=Ky(x,g.mode,_),k.return=g,g=k}return a(g);case Fo:return N=x._init,b(g,k,N(x._payload),_)}if(nd(x))return y(g,k,x,_);if(Lu(x))return v(g,k,x,_);Cp(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=Vy(x,g.mode,_),k.return=g,g=k),a(g)):n(g,k)}return b}var Lc=DE(!0),FE=DE(!1),Yh=ya(null),Jh=null,uc=null,mk=null;function gk(){mk=uc=Jh=null}function yk(e){var t=Yh.current;_n(Yh),e._currentValue=t}function bx(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 Sc(e,t){Jh=e,mk=uc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Zr=!0),e.firstContext=null)}function Fs(e){var t=e._currentValue;if(mk!==e)if(e={context:e,memoizedValue:t,next:null},uc===null){if(Jh===null)throw Error(Ie(308));uc=e,Jh.dependencies={lanes:0,firstContext:e}}else uc=uc.next=e;return t}var Ba=null;function wk(e){Ba===null?Ba=[e]:Ba.push(e)}function zE(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,wk(t)):(n.next=s.next,s.next=n),t.interleaved=n,ho(e,r)}function ho(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 zo=!1;function xk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function WE(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 ao(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ta(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Jt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ho(e,n)}return s=r.interleaved,s===null?(t.next=t,wk(r)):(t.next=s.next,s.next=t),r.interleaved=t,ho(e,n)}function mh(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,sk(e,n)}}function H0(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 Xh(e,t,n,r){var s=e.updateQueue;zo=!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 f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==a&&(l===null?f.firstBaseUpdate=u:l.next=u,f.lastBaseUpdate=c))}if(o!==null){var p=s.baseState;a=0,f=u=c=null,l=o;do{var d=l.lane,h=l.eventTime;if((r&d)===d){f!==null&&(f=f.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(d=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){p=y.call(h,p,d);break e}p=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,d=typeof y=="function"?y.call(h,p,d):y,d==null)break e;p=zn({},p,d);break e;case 2:zo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=s.effects,d===null?s.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(u=f=h,c=p):f=f.next=h,a|=d;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;d=l,l=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(f===null&&(c=p),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=f,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);rl|=a,e.lanes=a,e.memoizedState=p}}function V0(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(Ie(191,s));s.call(r)}}}var jf={},Ri=ya(jf),Vd=ya(jf),Kd=ya(jf);function Ha(e){if(e===jf)throw Error(Ie(174));return e}function bk(e,t){switch(yn(Kd,t),yn(Vd,e),yn(Ri,jf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ex(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ex(t,e)}_n(Ri),yn(Ri,t)}function Oc(){_n(Ri),_n(Vd),_n(Kd)}function BE(e){Ha(Kd.current);var t=Ha(Ri.current),n=ex(t,e.type);t!==n&&(yn(Vd,e),yn(Ri,n))}function kk(e){Vd.current===e&&(_n(Ri),_n(Vd))}var On=ya(0);function Qh(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 Dy=[];function vk(){for(var e=0;e<Dy.length;e++)Dy[e]._workInProgressVersionPrimary=null;Dy.length=0}var gh=bo.ReactCurrentDispatcher,Fy=bo.ReactCurrentBatchConfig,nl=0,Fn=null,ar=null,hr=null,Zh=!1,wd=!1,qd=0,wD=0;function Er(){throw Error(Ie(321))}function Sk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!di(e[n],t[n]))return!1;return!0}function jk(e,t,n,r,s,o){if(nl=o,Fn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,gh.current=e===null||e.memoizedState===null?vD:SD,e=n(r,s),wd){o=0;do{if(wd=!1,qd=0,25<=o)throw Error(Ie(301));o+=1,hr=ar=null,t.updateQueue=null,gh.current=jD,e=n(r,s)}while(wd)}if(gh.current=em,t=ar!==null&&ar.next!==null,nl=0,hr=ar=Fn=null,Zh=!1,t)throw Error(Ie(300));return e}function Nk(){var e=qd!==0;return qd=0,e}function vi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return hr===null?Fn.memoizedState=hr=e:hr=hr.next=e,hr}function zs(){if(ar===null){var e=Fn.alternate;e=e!==null?e.memoizedState:null}else e=ar.next;var t=hr===null?Fn.memoizedState:hr.next;if(t!==null)hr=t,ar=e;else{if(e===null)throw Error(Ie(310));ar=e,e={memoizedState:ar.memoizedState,baseState:ar.baseState,baseQueue:ar.baseQueue,queue:ar.queue,next:null},hr===null?Fn.memoizedState=hr=e:hr=hr.next=e}return hr}function Ud(e,t){return typeof t=="function"?t(e):t}function zy(e){var t=zs(),n=t.queue;if(n===null)throw Error(Ie(311));n.lastRenderedReducer=e;var r=ar,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 f=u.lane;if((nl&f)===f)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 p={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=p,a=r):c=c.next=p,Fn.lanes|=f,rl|=f}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,di(r,t.memoizedState)||(Zr=!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,Fn.lanes|=o,rl|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Wy(e){var t=zs(),n=t.queue;if(n===null)throw Error(Ie(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);di(o,t.memoizedState)||(Zr=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function HE(){}function VE(e,t){var n=Fn,r=zs(),s=t(),o=!di(r.memoizedState,s);if(o&&(r.memoizedState=s,Zr=!0),r=r.queue,_k(UE.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||hr!==null&&hr.memoizedState.tag&1){if(n.flags|=2048,Gd(9,qE.bind(null,n,r,s,t),void 0,null),yr===null)throw Error(Ie(349));nl&30||KE(n,t,s)}return s}function KE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Fn.updateQueue,t===null?(t={lastEffect:null,stores:null},Fn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function qE(e,t,n,r){t.value=n,t.getSnapshot=r,GE(t)&&YE(e)}function UE(e,t,n){return n(function(){GE(t)&&YE(e)})}function GE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!di(e,n)}catch{return!0}}function YE(e){var t=ho(e,1);t!==null&&ci(t,e,1,-1)}function K0(e){var t=vi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ud,lastRenderedState:e},t.queue=e,e=e.dispatch=kD.bind(null,Fn,e),[t.memoizedState,e]}function Gd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Fn.updateQueue,t===null?(t={lastEffect:null,stores:null},Fn.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 JE(){return zs().memoizedState}function yh(e,t,n,r){var s=vi();Fn.flags|=e,s.memoizedState=Gd(1|t,n,void 0,r===void 0?null:r)}function Xm(e,t,n,r){var s=zs();r=r===void 0?null:r;var o=void 0;if(ar!==null){var a=ar.memoizedState;if(o=a.destroy,r!==null&&Sk(r,a.deps)){s.memoizedState=Gd(t,n,o,r);return}}Fn.flags|=e,s.memoizedState=Gd(1|t,n,o,r)}function q0(e,t){return yh(8390656,8,e,t)}function _k(e,t){return Xm(2048,8,e,t)}function XE(e,t){return Xm(4,2,e,t)}function QE(e,t){return Xm(4,4,e,t)}function ZE(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 eI(e,t,n){return n=n!=null?n.concat([e]):null,Xm(4,4,ZE.bind(null,t,e),n)}function Ck(){}function tI(e,t){var n=zs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function nI(e,t){var n=zs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function rI(e,t,n){return nl&21?(di(n,t)||(n=lE(),Fn.lanes|=n,rl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Zr=!0),e.memoizedState=n)}function xD(e,t){var n=un;un=n!==0&&4>n?n:4,e(!0);var r=Fy.transition;Fy.transition={};try{e(!1),t()}finally{un=n,Fy.transition=r}}function sI(){return zs().memoizedState}function bD(e,t,n){var r=ra(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},iI(e))oI(t,n);else if(n=zE(e,t,n,r),n!==null){var s=Hr();ci(n,e,r,s),aI(n,t,r)}}function kD(e,t,n){var r=ra(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(iI(e))oI(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,di(l,a)){var c=t.interleaved;c===null?(s.next=s,wk(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=zE(e,t,s,r),n!==null&&(s=Hr(),ci(n,e,r,s),aI(n,t,r))}}function iI(e){var t=e.alternate;return e===Fn||t!==null&&t===Fn}function oI(e,t){wd=Zh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function aI(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sk(e,n)}}var em={readContext:Fs,useCallback:Er,useContext:Er,useEffect:Er,useImperativeHandle:Er,useInsertionEffect:Er,useLayoutEffect:Er,useMemo:Er,useReducer:Er,useRef:Er,useState:Er,useDebugValue:Er,useDeferredValue:Er,useTransition:Er,useMutableSource:Er,useSyncExternalStore:Er,useId:Er,unstable_isNewReconciler:!1},vD={readContext:Fs,useCallback:function(e,t){return vi().memoizedState=[e,t===void 0?null:t],e},useContext:Fs,useEffect:q0,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,yh(4194308,4,ZE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return yh(4194308,4,e,t)},useInsertionEffect:function(e,t){return yh(4,2,e,t)},useMemo:function(e,t){var n=vi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=vi();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=bD.bind(null,Fn,e),[r.memoizedState,e]},useRef:function(e){var t=vi();return e={current:e},t.memoizedState=e},useState:K0,useDebugValue:Ck,useDeferredValue:function(e){return vi().memoizedState=e},useTransition:function(){var e=K0(!1),t=e[0];return e=xD.bind(null,e[1]),vi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Fn,s=vi();if(In){if(n===void 0)throw Error(Ie(407));n=n()}else{if(n=t(),yr===null)throw Error(Ie(349));nl&30||KE(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,q0(UE.bind(null,r,o,e),[e]),r.flags|=2048,Gd(9,qE.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=vi(),t=yr.identifierPrefix;if(In){var n=ro,r=no;n=(r&~(1<<32-li(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=wD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},SD={readContext:Fs,useCallback:tI,useContext:Fs,useEffect:_k,useImperativeHandle:eI,useInsertionEffect:XE,useLayoutEffect:QE,useMemo:nI,useReducer:zy,useRef:JE,useState:function(){return zy(Ud)},useDebugValue:Ck,useDeferredValue:function(e){var t=zs();return rI(t,ar.memoizedState,e)},useTransition:function(){var e=zy(Ud)[0],t=zs().memoizedState;return[e,t]},useMutableSource:HE,useSyncExternalStore:VE,useId:sI,unstable_isNewReconciler:!1},jD={readContext:Fs,useCallback:tI,useContext:Fs,useEffect:_k,useImperativeHandle:eI,useInsertionEffect:XE,useLayoutEffect:QE,useMemo:nI,useReducer:Wy,useRef:JE,useState:function(){return Wy(Ud)},useDebugValue:Ck,useDeferredValue:function(e){var t=zs();return ar===null?t.memoizedState=e:rI(t,ar.memoizedState,e)},useTransition:function(){var e=Wy(Ud)[0],t=zs().memoizedState;return[e,t]},useMutableSource:HE,useSyncExternalStore:VE,useId:sI,unstable_isNewReconciler:!1};function ei(e,t){if(e&&e.defaultProps){t=zn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function kx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:zn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Qm={isMounted:function(e){return(e=e._reactInternals)?yl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Hr(),s=ra(e),o=ao(r,s);o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,s),t!==null&&(ci(t,e,s,r),mh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Hr(),s=ra(e),o=ao(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,s),t!==null&&(ci(t,e,s,r),mh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Hr(),r=ra(e),s=ao(n,r);s.tag=2,t!=null&&(s.callback=t),t=ta(e,s,r),t!==null&&(ci(t,e,r,n),mh(t,e,r))}};function U0(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?!zd(n,r)||!zd(s,o):!0}function lI(e,t,n){var r=!1,s=la,o=t.contextType;return typeof o=="object"&&o!==null?o=Fs(o):(s=rs(t)?el:Mr.current,r=t.contextTypes,o=(r=r!=null)?Mc(e,s):la),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Qm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function G0(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&&Qm.enqueueReplaceState(t,t.state,null)}function vx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},xk(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Fs(o):(o=rs(t)?el:Mr.current,s.context=Mc(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(kx(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&&Qm.enqueueReplaceState(s,s.state,null),Xh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Dc(e,t){try{var n="",r=t;do n+=Q2(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 By(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Sx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var ND=typeof WeakMap=="function"?WeakMap:Map;function cI(e,t,n){n=ao(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){nm||(nm=!0,Rx=r),Sx(e,t)},n}function uI(e,t,n){n=ao(-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(){Sx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Sx(e,t),typeof r!="function"&&(na===null?na=new Set([this]):na.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Y0(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ND;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=FD.bind(null,e,t,n),t.then(e,e))}function J0(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 X0(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=ao(-1,1),t.tag=2,ta(n,t,1))),n.lanes|=1),e)}var _D=bo.ReactCurrentOwner,Zr=!1;function Br(e,t,n,r){t.child=e===null?FE(t,null,n,r):Lc(t,e.child,n,r)}function Q0(e,t,n,r,s){n=n.render;var o=t.ref;return Sc(t,s),r=jk(e,t,n,r,o,s),n=Nk(),e!==null&&!Zr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,mo(e,t,s)):(In&&n&&fk(t),t.flags|=1,Br(e,t,r,s),t.child)}function Z0(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!$k(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,dI(e,t,o,r,s)):(e=kh(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:zd,n(a,r)&&e.ref===t.ref)return mo(e,t,s)}return t.flags|=1,e=sa(o,r),e.ref=t.ref,e.return=t,t.child=e}function dI(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(zd(o,r)&&e.ref===t.ref)if(Zr=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Zr=!0);else return t.lanes=e.lanes,mo(e,t,s)}return jx(e,t,n,r,s)}function fI(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},yn(fc,ds),ds|=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,yn(fc,ds),ds|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,yn(fc,ds),ds|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,yn(fc,ds),ds|=r;return Br(e,t,s,n),t.child}function pI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function jx(e,t,n,r,s){var o=rs(n)?el:Mr.current;return o=Mc(t,o),Sc(t,s),n=jk(e,t,n,r,o,s),r=Nk(),e!==null&&!Zr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,mo(e,t,s)):(In&&r&&fk(t),t.flags|=1,Br(e,t,n,s),t.child)}function eN(e,t,n,r,s){if(rs(n)){var o=!0;qh(t)}else o=!1;if(Sc(t,s),t.stateNode===null)wh(e,t),lI(t,n,r),vx(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=Fs(u):(u=rs(n)?el:Mr.current,u=Mc(t,u));var f=n.getDerivedStateFromProps,p=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&G0(t,a,r,u),zo=!1;var d=t.memoizedState;a.state=d,Xh(t,r,a,s),c=t.memoizedState,l!==r||d!==c||ns.current||zo?(typeof f=="function"&&(kx(t,n,f,r),c=t.memoizedState),(l=zo||U0(t,n,l,r,d,c,u))?(p||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,WE(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:ei(t.type,l),a.props=u,p=t.pendingProps,d=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Fs(c):(c=rs(n)?el:Mr.current,c=Mc(t,c));var h=n.getDerivedStateFromProps;(f=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==p||d!==c)&&G0(t,a,r,c),zo=!1,d=t.memoizedState,a.state=d,Xh(t,r,a,s);var y=t.memoizedState;l!==p||d!==y||ns.current||zo?(typeof h=="function"&&(kx(t,n,h,r),y=t.memoizedState),(u=zo||U0(t,n,u,r,d,y,c)||!1)?(f||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&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===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&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Nx(e,t,n,r,o,s)}function Nx(e,t,n,r,s,o){pI(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&F0(t,n,!1),mo(e,t,o);r=t.stateNode,_D.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Lc(t,e.child,null,o),t.child=Lc(t,null,l,o)):Br(e,t,l,o),t.memoizedState=r.state,s&&F0(t,n,!0),t.child}function hI(e){var t=e.stateNode;t.pendingContext?D0(e,t.pendingContext,t.pendingContext!==t.context):t.context&&D0(e,t.context,!1),bk(e,t.containerInfo)}function tN(e,t,n,r,s){return $c(),hk(s),t.flags|=256,Br(e,t,n,r),t.child}var _x={dehydrated:null,treeContext:null,retryLane:0};function Cx(e){return{baseLanes:e,cachePool:null,transitions:null}}function mI(e,t,n){var r=t.pendingProps,s=On.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),yn(On,s&1),e===null)return xx(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=tg(a,r,0,null),e=Ga(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Cx(n),t.memoizedState=_x,e):Ak(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return CD(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=sa(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=sa(l,o):(o=Ga(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?Cx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=_x,r}return o=e.child,e=o.sibling,r=sa(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 Ak(e,t){return t=tg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ap(e,t,n,r){return r!==null&&hk(r),Lc(t,e.child,null,n),e=Ak(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function CD(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=By(Error(Ie(422))),Ap(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=tg({mode:"visible",children:r.children},s,0,null),o=Ga(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Lc(t,e.child,null,a),t.child.memoizedState=Cx(a),t.memoizedState=_x,o);if(!(t.mode&1))return Ap(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ie(419)),r=By(o,r,void 0),Ap(e,t,a,r)}if(l=(a&e.childLanes)!==0,Zr||l){if(r=yr,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,ho(e,s),ci(r,e,s,-1))}return Mk(),r=By(Error(Ie(421))),Ap(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=zD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,hs=ea(s.nextSibling),gs=t,In=!0,ri=null,e!==null&&(Rs[Ms++]=no,Rs[Ms++]=ro,Rs[Ms++]=tl,no=e.id,ro=e.overflow,tl=t),t=Ak(t,r.children),t.flags|=4096,t)}function nN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),bx(e.return,t,n)}function Hy(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 gI(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Br(e,t,r.children,n),r=On.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&&nN(e,n,t);else if(e.tag===19)nN(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(yn(On,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&&Qh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Hy(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&&Qh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Hy(t,!0,n,null,o);break;case"together":Hy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function mo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),rl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ie(153));if(t.child!==null){for(e=t.child,n=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function AD(e,t,n){switch(t.tag){case 3:hI(t),$c();break;case 5:BE(t);break;case 1:rs(t.type)&&qh(t);break;case 4:bk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;yn(Yh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(yn(On,On.current&1),t.flags|=128,null):n&t.child.childLanes?mI(e,t,n):(yn(On,On.current&1),e=mo(e,t,n),e!==null?e.sibling:null);yn(On,On.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return gI(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),yn(On,On.current),r)break;return null;case 22:case 23:return t.lanes=0,fI(e,t,n)}return mo(e,t,n)}var yI,Ax,wI,xI;yI=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}};Ax=function(){};wI=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Ha(Ri.current);var o=null;switch(n){case"input":s=Jw(e,s),r=Jw(e,r),o=[];break;case"select":s=zn({},s,{value:void 0}),r=zn({},r,{value:void 0}),o=[];break;case"textarea":s=Zw(e,s),r=Zw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Vh)}tx(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"&&(Rd.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"&&(Rd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&jn("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)}};xI=function(e,t,n,r){n!==r&&(t.flags|=4)};function Bu(e,t){if(!In)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 Ir(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 ED(e,t,n){var r=t.pendingProps;switch(pk(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ir(t),null;case 1:return rs(t.type)&&Kh(),Ir(t),null;case 3:return r=t.stateNode,Oc(),_n(ns),_n(Mr),vk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(_p(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ri!==null&&(Lx(ri),ri=null))),Ax(e,t),Ir(t),null;case 5:kk(t);var s=Ha(Kd.current);if(n=t.type,e!==null&&t.stateNode!=null)wI(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ie(166));return Ir(t),null}if(e=Ha(Ri.current),_p(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[_i]=t,r[Hd]=o,e=(t.mode&1)!==0,n){case"dialog":jn("cancel",r),jn("close",r);break;case"iframe":case"object":case"embed":jn("load",r);break;case"video":case"audio":for(s=0;s<sd.length;s++)jn(sd[s],r);break;case"source":jn("error",r);break;case"img":case"image":case"link":jn("error",r),jn("load",r);break;case"details":jn("toggle",r);break;case"input":d0(r,o),jn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},jn("invalid",r);break;case"textarea":p0(r,o),jn("invalid",r)}tx(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&&Np(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Np(r.textContent,l,e),s=["children",""+l]):Rd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&jn("scroll",r)}switch(n){case"input":yp(r),f0(r,o,!0);break;case"textarea":yp(r),h0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Vh)}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=UA(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[_i]=t,e[Hd]=r,yI(e,t,!1,!1),t.stateNode=e;e:{switch(a=nx(n,r),n){case"dialog":jn("cancel",e),jn("close",e),s=r;break;case"iframe":case"object":case"embed":jn("load",e),s=r;break;case"video":case"audio":for(s=0;s<sd.length;s++)jn(sd[s],e);s=r;break;case"source":jn("error",e),s=r;break;case"img":case"image":case"link":jn("error",e),jn("load",e),s=r;break;case"details":jn("toggle",e),s=r;break;case"input":d0(e,r),s=Jw(e,r),jn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=zn({},r,{value:void 0}),jn("invalid",e);break;case"textarea":p0(e,r),s=Zw(e,r),jn("invalid",e);break;default:s=r}tx(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?JA(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&GA(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Md(e,c):typeof c=="number"&&Md(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Rd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&jn("scroll",e):c!=null&&Qb(e,o,c,a))}switch(n){case"input":yp(e),f0(e,r,!1);break;case"textarea":yp(e),h0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+aa(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?xc(e,!!r.multiple,o,!1):r.defaultValue!=null&&xc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Vh)}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 Ir(t),null;case 6:if(e&&t.stateNode!=null)xI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ie(166));if(n=Ha(Kd.current),Ha(Ri.current),_p(t)){if(r=t.stateNode,n=t.memoizedProps,r[_i]=t,(o=r.nodeValue!==n)&&(e=gs,e!==null))switch(e.tag){case 3:Np(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Np(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[_i]=t,t.stateNode=r}return Ir(t),null;case 13:if(_n(On),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(In&&hs!==null&&t.mode&1&&!(t.flags&128))OE(),$c(),t.flags|=98560,o=!1;else if(o=_p(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ie(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ie(317));o[_i]=t}else $c(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ir(t),o=!1}else ri!==null&&(Lx(ri),ri=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||On.current&1?lr===0&&(lr=3):Mk())),t.updateQueue!==null&&(t.flags|=4),Ir(t),null);case 4:return Oc(),Ax(e,t),e===null&&Wd(t.stateNode.containerInfo),Ir(t),null;case 10:return yk(t.type._context),Ir(t),null;case 17:return rs(t.type)&&Kh(),Ir(t),null;case 19:if(_n(On),o=t.memoizedState,o===null)return Ir(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Bu(o,!1);else{if(lr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Qh(e),a!==null){for(t.flags|=128,Bu(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 yn(On,On.current&1|2),t.child}e=e.sibling}o.tail!==null&&Un()>Fc&&(t.flags|=128,r=!0,Bu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Qh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Bu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!In)return Ir(t),null}else 2*Un()-o.renderingStartTime>Fc&&n!==1073741824&&(t.flags|=128,r=!0,Bu(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=Un(),t.sibling=null,n=On.current,yn(On,r?n&1|2:n&1),t):(Ir(t),null);case 22:case 23:return Rk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ds&1073741824&&(Ir(t),t.subtreeFlags&6&&(t.flags|=8192)):Ir(t),null;case 24:return null;case 25:return null}throw Error(Ie(156,t.tag))}function ID(e,t){switch(pk(t),t.tag){case 1:return rs(t.type)&&Kh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Oc(),_n(ns),_n(Mr),vk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kk(t),null;case 13:if(_n(On),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ie(340));$c()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _n(On),null;case 4:return Oc(),null;case 10:return yk(t.type._context),null;case 22:case 23:return Rk(),null;case 24:return null;default:return null}}var Ep=!1,Pr=!1,PD=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function dc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Hn(e,t,r)}else n.current=null}function Ex(e,t,n){try{n()}catch(r){Hn(e,t,r)}}var rN=!1;function TD(e,t){if(fx=Wh,e=jE(),dk(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,f=0,p=e,d=null;t:for(;;){for(var h;p!==n||s!==0&&p.nodeType!==3||(l=a+s),p!==o||r!==0&&p.nodeType!==3||(c=a+r),p.nodeType===3&&(a+=p.nodeValue.length),(h=p.firstChild)!==null;)d=p,p=h;for(;;){if(p===e)break t;if(d===n&&++u===s&&(l=a),d===o&&++f===r&&(c=a),(h=p.nextSibling)!==null)break;p=d,d=p.parentNode}p=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(px={focusedElem:e,selectionRange:n},Wh=!1,Qe=t;Qe!==null;)if(t=Qe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Qe=e;else for(;Qe!==null;){t=Qe;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:ei(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(Ie(163))}}catch(_){Hn(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,Qe=e;break}Qe=t.return}return y=rN,rN=!1,y}function xd(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&&Ex(t,n,o)}s=s.next}while(s!==r)}}function Zm(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 Ix(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 bI(e){var t=e.alternate;t!==null&&(e.alternate=null,bI(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_i],delete t[Hd],delete t[gx],delete t[hD],delete t[mD])),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 kI(e){return e.tag===5||e.tag===3||e.tag===4}function sN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kI(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 Px(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=Vh));else if(r!==4&&(e=e.child,e!==null))for(Px(e,t,n),e=e.sibling;e!==null;)Px(e,t,n),e=e.sibling}function Tx(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(Tx(e,t,n),e=e.sibling;e!==null;)Tx(e,t,n),e=e.sibling}var kr=null,ti=!1;function To(e,t,n){for(n=n.child;n!==null;)vI(e,t,n),n=n.sibling}function vI(e,t,n){if(Ti&&typeof Ti.onCommitFiberUnmount=="function")try{Ti.onCommitFiberUnmount(Km,n)}catch{}switch(n.tag){case 5:Pr||dc(n,t);case 6:var r=kr,s=ti;kr=null,To(e,t,n),kr=r,ti=s,kr!==null&&(ti?(e=kr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):kr.removeChild(n.stateNode));break;case 18:kr!==null&&(ti?(e=kr,n=n.stateNode,e.nodeType===8?Ly(e.parentNode,n):e.nodeType===1&&Ly(e,n),Dd(e)):Ly(kr,n.stateNode));break;case 4:r=kr,s=ti,kr=n.stateNode.containerInfo,ti=!0,To(e,t,n),kr=r,ti=s;break;case 0:case 11:case 14:case 15:if(!Pr&&(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)&&Ex(n,t,a),s=s.next}while(s!==r)}To(e,t,n);break;case 1:if(!Pr&&(dc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Hn(n,t,l)}To(e,t,n);break;case 21:To(e,t,n);break;case 22:n.mode&1?(Pr=(r=Pr)||n.memoizedState!==null,To(e,t,n),Pr=r):To(e,t,n);break;default:To(e,t,n)}}function iN(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new PD),t.forEach(function(r){var s=WD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Xs(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:kr=l.stateNode,ti=!1;break e;case 3:kr=l.stateNode.containerInfo,ti=!0;break e;case 4:kr=l.stateNode.containerInfo,ti=!0;break e}l=l.return}if(kr===null)throw Error(Ie(160));vI(o,a,s),kr=null,ti=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Hn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)SI(t,e),t=t.sibling}function SI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Xs(t,e),xi(e),r&4){try{xd(3,e,e.return),Zm(3,e)}catch(v){Hn(e,e.return,v)}try{xd(5,e,e.return)}catch(v){Hn(e,e.return,v)}}break;case 1:Xs(t,e),xi(e),r&512&&n!==null&&dc(n,n.return);break;case 5:if(Xs(t,e),xi(e),r&512&&n!==null&&dc(n,n.return),e.flags&32){var s=e.stateNode;try{Md(s,"")}catch(v){Hn(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&&KA(s,o),nx(l,a);var u=nx(l,o);for(a=0;a<c.length;a+=2){var f=c[a],p=c[a+1];f==="style"?JA(s,p):f==="dangerouslySetInnerHTML"?GA(s,p):f==="children"?Md(s,p):Qb(s,f,p,u)}switch(l){case"input":Xw(s,o);break;case"textarea":qA(s,o);break;case"select":var d=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?xc(s,!!o.multiple,h,!1):d!==!!o.multiple&&(o.defaultValue!=null?xc(s,!!o.multiple,o.defaultValue,!0):xc(s,!!o.multiple,o.multiple?[]:"",!1))}s[Hd]=o}catch(v){Hn(e,e.return,v)}}break;case 6:if(Xs(t,e),xi(e),r&4){if(e.stateNode===null)throw Error(Ie(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){Hn(e,e.return,v)}}break;case 3:if(Xs(t,e),xi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Dd(t.containerInfo)}catch(v){Hn(e,e.return,v)}break;case 4:Xs(t,e),xi(e);break;case 13:Xs(t,e),xi(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(Pk=Un())),r&4&&iN(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Pr=(u=Pr)||f,Xs(t,e),Pr=u):Xs(t,e),xi(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(Qe=e,f=e.child;f!==null;){for(p=Qe=f;Qe!==null;){switch(d=Qe,h=d.child,d.tag){case 0:case 11:case 14:case 15:xd(4,d,d.return);break;case 1:dc(d,d.return);var y=d.stateNode;if(typeof y.componentWillUnmount=="function"){r=d,n=d.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Hn(r,n,v)}}break;case 5:dc(d,d.return);break;case 22:if(d.memoizedState!==null){aN(p);continue}}h!==null?(h.return=d,Qe=h):aN(p)}f=f.sibling}e:for(f=null,p=e;;){if(p.tag===5){if(f===null){f=p;try{s=p.stateNode,u?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=p.stateNode,c=p.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=YA("display",a))}catch(v){Hn(e,e.return,v)}}}else if(p.tag===6){if(f===null)try{p.stateNode.nodeValue=u?"":p.memoizedProps}catch(v){Hn(e,e.return,v)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;f===p&&(f=null),p=p.return}f===p&&(f=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Xs(t,e),xi(e),r&4&&iN(e);break;case 21:break;default:Xs(t,e),xi(e)}}function xi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(kI(n)){var r=n;break e}n=n.return}throw Error(Ie(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Md(s,""),r.flags&=-33);var o=sN(e);Tx(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=sN(e);Px(e,l,a);break;default:throw Error(Ie(161))}}catch(c){Hn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function RD(e,t,n){Qe=e,jI(e)}function jI(e,t,n){for(var r=(e.mode&1)!==0;Qe!==null;){var s=Qe,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Ep;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Pr;l=Ep;var u=Pr;if(Ep=a,(Pr=c)&&!u)for(Qe=s;Qe!==null;)a=Qe,c=a.child,a.tag===22&&a.memoizedState!==null?lN(s):c!==null?(c.return=a,Qe=c):lN(s);for(;o!==null;)Qe=o,jI(o),o=o.sibling;Qe=s,Ep=l,Pr=u}oN(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Qe=o):oN(e)}}function oN(e){for(;Qe!==null;){var t=Qe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Pr||Zm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Pr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:ei(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&V0(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}V0(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 f=u.memoizedState;if(f!==null){var p=f.dehydrated;p!==null&&Dd(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ie(163))}Pr||t.flags&512&&Ix(t)}catch(d){Hn(t,t.return,d)}}if(t===e){Qe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Qe=n;break}Qe=t.return}}function aN(e){for(;Qe!==null;){var t=Qe;if(t===e){Qe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Qe=n;break}Qe=t.return}}function lN(e){for(;Qe!==null;){var t=Qe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Zm(4,t)}catch(c){Hn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Hn(t,s,c)}}var o=t.return;try{Ix(t)}catch(c){Hn(t,o,c)}break;case 5:var a=t.return;try{Ix(t)}catch(c){Hn(t,a,c)}}}catch(c){Hn(t,t.return,c)}if(t===e){Qe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Qe=l;break}Qe=t.return}}var MD=Math.ceil,tm=bo.ReactCurrentDispatcher,Ek=bo.ReactCurrentOwner,Ds=bo.ReactCurrentBatchConfig,Jt=0,yr=null,Zn=null,vr=0,ds=0,fc=ya(0),lr=0,Yd=null,rl=0,eg=0,Ik=0,bd=null,Xr=null,Pk=0,Fc=1/0,Zi=null,nm=!1,Rx=null,na=null,Ip=!1,Go=null,rm=0,kd=0,Mx=null,xh=-1,bh=0;function Hr(){return Jt&6?Un():xh!==-1?xh:xh=Un()}function ra(e){return e.mode&1?Jt&2&&vr!==0?vr&-vr:yD.transition!==null?(bh===0&&(bh=lE()),bh):(e=un,e!==0||(e=window.event,e=e===void 0?16:mE(e.type)),e):1}function ci(e,t,n,r){if(50<kd)throw kd=0,Mx=null,Error(Ie(185));kf(e,n,r),(!(Jt&2)||e!==yr)&&(e===yr&&(!(Jt&2)&&(eg|=n),lr===4&&Ho(e,vr)),ss(e,r),n===1&&Jt===0&&!(t.mode&1)&&(Fc=Un()+500,Jm&&wa()))}function ss(e,t){var n=e.callbackNode;yO(e,t);var r=zh(e,e===yr?vr:0);if(r===0)n!==null&&y0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&y0(n),t===1)e.tag===0?gD(cN.bind(null,e)):ME(cN.bind(null,e)),fD(function(){!(Jt&6)&&wa()}),n=null;else{switch(cE(r)){case 1:n=rk;break;case 4:n=oE;break;case 16:n=Fh;break;case 536870912:n=aE;break;default:n=Fh}n=TI(n,NI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function NI(e,t){if(xh=-1,bh=0,Jt&6)throw Error(Ie(327));var n=e.callbackNode;if(jc()&&e.callbackNode!==n)return null;var r=zh(e,e===yr?vr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=sm(e,r);else{t=r;var s=Jt;Jt|=2;var o=CI();(yr!==e||vr!==t)&&(Zi=null,Fc=Un()+500,Ua(e,t));do try{OD();break}catch(l){_I(e,l)}while(!0);gk(),tm.current=o,Jt=s,Zn!==null?t=0:(yr=null,vr=0,t=lr)}if(t!==0){if(t===2&&(s=ax(e),s!==0&&(r=s,t=$x(e,s))),t===1)throw n=Yd,Ua(e,0),Ho(e,r),ss(e,Un()),n;if(t===6)Ho(e,r);else{if(s=e.current.alternate,!(r&30)&&!$D(s)&&(t=sm(e,r),t===2&&(o=ax(e),o!==0&&(r=o,t=$x(e,o))),t===1))throw n=Yd,Ua(e,0),Ho(e,r),ss(e,Un()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ie(345));case 2:$a(e,Xr,Zi);break;case 3:if(Ho(e,r),(r&130023424)===r&&(t=Pk+500-Un(),10<t)){if(zh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Hr(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=mx($a.bind(null,e,Xr,Zi),t);break}$a(e,Xr,Zi);break;case 4:if(Ho(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-li(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Un()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*MD(r/1960))-r,10<r){e.timeoutHandle=mx($a.bind(null,e,Xr,Zi),r);break}$a(e,Xr,Zi);break;case 5:$a(e,Xr,Zi);break;default:throw Error(Ie(329))}}}return ss(e,Un()),e.callbackNode===n?NI.bind(null,e):null}function $x(e,t){var n=bd;return e.current.memoizedState.isDehydrated&&(Ua(e,t).flags|=256),e=sm(e,t),e!==2&&(t=Xr,Xr=n,t!==null&&Lx(t)),e}function Lx(e){Xr===null?Xr=e:Xr.push.apply(Xr,e)}function $D(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(!di(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 Ho(e,t){for(t&=~Ik,t&=~eg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-li(t),r=1<<n;e[n]=-1,t&=~r}}function cN(e){if(Jt&6)throw Error(Ie(327));jc();var t=zh(e,0);if(!(t&1))return ss(e,Un()),null;var n=sm(e,t);if(e.tag!==0&&n===2){var r=ax(e);r!==0&&(t=r,n=$x(e,r))}if(n===1)throw n=Yd,Ua(e,0),Ho(e,t),ss(e,Un()),n;if(n===6)throw Error(Ie(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,$a(e,Xr,Zi),ss(e,Un()),null}function Tk(e,t){var n=Jt;Jt|=1;try{return e(t)}finally{Jt=n,Jt===0&&(Fc=Un()+500,Jm&&wa())}}function sl(e){Go!==null&&Go.tag===0&&!(Jt&6)&&jc();var t=Jt;Jt|=1;var n=Ds.transition,r=un;try{if(Ds.transition=null,un=1,e)return e()}finally{un=r,Ds.transition=n,Jt=t,!(Jt&6)&&wa()}}function Rk(){ds=fc.current,_n(fc)}function Ua(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,dD(n)),Zn!==null)for(n=Zn.return;n!==null;){var r=n;switch(pk(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Kh();break;case 3:Oc(),_n(ns),_n(Mr),vk();break;case 5:kk(r);break;case 4:Oc();break;case 13:_n(On);break;case 19:_n(On);break;case 10:yk(r.type._context);break;case 22:case 23:Rk()}n=n.return}if(yr=e,Zn=e=sa(e.current,null),vr=ds=t,lr=0,Yd=null,Ik=eg=rl=0,Xr=bd=null,Ba!==null){for(t=0;t<Ba.length;t++)if(n=Ba[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}Ba=null}return e}function _I(e,t){do{var n=Zn;try{if(gk(),gh.current=em,Zh){for(var r=Fn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Zh=!1}if(nl=0,hr=ar=Fn=null,wd=!1,qd=0,Ek.current=null,n===null||n.return===null){lr=1,Yd=t,Zn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=vr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,f=l,p=f.tag;if(!(f.mode&1)&&(p===0||p===11||p===15)){var d=f.alternate;d?(f.updateQueue=d.updateQueue,f.memoizedState=d.memoizedState,f.lanes=d.lanes):(f.updateQueue=null,f.memoizedState=null)}var h=J0(a);if(h!==null){h.flags&=-257,X0(h,a,l,o,t),h.mode&1&&Y0(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)){Y0(o,u,t),Mk();break e}c=Error(Ie(426))}}else if(In&&l.mode&1){var b=J0(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),X0(b,a,l,o,t),hk(Dc(c,l));break e}}o=c=Dc(c,l),lr!==4&&(lr=2),bd===null?bd=[o]:bd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=cI(o,c,t);H0(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"&&(na===null||!na.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var _=uI(o,l,t);H0(o,_);break e}}o=o.return}while(o!==null)}EI(n)}catch(S){t=S,Zn===n&&n!==null&&(Zn=n=n.return);continue}break}while(!0)}function CI(){var e=tm.current;return tm.current=em,e===null?em:e}function Mk(){(lr===0||lr===3||lr===2)&&(lr=4),yr===null||!(rl&268435455)&&!(eg&268435455)||Ho(yr,vr)}function sm(e,t){var n=Jt;Jt|=2;var r=CI();(yr!==e||vr!==t)&&(Zi=null,Ua(e,t));do try{LD();break}catch(s){_I(e,s)}while(!0);if(gk(),Jt=n,tm.current=r,Zn!==null)throw Error(Ie(261));return yr=null,vr=0,lr}function LD(){for(;Zn!==null;)AI(Zn)}function OD(){for(;Zn!==null&&!lO();)AI(Zn)}function AI(e){var t=PI(e.alternate,e,ds);e.memoizedProps=e.pendingProps,t===null?EI(e):Zn=t,Ek.current=null}function EI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ID(n,t),n!==null){n.flags&=32767,Zn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{lr=6,Zn=null;return}}else if(n=ED(n,t,ds),n!==null){Zn=n;return}if(t=t.sibling,t!==null){Zn=t;return}Zn=t=e}while(t!==null);lr===0&&(lr=5)}function $a(e,t,n){var r=un,s=Ds.transition;try{Ds.transition=null,un=1,DD(e,t,n,r)}finally{Ds.transition=s,un=r}return null}function DD(e,t,n,r){do jc();while(Go!==null);if(Jt&6)throw Error(Ie(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(Ie(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(wO(e,o),e===yr&&(Zn=yr=null,vr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ip||(Ip=!0,TI(Fh,function(){return jc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Ds.transition,Ds.transition=null;var a=un;un=1;var l=Jt;Jt|=4,Ek.current=null,TD(e,n),SI(n,e),sD(px),Wh=!!fx,px=fx=null,e.current=n,RD(n),cO(),Jt=l,un=a,Ds.transition=o}else e.current=n;if(Ip&&(Ip=!1,Go=e,rm=s),o=e.pendingLanes,o===0&&(na=null),fO(n.stateNode),ss(e,Un()),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(nm)throw nm=!1,e=Rx,Rx=null,e;return rm&1&&e.tag!==0&&jc(),o=e.pendingLanes,o&1?e===Mx?kd++:(kd=0,Mx=e):kd=0,wa(),null}function jc(){if(Go!==null){var e=cE(rm),t=Ds.transition,n=un;try{if(Ds.transition=null,un=16>e?16:e,Go===null)var r=!1;else{if(e=Go,Go=null,rm=0,Jt&6)throw Error(Ie(331));var s=Jt;for(Jt|=4,Qe=e.current;Qe!==null;){var o=Qe,a=o.child;if(Qe.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Qe=u;Qe!==null;){var f=Qe;switch(f.tag){case 0:case 11:case 15:xd(8,f,o)}var p=f.child;if(p!==null)p.return=f,Qe=p;else for(;Qe!==null;){f=Qe;var d=f.sibling,h=f.return;if(bI(f),f===u){Qe=null;break}if(d!==null){d.return=h,Qe=d;break}Qe=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)}}Qe=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Qe=a;else e:for(;Qe!==null;){if(o=Qe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:xd(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,Qe=g;break e}Qe=o.return}}var k=e.current;for(Qe=k;Qe!==null;){a=Qe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Qe=x;else e:for(a=k;Qe!==null;){if(l=Qe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Zm(9,l)}}catch(S){Hn(l,l.return,S)}if(l===a){Qe=null;break e}var _=l.sibling;if(_!==null){_.return=l.return,Qe=_;break e}Qe=l.return}}if(Jt=s,wa(),Ti&&typeof Ti.onPostCommitFiberRoot=="function")try{Ti.onPostCommitFiberRoot(Km,e)}catch{}r=!0}return r}finally{un=n,Ds.transition=t}}return!1}function uN(e,t,n){t=Dc(n,t),t=cI(e,t,1),e=ta(e,t,1),t=Hr(),e!==null&&(kf(e,1,t),ss(e,t))}function Hn(e,t,n){if(e.tag===3)uN(e,e,n);else for(;t!==null;){if(t.tag===3){uN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(na===null||!na.has(r))){e=Dc(n,e),e=uI(t,e,1),t=ta(t,e,1),e=Hr(),t!==null&&(kf(t,1,e),ss(t,e));break}}t=t.return}}function FD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Hr(),e.pingedLanes|=e.suspendedLanes&n,yr===e&&(vr&n)===n&&(lr===4||lr===3&&(vr&130023424)===vr&&500>Un()-Pk?Ua(e,0):Ik|=n),ss(e,t)}function II(e,t){t===0&&(e.mode&1?(t=bp,bp<<=1,!(bp&130023424)&&(bp=4194304)):t=1);var n=Hr();e=ho(e,t),e!==null&&(kf(e,t,n),ss(e,n))}function zD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),II(e,n)}function WD(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(Ie(314))}r!==null&&r.delete(t),II(e,n)}var PI;PI=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ns.current)Zr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Zr=!1,AD(e,t,n);Zr=!!(e.flags&131072)}else Zr=!1,In&&t.flags&1048576&&$E(t,Gh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wh(e,t),e=t.pendingProps;var s=Mc(t,Mr.current);Sc(t,n),s=jk(null,t,r,e,s,n);var o=Nk();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,rs(r)?(o=!0,qh(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,xk(t),s.updater=Qm,t.stateNode=s,s._reactInternals=t,vx(t,r,e,n),t=Nx(null,t,r,!0,o,n)):(t.tag=0,In&&o&&fk(t),Br(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=HD(r),e=ei(r,e),s){case 0:t=jx(null,t,r,e,n);break e;case 1:t=eN(null,t,r,e,n);break e;case 11:t=Q0(null,t,r,e,n);break e;case 14:t=Z0(null,t,r,ei(r.type,e),n);break e}throw Error(Ie(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),jx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),eN(e,t,r,s,n);case 3:e:{if(hI(t),e===null)throw Error(Ie(387));r=t.pendingProps,o=t.memoizedState,s=o.element,WE(e,t),Xh(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=Dc(Error(Ie(423)),t),t=tN(e,t,r,n,s);break e}else if(r!==s){s=Dc(Error(Ie(424)),t),t=tN(e,t,r,n,s);break e}else for(hs=ea(t.stateNode.containerInfo.firstChild),gs=t,In=!0,ri=null,n=FE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if($c(),r===s){t=mo(e,t,n);break e}Br(e,t,r,n)}t=t.child}return t;case 5:return BE(t),e===null&&xx(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,hx(r,s)?a=null:o!==null&&hx(r,o)&&(t.flags|=32),pI(e,t),Br(e,t,a,n),t.child;case 6:return e===null&&xx(t),null;case 13:return mI(e,t,n);case 4:return bk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Lc(t,null,r,n):Br(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),Q0(e,t,r,s,n);case 7:return Br(e,t,t.pendingProps,n),t.child;case 8:return Br(e,t,t.pendingProps.children,n),t.child;case 12:return Br(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,yn(Yh,r._currentValue),r._currentValue=a,o!==null)if(di(o.value,a)){if(o.children===s.children&&!ns.current){t=mo(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=ao(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?c.next=c:(c.next=f.next,f.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),bx(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(Ie(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),bx(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}Br(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Sc(t,n),s=Fs(s),r=r(s),t.flags|=1,Br(e,t,r,n),t.child;case 14:return r=t.type,s=ei(r,t.pendingProps),s=ei(r.type,s),Z0(e,t,r,s,n);case 15:return dI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),wh(e,t),t.tag=1,rs(r)?(e=!0,qh(t)):e=!1,Sc(t,n),lI(t,r,s),vx(t,r,s,n),Nx(null,t,r,!0,e,n);case 19:return gI(e,t,n);case 22:return fI(e,t,n)}throw Error(Ie(156,t.tag))};function TI(e,t){return iE(e,t)}function BD(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 Os(e,t,n,r){return new BD(e,t,n,r)}function $k(e){return e=e.prototype,!(!e||!e.isReactComponent)}function HD(e){if(typeof e=="function")return $k(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ek)return 11;if(e===tk)return 14}return 2}function sa(e,t){var n=e.alternate;return n===null?(n=Os(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 kh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")$k(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case nc:return Ga(n.children,s,o,t);case Zb:a=8,s|=8;break;case qw:return e=Os(12,n,t,s|2),e.elementType=qw,e.lanes=o,e;case Uw:return e=Os(13,n,t,s),e.elementType=Uw,e.lanes=o,e;case Gw:return e=Os(19,n,t,s),e.elementType=Gw,e.lanes=o,e;case BA:return tg(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case zA:a=10;break e;case WA:a=9;break e;case ek:a=11;break e;case tk:a=14;break e;case Fo:a=16,r=null;break e}throw Error(Ie(130,e==null?e:typeof e,""))}return t=Os(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Ga(e,t,n,r){return e=Os(7,e,r,t),e.lanes=n,e}function tg(e,t,n,r){return e=Os(22,e,r,t),e.elementType=BA,e.lanes=n,e.stateNode={isHidden:!1},e}function Vy(e,t,n){return e=Os(6,e,null,t),e.lanes=n,e}function Ky(e,t,n){return t=Os(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function VD(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=Ny(0),this.expirationTimes=Ny(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ny(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Lk(e,t,n,r,s,o,a,l,c){return e=new VD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Os(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},xk(o),e}function KD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:tc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function RI(e){if(!e)return la;e=e._reactInternals;e:{if(yl(e)!==e||e.tag!==1)throw Error(Ie(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(rs(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ie(171))}if(e.tag===1){var n=e.type;if(rs(n))return RE(e,n,t)}return t}function MI(e,t,n,r,s,o,a,l,c){return e=Lk(n,r,!0,e,s,o,a,l,c),e.context=RI(null),n=e.current,r=Hr(),s=ra(n),o=ao(r,s),o.callback=t??null,ta(n,o,s),e.current.lanes=s,kf(e,s,r),ss(e,r),e}function ng(e,t,n,r){var s=t.current,o=Hr(),a=ra(s);return n=RI(n),t.context===null?t.context=n:t.pendingContext=n,t=ao(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ta(s,t,a),e!==null&&(ci(e,s,a,o),mh(e,s,a)),a}function im(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 dN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ok(e,t){dN(e,t),(e=e.alternate)&&dN(e,t)}function qD(){return null}var $I=typeof reportError=="function"?reportError:function(e){console.error(e)};function Dk(e){this._internalRoot=e}rg.prototype.render=Dk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ie(409));ng(e,t,null,null)};rg.prototype.unmount=Dk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;sl(function(){ng(null,e,null,null)}),t[po]=null}};function rg(e){this._internalRoot=e}rg.prototype.unstable_scheduleHydration=function(e){if(e){var t=fE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Bo.length&&t!==0&&t<Bo[n].priority;n++);Bo.splice(n,0,e),n===0&&hE(e)}};function Fk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function sg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function fN(){}function UD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=im(a);o.call(u)}}var a=MI(t,r,e,0,null,!1,!1,"",fN);return e._reactRootContainer=a,e[po]=a.current,Wd(e.nodeType===8?e.parentNode:e),sl(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=im(c);l.call(u)}}var c=Lk(e,0,!1,null,null,!1,!1,"",fN);return e._reactRootContainer=c,e[po]=c.current,Wd(e.nodeType===8?e.parentNode:e),sl(function(){ng(t,c,n,r)}),c}function ig(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=im(a);l.call(c)}}ng(t,a,e,s)}else a=UD(n,t,e,s,r);return im(a)}uE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=rd(t.pendingLanes);n!==0&&(sk(t,n|1),ss(t,Un()),!(Jt&6)&&(Fc=Un()+500,wa()))}break;case 13:sl(function(){var r=ho(e,1);if(r!==null){var s=Hr();ci(r,e,1,s)}}),Ok(e,1)}};ik=function(e){if(e.tag===13){var t=ho(e,134217728);if(t!==null){var n=Hr();ci(t,e,134217728,n)}Ok(e,134217728)}};dE=function(e){if(e.tag===13){var t=ra(e),n=ho(e,t);if(n!==null){var r=Hr();ci(n,e,t,r)}Ok(e,t)}};fE=function(){return un};pE=function(e,t){var n=un;try{return un=e,t()}finally{un=n}};sx=function(e,t,n){switch(t){case"input":if(Xw(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=Ym(r);if(!s)throw Error(Ie(90));VA(r),Xw(r,s)}}}break;case"textarea":qA(e,n);break;case"select":t=n.value,t!=null&&xc(e,!!n.multiple,t,!1)}};ZA=Tk;eE=sl;var GD={usingClientEntryPoint:!1,Events:[Sf,oc,Ym,XA,QA,Tk]},Hu={findFiberByHostInstance:Wa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},YD={bundleType:Hu.bundleType,version:Hu.version,rendererPackageName:Hu.rendererPackageName,rendererConfig:Hu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:bo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=rE(e),e===null?null:e.stateNode},findFiberByHostInstance:Hu.findFiberByHostInstance||qD,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 Pp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Pp.isDisabled&&Pp.supportsFiber)try{Km=Pp.inject(YD),Ti=Pp}catch{}}bs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=GD;bs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Fk(t))throw Error(Ie(200));return KD(e,t,null,n)};bs.createRoot=function(e,t){if(!Fk(e))throw Error(Ie(299));var n=!1,r="",s=$I;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Lk(e,1,!1,null,null,n,!1,r,s),e[po]=t.current,Wd(e.nodeType===8?e.parentNode:e),new Dk(t)};bs.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(Ie(188)):(e=Object.keys(e).join(","),Error(Ie(268,e)));return e=rE(t),e=e===null?null:e.stateNode,e};bs.flushSync=function(e){return sl(e)};bs.hydrate=function(e,t,n){if(!sg(t))throw Error(Ie(200));return ig(null,e,t,!0,n)};bs.hydrateRoot=function(e,t,n){if(!Fk(e))throw Error(Ie(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=$I;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=MI(t,null,e,1,n??null,s,!1,o,a),e[po]=t.current,Wd(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 rg(t)};bs.render=function(e,t,n){if(!sg(t))throw Error(Ie(200));return ig(null,e,t,!1,n)};bs.unmountComponentAtNode=function(e){if(!sg(e))throw Error(Ie(40));return e._reactRootContainer?(sl(function(){ig(null,null,e,!1,function(){e._reactRootContainer=null,e[po]=null})}),!0):!1};bs.unstable_batchedUpdates=Tk;bs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!sg(n))throw Error(Ie(200));if(e==null||e._reactInternals===void 0)throw Error(Ie(38));return ig(e,t,n,!1,r)};bs.version="18.3.1-next-f1338f8080-20240426";function LI(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(LI)}catch(e){console.error(e)}}LI(),LA.exports=bs;var pr=LA.exports,pN=pr;Vw.createRoot=pN.createRoot,Vw.hydrateRoot=pN.hydrateRoot;const OI=m.createContext(null);function Ox(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function JD(){const e=Ox(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function XD({children:e}){const[t,n]=m.useState(JD);m.useEffect(()=>{const o=()=>n(Ox(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=Ox(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(OI.Provider,{value:s,children:e})}function os(){const e=m.useContext(OI);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function QD(){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 hN={};function Dx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&hN[t[0]]||(typeof t[0]=="string"&&(hN[t[0]]=new Date),QD(...t))}const DI=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function mN(e,t,n){e.loadNamespaces(t,DI(e,n))}function gN(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,DI(e,r))}function ZD(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 eF(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Dx("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}}):ZD(e,t,n)}const tF=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,nF={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},rF=e=>nF[e],sF=e=>e.replace(tF,rF);let Fx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:sF};function iF(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fx={...Fx,...e}}function oF(){return Fx}let FI;function aF(e){FI=e}function lF(){return FI}const cF={type:"3rdParty",init(e){iF(e.options.react),aF(e)}},uF=m.createContext();class dF{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const fF=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function qr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(uF)||{},o=n||r||lF();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new dF),!o){Dx("You will need to pass in an i18next instance by using initReactI18next");const x=(S,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(S)?S[S.length-1]:S,_=[x,{},!1];return _.t=x,_.i18n={},_.ready=!1,_}o.options.react&&o.options.react.wait!==void 0&&Dx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...oF(),...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 f=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>eF(x,o,a));function p(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[d,h]=m.useState(p);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=fF(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:_}=a;b.current=!0,!f&&!l&&(t.lng?gN(o,t.lng,u,()=>{b.current&&h(p)}):mN(o,u,()=>{b.current&&h(p)})),f&&v&&v!==y&&b.current&&h(p);function S(){b.current&&h(p)}return x&&o&&o.on(x,S),_&&o&&o.store.on(_,S),()=>{b.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,S)),_&&o&&_.split(" ").forEach(N=>o.store.off(N,S))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(p),g.current=!1},[o,c]);const k=[d,o,f];if(k.t=d,k.i18n=o,k.ready=f,f||!f&&!l)return k;throw new Promise(x=>{t.lng?gN(o,t.lng,u,()=>x()):mN(o,u,()=>x())})}const zI="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",pF=[{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"}],hF=[{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 mF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function gF({authUser:e,onLogout:t}){const{path:n,navigate:r}=os(),{t:s}=qr(),[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:zI,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:pF.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(mF(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&&hF.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 yF="agentflow.pipelineRecent",wF=15;function xF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function bF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(yF);return e?xF(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 kF(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 yN(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 f=Math.floor(a/24);return f<7?t("flow:time.daysAgo",{n:f}):`${l.getMonth()+1}/${l.getDate()}`}function vF(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:kF(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,wF)}var fs=Uint8Array,pc=Uint16Array,SF=Int32Array,WI=new fs([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]),BI=new fs([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]),jF=new fs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),HI=function(e,t){for(var n=new pc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new SF(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}},VI=HI(WI,2),KI=VI.b,NF=VI.r;KI[28]=258,NF[258]=28;var _F=HI(BI,0),CF=_F.b,zx=new pc(32768);for(var Nn=0;Nn<32768;++Nn){var Ro=(Nn&43690)>>1|(Nn&21845)<<1;Ro=(Ro&52428)>>2|(Ro&13107)<<2,Ro=(Ro&61680)>>4|(Ro&3855)<<4,zx[Nn]=((Ro&65280)>>8|(Ro&255)<<8)>>1}var vd=function(e,t,n){for(var r=e.length,s=0,o=new pc(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new pc(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new pc(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],f=t-e[s],p=a[e[s]-1]++<<f,d=p|(1<<f)-1;p<=d;++p)l[zx[p]>>c]=u}else for(l=new pc(r),s=0;s<r;++s)e[s]&&(l[s]=zx[a[e[s]-1]++]>>15-e[s]);return l},Nf=new fs(288);for(var Nn=0;Nn<144;++Nn)Nf[Nn]=8;for(var Nn=144;Nn<256;++Nn)Nf[Nn]=9;for(var Nn=256;Nn<280;++Nn)Nf[Nn]=7;for(var Nn=280;Nn<288;++Nn)Nf[Nn]=8;var qI=new fs(32);for(var Nn=0;Nn<32;++Nn)qI[Nn]=5;var AF=vd(Nf,9,1),EF=vd(qI,5,1),qy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Qs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Uy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},IF=function(e){return(e+7)/8|0},zk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new fs(e.subarray(t,n))},PF=["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"],Ts=function(e,t,n){var r=new Error(t||PF[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ts),!n)throw r;return r},TF=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new fs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new fs(s*3));var u=function(ue){var de=n.length;if(ue>de){var me=new fs(Math.max(de*2,ue));me.set(n),n=me}},f=t.f||0,p=t.p||0,d=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!h){f=Qs(e,p,1);var k=Qs(e,p+1,3);if(p+=3,k)if(k==1)h=AF,y=EF,v=9,b=5;else if(k==2){var N=Qs(e,p,31)+257,I=Qs(e,p+10,15)+4,T=N+Qs(e,p+5,31)+1;p+=14;for(var z=new fs(T),E=new fs(19),D=0;D<I;++D)E[jF[D]]=Qs(e,p+D*3,7);p+=I*3;for(var L=qy(E),O=(1<<L)-1,M=vd(E,L,1),D=0;D<T;){var V=M[Qs(e,p,O)];p+=V&15;var x=V>>4;if(x<16)z[D++]=x;else{var B=0,F=0;for(x==16?(F=3+Qs(e,p,3),p+=2,B=z[D-1]):x==17?(F=3+Qs(e,p,7),p+=3):x==18&&(F=11+Qs(e,p,127),p+=7);F--;)z[D++]=B}}var $=z.subarray(0,N),H=z.subarray(N);v=qy($),b=qy(H),h=vd($,v,1),y=vd(H,b,1)}else Ts(1);else{var x=IF(p)+4,_=e[x-4]|e[x-3]<<8,S=x+_;if(S>s){c&&Ts(0);break}l&&u(d+_),n.set(e.subarray(x,S),d),t.b=d+=_,t.p=p=S*8,t.f=f;continue}if(p>g){c&&Ts(0);break}}l&&u(d+131072);for(var A=(1<<v)-1,Q=(1<<b)-1,K=p;;K=p){var B=h[Uy(e,p)&A],W=B>>4;if(p+=B&15,p>g){c&&Ts(0);break}if(B||Ts(2),W<256)n[d++]=W;else if(W==256){K=p,h=null;break}else{var ne=W-254;if(W>264){var D=W-257,Z=WI[D];ne=Qs(e,p,(1<<Z)-1)+KI[D],p+=Z}var G=y[Uy(e,p)&Q],te=G>>4;G||Ts(3),p+=G&15;var H=CF[te];if(te>3){var Z=BI[te];H+=Uy(e,p)&(1<<Z)-1,p+=Z}if(p>g){c&&Ts(0);break}l&&u(d+131072);var re=d+ne;if(d<H){var se=o-H,ee=Math.min(H,re);for(se+d<0&&Ts(3);d<ee;++d)n[d]=r[se+d]}for(;d<re;++d)n[d]=n[d-H]}}t.l=h,t.p=K,t.b=d,t.f=f,h&&(f=1,t.m=v,t.d=y,t.n=b)}while(!f);return d!=n.length&&a?zk(n,0,d):n.subarray(0,d)},RF=new fs(0),Ci=function(e,t){return e[t]|e[t+1]<<8},si=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Gy=function(e,t){return si(e,t)+si(e,t+4)*4294967296};function MF(e,t){return TF(e,{i:2},t&&t.out,t&&t.dictionary)}var Wx=typeof TextDecoder<"u"&&new TextDecoder,$F=0;try{Wx.decode(RF,{stream:!0}),$F=1}catch{}var LF=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:zk(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 OF(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(Wx)return Wx.decode(e);var s=LF(e),o=s.s,n=s.r;return n.length&&Ts(8),o}}var DF=function(e,t){return t+30+Ci(e,t+26)+Ci(e,t+28)},FF=function(e,t,n){var r=Ci(e,t+28),s=OF(e.subarray(t+46,t+46+r),!(Ci(e,t+8)&2048)),o=t+46+r,a=si(e,t+20),l=n&&a==4294967295?zF(e,o):[a,si(e,t+24),si(e,t+42)],c=l[0],u=l[1],f=l[2];return[Ci(e,t+10),c,u,s,o+Ci(e,t+30)+Ci(e,t+32),f]},zF=function(e,t){for(;Ci(e,t)!=1;t+=4+Ci(e,t+2));return[Gy(e,t+12),Gy(e,t+4),Gy(e,t+20)]};function WF(e,t){for(var n={},r=e.length-22;si(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Ts(13);var s=Ci(e,r+8);if(!s)return{};var o=si(e,r+16),a=o==4294967295||s==65535;if(a){var l=si(e,r-12);a=si(e,l)==101075792,a&&(s=si(e,l+32),o=si(e,l+48))}for(var c=0;c<s;++c){var u=FF(e,o,a),f=u[0],p=u[1],d=u[2],h=u[3],y=u[4],v=u[5],b=DF(e,v);o=y,f?f==8?n[h]=MF(e.subarray(b,b+p),{out:new fs(d)}):Ts(14,"unknown compression type "+f):n[h]=zk(e,b,b+p)}return n}const BF=8*1024*1024,HF=500;function VF(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 KF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function qF(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 UF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function GF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=WF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const f=VF(c);if(!f||KF(f))continue;const p=(u==null?void 0:u.length)??0;if(s+=p,s>BF||(o+=1,o>HF))return null;r.set(f,p)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=qF(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 UF.test(l)?l:null}catch{return null}}const Yy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function YF({file:e,onClose:t,onImported:n}){const{t:r}=qr(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,f]=m.useState("user"),[p,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const S=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(S)},[]),m.useEffect(()=>{let S=!1;return(async()=>{const N=g.name||"",I=N.toLowerCase();let T="";if(I.endsWith(".zip")){if(T=await GF(g)||"",!T){const z=N.replace(/\.zip$/i,"");Yy.test(z)&&(T=z)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");Yy.test(z)&&(T=z)}S||c(T)})(),()=>{S=!0}},[g]);const k=l.trim(),x=k.length>0&&Yy.test(k);async function _(S){if(S.preventDefault(),!(!x||p)){d(!0),y("");try{const N=new FormData;N.set("flowId",k),N.set("targetSpace",u),N.set("file",g,g.name);const I=await fetch("/api/flows/import",{method:"POST",body:N}),T=await I.json().catch(()=>({}));if(!I.ok){y(typeof T.error=="string"?T.error:r("project:importModal.importFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(N){y(String((N==null?void 0:N.message)||N))}finally{d(!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:_,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 I;const N=(I=S.target.files)==null?void 0:I[0];N&&b(N),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:p,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||p,children:r(p?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const JF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,wN="af:newPipelineGuide";function XF({open:e,onClose:t,onCreated:n}){const{t:r}=qr(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[f,p]=m.useState("user"),[d,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),p("user"),v(""),h(!1),localStorage.getItem(wN)==="true"&&g(!0);const I=requestAnimationFrame(()=>{var T;return(T=o.current)==null?void 0:T.focus()});return()=>cancelAnimationFrame(I)},[e]);const k=()=>{localStorage.removeItem(wN),g(!1)};if(!e)return null;const x=a.trim(),_=x.length>0&&JF.test(x);async function S(N){if(N.preventDefault(),!(!_||d)){h(!0),v(""),k();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:f})}),T=await I.json().catch(()=>({}));if(!I.ok){v(typeof T.error=="string"?T.error:r("project:newPipelineModal.createFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(I){v(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.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:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{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:N=>l(N.target.value),"aria-invalid":x.length>0&&!_}),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:N=>u(N.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:d,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!_||d,children:r(d?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const UI="agentflow.pipelineViewPreference";function GI(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function YI(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(UI)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function QF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(UI,JSON.stringify(e))}catch{}}function Wk(e){return e==="display"?"display":"workspace"}function ZF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function JI(e,t){const n=Wk(t);return n==="pipeline"&&ZF(e==null?void 0:e.source)?"workspace":n}function ez(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function tz(e,t,n,r=!1){if(!e)return;const s=YI();s[GI(e,t,r)]={view:Wk(n),at:Date.now()},QF(s)}function nz(e,t="workspace"){if(!(e!=null&&e.id))return Wk(t);const r=YI()[GI(e.id,e.source??"user",!!e.archived)],s=JI(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!ez(e)?"workspace":s}function rz(e,t="workspace"){var s;const n=JI(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 Tp(e,t="workspace"){return rz(e,nz(e,t))}function sz(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 Bx(e){return String((e==null?void 0:e.version)||"").trim()}function iz(e){const t=Bx(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 oz({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(""),[f,p]=m.useState("keyword"),[d,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(""),N=m.useCallback(async()=>{x("");try{const[L,O]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await L.json().catch(()=>({}));L.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 O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+O.status);o(Array.isArray(V.skills)?V.skills:[]),l(typeof V.skillsRoot=="string"?V.skillsRoot:""),v({})}catch(L){x(String(L.message||L))}},[]);m.useEffect(()=>{N()},[N]);const I=m.useCallback(async()=>{const L=c.trim();if(L){g("search"),x(""),S("");try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent(L)}&mode=${encodeURIComponent(f)}`),M=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+O.status);h(Array.isArray(M.items)?M.items:[])}catch(O){x(String(O.message||O))}finally{g("")}}},[c,f]),T=m.useCallback(async(L,O=!1)=>{if(!t)return;const M=L&&typeof L=="object"?L:null,V=String(M?M.slug||M.name||M.collection||M.skillId||M.id:L||"").trim();if(V){g(`install:${V}`),x(""),S("");try{const B=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:O}:{slug:V,target:"agentflow",agent:"codex",force:O},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);S(O?`已更新 ${V}`:`已安装 ${V}`),await N(),typeof e=="function"&&await e()}catch(B){x(String(B.message||B))}finally{g("")}}},[t,N,e]),z=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),x(""),S("");try{const L=await Promise.all(s.map(async V=>{const B=String(V.name||"").trim();if(!B)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(B)}&mode=keyword`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);const H=Array.isArray($.items)?$.items:[],A=H.find(ne=>ne.slug===B||ne.name===B||ne.id===B)||H[0],Q=Bx(V),K=String((A==null?void 0:A.version)||"").trim();let W="unknown";return A?Q&&K?W=sz(Q,K)<0?"update":"current":K&&(W="remote-only"):W="missing",[B,{state:W,latestVersion:K,installedVersion:Q,summary:(A==null?void 0:A.summary)||""}]}catch(F){return[B,{state:"error",error:String(F.message||F),installedVersion:Bx(V)}]}})),O={};for(const V of L)V&&(O[V[0]]=V[1]);v(O);const M=Object.values(O).filter(V=>V.state==="update").length;S(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),E=m.useCallback(async L=>{if(!t)return;const O=String(L||"").trim();if(O){g(`uninstall:${O}`),x(""),S("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:O,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(`已卸载 ${O}`),await N(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{g("")}}},[t,N,e]),D=m.useCallback(async()=>{if(t){g("update-cli"),x(""),S("");try{const L=await fetch("/api/skillhub/update",{method:"POST"}),O=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+L.status);S("SkillHub CLI 已更新"),await N()}catch(L){x(String(L.message||L))}finally{g("")}}},[t,N]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",i.jsx("code",{children:a})]}):null]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!b,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!b||s.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:D,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:f,onChange:L=>{p(L.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:L=>u(L.target.value),onKeyDown:L=>{L.key==="Enter"&&I()},placeholder:f==="collectionId"?"输入 collection id,例如 1":f==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>I(),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,_?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:_}):null,i.jsxs("div",{className:"af-set-skillhub-grid",children:[i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"已安装"}),i.jsx("span",{children:s.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(L=>{const O=y[L.name],M=!O||O.state==="update"||O.state==="remote-only"||O.state==="unknown"||O.state==="error",V=b===`install:${L.name}`?"更新中…":(O==null?void 0:O.state)==="current"?"已最新":(O==null?void 0:O.state)==="update"&&O.latestVersion?`更新到 v${O.latestVersion}`:(O==null?void 0:O.state)==="remote-only"&&O.latestVersion?`安装 v${O.latestVersion}`:"重装";return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:L.displayName||L.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:iz(L)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:O?O.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",O.installedVersion?`v${O.installedVersion} -> `:"","v",O.latestVersion]}):O.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",O.latestVersion||O.installedVersion]}):O.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",O.latestVersion,",本地版本未知"]}):O.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):O.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:()=>T(L.name,!0),disabled:!t||!!b||!M,children:V}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>E(L.name),disabled:!t||!!b,children:"卸载"})]})]},`${L.agent}:${L.path}:${L.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:d.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(L=>{const O=L.slug||L.name,M=L.kind==="collection"||L.collection,V=!M&&s.some(B=>B.name===O||B.name===L.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:L.name||O}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${L.collection}`:O,L.skillId?` · id:${L.skillId}`:"",L.version?` · ${L.version}`:""]}),L.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:L.summary}):null]}),i.jsx("button",{type:"button",className:V?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>T(L,V),disabled:!t||!!b,children:V?"更新":M?"安装合集":"安装"})]},L.id||O)})})]})]})]})}function Ya(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 az(e){return{version:1,collections:Ya({collections:e})}}function lz(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function XI(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(lz(s)))||""}}function ca(e,t){const n=XI(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function cz(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 uz(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function dz(e,t,n){const r=ca(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 fz(e,t,n){const r=String(e).trim().toLowerCase(),s=Ya({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return ca(s,t)}function pz(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Ya({collections:r}),l=fz(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const f=JSON.parse(u);if(Array.isArray(f)){const p=XI(n),d=Array.from(new Set(f.map(p).filter(Boolean)));if(s.length>0&&d.length===s.length)return c;const h=new Set(d),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=ca(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:d}}}catch{}return c}function Vl(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 hz(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function mz(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 Hx(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 QI(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 gz="project:defaultCardDesc";function ZI(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(gz)}function yz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kn({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(`(${yz(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 wz(e,t,n){const r=[String(e.id),ZI(e,n),QI(e),Hx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function xz(e,t,n){return t?wz(e,t,n).includes(t):!0}function bz(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 Jy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function xN(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 bN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const kz=["all","agent","control","provide","marketplace"],vz=["all","agent","control","provide"],eP="agentflow.projects.activityPanelOpen",Vx="agentflow.projects.activitySelected",tP="agentflow.projects.scopeView";function Sz(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(tP)==="team"?"team":"personal"}catch{return"personal"}}function jz(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(eP);return e!=="0"}function kN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function Nz(){return typeof localStorage>"u"?"":localStorage.getItem(Vx)||""}function Rp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function qn(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 _z(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 Mo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function nP(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 rP(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 Kx(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 vN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Kx(e,t))}function Cz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function SN(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 Az(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 Xy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Ez(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 Iz(e,t){const n=e.map(f=>f.id),r=new Set(n),s=new Map(n.map(f=>[f,0])),o=new Map(n.map(f=>[f,[]]));t.forEach(f=>{var p;!r.has(f.sourceId)||!r.has(f.targetId)||(s.set(f.targetId,(s.get(f.targetId)||0)+1),(p=o.get(f.sourceId))==null||p.push(f.targetId))});const a=new Map,l=n.filter(f=>(s.get(f)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(f=>a.set(f,0));for(let f=0;f<l.length;f+=1){const p=l[f],d=(a.get(p)||0)+1;for(const h of o.get(p)||[])(!a.has(h)||d>a.get(h))&&(a.set(h,d),l.push(h))}n.forEach((f,p)=>{a.has(f)||a.set(f,p%3)});const c=new Map,u=new Map;return n.forEach(f=>{const p=a.get(f)||0,d=c.get(p)||0;c.set(p,d+1),u.set(f,{x:p*190,y:d*86})}),u}function Pz(e){var v,b,g,k;const t=nP(e),n=rP(e),r=new Map(t.map((x,_)=>[Kx(x,_),vN(x,_)])),s=t.map((x,_)=>({id:Kx(x,_),title:vN(x,_),meta:Cz(x)})),o=n.map((x,_)=>{const S=SN(x,"source"),N=SN(x,"target");return{key:(x==null?void 0:x.id)||`${S}-${N}-${_}`,sourceId:S,targetId:N,source:r.get(S)||S||"?",target:r.get(N)||N||"?",label:Az(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=Iz(s,o),u=s.map(x=>{const _=Ez(a[x.id])||c.get(x.id)||{x:0,y:0},S=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},N=Number(S.width),I=Number(S.height),T=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),z=Math.max(48,Math.min(76,Number.isFinite(I)?I*.46:54));return{...x,x:_.x,y:_.y,width:T,height:z}}),f=new Map(u.map(x=>[x.id,x])),p=o.map(x=>{const _=f.get(x.sourceId),S=f.get(x.targetId);if(!_||!S)return null;const N=_.x+_.width,I=_.y+_.height/2,T=S.x,z=S.y+S.height/2,E=Math.max(48,Math.abs(T-N)*.45);return{...x,path:`M ${N} ${I} C ${N+E} ${I}, ${T-E} ${z}, ${T} ${z}`,labelX:(N+T)/2,labelY:(I+z)/2}}).filter(Boolean),d=u.reduce((x,_)=>({minX:Math.min(x.minX,_.x),minY:Math.min(x.minY,_.y),maxX:Math.max(x.maxX,_.x+_.width),maxY:Math.max(x.maxY,_.y+_.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${d.minX-h} ${d.minY-h} ${Math.max(360,d.maxX-d.minX+h*2)} ${Math.max(180,d.maxY-d.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:p,viewBox:y}}}function Kl({resourceKind:e="",authUser:t=null}){var $t,rn,vn,Vn,Ss,js;const{t:n}=qr(),{navigate:r,path:s}=os(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[f,p]=m.useState(Sz),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState([]),[_,S]=m.useState(""),[N,I]=m.useState(!1),[T,z]=m.useState([]),[E,D]=m.useState(""),[L,O]=m.useState(""),[M,V]=m.useState(!1),[B,F]=m.useState(!1),[$,H]=m.useState(!1),[A,Q]=m.useState(null),[K,W]=m.useState(!1),[ne,Z]=m.useState(""),[G,te]=m.useState(jz),[re,se]=m.useState(Nz),[ee,ue]=m.useState("all"),[de,me]=m.useState(""),[Me,Se]=m.useState("overview"),[_e,Fe]=m.useState({}),[at,mt]=m.useState(""),[Te,it]=m.useState({}),[jt,Vt]=m.useState(""),[kt,Mt]=m.useState(""),[ae,ke]=m.useState({}),[qe,tt]=m.useState(""),[Ee,Dt]=m.useState(""),[nn,Kt]=m.useState(""),[yt,Cn]=m.useState(""),[ie,Ce]=m.useState(""),[Ge,Be]=m.useState(!1),[Et,vt]=m.useState(""),[pe,He]=m.useState({hiddenBuiltins:[],promoted:[]}),wt=m.useRef(0),bt=m.useRef(0),ln=m.useRef(0),Tn=m.useCallback(async()=>{var we,$e;const U=++bt.current;D("");try{const Ae=await fetch(`/api/flows?view=${encodeURIComponent(f)}`);if(U!==bt.current)return;if(!Ae.ok)throw new Error("HTTP "+Ae.status);const Ze=await Ae.json();if(U!==bt.current)return;u(Array.isArray(Ze)?Ze:[])}catch(Ae){if(U!==bt.current)return;u([]),D(String(Ae.message||Ae))}try{const Ae=await fetch("/api/pipeline-recent-runs");if(U!==bt.current)return;if(Ae.ok){const Ze=await Ae.json();if(U!==bt.current)return;z(Array.isArray(Ze.runs)?Ze.runs:[])}else z([])}catch{if(U!==bt.current)return;z([])}if(t!=null&&t.isAdmin)try{const Ae=await fetch("/api/admin/builtin-flows");if(U!==bt.current)return;const Ze=await Ae.json().catch(()=>({}));Ae.ok&&He({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(U!==bt.current)return;He({hiddenBuiltins:[],promoted:[]})}else He({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,f]),An=m.useCallback(async(U,we)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const $e=`${we}:${U.source}:${U.id}`;vt($e),D("");try{const Ae=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:we,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),Ze=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(Ze.error||"更新内置配置失败");await Tn()}catch(Ae){D(String(Ae.message||Ae))}finally{vt("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,Tn]),en=m.useCallback(async()=>{const U=++ln.current;O(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";h([]),g([]),me("");try{const[Ae,Ze,En,Ft]=await Promise.all([fetch(we),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Rn=await Ae.json().catch(()=>({})),cr=await Ze.json().catch(()=>({})),br=await En.json().catch(()=>({})),sn=await Ft.json().catch(()=>({}));if(!Ae.ok)throw new Error(Rn.error||"Nodes HTTP "+Ae.status);if(!Ze.ok)throw new Error(cr.error||"Skills HTTP "+Ze.status);if(!En.ok)throw new Error(br.error||"Collections HTTP "+En.status);if(!Ft.ok)throw new Error(sn.error||"Flow snippets HTTP "+Ft.status);if(U!==ln.current)return;h(Array.isArray(Rn.nodes)?Rn.nodes:Array.isArray(Rn)?Rn:[]),v(Array.isArray(cr.skills)?cr.skills:[]),x(Ya(br)),g(Array.isArray(sn.snippets)?sn.snippets:[])}catch(Ae){if(U!==ln.current)return;h([]),v([]),g([]),x([]),O(String(Ae.message||Ae))}finally{if(U!==ln.current)return;F(!0)}},[e]);m.useEffect(()=>{V(!1),Tn(),en()},[Tn,en]),m.useEffect(()=>{try{localStorage.setItem(eP,G?"1":"0")}catch{}},[G]),m.useEffect(()=>{try{localStorage.setItem(tP,f)}catch{}},[f]),m.useEffect(()=>{try{re?localStorage.setItem(Vx,re):localStorage.removeItem(Vx)}catch{}},[re]),m.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{U||Be(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const bn=m.useCallback(async U=>{if(!o)return;const we=Ya({collections:U});I(!0),O("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(az(we))}),Ae=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ae.error||"Collections HTTP "+$e.status);x(Ya(Ae))}catch($e){O(String($e.message||$e))}finally{I(!1)}},[o]),nr=m.useCallback(()=>{if(!o)return;const U=_.trim();if(!U)return;const we=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(Ft=>Ft.id));let Ae=we,Ze=2;for(;$e.has(Ae);)Ae=`${we}-${Ze++}`;const En=Date.now();bn([...k,{id:Ae,name:U,skillKeys:[],createdAt:En,updatedAt:En}]),S(""),ue(`collection:${Ae}`)},[o,_,bn,k]),fn=m.useCallback(U=>{if(!o)return;const we=k.find(Ae=>Ae.id===U);if(we!=null&&we.builtin)return;const $e=k.filter(Ae=>Ae.id!==U);ee===`collection:${U}`&&ue("all"),bn($e)},[o,ee,bn,k]),kn=m.useCallback((U,we,$e)=>{if(!o)return;const Ae=String(we||"").trim();if(!Ae)return;const Ze=Date.now(),En=k.map(Ft=>{if(Ft.id!==U)return Ft;const Rn=new Set(Ft.skillKeys||[]);return $e?Rn.add(Ae):Rn.delete(Ae),{...Ft,skillKeys:Array.from(Rn),updatedAt:Ze}});bn(En)},[o,bn,k]),rr=m.useCallback(async U=>{const we=U==null?void 0:U.packageId,$e=U==null?void 0:U.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ae=qn(U);Dt(Ae),Kt(""),O("");try{const Ze=new URLSearchParams({id:we,version:$e}),En=await fetch(`/api/marketplace/node?${Ze.toString()}`,{method:"DELETE"}),Ft=await En.json().catch(()=>({}));if(!En.ok||(Ft==null?void 0:Ft.ok)===!1){const Rn=Array.isArray(Ft==null?void 0:Ft.usage)&&Ft.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Ft.usage.length})}`:"";throw new Error(((Ft==null?void 0:Ft.error)||"Delete failed")+Rn)}Kt(n("project:deleteMyNodeSuccess",{id:we,version:$e})),it(Rn=>{const cr={...Rn};return delete cr[Ae],cr}),ke(Rn=>{const cr={};for(const[br,sn]of Object.entries(Rn))br.startsWith(`${Ae}:`)||(cr[br]=sn);return cr}),me(""),await en()}catch(Ze){Kt(String(Ze.message||Ze))}finally{Dt("")}},[en,n]),vs=m.useCallback(async U=>{const we=U==null?void 0:U.id,$e=(U==null?void 0:U.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ae=Mo(U);Cn(Ae),Ce(""),O("");try{const Ze=new URLSearchParams({id:we,version:$e}),En=await fetch(`/api/marketplace/flow-snippet?${Ze.toString()}`,{method:"DELETE"}),Ft=await En.json().catch(()=>({}));if(!En.ok||(Ft==null?void 0:Ft.ok)===!1)throw new Error((Ft==null?void 0:Ft.error)||"Delete failed");Ce(n("project:deleteMyFlowSuccess",{id:we,version:$e})),me(""),await en()}catch(Ze){Ce(String(Ze.message||Ze))}finally{Cn("")}},[en,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ue("all"),me(""),Se("overview");return}l(U=>U==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const U=new URLSearchParams(window.location.search),we=U.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"),U.delete("tab"),$e=!0):we&&(l("all"),U.delete("tab"),$e=!0),U.get("new")==="1"&&(H(!0),U.delete("new"),$e=!0),$e){const Ae=U.toString();window.history.replaceState({},"",Ae?`/projects?${Ae}`:"/projects")}},[s,r]);const sr=m.useMemo(()=>vF(T,bF(),c),[T,c,s]),Gn=m.useMemo(()=>sr.filter(U=>bz(ne,U)),[sr,ne]),Nr=ne.trim().toLowerCase(),_r=m.useMemo(()=>a==="archived"?c.filter(U=>U.archived):c.filter(U=>!U.archived),[c,a]),Yn=m.useMemo(()=>_r.filter(U=>xz(U,Nr,n)),[_r,Nr,n]),Lr=m.useMemo(()=>new Set((pe.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[pe.promoted]),Or=m.useMemo(()=>(pe.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[pe.hiddenBuiltins]),ce=a==="nodes"||a==="my-nodes",ge=a==="my-nodes",et=a==="my-flows",rt=m.useMemo(()=>d.filter(U=>ge&&!_z(U,t)?!1:(ee==="all"||(ee==="marketplace"?U.source==="marketplace":U.type===ee))&&Jy(ne,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[t,d,ge,ne,ee]),Bt=m.useMemo(()=>{const U=new Map;for(const we of k)U.set(we.id,new Set(ca(we,y)));return U},[y,k]),Wn=m.useMemo(()=>[{id:"all",label:"全部"},...k.map(U=>{var we;return{id:`collection:${U.id}`,label:U.name,count:((we=Bt.get(U.id))==null?void 0:we.size)||0,collection:U}}),{id:"ungrouped",label:"未分组"}],[Bt,k]),Cr=m.useMemo(()=>y.filter(U=>{var Ae;const we=qn(U);let $e=ee==="all";if(ee.startsWith("collection:")){const Ze=ee.slice(11);$e=!!((Ae=Bt.get(Ze))!=null&&Ae.has(we))}else ee==="ungrouped"&&($e=!Array.from(Bt.values()).some(Ze=>Ze.has(we)));return $e&&Jy(ne,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[y,ne,ee,Bt]),Ar=m.useMemo(()=>b.filter(U=>Jy(ne,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[b,ne]),wr=ce||et||a==="skills",ct=m.useMemo(()=>rt.find(U=>qn(U)===de)||rt[0]||null,[rt,de]),Xt=m.useMemo(()=>Cr.find(U=>qn(U)===de)||Cr[0]||null,[Cr,de]),Qt=m.useMemo(()=>Ar.find(U=>Mo(U)===de)||Ar[0]||null,[Ar,de]),ir=Xt?_e[qn(Xt)]:null,ot=ct?Te[qn(ct)]:null,xr=ct&&kt?ae[`${qn(ct)}:${kt}`]:null,Ws=n(ce?"project:searchNodes":et?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Xt)return;const U=qn(Xt);if(_e[U])return;let we=!1;return mt(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&Ae.skill&&Fe(Ze=>({...Ze,[U]:Ae.skill}))}).catch(()=>{}).finally(()=>{we||mt("")}),()=>{we=!0}},[a,Xt,_e]),m.useEffect(()=>{if(!ce||!ct)return;const U=qn(ct);if(Te[U])return;let we=!1;return Vt(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(ct.id)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&it(Ze=>({...Ze,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||Vt("")}),()=>{we=!0}},[ce,ct,Te]),m.useEffect(()=>{if(!ce)return;const U=Array.isArray(ot==null?void 0:ot.files)?ot.files:[];Mt(we=>{var $e;return we&&U.some(Ae=>Ae.path===we)?we:(($e=U[0])==null?void 0:$e.path)||""})},[ce,ot]),m.useEffect(()=>{if(!ce||!ct||!kt)return;const U=`${qn(ct)}:${kt}`;if(ae[U])return;let we=!1;return tt(U),fetch(`/api/nodes/file?id=${encodeURIComponent(ct.id)}&path=${encodeURIComponent(kt)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&ke(Ze=>({...Ze,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||tt("")}),()=>{we=!0}},[ce,ct,kt,ae]),m.useEffect(()=>{Kt("")},[de,a]);const Hi=U=>{r(Tp(U,"workspace"))},Bs=U=>{se(kN(U)),r(Tp({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},oe=m.useCallback(U=>{var we,$e;U.preventDefault(),U.stopPropagation(),($e=(we=U.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(wt.current+=1,W(!0))},[]),ve=m.useCallback(U=>{U.preventDefault(),U.stopPropagation(),wt.current-=1,wt.current<=0&&(wt.current=0,W(!1))},[]),Re=m.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),Nt=m.useCallback(U=>{var Ae,Ze;U.preventDefault(),U.stopPropagation(),wt.current=0,W(!1);const we=(Ze=(Ae=U.dataTransfer)==null?void 0:Ae.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:Re,onDrop:Nt,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:[wr?null:i.jsxs("div",{className:"af-scope-switch af-project-scope-switch","aria-label":"Project 视图",children:[i.jsx("button",{type:"button",className:f==="personal"?"is-active":"",onClick:()=>p("personal"),children:"个人"}),i.jsx("button",{type:"button",className:f==="team"?"is-active":"",onClick:()=>p("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"+(ne.trim()?" af-search--has-clear":""),type:"search",placeholder:Ws,"aria-label":Ws,autoComplete:"off",value:ne,onChange:U=>Z(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(Z(""),U.currentTarget.blur())}}),ne.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Z(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),wr?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>en(),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(U=>!U),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>H(!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:Nr?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?rt.length:a==="my-flows"?Ar.length:a==="skills"?Cr.length:Yn.length}):a==="my-nodes"?n("project:myNodesHint",{count:rt.length}):a==="my-flows"?n("project:myFlowsHint",{count:Ar.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:y.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),E?i.jsx("p",{className:"af-err af-projects-api-hint",children:E}):null,L&&wr?i.jsx("p",{className:"af-err af-projects-api-hint",children:L}):null]}),wr?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(oz,{onChanged:en,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:et?"schema":ce?ge?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(et?"project:myFlowsPurposeTitle":ge?"project:myNodesPurposeTitle":ce?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(et?"project:myFlowsPurposeDesc":ge?"project:myNodesPurposeDesc":ce?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),et?null:i.jsxs(i.Fragment,{children:[ce?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(ge?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ue("all"),me("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(ge?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ue("all"),me("")},children:n("project:nodeScopeMine")})]}):null,i.jsx("div",{className:"af-resource-filter-row",children:(ce?(ge?vz:kz).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):Wn).map(U=>U.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(ee===U.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ue(U.id),me("")},children:[U.label,i.jsx("em",{children:U.count}),U.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!U.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${U.collection.name}`,onClick:()=>fn(U.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},U.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(ee===U.id?" af-resource-filter--active":""),onClick:()=>{ue(U.id),me("")},children:U.label},U.id))})]}),a==="skills"&&o?i.jsx("div",{className:"af-skill-collections-manager",children:i.jsxs("div",{className:"af-skill-collections-create",children:[i.jsx("input",{className:"af-set-input af-set-input--sm",value:_,onChange:U=>S(U.target.value),onKeyDown:U=>{U.key==="Enter"&&nr()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!_.trim()||N,onClick:()=>nr(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,ce?i.jsx("div",{className:"af-resource-grid",children:rt.length>0?rt.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ct&&qn(U)===qn(ct)?" af-resource-card--active":""),onClick:()=>me(qn(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:i.jsx(Kn,{query:ne,children:U.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Kn,{query:ne,children:xN(U.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Kn,{query:ne,children:U.label||U.displayName||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Kn,{query:ne,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Kn,{query:ne,children:U.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Kn,{query:ne,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:Nr?n("project:noNodeMatch",{query:ne.trim()}):n(ge?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):et?i.jsx("div",{className:"af-resource-grid",children:Ar.length>0?Ar.map(U=>{const we=nP(U),$e=rP(U),Ae=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):we.length,Ze=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):$e.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Qt&&Mo(U)===Mo(Qt)?" af-resource-card--active":""),onClick:()=>me(Mo(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl("primary"),children:i.jsx(Kn,{query:ne,children:U.version?`v${U.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Kn,{query:ne,children:U.displayName||U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Kn,{query:ne,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ae,edges:Ze})}),i.jsx("span",{children:i.jsx(Kn,{query:ne,children:U.id})})]}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Kn,{query:ne,children:bN(U)})})]})]},Mo(U))}):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:Nr?n("project:noFlowSnippetMatch",{query:ne.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:Cr.length>0?Cr.map(U=>{const we=qn(U),$e=k.filter(Ae=>{var Ze;return(Ze=Bt.get(Ae.id))==null?void 0:Ze.has(we)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(Xt&&we===qn(Xt)?" af-resource-card--active":""),onClick:()=>me(we),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl(U.source==="builtin"?"muted":"primary"),children:i.jsx(Kn,{query:ne,children:U.sourceLabel||U.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Kn,{query:ne,children:U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Kn,{query:ne,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Kn,{query:ne,children:U.path||U.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ae=>i.jsx("span",{children:Ae.name},Ae.id)),$e.length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)}):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:Nr?n("project:noSkillMatch",{query:ne.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"&&Or.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:Or.map(U=>{const we=Et===`show-builtin:builtin:${U}`;return i.jsxs("button",{type:"button",disabled:we,onClick:()=>An({id:U,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:U}),i.jsx("em",{children:we?"恢复中":"恢复"})]},U)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[Yn.length>0?Yn.map(U=>{var En,Ft,Rn,cr,br;const we=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!Lr.has(U.id),$e=(t==null?void 0:t.isAdmin)&&U.source==="admin",Ae=(t==null?void 0:t.isAdmin)&&U.source==="builtin",Ze=Et.endsWith(`:${U.source}:${U.id}`);return i.jsx("div",{className:hz(U.source),role:"button",tabIndex:0,onClick:()=>Hi(U),onKeyDown:sn=>{(sn.key==="Enter"||sn.key===" ")&&(sn.preventDefault(),Hi(U))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Vl(Hx(U.source,n).tone),children:i.jsx(Kn,{query:ne,children:Hx(U.source,n).label})}),(En=U.collaboration)!=null&&En.role?i.jsx("span",{className:Vl(U.collaboration.role==="owner"?"primary":"muted"),children:U.collaboration.role==="owner"?(Ft=U.collaboration.teamShares)!=null&&Ft.length?"已分享团队":"我创建的":U.collaboration.accessSource==="team"?`${((cr=(Rn=U.collaboration.teamShares)==null?void 0:Rn.find(sn=>sn.teamId===U.collaboration.teamId))==null?void 0:cr.teamName)||"团队"}共享`:`${U.collaboration.ownerUsername||U.collaboration.ownerId} 分享`}):null,U.archived?i.jsx("span",{className:Vl("muted"),children:i.jsx(Kn,{query:ne,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Kn,{query:ne,children:U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Kn,{query:ne,children:ZI(U,n)})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Kn,{query:ne,children:QI(U)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:sn=>sn.stopPropagation(),onKeyDown:sn=>sn.stopPropagation(),children:[we?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>An(U,"promote"),children:"设为内置"}):null,$e?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>An(U,"unpromote"),children:"取消内置"}):null,Ae?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>An(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}:${((br=U.collaboration)==null?void 0:br.id)||"own"}`)}):M?_r.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(E?"project:loadFailed":"project:noPipelines")}),!E&&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:ne.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:()=>H(!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")})]}),Ge?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")})]})]})]})]}),wr?i.jsx("aside",{className:"af-resource-detail","aria-label":n(ce?"project:nodeDetail":et?"project:flowDetail":"project:skillDetail"),children:ce&&ct?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:ct.label||ct.displayName||ct.id}),i.jsx("p",{children:ct.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Me===U?" af-resource-detail-tab--active":""),onClick:()=>Se(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),jt===qn(ct)?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:ct.description||(($t=ot==null?void 0:ot.node)==null?void 0:$t.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:ct.type||((rn=ot==null?void 0:ot.node)==null?void 0:rn.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:xN(ct.source,n)})]}),ct.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:ct.packageId})]}):null,ct.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:ct.version})]}):null,ct.packageDir||ot!=null&&ot.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ct.packageDir||(ot==null?void 0:ot.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(ot==null?void 0:ot.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),ge&&ct.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:Ee===qn(ct),onClick:()=>rr(ct),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ee===qn(ct)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),nn?i.jsx("p",{className:"af-resource-action-message",children:nn}):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")}),Rp(((vn=ot==null?void 0:ot.node)==null?void 0:vn.inputs)||ct.inputs).length>0?Rp(((Vn=ot==null?void 0:ot.node)==null?void 0:Vn.inputs)||ct.inputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),Rp(((Ss=ot==null?void 0:ot.node)==null?void 0:Ss.outputs)||ct.outputs).length>0?Rp(((js=ot==null?void 0:ot.node)==null?void 0:js.outputs)||ct.outputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.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")}),ot!=null&&ot.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(ot.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),ot!=null&&ot.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:ot.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(ot==null?void 0:ot.files)&&ot.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:ot.files.map(U=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(kt===U.path?" af-node-file-item--active":""),onClick:()=>Mt(U.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:U.path})]},U.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[qe===`${qn(ct)}:${kt}`?n("project:loadingResources"):xr!=null&&xr.binary?n("project:binaryFile"):(xr==null?void 0:xr.content)||n("project:selectNodeFile"),xr!=null&&xr.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(ot==null?void 0:ot.usage)&&ot.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:ot.usage.map(U=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:U.flowId}),i.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:U.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):et&&Qt?(()=>{const U=Pz(Qt);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:Qt.displayName||Qt.name||Qt.id}),i.jsx("p",{children:Qt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Qt.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:Qt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:bN(Qt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Qt.nodeCount))?Number(Qt.nodeCount):U.nodes.length,edges:Number.isFinite(Number(Qt.edgeCount))?Number(Qt.edgeCount):U.edges.length})})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:myFlowsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myFlowManagement")}),i.jsx("p",{children:n("project:deleteMyFlowHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:yt===Mo(Qt),onClick:()=>vs(Qt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),yt===Mo(Qt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),ie?i.jsx("p",{className:"af-resource-action-message",children:ie}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:i.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),i.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(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:Xy(we.label,18)}):null]},we.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.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:Xy(we.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:Xy(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(Qt.snippet||{},null,2)})]})]})]})})():a==="skills"&&Xt?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:Xt.name||Xt.id}),i.jsx("p",{children:Xt.sourceLabel||Xt.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Xt.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:Xt.sourceLabel||Xt.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:Xt.path||Xt.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),k.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:k.map(U=>{const we=qn(Xt),$e=Bt.get(U.id)||new Set,Ae=$e.has(we);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ae,disabled:N||!o,onChange:Ze=>kn(U.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:U.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},U.id)})})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:skillsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:skillPreview")}),i.jsx("pre",{className:"af-resource-skill-preview",children:at===qn(Xt)?n("project:loadingResources"):(ir==null?void 0:ir.body)||(ir==null?void 0:ir.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:Gn.length===0?i.jsx("p",{className:"af-activity-empty",children:sr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Gn.map(U=>{const we=re===kN(U);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:()=>Bs(U),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Kn,{query:ne,children:U.flowId})}),i.jsx("span",{className:"af-activity-time",children:yN(U.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:mz(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",yN(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),i.jsx(XF,{open:$,onClose:()=>H(!1),onCreated:async U=>{H(!1),await Tn();const we=U.source??"user";r(Tp({id:U.id,source:we},"workspace"))}}),A?i.jsx(YF,{file:A,onClose:()=>Q(null),onImported:async U=>{Q(null),await Tn();const we=U.source??"user";r(Tp({id:U.id,source:we},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}function tr(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=tr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Tz={value:()=>{}};function og(){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 vh(n)}function vh(e){this._=e}function Rz(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}})}vh.prototype=og.prototype={constructor:vh,on:function(e,t){var n=this._,r=Rz(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=Mz(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]=jN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=jN(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 vh(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 Mz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function jN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Tz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var qx="http://www.w3.org/1999/xhtml";const NN={svg:"http://www.w3.org/2000/svg",xhtml:qx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ag(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),NN.hasOwnProperty(t)?{space:NN[t],local:e}:e}function $z(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===qx&&t.documentElement.namespaceURI===qx?t.createElement(e):t.createElementNS(n,e)}}function Lz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sP(e){var t=ag(e);return(t.local?Lz:$z)(t)}function Oz(){}function Bk(e){return e==null?Oz:function(){return this.querySelector(e)}}function Dz(e){typeof e!="function"&&(e=Bk(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,f=0;f<a;++f)(c=o[f])&&(u=e.call(c,c.__data__,f,o))&&("__data__"in c&&(u.__data__=c.__data__),l[f]=u);return new xs(r,this._parents)}function Fz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zz(){return[]}function iP(e){return e==null?zz:function(){return this.querySelectorAll(e)}}function Wz(e){return function(){return Fz(e.apply(this,arguments))}}function Bz(e){typeof e=="function"?e=Wz(e):e=iP(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 xs(r,s)}function oP(e){return function(){return this.matches(e)}}function aP(e){return function(t){return t.matches(e)}}var Hz=Array.prototype.find;function Vz(e){return function(){return Hz.call(this.children,e)}}function Kz(){return this.firstElementChild}function qz(e){return this.select(e==null?Kz:Vz(typeof e=="function"?e:aP(e)))}var Uz=Array.prototype.filter;function Gz(){return Array.from(this.children)}function Yz(e){return function(){return Uz.call(this.children,e)}}function Jz(e){return this.selectAll(e==null?Gz:Yz(typeof e=="function"?e:aP(e)))}function Xz(e){typeof e!="function"&&(e=oP(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 xs(r,this._parents)}function lP(e){return new Array(e.length)}function Qz(){return new xs(this._enter||this._groups.map(lP),this._parents)}function om(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}om.prototype={constructor:om,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 Zz(e){return function(){return e}}function e3(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 om(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function t3(e,t,n,r,s,o,a){var l,c,u=new Map,f=t.length,p=o.length,d=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(d[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<p;++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 om(e,o[l]);for(l=0;l<f;++l)(c=t[l])&&u.get(d[l])===c&&(s[l]=c)}function n3(e){return e.__data__}function r3(e,t){if(!arguments.length)return Array.from(this,n3);var n=t?t3:e3,r=this._parents,s=this._groups;typeof e!="function"&&(e=Zz(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var f=r[u],p=s[u],d=p.length,h=s3(e.call(f,f&&f.__data__,u,r)),y=h.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(d);n(f,p,v,b,g,h,t);for(var k=0,x=0,_,S;k<y;++k)if(_=v[k]){for(k>=x&&(x=k+1);!(S=b[x])&&++x<y;);_._next=S||null}}return a=new xs(a,r),a._enter=l,a._exit=c,a}function s3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function i3(){return new xs(this._exit||this._groups.map(lP),this._parents)}function o3(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 a3(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],f=r[c],p=u.length,d=l[c]=new Array(p),h,y=0;y<p;++y)(h=u[y]||f[y])&&(d[y]=h);for(;c<s;++c)l[c]=n[c];return new xs(l,this._parents)}function l3(){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 c3(e){e||(e=u3);function t(p,d){return p&&d?e(p.__data__,d.__data__):!p-!d}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,f=0;f<l;++f)(u=a[f])&&(c[f]=u);c.sort(t)}return new xs(s,this._parents).order()}function u3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function d3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function f3(){return Array.from(this)}function p3(){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 h3(){let e=0;for(const t of this)++e;return e}function m3(){return!this.node()}function g3(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 y3(e){return function(){this.removeAttribute(e)}}function w3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function x3(e,t){return function(){this.setAttribute(e,t)}}function b3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function k3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function v3(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 S3(e,t){var n=ag(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?w3:y3:typeof t=="function"?n.local?v3:k3:n.local?b3:x3)(n,t))}function cP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function j3(e){return function(){this.style.removeProperty(e)}}function N3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function C3(e,t,n){return arguments.length>1?this.each((t==null?j3:typeof t=="function"?_3:N3)(e,t,n??"")):zc(this.node(),e)}function zc(e,t){return e.style.getPropertyValue(t)||cP(e).getComputedStyle(e,null).getPropertyValue(t)}function A3(e){return function(){delete this[e]}}function E3(e,t){return function(){this[e]=t}}function I3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function P3(e,t){return arguments.length>1?this.each((t==null?A3:typeof t=="function"?I3:E3)(e,t)):this.node()[e]}function uP(e){return e.trim().split(/^|\s+/)}function Hk(e){return e.classList||new dP(e)}function dP(e){this._node=e,this._names=uP(e.getAttribute("class")||"")}dP.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 fP(e,t){for(var n=Hk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function pP(e,t){for(var n=Hk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function T3(e){return function(){fP(this,e)}}function R3(e){return function(){pP(this,e)}}function M3(e,t){return function(){(t.apply(this,arguments)?fP:pP)(this,e)}}function $3(e,t){var n=uP(e+"");if(arguments.length<2){for(var r=Hk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?M3:t?T3:R3)(n,t))}function L3(){this.textContent=""}function O3(e){return function(){this.textContent=e}}function D3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function F3(e){return arguments.length?this.each(e==null?L3:(typeof e=="function"?D3:O3)(e)):this.node().textContent}function z3(){this.innerHTML=""}function W3(e){return function(){this.innerHTML=e}}function B3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function H3(e){return arguments.length?this.each(e==null?z3:(typeof e=="function"?B3:W3)(e)):this.node().innerHTML}function V3(){this.nextSibling&&this.parentNode.appendChild(this)}function K3(){return this.each(V3)}function q3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function U3(){return this.each(q3)}function G3(e){var t=typeof e=="function"?e:sP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Y3(){return null}function J3(e,t){var n=typeof e=="function"?e:sP(e),r=t==null?Y3:typeof t=="function"?t:Bk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function X3(){var e=this.parentNode;e&&e.removeChild(this)}function Q3(){return this.each(X3)}function Z3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eW(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tW(e){return this.select(e?eW:Z3)}function nW(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rW(e){return function(t){e.call(this,t,this.__data__)}}function sW(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 iW(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 oW(e,t,n){return function(){var r=this.__on,s,o=rW(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 aW(e,t,n){var r=sW(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,f;c<u;++c)for(s=0,f=l[c];s<o;++s)if((a=r[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?oW:iW,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function hP(e,t,n){var r=cP(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 lW(e,t){return function(){return hP(this,e,t)}}function cW(e,t){return function(){return hP(this,e,t.apply(this,arguments))}}function uW(e,t){return this.each((typeof t=="function"?cW:lW)(e,t))}function*dW(){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 mP=[null];function xs(e,t){this._groups=e,this._parents=t}function _f(){return new xs([[document.documentElement]],mP)}function fW(){return this}xs.prototype=_f.prototype={constructor:xs,select:Dz,selectAll:Bz,selectChild:qz,selectChildren:Jz,filter:Xz,data:r3,enter:Qz,exit:i3,join:o3,merge:a3,selection:fW,order:l3,sort:c3,call:d3,nodes:f3,node:p3,size:h3,empty:m3,each:g3,attr:S3,style:C3,property:P3,classed:$3,text:F3,html:H3,raise:K3,lower:U3,append:G3,insert:J3,remove:Q3,clone:tW,datum:nW,on:aW,dispatch:uW,[Symbol.iterator]:dW};function ps(e){return typeof e=="string"?new xs([[document.querySelector(e)]],[document.documentElement]):new xs([[e]],mP)}function pW(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ni(e,t){if(e=pW(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 hW={passive:!1},Jd={capture:!0,passive:!1};function Qy(e){e.stopImmediatePropagation()}function Nc(e){e.preventDefault(),e.stopImmediatePropagation()}function gP(e){var t=e.document.documentElement,n=ps(e).on("dragstart.drag",Nc,Jd);"onselectstart"in t?n.on("selectstart.drag",Nc,Jd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function yP(e,t){var n=e.document.documentElement,r=ps(e).on("dragstart.drag",null);t&&(r.on("click.drag",Nc,Jd),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 Mp=e=>()=>e;function Ux(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value: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:f}})}Ux.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function mW(e){return!e.ctrlKey&&!e.button}function gW(){return this.parentNode}function yW(e,t){return t??{x:e.x,y:e.y}}function wW(){return navigator.maxTouchPoints||"ontouchstart"in this}function wP(){var e=mW,t=gW,n=yW,r=wW,s={},o=og("start","drag","end"),a=0,l,c,u,f,p=0;function d(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,hW).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,S){if(!(f||!e.call(this,_,S))){var N=x(this,t.call(this,_,S),_,S,"mouse");N&&(ps(_.view).on("mousemove.drag",y,Jd).on("mouseup.drag",v,Jd),gP(_.view),Qy(_),u=!1,l=_.clientX,c=_.clientY,N("start",_))}}function y(_){if(Nc(_),!u){var S=_.clientX-l,N=_.clientY-c;u=S*S+N*N>p}s.mouse("drag",_)}function v(_){ps(_.view).on("mousemove.drag mouseup.drag",null),yP(_.view,u),Nc(_),s.mouse("end",_)}function b(_,S){if(e.call(this,_,S)){var N=_.changedTouches,I=t.call(this,_,S),T=N.length,z,E;for(z=0;z<T;++z)(E=x(this,I,_,S,N[z].identifier,N[z]))&&(Qy(_),E("start",_,N[z]))}}function g(_){var S=_.changedTouches,N=S.length,I,T;for(I=0;I<N;++I)(T=s[S[I].identifier])&&(Nc(_),T("drag",_,S[I]))}function k(_){var S=_.changedTouches,N=S.length,I,T;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),I=0;I<N;++I)(T=s[S[I].identifier])&&(Qy(_),T("end",_,S[I]))}function x(_,S,N,I,T,z){var E=o.copy(),D=ni(z||N,S),L,O,M;if((M=n.call(_,new Ux("beforestart",{sourceEvent:N,target:d,identifier:T,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:E}),I))!=null)return L=M.x-D[0]||0,O=M.y-D[1]||0,function V(B,F,$){var H=D,A;switch(B){case"start":s[T]=V,A=a++;break;case"end":delete s[T],--a;case"drag":D=ni($||F,S),A=a;break}E.call(B,_,new Ux(B,{sourceEvent:F,subject:M,target:d,identifier:T,active:A,x:D[0]+L,y:D[1]+O,dx:D[0]-H[0],dy:D[1]-H[1],dispatch:E}),I)}}return d.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Mp(!!_),d):e},d.container=function(_){return arguments.length?(t=typeof _=="function"?_:Mp(_),d):t},d.subject=function(_){return arguments.length?(n=typeof _=="function"?_:Mp(_),d):n},d.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Mp(!!_),d):r},d.on=function(){var _=o.on.apply(o,arguments);return _===o?d:_},d.clickDistance=function(_){return arguments.length?(p=(_=+_)*_,d):Math.sqrt(p)},d}function Vk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function xP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Cf(){}var Xd=.7,am=1/Xd,_c="\\s*([+-]?\\d+)\\s*",Qd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xW=/^#([0-9a-f]{3,8})$/,bW=new RegExp(`^rgb\\(${_c},${_c},${_c}\\)$`),kW=new RegExp(`^rgb\\(${Mi},${Mi},${Mi}\\)$`),vW=new RegExp(`^rgba\\(${_c},${_c},${_c},${Qd}\\)$`),SW=new RegExp(`^rgba\\(${Mi},${Mi},${Mi},${Qd}\\)$`),jW=new RegExp(`^hsl\\(${Qd},${Mi},${Mi}\\)$`),NW=new RegExp(`^hsla\\(${Qd},${Mi},${Mi},${Qd}\\)$`),_N={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};Vk(Cf,il,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:CN,formatHex:CN,formatHex8:_W,formatHsl:CW,formatRgb:AN,toString:AN});function CN(){return this.rgb().formatHex()}function _W(){return this.rgb().formatHex8()}function CW(){return bP(this).formatHsl()}function AN(){return this.rgb().formatRgb()}function il(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=xW.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?EN(t):n===3?new es(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$p(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$p(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=bW.exec(e))?new es(t[1],t[2],t[3],1):(t=kW.exec(e))?new es(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vW.exec(e))?$p(t[1],t[2],t[3],t[4]):(t=SW.exec(e))?$p(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jW.exec(e))?TN(t[1],t[2]/100,t[3]/100,1):(t=NW.exec(e))?TN(t[1],t[2]/100,t[3]/100,t[4]):_N.hasOwnProperty(e)?EN(_N[e]):e==="transparent"?new es(NaN,NaN,NaN,0):null}function EN(e){return new es(e>>16&255,e>>8&255,e&255,1)}function $p(e,t,n,r){return r<=0&&(e=t=n=NaN),new es(e,t,n,r)}function AW(e){return e instanceof Cf||(e=il(e)),e?(e=e.rgb(),new es(e.r,e.g,e.b,e.opacity)):new es}function Gx(e,t,n,r){return arguments.length===1?AW(e):new es(e,t,n,r??1)}function es(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Vk(es,Gx,xP(Cf,{brighter(e){return e=e==null?am:Math.pow(am,e),new es(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new es(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new es(Ja(this.r),Ja(this.g),Ja(this.b),lm(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:IN,formatHex:IN,formatHex8:EW,formatRgb:PN,toString:PN}));function IN(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}`}function EW(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}${Va((isNaN(this.opacity)?1:this.opacity)*255)}`}function PN(){const e=lm(this.opacity);return`${e===1?"rgb(":"rgba("}${Ja(this.r)}, ${Ja(this.g)}, ${Ja(this.b)}${e===1?")":`, ${e})`}`}function lm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ja(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Va(e){return e=Ja(e),(e<16?"0":"")+e.toString(16)}function TN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ii(e,t,n,r)}function bP(e){if(e instanceof ii)return new ii(e.h,e.s,e.l,e.opacity);if(e instanceof Cf||(e=il(e)),!e)return new ii;if(e instanceof ii)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 ii(a,l,c,e.opacity)}function IW(e,t,n,r){return arguments.length===1?bP(e):new ii(e,t,n,r??1)}function ii(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Vk(ii,IW,xP(Cf,{brighter(e){return e=e==null?am:Math.pow(am,e),new ii(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new ii(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 es(Zy(e>=240?e-240:e+120,s,r),Zy(e,s,r),Zy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ii(RN(this.h),Lp(this.s),Lp(this.l),lm(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=lm(this.opacity);return`${e===1?"hsl(":"hsla("}${RN(this.h)}, ${Lp(this.s)*100}%, ${Lp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function RN(e){return e=(e||0)%360,e<0?e+360:e}function Lp(e){return Math.max(0,Math.min(1,e||0))}function Zy(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 Kk=e=>()=>e;function PW(e,t){return function(n){return e+n*t}}function TW(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 RW(e){return(e=+e)==1?kP:function(t,n){return n-t?TW(t,n,e):Kk(isNaN(t)?n:t)}}function kP(e,t){var n=t-e;return n?PW(e,n):Kk(isNaN(e)?t:e)}const cm=function e(t){var n=RW(t);function r(s,o){var a=n((s=Gx(s)).r,(o=Gx(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=kP(s.opacity,o.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=c(f),s.opacity=u(f),s+""}}return r.gamma=e,r}(1);function MW(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 $W(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LW(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]=Sd(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 OW(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ji(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function DW(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]=Sd(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Yx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ew=new RegExp(Yx.source,"g");function FW(e){return function(){return e}}function zW(e){return function(t){return e(t)+""}}function vP(e,t){var n=Yx.lastIndex=ew.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Yx.exec(e))&&(s=ew.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:ji(r,s)})),n=ew.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?zW(c[0].x):FW(t):(t=c.length,function(u){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(u);return l.join("")})}function Sd(e,t){var n=typeof t,r;return t==null||n==="boolean"?Kk(t):(n==="number"?ji:n==="string"?(r=il(t))?(t=r,cm):vP:t instanceof il?cm:t instanceof Date?OW:$W(t)?MW:Array.isArray(t)?LW:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?DW:ji)(e,t)}var MN=180/Math.PI,Jx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function SP(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)*MN,skewX:Math.atan(c)*MN,scaleX:a,scaleY:l}}var Op;function WW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Jx:SP(t.a,t.b,t.c,t.d,t.e,t.f)}function BW(e){return e==null||(Op||(Op=document.createElementNS("http://www.w3.org/2000/svg","g")),Op.setAttribute("transform",e),!(e=Op.transform.baseVal.consolidate()))?Jx:(e=e.matrix,SP(e.a,e.b,e.c,e.d,e.e,e.f))}function jP(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function o(u,f,p,d,h,y){if(u!==p||f!==d){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:ji(u,p)},{i:v-2,x:ji(f,d)})}else(p||d)&&h.push("translate("+p+t+d+n)}function a(u,f,p,d){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),d.push({i:p.push(s(p)+"rotate(",null,r)-2,x:ji(u,f)})):f&&p.push(s(p)+"rotate("+f+r)}function l(u,f,p,d){u!==f?d.push({i:p.push(s(p)+"skewX(",null,r)-2,x:ji(u,f)}):f&&p.push(s(p)+"skewX("+f+r)}function c(u,f,p,d,h,y){if(u!==p||f!==d){var v=h.push(s(h)+"scale(",null,",",null,")");y.push({i:v-4,x:ji(u,p)},{i:v-2,x:ji(f,d)})}else(p!==1||d!==1)&&h.push(s(h)+"scale("+p+","+d+")")}return function(u,f){var p=[],d=[];return u=e(u),f=e(f),o(u.translateX,u.translateY,f.translateX,f.translateY,p,d),a(u.rotate,f.rotate,p,d),l(u.skewX,f.skewX,p,d),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,p,d),u=f=null,function(h){for(var y=-1,v=d.length,b;++y<v;)p[(b=d[y]).i]=b.x(h);return p.join("")}}}var HW=jP(WW,"px, ","px)","deg)"),VW=jP(BW,", ",")",")"),KW=1e-12;function $N(e){return((e=Math.exp(e))+1/e)/2}function qW(e){return((e=Math.exp(e))-1/e)/2}function UW(e){return((e=Math.exp(2*e))-1)/(e+1)}const Sh=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],u=o[2],f=a[0],p=a[1],d=a[2],h=f-l,y=p-c,v=h*h+y*y,b,g;if(v<KW)g=Math.log(d/u)/t,b=function(I){return[l+I*h,c+I*y,u*Math.exp(t*I*g)]};else{var k=Math.sqrt(v),x=(d*d-u*u+r*v)/(2*u*n*k),_=(d*d-u*u-r*v)/(2*d*n*k),S=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(_*_+1)-_);g=(N-S)/t,b=function(I){var T=I*g,z=$N(S),E=u/(n*k)*(z*UW(t*T+S)-qW(S));return[l+E*h,c+E*y,u*z/$N(t*T+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 Wc=0,id=0,Vu=0,NP=1e3,um,od,dm=0,ol=0,lg=0,Zd=typeof performance=="object"&&performance.now?performance:Date,_P=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qk(){return ol||(_P(GW),ol=Zd.now()+lg)}function GW(){ol=0}function fm(){this._call=this._time=this._next=null}fm.prototype=CP.prototype={constructor:fm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qk():+n)+(t==null?0:+t),!this._next&&od!==this&&(od?od._next=this:um=this,od=this),this._call=e,this._time=n,Xx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Xx())}};function CP(e,t,n){var r=new fm;return r.restart(e,t,n),r}function YW(){qk(),++Wc;for(var e=um,t;e;)(t=ol-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Wc}function LN(){ol=(dm=Zd.now())+lg,Wc=id=0;try{YW()}finally{Wc=0,XW(),ol=0}}function JW(){var e=Zd.now(),t=e-dm;t>NP&&(lg-=t,dm=e)}function XW(){for(var e,t=um,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:um=n);od=e,Xx(r)}function Xx(e){if(!Wc){id&&(id=clearTimeout(id));var t=e-ol;t>24?(e<1/0&&(id=setTimeout(LN,e-Zd.now()-lg)),Vu&&(Vu=clearInterval(Vu))):(Vu||(dm=Zd.now(),Vu=setInterval(JW,NP)),Wc=1,_P(LN))}}function ON(e,t,n){var r=new fm;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var QW=og("start","end","cancel","interrupt"),ZW=[],AP=0,DN=1,Qx=2,jh=3,FN=4,Zx=5,Nh=6;function cg(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;eB(e,n,{name:t,index:r,group:s,on:QW,tween:ZW,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:AP})}function Uk(e,t){var n=hi(e,t);if(n.state>AP)throw new Error("too late; already scheduled");return n}function Wi(e,t){var n=hi(e,t);if(n.state>jh)throw new Error("too late; already running");return n}function hi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function eB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=CP(o,0,n.time);function o(u){n.state=DN,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,p,d,h;if(n.state!==DN)return c();for(f in r)if(h=r[f],h.name===n.name){if(h.state===jh)return ON(a);h.state===FN?(h.state=Nh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[f]):+f<t&&(h.state=Nh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[f])}if(ON(function(){n.state===jh&&(n.state=FN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Qx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Qx){for(n.state=jh,s=new Array(d=n.tween.length),f=0,p=-1;f<d;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=h);s.length=p+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Zx,1),p=-1,d=s.length;++p<d;)s[p].call(e,f);n.state===Zx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Nh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function _h(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>Qx&&r.state<Zx,r.state=Nh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function tB(e){return this.each(function(){_h(this,e)})}function nB(e,t){var n,r;return function(){var s=Wi(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 rB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Wi(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 sB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=hi(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?nB:rB)(n,e,t))}function Gk(e,t,n){var r=e._id;return e.each(function(){var s=Wi(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return hi(s,r).value[t]}}function EP(e,t){var n;return(typeof t=="number"?ji:t instanceof il?cm:(n=il(t))?(t=n,cm):vP)(e,t)}function iB(e){return function(){this.removeAttribute(e)}}function oB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aB(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 lB(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 cB(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 uB(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 dB(e,t){var n=ag(e),r=n==="transform"?VW:EP;return this.attrTween(e,typeof t=="function"?(n.local?uB:cB)(n,r,Gk(this,"attr."+e,t)):t==null?(n.local?oB:iB)(n):(n.local?lB:aB)(n,r,t))}function fB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function pB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&pB(e,o)),n}return s._value=t,s}function mB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&fB(e,o)),n}return s._value=t,s}function gB(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=ag(e);return this.tween(n,(r.local?hB:mB)(r,t))}function yB(e,t){return function(){Uk(this,e).delay=+t.apply(this,arguments)}}function wB(e,t){return t=+t,function(){Uk(this,e).delay=t}}function xB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yB:wB)(t,e)):hi(this.node(),t).delay}function bB(e,t){return function(){Wi(this,e).duration=+t.apply(this,arguments)}}function kB(e,t){return t=+t,function(){Wi(this,e).duration=t}}function vB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bB:kB)(t,e)):hi(this.node(),t).duration}function SB(e,t){if(typeof t!="function")throw new Error;return function(){Wi(this,e).ease=t}}function jB(e){var t=this._id;return arguments.length?this.each(SB(t,e)):hi(this.node(),t).ease}function NB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Wi(this,e).ease=n}}function _B(e){if(typeof e!="function")throw new Error;return this.each(NB(this._id,e))}function CB(e){typeof e!="function"&&(e=oP(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 go(r,this._parents,this._name,this._id)}function AB(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],f=c.length,p=a[l]=new Array(f),d,h=0;h<f;++h)(d=c[h]||u[h])&&(p[h]=d);for(;l<r;++l)a[l]=t[l];return new go(a,this._parents,this._name,this._id)}function EB(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 IB(e,t,n){var r,s,o=EB(t)?Uk:Wi;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function PB(e,t){var n=this._id;return arguments.length<2?hi(this.node(),n).on.on(e):this.each(IB(n,e,t))}function TB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RB(){return this.on("end.remove",TB(this._id))}function MB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bk(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),f,p,d=0;d<c;++d)(f=l[d])&&(p=e.call(f,f.__data__,d,l))&&("__data__"in f&&(p.__data__=f.__data__),u[d]=p,cg(u[d],t,n,d,u,hi(f,n)));return new go(o,this._parents,t,n)}function $B(e){var t=this._name,n=this._id;typeof e!="function"&&(e=iP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,f,p=0;p<u;++p)if(f=c[p]){for(var d=e.call(f,f.__data__,p,c),h,y=hi(f,n),v=0,b=d.length;v<b;++v)(h=d[v])&&cg(h,t,n,v,d,y);o.push(d),a.push(f)}return new go(o,a,t,n)}var LB=_f.prototype.constructor;function OB(){return new LB(this._groups,this._parents)}function DB(e,t){var n,r,s;return function(){var o=zc(this,e),a=(this.style.removeProperty(e),zc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function IP(e){return function(){this.style.removeProperty(e)}}function FB(e,t,n){var r,s=n+"",o;return function(){var a=zc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function zB(e,t,n){var r,s,o;return function(){var a=zc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),zc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function WB(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Wi(this,e),u=c.on,f=c.value[o]==null?l||(l=IP(t)):void 0;(u!==n||s!==f)&&(r=(n=u).copy()).on(a,s=f),c.on=r}}function BB(e,t,n){var r=(e+="")=="transform"?HW:EP;return t==null?this.styleTween(e,DB(e,r)).on("end.style."+e,IP(e)):typeof t=="function"?this.styleTween(e,zB(e,r,Gk(this,"style."+e,t))).each(WB(this._id,e)):this.styleTween(e,FB(e,r,t),n).on("end.style."+e,null)}function HB(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function VB(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&HB(e,a,n)),r}return o._value=t,o}function KB(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,VB(e,t,n??""))}function qB(e){return function(){this.textContent=e}}function UB(e){return function(){var t=e(this);this.textContent=t??""}}function GB(e){return this.tween("text",typeof e=="function"?UB(Gk(this,"text",e)):qB(e==null?"":e+""))}function YB(e){return function(t){this.textContent=e.call(this,t)}}function JB(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&YB(s)),t}return r._value=e,r}function XB(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,JB(e))}function QB(){for(var e=this._name,t=this._id,n=PP(),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 f=hi(c,t);cg(c,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new go(r,this._parents,e,n)}function ZB(){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=Wi(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&o()})}var e4=0;function go(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function PP(){return++e4}var Ji=_f.prototype;go.prototype={constructor:go,select:MB,selectAll:$B,selectChild:Ji.selectChild,selectChildren:Ji.selectChildren,filter:CB,merge:AB,selection:OB,transition:QB,call:Ji.call,nodes:Ji.nodes,node:Ji.node,size:Ji.size,empty:Ji.empty,each:Ji.each,on:PB,attr:dB,attrTween:gB,style:BB,styleTween:KB,text:GB,textTween:XB,remove:RB,tween:sB,delay:xB,duration:vB,ease:jB,easeVarying:_B,end:ZB,[Symbol.iterator]:Ji[Symbol.iterator]};function t4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var n4={time:null,delay:0,duration:250,ease:t4};function r4(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 s4(e){var t,n;e instanceof go?(t=e._id,e=e._name):(t=PP(),(n=n4).time=qk(),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])&&cg(c,e,t,u,a,n||r4(c,t));return new go(r,this._parents,e,t)}_f.prototype.interrupt=tB;_f.prototype.transition=s4;const Dp=e=>()=>e;function i4(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 so(e,t,n){this.k=e,this.x=t,this.y=n}so.prototype={constructor:so,scale:function(e){return e===1?this:new so(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new so(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 ug=new so(1,0,0);TP.prototype=so.prototype;function TP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ug;return e.__zoom}function tw(e){e.stopImmediatePropagation()}function Ku(e){e.preventDefault(),e.stopImmediatePropagation()}function o4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function a4(){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 zN(){return this.__zoom||ug}function l4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function c4(){return navigator.maxTouchPoints||"ontouchstart"in this}function u4(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 RP(){var e=o4,t=a4,n=u4,r=l4,s=c4,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Sh,u=og("start","zoom","end"),f,p,d,h=500,y=150,v=0,b=10;function g(M){M.property("__zoom",zN).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,V,B,F){var $=M.selection?M.selection():M;$.property("__zoom",zN),M!==$?S(M,V,B,F):$.interrupt().each(function(){N(this,arguments).event(F).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},g.scaleBy=function(M,V,B,F){g.scaleTo(M,function(){var $=this.__zoom.k,H=typeof V=="function"?V.apply(this,arguments):V;return $*H},B,F)},g.scaleTo=function(M,V,B,F){g.transform(M,function(){var $=t.apply(this,arguments),H=this.__zoom,A=B==null?_($):typeof B=="function"?B.apply(this,arguments):B,Q=H.invert(A),K=typeof V=="function"?V.apply(this,arguments):V;return n(x(k(H,K),A,Q),$,a)},B,F)},g.translateBy=function(M,V,B,F){g.transform(M,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),a)},null,F)},g.translateTo=function(M,V,B,F,$){g.transform(M,function(){var H=t.apply(this,arguments),A=this.__zoom,Q=F==null?_(H):typeof F=="function"?F.apply(this,arguments):F;return n(ug.translate(Q[0],Q[1]).scale(A.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof B=="function"?-B.apply(this,arguments):-B),H,a)},F,$)};function k(M,V){return V=Math.max(o[0],Math.min(o[1],V)),V===M.k?M:new so(V,M.x,M.y)}function x(M,V,B){var F=V[0]-B[0]*M.k,$=V[1]-B[1]*M.k;return F===M.x&&$===M.y?M:new so(M.k,F,$)}function _(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function S(M,V,B,F){M.on("start.zoom",function(){N(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(F).end()}).tween("zoom",function(){var $=this,H=arguments,A=N($,H).event(F),Q=t.apply($,H),K=B==null?_(Q):typeof B=="function"?B.apply($,H):B,W=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),ne=$.__zoom,Z=typeof V=="function"?V.apply($,H):V,G=c(ne.invert(K).concat(W/ne.k),Z.invert(K).concat(W/Z.k));return function(te){if(te===1)te=Z;else{var re=G(te),se=W/re[2];te=new so(se,K[0]-re[0]*se,K[1]-re[1]*se)}A.zoom(null,te)}})}function N(M,V,B){return!B&&M.__zooming||new I(M,V)}function I(M,V){this.that=M,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,V),this.taps=0}I.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=ps(this.that).datum();u.call(M,this.that,new i4(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),V)}};function T(M,...V){if(!e.apply(this,arguments))return;var B=N(this,V).event(M),F=this.__zoom,$=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),H=ni(M);if(B.wheel)(B.mouse[0][0]!==H[0]||B.mouse[0][1]!==H[1])&&(B.mouse[1]=F.invert(B.mouse[0]=H)),clearTimeout(B.wheel);else{if(F.k===$)return;B.mouse=[H,F.invert(H)],_h(this),B.start()}Ku(M),B.wheel=setTimeout(A,y),B.zoom("mouse",n(x(k(F,$),B.mouse[0],B.mouse[1]),B.extent,a));function A(){B.wheel=null,B.end()}}function z(M,...V){if(d||!e.apply(this,arguments))return;var B=M.currentTarget,F=N(this,V,!0).event(M),$=ps(M.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",W,!0),H=ni(M,B),A=M.clientX,Q=M.clientY;gP(M.view),tw(M),F.mouse=[H,this.__zoom.invert(H)],_h(this),F.start();function K(ne){if(Ku(ne),!F.moved){var Z=ne.clientX-A,G=ne.clientY-Q;F.moved=Z*Z+G*G>v}F.event(ne).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ni(ne,B),F.mouse[1]),F.extent,a))}function W(ne){$.on("mousemove.zoom mouseup.zoom",null),yP(ne.view,F.moved),Ku(ne),F.event(ne).end()}}function E(M,...V){if(e.apply(this,arguments)){var B=this.__zoom,F=ni(M.changedTouches?M.changedTouches[0]:M,this),$=B.invert(F),H=B.k*(M.shiftKey?.5:2),A=n(x(k(B,H),F,$),t.apply(this,V),a);Ku(M),l>0?ps(this).transition().duration(l).call(S,A,F,M):ps(this).call(g.transform,A,F,M)}}function D(M,...V){if(e.apply(this,arguments)){var B=M.touches,F=B.length,$=N(this,V,M.changedTouches.length===F).event(M),H,A,Q,K;for(tw(M),A=0;A<F;++A)Q=B[A],K=ni(Q,this),K=[K,this.__zoom.invert(K),Q.identifier],$.touch0?!$.touch1&&$.touch0[2]!==K[2]&&($.touch1=K,$.taps=0):($.touch0=K,H=!0,$.taps=1+!!f);f&&(f=clearTimeout(f)),H&&($.taps<2&&(p=K[0],f=setTimeout(function(){f=null},h)),_h(this),$.start())}}function L(M,...V){if(this.__zooming){var B=N(this,V).event(M),F=M.changedTouches,$=F.length,H,A,Q,K;for(Ku(M),H=0;H<$;++H)A=F[H],Q=ni(A,this),B.touch0&&B.touch0[2]===A.identifier?B.touch0[0]=Q:B.touch1&&B.touch1[2]===A.identifier&&(B.touch1[0]=Q);if(A=B.that.__zoom,B.touch1){var W=B.touch0[0],ne=B.touch0[1],Z=B.touch1[0],G=B.touch1[1],te=(te=Z[0]-W[0])*te+(te=Z[1]-W[1])*te,re=(re=G[0]-ne[0])*re+(re=G[1]-ne[1])*re;A=k(A,Math.sqrt(te/re)),Q=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],K=[(ne[0]+G[0])/2,(ne[1]+G[1])/2]}else if(B.touch0)Q=B.touch0[0],K=B.touch0[1];else return;B.zoom("touch",n(x(A,Q,K),B.extent,a))}}function O(M,...V){if(this.__zooming){var B=N(this,V).event(M),F=M.changedTouches,$=F.length,H,A;for(tw(M),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),H=0;H<$;++H)A=F[H],B.touch0&&B.touch0[2]===A.identifier?delete B.touch0:B.touch1&&B.touch1[2]===A.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(A=ni(A,this),Math.hypot(p[0]-A[0],p[1]-A[1])<b)){var Q=ps(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Dp(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Dp(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Dp(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Dp([[+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 Fi={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."},ef=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],MP=["Enter"," ","Escape"],$P={"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 Bc;(function(e){e.Strict="strict",e.Loose="loose"})(Bc||(Bc={}));var Xa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xa||(Xa={}));var tf;(function(e){e.Partial="partial",e.Full="full"})(tf||(tf={}));const LP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Vo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Vo||(Vo={}));var Ai;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ai||(Ai={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));const WN={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};function OP(e){return e===null?null:e?"valid":"invalid"}const DP=e=>"id"in e&&"source"in e&&"target"in e,d4=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Yk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Af=(e,t=[0,0])=>{const{width:n,height:r}=ko(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},f4=(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):Yk(s)?s:t.nodeLookup.get(s.id));const l=a?pm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return dg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fg(n)},Ef=(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=dg(n,pm(s)),r=!0)}),r?fg(n):{x:0,y:0,width:0,height:0}},Jk=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...Pf(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:f,selectable:p=!0,hidden:d=!1}=u;if(a&&!p||d)continue;const h=f.width??u.width??u.initialWidth??null,y=f.height??u.height??u.initialHeight??null,v=nf(l,Vc(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},p4=(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 h4(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 m4({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=h4(e,a),c=Ef(l),u=Xk(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 FP({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},f=a.origin??r;let p=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Fi.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(p=[[c,u],[c+h,u+y]])}else l&&Kc(a.extent)&&(p=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const d=Kc(p)?al(t,p,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Fi.error015())),{position:{x:d.x-c+(a.measured.width??0)*f[0],y:d.y-u+(a.measured.height??0)*f[1]},positionAbsolute:d}}async function g4({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const h=o.has(d.id),y=!h&&d.parentId&&a.find(v=>v.id===d.parentId);(h||y)&&a.push(d)}const l=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),f=p4(a,c);for(const d of c)l.has(d.id)&&!f.find(y=>y.id===d.id)&&f.push(d);if(!s)return{edges:f,nodes:a};const p=await s({nodes:a,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:a}:{edges:[],nodes:[]}:p}const Hc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),al=(e={x:0,y:0},t,n)=>({x:Hc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Hc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function zP(e,t,n){const{width:r,height:s}=ko(n),{x:o,y:a}=n.internals.positionAbsolute;return al(e,[[o,a],[o+r,a+s]],t)}const BN=(e,t,n)=>e<t?Hc(Math.abs(e-t),1,t)/t:e>n?-Hc(Math.abs(e-n),1,t)/t:0,WP=(e,t,n=15,r=40)=>{const s=BN(e.x,r,t.width-r)*n,o=BN(e.y,r,t.height-r)*n;return[s,o]},dg=(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)}),eb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),fg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Vc=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Yk(e)?e.internals.positionAbsolute:Af(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}},pm=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Yk(e)?e.internals.positionAbsolute:Af(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)}},BP=(e,t)=>fg(dg(eb(e),eb(t))),nf=(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)},HN=e=>oi(e.width)&&oi(e.height)&&oi(e.x)&&oi(e.y),oi=e=>!isNaN(e)&&isFinite(e),y4=(e,t)=>{},If=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pf=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?If(l,a):l},hm=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function ql(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 w4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ql(e,n),s=ql(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=ql(e.top??e.y??0,n),s=ql(e.bottom??e.y??0,n),o=ql(e.left??e.x??0,t),a=ql(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 x4(e,t,n,r,s,o){const{x:a,y:l}=hm(e,[t,n,r]),{x:c,y:u}=hm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=s-c,p=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const Xk=(e,t,n,r,s,o)=>{const a=w4(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),f=Hc(u,r,s),p=e.x+e.width/2,d=e.y+e.height/2,h=t/2-p*f,y=n/2-d*f,v=x4(e,h,y,f,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:f}},rf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Kc(e){return e!=null&&e!=="parent"}function ko(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function HP(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function VP(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 VN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function b4(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function k4(e){return{...$P,...e||{}}}function jd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=ai(e),l=Pf({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?If(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Qk=e=>({width:e.offsetWidth,height:e.offsetHeight}),KP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},v4=["INPUT","SELECT","TEXTAREA"];function qP(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:v4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const UP=e=>"clientX"in e,ai=(e,t)=>{var o,a;const n=UP(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)}},KN=(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,...Qk(a)}})};function GP({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,f=Math.abs(c-e),p=Math.abs(u-t);return[c,u,f,p]}function Fp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function qN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ue.Left:return[t-Fp(t-r,o),n];case Ue.Right:return[t+Fp(r-t,o),n];case Ue.Top:return[t,n-Fp(n-s,o)];case Ue.Bottom:return[t,n+Fp(s-n,o)]}}function YP({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,curvature:a=.25}){const[l,c]=qN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,f]=qN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[p,d,h,y]=GP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${c} ${u},${f} ${r},${s}`,p,d,h,y]}function JP({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 S4({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 j4({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=dg(pm(e),pm(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 nf(a,fg(o))>0}const N4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,_4=(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)),Ch=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||N4;let s;return DP(e)?s={...e}:s={...e,id:r(e)},_4(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function XP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=JP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const UN={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},C4=({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},GN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function A4({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:s,offset:o,stepPosition:a}){const l=UN[t],c=UN[r],u={x:e.x+l.x*o,y:e.y+l.y*o},f={x:n.x+c.x*o,y:n.y+c.y*o},p=C4({source:u,sourcePosition:t,target:f}),d=p.x!==0?"x":"y",h=p[d];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,_]=JP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*c[d]===-1){d==="x"?(v=s.x??u.x+(f.x-u.x)*a,b=s.y??(u.y+f.y)/2):(v=s.x??(u.x+f.x)/2,b=s.y??u.y+(f.y-u.y)*a);const T=[{x:v,y:u.y},{x:v,y:f.y}],z=[{x:u.x,y:b},{x:f.x,y:b}];l[d]===h?y=d==="x"?T:z:y=d==="x"?z:T}else{const T=[{x:u.x,y:f.y}],z=[{x:f.x,y:u.y}];if(d==="x"?y=l.x===h?z:T:y=l.y===h?T:z,t===r){const M=Math.abs(e[d]-n[d]);if(M<=o){const V=Math.min(o-1,o-M);l[d]===h?g[d]=(u[d]>e[d]?-1:1)*V:k[d]=(f[d]>n[d]?-1:1)*V}}if(t!==r){const M=d==="x"?"y":"x",V=l[d]===c[M],B=u[M]>f[M],F=u[M]<f[M];(l[d]===1&&(!V&&B||V&&F)||l[d]!==1&&(!V&&F||V&&B))&&(y=d==="x"?T:z)}const E={x:u.x+g.x,y:u.y+g.y},D={x:f.x+k.x,y:f.y+k.y},L=Math.max(Math.abs(E.x-y[0].x),Math.abs(D.x-y[0].x)),O=Math.max(Math.abs(E.y-y[0].y),Math.abs(D.y-y[0].y));L>=O?(v=(E.x+D.x)/2,b=y[0].y):(v=y[0].x,b=(E.y+D.y)/2)}const S={x:u.x+g.x,y:u.y+g.y},N={x:f.x+k.x,y:f.y+k.y};return[[e,...S.x!==y[0].x||S.y!==y[0].y?[S]:[],...y,...N.x!==y[y.length-1].x||N.y!==y[y.length-1].y?[N]:[],n],v,b,x,_]}function E4(e,t,n,r){const s=Math.min(GN(e,t)/2,GN(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,f=e.y<n.y?1:-1;return`L ${o+s*u},${a}Q ${o},${a} ${o},${a+s*f}`}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 tb({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:f=.5}){const[p,d,h,y,v]=A4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:f});let b=`M${p[0].x} ${p[0].y}`;for(let g=1;g<p.length-1;g++)b+=E4(p[g-1],p[g],p[g+1],a);return b+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[b,d,h,y,v]}function YN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function I4(e){var p;const{sourceNode:t,targetNode:n}=e;if(!YN(t)||!YN(n))return null;const r=t.internals.handleBounds||JN(t.handles),s=n.internals.handleBounds||JN(n.handles),o=XN((r==null?void 0:r.source)??[],e.sourceHandle),a=XN(e.connectionMode===Bc.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(p=e.onError)==null||p.call(e,"008",Fi.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=ll(t,o,l),f=ll(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function JN(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 ll(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??ko(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 XN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function nb(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function P4(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=nb(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 QP=1e3,T4=10,Zk={nodeOrigin:[0,0],nodeExtent:ef,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},R4={...Zk,checkEquality:!0};function ev(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function M4(e,t,n){const r=ev(Zk,n);for(const s of e.values())if(s.parentId)nv(s,e,t,r);else{const o=Af(s,r.nodeOrigin),a=Kc(s.extent)?s.extent:r.nodeExtent,l=al(o,a,ko(s));s.internals.positionAbsolute=l}}function $4(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 tv(e){return e==="manual"}function rb(e,t,n,r={}){var f,p;const s=ev(R4,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!tv(s.zIndexMode)?QP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let h=a.get(d.id);if(s.checkEquality&&d===(h==null?void 0:h.internals.userNode))t.set(d.id,h);else{const y=Af(d,s.nodeOrigin),v=Kc(d.extent)?d.extent:s.nodeExtent,b=al(y,v,ko(d));h={...s.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(p=d.measured)==null?void 0:p.height},internals:{positionAbsolute:b,handleBounds:$4(d,h),z:ZP(d,l,s.zIndexMode),userNode:d}},t.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),d.parentId&&nv(h,t,n,r,o),u||(u=d.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function L4(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 nv(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=ev(Zk,r),u=e.parentId,f=t.get(u);if(!f){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}L4(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*T4),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=o&&!tv(c)?QP:0,{x:d,y:h,z:y}=O4(e,f,a,l,p,c),{positionAbsolute:v}=e.internals,b=d!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:d,y:h}:v,z:y}})}function ZP(e,t,n){const r=oi(e.zIndex)?e.zIndex:0;return tv(n)?r:r+(e.selected?t:0)}function O4(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=ko(e),u=Af(e,n),f=Kc(e.extent)?al(u,e.extent,c):u;let p=al({x:a+f.x,y:l+f.y},r,c);e.extent==="parent"&&(p=zP(p,c,t));const d=ZP(e,s,o),h=t.internals.z??0;return{x:p.x,y:p.y,z:h>=d?h+1:d}}function rv(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)??Vc(c),f=BP(u,l.rect);o.set(l.parentId,{expandedRect:f,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const f=c.internals.positionAbsolute,p=ko(c),d=c.origin??r,h=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,y=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,v=Math.max(p.width,Math.round(l.width)),b=Math.max(p.height,Math.round(l.height)),g=(v-p.width)*d[0],k=(b-p.height)*d[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(_=>{e.some(S=>S.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+h,y:_.position.y+y}})})),(p.width<l.width||p.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?d[0]*h-g:0),height:b+(y?d[1]*y-k:0)}})}),s}function D4(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=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),d=[];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=Qk(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=Kc(y.extent)?y.extent:o;let{positionAbsolute:_}=y.internals;y.parentId&&y.extent==="parent"?_=zP(_,v,t.get(y.parentId)):x&&(_=al(_,x,v));const S={...y,measured:v,internals:{...y.internals,positionAbsolute:_,handleBounds:{source:KN("source",h.nodeElement,k,p,y.id),target:KN("target",h.nodeElement,k,p,y.id)}}};t.set(y.id,S),y.parentId&&nv(S,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&d.push({id:y.id,parentId:y.parentId,rect:Vc(S,s)}))}}if(d.length>0){const h=rv(d,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function F4({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 QN(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 eT(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}`,f=`${o}-${l}--${s}-${a}`;QN("source",c,f,e,s,a),QN("target",c,u,e,o,l),t.set(r.id,r)}}function tT(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:tT(n,t):!1}function ZN(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 z4(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!tT(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 nw({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,f]of t){const p=(a=n.get(u))==null?void 0:a.internals.userNode;p&&s.push({...p,position:f.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 W4({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=If(o,t);return{x:a.x-o.x,y:a.y-o.y}}function B4({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},f=null,p=!1,d=null,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:_,isSelectable:S,nodeId:N,nodeClickDistance:I=0}){d=ps(_);function T({x:L,y:O}){const{nodeLookup:M,nodeExtent:V,snapGrid:B,snapToGrid:F,nodeOrigin:$,onNodeDrag:H,onSelectionDrag:A,onError:Q,updateNodePositions:K}=t();o={x:L,y:O};let W=!1;const ne=l.size>1,Z=ne&&V?eb(Ef(l)):null,G=ne&&F?W4({dragItems:l,snapGrid:B,x:L,y:O}):null;for(const[te,re]of l){if(!M.has(te))continue;let se={x:L-re.distance.x,y:O-re.distance.y};F&&(se=G?{x:Math.round(se.x+G.x),y:Math.round(se.y+G.y)}:If(se,B));let ee=null;if(ne&&V&&!re.extent&&Z){const{positionAbsolute:me}=re.internals,Me=me.x-Z.x+V[0][0],Se=me.x+re.measured.width-Z.x2+V[1][0],_e=me.y-Z.y+V[0][1],Fe=me.y+re.measured.height-Z.y2+V[1][1];ee=[[Me,_e],[Se,Fe]]}const{position:ue,positionAbsolute:de}=FP({nodeId:te,nextPosition:se,nodeLookup:M,nodeExtent:ee||V,nodeOrigin:$,onError:Q});W=W||re.position.x!==ue.x||re.position.y!==ue.y,re.position=ue,re.internals.positionAbsolute=de}if(y=y||W,!!W&&(K(l,!0),v&&(r||H||!N&&A))){const[te,re]=nw({nodeId:N,dragItems:l,nodeLookup:M});r==null||r(v,l,te,re),H==null||H(v,te,re),N||A==null||A(v,re)}}async function z(){if(!f)return;const{transform:L,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[B,F]=WP(u,f,M);(B!==0||F!==0)&&(o.x=(o.x??0)-B/L[2],o.y=(o.y??0)-F/L[2],await O({x:B,y:F})&&T(o)),a=requestAnimationFrame(z)}function E(L){var ne;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:V,transform:B,snapGrid:F,snapToGrid:$,selectNodesOnDrag:H,onNodeDragStart:A,onSelectionDragStart:Q,unselectNodesAndEdges:K}=t();p=!0,(!H||!S)&&!M&&N&&((ne=O.get(N))!=null&&ne.selected||K()),S&&H&&N&&(e==null||e(N));const W=jd(L.sourceEvent,{transform:B,snapGrid:F,snapToGrid:$,containerBounds:f});if(o=W,l=z4(O,V,W,N),l.size>0&&(n||A||!N&&Q)){const[Z,G]=nw({nodeId:N,dragItems:l,nodeLookup:O});n==null||n(L.sourceEvent,l,Z,G),A==null||A(L.sourceEvent,Z,G),N||Q==null||Q(L.sourceEvent,G)}}const D=wP().clickDistance(I).on("start",L=>{const{domNode:O,nodeDragThreshold:M,transform:V,snapGrid:B,snapToGrid:F}=t();f=(O==null?void 0:O.getBoundingClientRect())||null,h=!1,y=!1,v=L.sourceEvent,M===0&&E(L),o=jd(L.sourceEvent,{transform:V,snapGrid:B,snapToGrid:F,containerBounds:f}),u=ai(L.sourceEvent,f)}).on("drag",L=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:V,snapToGrid:B,nodeDragThreshold:F,nodeLookup:$}=t(),H=jd(L.sourceEvent,{transform:M,snapGrid:V,snapToGrid:B,containerBounds:f});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!$.has(N))&&(h=!0),!h){if(!c&&O&&p&&(c=!0,z()),!p){const A=ai(L.sourceEvent,f),Q=A.x-u.x,K=A.y-u.y;Math.sqrt(Q*Q+K*K)>F&&E(L)}(o.x!==H.xSnapped||o.y!==H.ySnapped)&&l&&p&&(u=ai(L.sourceEvent,f),T(H))}}).on("end",L=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:V,onSelectionDragStop:B}=t();if(y&&(M(l,!1),y=!1),s||V||!N&&B){const[F,$]=nw({nodeId:N,dragItems:l,nodeLookup:O,dragging:!1});s==null||s(L.sourceEvent,l,F,$),V==null||V(L.sourceEvent,F,$),N||B==null||B(L.sourceEvent,$)}}}).filter(L=>{const O=L.target;return!L.button&&(!k||!ZN(O,`.${k}`,_))&&(!x||ZN(O,x,_))});d.call(D)}function g(){d==null||d.on(".drag",null)}return{update:b,destroy:g}}function H4(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())nf(s,Vc(o))>0&&r.push(o);return r}const V4=250;function K4(e,t,n,r){var l,c;let s=[],o=1/0;const a=H4(e,n,t+V4);for(const u of a){const f=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const p of f){if(r.nodeId===p.nodeId&&r.type===p.type&&r.id===p.id)continue;const{x:d,y:h}=ll(u,p,p.position,!0),y=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(s=[{...p,x:d,y:h}],o=y):y===o&&s.push({...p,x:d,y:h}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(f=>f.type===u)??s[0]}return s[0]}function nT(e,t,n,r,s,o=!1){var u,f,p;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((f=a.internals.handleBounds)==null?void 0:f.source)??[],...((p=a.internals.handleBounds)==null?void 0:p.target)??[]],c=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...ll(a,c,c.position,!0)}:c}function rT(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function q4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const sT=()=>!0;function U4(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:p,panBy:d,cancelConnection:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=sT,onReconnectEnd:k,updateConnection:x,getTransform:_,getFromHandle:S,autoPanSpeed:N,dragThreshold:I=1,handleDomNode:T}){const z=KP(e.target);let E=0,D;const{x:L,y:O}=ai(e),M=rT(o,T),V=l==null?void 0:l.getBoundingClientRect();let B=!1;if(!V||!M)return;const F=nT(s,M,r,c,t);if(!F)return;let $=ai(e,V),H=!1,A=null,Q=!1,K=null;function W(){if(!f||!V)return;const[ue,de]=WP($,V,N);d({x:ue,y:de}),E=requestAnimationFrame(W)}const ne={...F,nodeId:s,type:M,position:F.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:ll(Z,ne,Ue.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:Z,to:$,toHandle:null,toPosition:WN[ne.position],toNode:null,pointer:$};function re(){B=!0,x(te),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}I===0&&re();function se(ue){if(!B){const{x:Fe,y:at}=ai(ue),mt=Fe-L,Te=at-O;if(!(mt*mt+Te*Te>I*I))return;re()}if(!S()||!ne){ee(ue);return}const de=_();$=ai(ue,V),D=K4(Pf($,de,!1,[1,1]),n,c,ne),H||(W(),H=!0);const me=iT(ue,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:z,lib:u,flowId:p,nodeLookup:c});K=me.handleDomNode,A=me.connection,Q=q4(!!D,me.isValid);const Me=c.get(s),Se=Me?ll(Me,ne,Ue.Left,!0):te.from,_e={...te,from:Se,isValid:Q,to:me.toHandle&&Q?hm({x:me.toHandle.x,y:me.toHandle.y},de):$,toHandle:me.toHandle,toPosition:Q&&me.toHandle?me.toHandle.position:WN[ne.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null,pointer:$};x(_e),te=_e}function ee(ue){if(!("touches"in ue&&ue.touches.length>0)){if(B){(D||K)&&A&&Q&&(v==null||v(A));const{inProgress:de,...me}=te,Me={...me,toPosition:te.toHandle?te.toPosition:null};b==null||b(ue,Me),o&&(k==null||k(ue,Me))}h(),cancelAnimationFrame(E),H=!1,Q=!1,A=null,K=null,z.removeEventListener("mousemove",se),z.removeEventListener("mouseup",ee),z.removeEventListener("touchmove",se),z.removeEventListener("touchend",ee)}}z.addEventListener("mousemove",se),z.addEventListener("mouseup",ee),z.addEventListener("touchmove",se),z.addEventListener("touchend",ee)}function iT(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=sT,nodeLookup:f}){const p=o==="target",d=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y}=ai(e),v=a.elementFromPoint(h,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:d,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=rT(void 0,b),x=b.getAttribute("data-nodeid"),_=b.getAttribute("data-handleid"),S=b.classList.contains("connectable"),N=b.classList.contains("connectableend");if(!x||!k)return g;const I={source:p?x:r,sourceHandle:p?_:s,target:p?r:x,targetHandle:p?s:_};g.connection=I;const z=S&&N&&(n===Bc.Strict?p&&k==="source"||!p&&k==="target":x!==r||_!==s);g.isValid=z&&u(I),g.toHandle=nT(x,k,_,f,n,!0)}return g}const sb={onPointerDown:U4,isValid:iT};function G4({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ps(e);function o({translateExtent:l,width:c,height:u,zoomStep:f=1,pannable:p=!0,zoomable:d=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const _=n(),S=x.sourceEvent.ctrlKey&&rf()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*f,I=_[2]*Math.pow(2,N*S);t.scaleTo(I)};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 _=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],N=[S[0]-v[0],S[1]-v[1]];v=S;const I=r()*Math.max(_[2],Math.log(_[2]))*(h?-1:1),T={x:_[0]-N[0]*I,y:_[1]-N[1]*I},z=[[0,0],[c,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:_[2]},z,l)},k=RP().on("start",b).on("zoom",p?g:null).on("zoom.wheel",d?y:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:ni}}const pg=e=>({x:e.x,y:e.y,zoom:e.k}),rw=({x:e,y:t,zoom:n})=>ug.translate(e,t).scale(n),hc=(e,t)=>e.target.closest(`.${t}`),oT=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Y4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sw=(e,t=0,n=Y4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},aT=e=>{const t=e.ctrlKey&&rf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function J4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(hc(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&a){const b=ni(f),g=aT(f),k=p*Math.pow(2,g);r.scaleTo(n,k,b,f);return}const d=f.deltaMode===1?20:1;let h=s===Xa.Vertical?0:f.deltaX*d,y=s===Xa.Horizontal?0:f.deltaY*d;!rf()&&f.shiftKey&&s!==Xa.Vertical&&(h=f.deltaY*d,y=0),r.translateBy(n,-(h/p)*o,-(y/p)*o,{internal:!0});const v=pg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,v))}}function X4({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=hc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function Q4({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=pg(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 Z4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&oT(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,pg(o.transform)))}}function e5({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&&oT(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=pg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function t5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:f}){return p=>{var b;const d=e||t,h=n&&p.ctrlKey,y=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(hc(p,`${u}-flow__node`)||hc(p,`${u}-flow__edge`)))return!0;if(!r&&!d&&!s&&!o&&!n||a||f&&!y||hc(p,l)&&y||hc(p,c)&&(!y||s&&y&&!e)||!n&&p.ctrlKey&&y)return!1;if(!n&&p.type==="touchstart"&&((b=p.touches)==null?void 0:b.length)>1)return p.preventDefault(),!1;if(!d&&!s&&!h&&y||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||y)&&v}}function n5({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},f=e.getBoundingClientRect(),p=RP().scaleExtent([t,n]).translateExtent(r),d=ps(e).call(p);k({x:s.x,y:s.y,zoom:Hc(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const h=d.on("wheel.zoom"),y=d.on("dblclick.zoom");p.wheelDelta(aT);function v(D,L){return d?new Promise(O=>{p==null||p.interpolate((L==null?void 0:L.interpolate)==="linear"?Sd:Sh).transform(sw(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function b({noWheelClassName:D,noPanClassName:L,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:V,panOnDrag:B,panOnScrollMode:F,panOnScrollSpeed:$,preventScrolling:H,zoomOnPinch:A,zoomOnScroll:Q,zoomOnDoubleClick:K,zoomActivationKeyPressed:W,lib:ne,onTransformChange:Z,connectionInProgress:G,paneClickDistance:te,selectionOnDrag:re}){M&&!u.isZoomingOrPanning&&g();const se=V&&!W&&!M;p.clickDistance(re?1/0:!oi(te)||te<0?0:te);const ee=se?J4({zoomPanValues:u,noWheelClassName:D,d3Selection:d,d3Zoom:p,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:A,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):X4({noWheelClassName:D,preventScrolling:H,d3ZoomHandler:h});if(d.on("wheel.zoom",ee,{passive:!1}),!M){const de=Q4({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});p.on("start",de);const me=Z4({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!O,onPanZoom:o,onTransformChange:Z});p.on("zoom",me);const Me=e5({zoomPanValues:u,panOnDrag:B,panOnScroll:V,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});p.on("end",Me)}const ue=t5({zoomActivationKeyPressed:W,panOnDrag:B,zoomOnScroll:Q,panOnScroll:V,zoomOnDoubleClick:K,zoomOnPinch:A,userSelectionActive:M,noPanClassName:L,noWheelClassName:D,lib:ne,connectionInProgress:G});p.filter(ue),K?d.on("dblclick.zoom",y):d.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function k(D,L,O){const M=rw(D),V=p==null?void 0:p.constrain()(M,L,O);return V&&await v(V),new Promise(B=>B(V))}async function x(D,L){const O=rw(D);return await v(O,L),new Promise(M=>M(O))}function _(D){if(d){const L=rw(D),O=d.property("__zoom");(O.k!==D.zoom||O.x!==D.x||O.y!==D.y)&&(p==null||p.transform(d,L,null,{sync:!0}))}}function S(){const D=d?TP(d.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function N(D,L){return d?new Promise(O=>{p==null||p.interpolate((L==null?void 0:L.interpolate)==="linear"?Sd:Sh).scaleTo(sw(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function I(D,L){return d?new Promise(O=>{p==null||p.interpolate((L==null?void 0:L.interpolate)==="linear"?Sd:Sh).scaleBy(sw(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function T(D){p==null||p.scaleExtent(D)}function z(D){p==null||p.translateExtent(D)}function E(D){const L=!oi(D)||D<0?0:D;p==null||p.clickDistance(L)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:S,scaleTo:N,scaleBy:I,setScaleExtent:T,setTranslateExtent:z,syncViewport:_,setClickDistance:E}}var qc;(function(e){e.Line="line",e.Handle="handle"})(qc||(qc={}));function r5({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 e1(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 $o(e,t){return Math.max(0,t-e)}function Lo(e,t){return Math.max(0,e-t)}function zp(e,t,n){return Math.max(0,t-e,e-n)}function t1(e,t){return e?!t:t}function s5(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:p}=t,d=f&&p,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:_,width:S,height:N,aspectRatio:I}=e;let T=Math.floor(f?h-e.pointerX:0),z=Math.floor(p?y-e.pointerY:0);const E=S+(c?-T:T),D=N+(u?-z:z),L=-o[0]*S,O=-o[1]*N;let M=zp(E,v,b),V=zp(D,g,k);if(a){let $=0,H=0;c&&T<0?$=$o(x+T+L,a[0][0]):!c&&T>0&&($=Lo(x+E+L,a[1][0])),u&&z<0?H=$o(_+z+O,a[0][1]):!u&&z>0&&(H=Lo(_+D+O,a[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(l){let $=0,H=0;c&&T>0?$=Lo(x+T,l[0][0]):!c&&T<0&&($=$o(x+E,l[1][0])),u&&z>0?H=Lo(_+z,l[0][1]):!u&&z<0&&(H=$o(_+D,l[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(s){if(f){const $=zp(E/I,g,k)*I;if(M=Math.max(M,$),a){let H=0;!c&&!u||c&&!u&&d?H=Lo(_+O+E/I,a[1][1])*I:H=$o(_+O+(c?T:-T)/I,a[0][1])*I,M=Math.max(M,H)}if(l){let H=0;!c&&!u||c&&!u&&d?H=$o(_+E/I,l[1][1])*I:H=Lo(_+(c?T:-T)/I,l[0][1])*I,M=Math.max(M,H)}}if(p){const $=zp(D*I,v,b)/I;if(V=Math.max(V,$),a){let H=0;!c&&!u||u&&!c&&d?H=Lo(x+D*I+L,a[1][0])/I:H=$o(x+(u?z:-z)*I+L,a[0][0])/I,V=Math.max(V,H)}if(l){let H=0;!c&&!u||u&&!c&&d?H=$o(x+D*I,l[1][0])/I:H=Lo(x+(u?z:-z)*I,l[0][0])/I,V=Math.max(V,H)}}}z=z+(z<0?V:-V),T=T+(T<0?M:-M),s&&(d?E>D*I?z=(t1(c,u)?-T:T)/I:T=(t1(c,u)?-z:z)*I:f?(z=T/I,u=c):(T=z*I,c=u));const B=c?x+T:x,F=u?_+z:_;return{width:S+(c?-T:T),height:N+(u?-z:z),x:o[0]*T*(c?-1:1)+B,y:o[1]*z*(u?-1:1)+F}}const lT={width:0,height:0,x:0,y:0},i5={...lT,pointerX:0,pointerY:0,aspectRatio:1};function o5(e){return[[0,0],[e.measured.width,e.measured.height]]}function a5(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 l5({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=ps(e);let a={controlDirection:e1("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:f,keepAspectRatio:p,resizeDirection:d,onResizeStart:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...lT},k={...i5};a={boundaries:f,resizeDirection:d,keepAspectRatio:p,controlDirection:e1(u)};let x,_=null,S=[],N,I,T,z=!1;const E=wP().on("start",D=>{const{nodeLookup:L,transform:O,snapGrid:M,snapToGrid:V,nodeOrigin:B,paneDomNode:F}=n();if(x=L.get(t),!x)return;_=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:H}=jd(D.sourceEvent,{transform:O,snapGrid:M,snapToGrid:V,containerBounds:_});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:H,aspectRatio:g.width/g.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=L.get(x.parentId),I=N&&x.extent==="parent"?o5(N):void 0),S=[],T=void 0;for(const[A,Q]of L)if(Q.parentId===t&&(S.push({id:A,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const K=a5(Q,x,Q.origin??B);T?T=[[Math.min(K[0][0],T[0][0]),Math.min(K[0][1],T[0][1])],[Math.max(K[1][0],T[1][0]),Math.max(K[1][1],T[1][1])]]:T=K}h==null||h(D,{...g})}).on("drag",D=>{const{transform:L,snapGrid:O,snapToGrid:M,nodeOrigin:V}=n(),B=jd(D.sourceEvent,{transform:L,snapGrid:O,snapToGrid:M,containerBounds:_}),F=[];if(!x)return;const{x:$,y:H,width:A,height:Q}=g,K={},W=x.origin??V,{width:ne,height:Z,x:G,y:te}=s5(k,a.controlDirection,B,a.boundaries,a.keepAspectRatio,W,I,T),re=ne!==A,se=Z!==Q,ee=G!==$&&re,ue=te!==H&&se;if(!ee&&!ue&&!re&&!se)return;if((ee||ue||W[0]===1||W[1]===1)&&(K.x=ee?G:g.x,K.y=ue?te:g.y,g.x=K.x,g.y=K.y,S.length>0)){const Se=G-$,_e=te-H;for(const Fe of S)Fe.position={x:Fe.position.x-Se+W[0]*(ne-A),y:Fe.position.y-_e+W[1]*(Z-Q)},F.push(Fe)}if((re||se)&&(K.width=re&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ne:g.width,K.height=se&&(!a.resizeDirection||a.resizeDirection==="vertical")?Z:g.height,g.width=K.width,g.height=K.height),N&&x.expandParent){const Se=W[0]*(K.width??0);K.x&&K.x<Se&&(g.x=Se,k.x=k.x-(K.x-Se));const _e=W[1]*(K.height??0);K.y&&K.y<_e&&(g.y=_e,k.y=k.y-(K.y-_e))}const de=r5({width:g.width,prevWidth:A,height:g.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),me={...g,direction:de};(b==null?void 0:b(D,me))!==!1&&(z=!0,y==null||y(D,me),r(K,F))}).on("end",D=>{z&&(v==null||v(D,{...g}),s==null||s({...g}),z=!1)});o.call(E)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var cT={exports:{}},uT={},dT={exports:{}},fT={};/**
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 Uc=m;function c5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var u5=typeof Object.is=="function"?Object.is:c5,d5=Uc.useState,f5=Uc.useEffect,p5=Uc.useLayoutEffect,h5=Uc.useDebugValue;function m5(e,t){var n=t(),r=d5({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return p5(function(){s.value=n,s.getSnapshot=t,iw(s)&&o({inst:s})},[e,n,t]),f5(function(){return iw(s)&&o({inst:s}),e(function(){iw(s)&&o({inst:s})})},[e]),h5(n),n}function iw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!u5(e,n)}catch{return!0}}function g5(e,t){return t()}var y5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g5:m5;fT.useSyncExternalStore=Uc.useSyncExternalStore!==void 0?Uc.useSyncExternalStore:y5;dT.exports=fT;var pT=dT.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 hg=m,w5=pT;function x5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var b5=typeof Object.is=="function"?Object.is:x5,k5=w5.useSyncExternalStore,v5=hg.useRef,S5=hg.useEffect,j5=hg.useMemo,N5=hg.useDebugValue;uT.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=v5(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=j5(function(){function c(h){if(!u){if(u=!0,f=h,h=r(h),s!==void 0&&a.hasValue){var y=a.value;if(s(y,h))return p=y}return p=h}if(y=p,b5(f,h))return y;var v=r(h);return s!==void 0&&s(y,v)?(f=h,y):(f=h,p=v)}var u=!1,f,p,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,s]);var l=k5(e,o[0],o[1]);return S5(function(){a.hasValue=!0,a.value=l},[l]),N5(l),l};cT.exports=uT;var _5=cT.exports;const C5=ma(_5),A5={},n1=e=>{let t;const n=new Set,r=(f,p)=>{const d=typeof f=="function"?f(t):f;if(!Object.is(d,t)){const h=t;t=p??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(y=>y(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(A5?"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},E5=e=>e?n1(e):n1,{useDebugValue:I5}=ft,{useSyncExternalStoreWithSelector:P5}=C5,T5=e=>e;function hT(e,t=T5,n){const r=P5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return I5(r),r}const r1=(e,t)=>{const n=E5(e),r=(s,o=t)=>hT(n,s,o);return Object.assign(r,n),r},R5=(e,t)=>e?r1(e,t):r1;function Pn(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 mg=m.createContext(null),M5=mg.Provider,mT=Fi.error001();function Gt(e,t){const n=m.useContext(mg);if(n===null)throw new Error(mT);return hT(n,e,t)}function xn(){const e=m.useContext(mg);if(e===null)throw new Error(mT);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const s1={display:"none"},$5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},gT="react-flow__node-desc",yT="react-flow__edge-desc",L5="react-flow__aria-live",O5=e=>e.ariaLiveMessage,D5=e=>e.ariaLabelConfig;function F5({rfId:e}){const t=Gt(O5);return i.jsx("div",{id:`${L5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:$5,children:t})}function z5({rfId:e,disableKeyboardA11y:t}){const n=Gt(D5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${gT}-${e}`,style:s1,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${yT}-${e}`,style:s1,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(F5,{rfId:e})]})}const gg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:tr(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});gg.displayName="Panel";function W5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(gg,{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 B5=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}},Wp=e=>e.id;function H5(e,t){return Pn(e.selectedNodes.map(Wp),t.selectedNodes.map(Wp))&&Pn(e.selectedEdges.map(Wp),t.selectedEdges.map(Wp))}function V5({onSelectionChange:e}){const t=xn(),{selectedNodes:n,selectedEdges:r}=Gt(B5,H5);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 K5=e=>!!e.onSelectionChangeHandlers;function q5({onSelectionChange:e}){const t=Gt(K5);return e||t?i.jsx(V5,{onSelectionChange:e}):null}const ib=typeof window<"u"?m.useLayoutEffect:m.useEffect,wT=[0,0],U5={x:0,y:0,zoom:1},G5=["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"],i1=[...G5,"rfId"],Y5=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}),o1={translateExtent:ef,nodeOrigin:wT,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function J5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Gt(Y5,Pn),u=xn();ib(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=o1,l()}),[]);const f=m.useRef(o1);return ib(()=>{for(const p of i1){const d=e[p],h=f.current[p];d!==h&&(typeof e[p]>"u"||(p==="nodes"?t(d):p==="edges"?n(d):p==="minZoom"?r(d):p==="maxZoom"?s(d):p==="translateExtent"?o(d):p==="nodeExtent"?a(d):p==="ariaLabelConfig"?u.setState({ariaLabelConfig:k4(d)}):p==="fitView"?u.setState({fitViewQueued:d}):p==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[p]:d})))}f.current=e},i1.map(p=>e[p])),null}function a1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function X5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=a1(),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=a1())!=null&&r.matches?"dark":"light"}const l1=typeof document<"u"?document:null;function sf(e=null,t={target:l1,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(p=>typeof p=="string").map(p=>p.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),f=u.reduce((p,d)=>p.concat(...d),[]);return[u,f]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??l1,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=h=>{var b,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&qP(h))return!1;const v=u1(h.code,l);if(o.current.add(h[v]),c1(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)}},p=h=>{const y=u1(h.code,l);c1(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.key==="Meta"&&o.current.clear(),s.current=!1},d=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",p),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",p),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function c1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function u1(e,t){return t.includes(e)?"code":"key"}const Q5=()=>{const e=xn();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=Xk(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},f=n.snapGrid??s,p=n.snapToGrid??o;return Pf(u,r,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=hm(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function xT(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)Z5(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 Z5(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 Nd(e,t){return xT(e,t)}function mm(e,t){return xT(e,t)}function La(e,t){return{id:e,type:"select",selected:t}}function mc(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(La(o.id,a)))}return r}function d1({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 f1(e){return{id:e.id,type:"remove"}}const p1=e=>d4(e),eH=e=>DP(e);function bT(e){return m.forwardRef(e)}function h1(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>tH(()=>n(s=>s+BigInt(1))));return ib(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function tH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const kT=m.createContext(null);function nH({children:e}){const t=xn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:f,onNodesChange:p,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=d1({items:v,lookup:d});for(const g of y.values())b=g(b);f&&u(v),b.length>0?p==null||p(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=h1(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:d}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;f?u(h):p&&p(d1({items:h,lookup:d}))},[]),o=h1(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(kT.Provider,{value:a,children:e})}function rH(){const e=m.useContext(kT);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const sH=e=>!!e.panZoom;function tu(){const e=Q5(),t=xn(),n=rH(),r=Gt(sH),s=m.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),a=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{var g,k;const{nodeLookup:d,nodeOrigin:h}=t.getState(),y=p1(p)?p:d.get(p.id),v=y.parentId?VP(y.position,y.measured,y.parentId,d,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 Vc(b)},u=(p,d,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===p){const b=typeof d=="function"?d(v):d;return h.replace&&p1(b)?b:{...v,...b}}return v}))},f=(p,d,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===p){const b=typeof d=="function"?d(v):d;return h.replace&&eH(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var d;return(d=o(p))==null?void 0:d.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(d=>({...d}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:a,setEdges:l,addNodes:p=>{const d=Array.isArray(p)?p:[p];n.nodeQueue.push(h=>[...h,...d])},addEdges:p=>{const d=Array.isArray(p)?p:[p];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:p=[],edges:d=[],transform:h}=t.getState(),[y,v,b]=h;return{nodes:p.map(g=>({...g})),edges:d.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:p=[],edges:d=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:_}=t.getState(),{nodes:S,edges:N}=await g4({nodesToRemove:p,edgesToRemove:d,nodes:h,edges:y,onBeforeDelete:_}),I=N.length>0,T=S.length>0;if(I){const z=N.map(f1);b==null||b(N),k(z)}if(T){const z=S.map(f1);v==null||v(S),g(z)}return(T||I)&&(x==null||x({nodes:S,edges:N})),{deletedNodes:S,deletedEdges:N}},getIntersectingNodes:(p,d=!0,h)=>{const y=HN(p),v=y?p:c(p),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===p.id||!k.internals.positionAbsolute))return!1;const x=Vc(b?g:k),_=nf(x,v);return d&&_>0||_>=x.width*x.height||_>=v.width*v.height}):[]},isNodeIntersecting:(p,d,h=!0)=>{const v=HN(p)?p:c(p);if(!v)return!1;const b=nf(v,d);return h&&b>0||b>=d.width*d.height||b>=v.width*v.height},updateNode:u,updateNodeData:(p,d,h={replace:!1})=>{u(p,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:f,updateEdgeData:(p,d,h={replace:!1})=>{f(p,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:p=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return f4(p,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:p,id:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${p}${d?`-${d}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:p,handleId:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${p?d?`-${p}-${d}`:`-${p}`:""}`))==null?void 0:y.values())??[])},fitView:async p=>{const d=t.getState().fitViewResolver??b4();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const m1=e=>e.selected,iH=typeof window<"u"?window:void 0;function oH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=xn(),{deleteElements:r}=tu(),s=sf(e,{actInsideInputWithModifier:!1}),o=sf(t,{target:iH});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(m1),edges:a.filter(m1)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function aH(e){const t=xn();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=Qk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Fi.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 yg={position:"absolute",width:"100%",height:"100%",top:0,left:0},lH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function cH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=Xa.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:f,maxZoom:p,zoomActivationKeyCode:d,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:_}){const S=xn(),N=m.useRef(null),{userSelectionActive:I,lib:T,connectionInProgress:z}=Gt(lH,Pn),E=sf(d),D=m.useRef();aH(N);const L=m.useCallback(O=>{g==null||g({x:O[0],y:O[1],zoom:O[2]}),k||S.setState({transform:O})},[g,k]);return m.useEffect(()=>{if(N.current){D.current=n5({domNode:N.current,minZoom:f,maxZoom:p,translateExtent:u,viewport:c,onDraggingChange:B=>S.setState(F=>F.paneDragging===B?F:{paneDragging:B}),onPanZoomStart:(B,F)=>{const{onViewportChangeStart:$,onMoveStart:H}=S.getState();H==null||H(B,F),$==null||$(F)},onPanZoom:(B,F)=>{const{onViewportChange:$,onMove:H}=S.getState();H==null||H(B,F),$==null||$(F)},onPanZoomEnd:(B,F)=>{const{onViewportChangeEnd:$,onMoveEnd:H}=S.getState();H==null||H(B,F),$==null||$(F)}});const{x:O,y:M,zoom:V}=D.current.getViewport();return S.setState({panZoom:D.current,transform:[O,M,V],domNode:N.current.closest(".react-flow")}),()=>{var B;(B=D.current)==null||B.destroy()}}},[]),m.useEffect(()=>{var O;(O=D.current)==null||O.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:E,preventScrolling:h,noPanClassName:b,userSelectionActive:I,noWheelClassName:v,lib:T,onTransformChange:L,connectionInProgress:z,selectionOnDrag:_,paneClickDistance:x})},[e,t,n,r,s,o,a,l,E,h,b,I,v,T,L,z,_,x]),i.jsx("div",{className:"react-flow__renderer",ref:N,style:yg,children:y})}const uH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function dH(){const{userSelectionActive:e,userSelectionRect:t}=Gt(uH,Pn);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 ow=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},fH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function pH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=tf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:d,onPaneMouseLeave:h,children:y}){const v=xn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Gt(fH,Pn),_=g&&(e||b),S=m.useRef(null),N=m.useRef(),I=m.useRef(new Set),T=m.useRef(new Set),z=m.useRef(!1),E=$=>{if(z.current||x){z.current=!1;return}c==null||c($),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},D=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}u==null||u($)},L=f?$=>f($):void 0,O=$=>{z.current&&($.stopPropagation(),z.current=!1)},M=$=>{var Z,G;const{domNode:H}=v.getState();if(N.current=H==null?void 0:H.getBoundingClientRect(),!N.current)return;const A=$.target===S.current;if(!A&&!!$.target.closest(".nokey")||!e||!(o&&A||t)||$.button!==0||!$.isPrimary)return;(G=(Z=$.target)==null?void 0:Z.setPointerCapture)==null||G.call(Z,$.pointerId),z.current=!1;const{x:W,y:ne}=ai($.nativeEvent,N.current);v.setState({userSelectionRect:{width:0,height:0,startX:W,startY:ne,x:W,y:ne}}),A||($.stopPropagation(),$.preventDefault())},V=$=>{const{userSelectionRect:H,transform:A,nodeLookup:Q,edgeLookup:K,connectionLookup:W,triggerNodeChanges:ne,triggerEdgeChanges:Z,defaultEdgeOptions:G,resetSelectedElements:te}=v.getState();if(!N.current||!H)return;const{x:re,y:se}=ai($.nativeEvent,N.current),{startX:ee,startY:ue}=H;if(!z.current){const _e=t?0:s;if(Math.hypot(re-ee,se-ue)<=_e)return;te(),a==null||a($)}z.current=!0;const de={startX:ee,startY:ue,x:re<ee?re:ee,y:se<ue?se:ue,width:Math.abs(re-ee),height:Math.abs(se-ue)},me=I.current,Me=T.current;I.current=new Set(Jk(Q,de,A,n===tf.Partial,!0).map(_e=>_e.id)),T.current=new Set;const Se=(G==null?void 0:G.selectable)??!0;for(const _e of I.current){const Fe=W.get(_e);if(Fe)for(const{edgeId:at}of Fe.values()){const mt=K.get(at);mt&&(mt.selectable??Se)&&T.current.add(at)}}if(!VN(me,I.current)){const _e=mc(Q,I.current,!0);ne(_e)}if(!VN(Me,T.current)){const _e=mc(K,T.current);Z(_e)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},B=$=>{var H,A;$.button===0&&((A=(H=$.target)==null?void 0:H.releasePointerCapture)==null||A.call(H,$.pointerId),!b&&$.target===S.current&&v.getState().userSelectionRect&&(E==null||E($)),v.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l==null||l($),v.setState({nodesSelectionActive:I.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:tr(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:_?void 0:ow(E,S),onContextMenu:ow(D,S),onWheel:ow(L,S),onPointerEnter:_?void 0:p,onPointerMove:_?V:d,onPointerUp:_?B:void 0,onPointerDownCapture:_?M:void 0,onClickCapture:_?O:void 0,onPointerLeave:h,ref:S,style:yg,children:[y,i.jsx(dH,{})]})}function ob({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",Fi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function vT({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=xn(),[c,u]=m.useState(!1),f=m.useRef();return m.useEffect(()=>{f.current=B4({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{ob({id:p,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var p;(p=f.current)==null||p.destroy()}},[n,r,t,o,e,s,a]),c}const hH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ST(){const e=xn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:f}=e.getState(),p=new Map,d=hH(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(!d(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=If(k,o));const{position:x,positionAbsolute:_}=FP({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:f,onError:l});g.position=x,g.internals.positionAbsolute=_,p.set(g.id,g)}c(p)},[])}const sv=m.createContext(null),mH=sv.Provider;sv.Consumer;const jT=()=>m.useContext(sv),gH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),yH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===Bc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&u}};function wH({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:f,onTouchStart:p,...d},h){var V,B;const y=a||null,v=e==="target",b=xn(),g=jT(),{connectOnClick:k,noPanClassName:x,rfId:_}=Gt(gH,Pn),{connectingFrom:S,connectingTo:N,clickConnecting:I,isPossibleEndHandle:T,connectionInProcess:z,clickConnectionInProcess:E,valid:D}=Gt(yH(g,y,e),Pn);g||(B=(V=b.getState()).onError)==null||B.call(V,"010",Fi.error010());const L=F=>{const{defaultEdgeOptions:$,onConnect:H,hasDefaultEdges:A}=b.getState(),Q={...$,...F};if(A){const{edges:K,setEdges:W}=b.getState();W(Ch(Q,K))}H==null||H(Q),l==null||l(Q)},O=F=>{if(!g)return;const $=UP(F.nativeEvent);if(s&&($&&F.button===0||!$)){const H=b.getState();sb.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:v,handleId:y,nodeId:g,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...A)=>{var Q,K;return(K=(Q=b.getState()).onConnectEnd)==null?void 0:K.call(Q,...A)},updateConnection:H.updateConnection,onConnect:L,isValidConnection:n||((...A)=>{var Q,K;return((K=(Q=b.getState()).isValidConnection)==null?void 0:K.call(Q,...A))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}$?f==null||f(F):p==null||p(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:H,connectionClickStartHandle:A,connectionMode:Q,isValidConnection:K,lib:W,rfId:ne,nodeLookup:Z,connection:G}=b.getState();if(!g||!A&&!s)return;if(!A){$==null||$(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const te=KP(F.target),re=n||K,{connection:se,isValid:ee}=sb.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:Q,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:re,flowId:ne,doc:te,lib:W,nodeLookup:Z});ee&&se&&L(se);const ue=structuredClone(G);delete ue.inProgress,ue.toPosition=ue.toHandle?ue.toHandle.position:null,H==null||H(F,ue),b.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${_}-${g}-${y}-${e}`,className:tr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:I,connectingfrom:S,connectingto:N,valid:D,connectionindicator:r&&(!z||T)&&(z||E?o:s)}]),onMouseDown:O,onTouchStart:O,onClick:k?M:void 0,ref:h,...d,children:c})}const er=m.memo(bT(wH));function xH({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(er,{type:"source",position:n,isConnectable:t})]})}function bH({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:r=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(er,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(er,{type:"source",position:r,isConnectable:t})]})}function kH(){return null}function vH({data:e,isConnectable:t,targetPosition:n=Ue.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(er,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const gm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},g1={input:xH,default:bH,output:vH,group:kH};function SH(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 jH=e=>{const{width:t,height:n,x:r,y:s}=Ef(e.nodeLookup,{filter:o=>!!o.selected});return{width:oi(t)?t:null,height:oi(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 NH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=xn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Gt(jH,Pn),c=ST(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&o!==null;if(vT({nodeRef:u,disabled:!f}),!f)return null;const p=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(gm,h.key)&&(h.preventDefault(),c({direction:gm[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:tr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:s,height:o}})})}const y1=typeof window<"u"?window:void 0,_H=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function NT({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:f,selectionMode:p,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:_,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:T,defaultViewport:z,translateExtent:E,minZoom:D,maxZoom:L,preventScrolling:O,onSelectionContextMenu:M,noWheelClassName:V,noPanClassName:B,disableKeyboardA11y:F,onViewportChange:$,isControlledViewport:H}){const{nodesSelectionActive:A,userSelectionActive:Q}=Gt(_H,Pn),K=sf(u,{target:y1}),W=sf(v,{target:y1}),ne=W||T,Z=W||_,G=f&&ne!==!0,te=K||Q||G;return oH({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(cH,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:Z,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:!K&&ne,defaultViewport:z,translateExtent:E,minZoom:D,maxZoom:L,zoomActivationKeyCode:b,preventScrolling:O,noWheelClassName:V,noPanClassName:B,onViewportChange:$,isControlledViewport:H,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(pH,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:ne,isSelecting:!!te,selectionMode:p,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:G,children:[e,A&&i.jsx(NH,{onSelectionContextMenu:M,noPanClassName:B,disableKeyboardA11y:F})]})})}NT.displayName="FlowRenderer";const CH=m.memo(NT),AH=e=>t=>e?Jk(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function EH(e){return Gt(m.useCallback(AH(e),[e]),Pn)}const IH=e=>e.updateNodeInternals;function PH(){const e=Gt(IH),[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 TH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=xn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),f=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!f||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[f,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const p=u.current!==t,d=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(p||d||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 RH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:f,resizeObserver:p,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:_,isParent:S}=Gt(re=>{const se=re.nodeLookup.get(e),ee=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:ee}},Pn);let N=x.type||"default",I=(b==null?void 0:b[N])||g1[N];I===void 0&&(k==null||k("003",Fi.error003(N)),N="default",I=(b==null?void 0:b.default)||g1.default);const T=!!(x.draggable||l&&typeof x.draggable>"u"),z=!!(x.selectable||c&&typeof x.selectable>"u"),E=!!(x.connectable||u&&typeof x.connectable>"u"),D=!!(x.focusable||f&&typeof x.focusable>"u"),L=xn(),O=HP(x),M=TH({node:x,nodeType:N,hasDimensions:O,resizeObserver:p}),V=vT({nodeRef:M,disabled:x.hidden||!T,noDragClassName:d,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:g}),B=ST();if(x.hidden)return null;const F=ko(x),$=SH(x),H=z||T||t||n||r||s,A=n?re=>n(re,{..._.userNode}):void 0,Q=r?re=>r(re,{..._.userNode}):void 0,K=s?re=>s(re,{..._.userNode}):void 0,W=o?re=>o(re,{..._.userNode}):void 0,ne=a?re=>a(re,{..._.userNode}):void 0,Z=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:ee}=L.getState();z&&(!se||!T||ee>0)&&ob({id:e,store:L,nodeRef:M}),t&&t(re,{..._.userNode})},G=re=>{if(!(qP(re.nativeEvent)||y)){if(MP.includes(re.key)&&z){const se=re.key==="Escape";ob({id:e,store:L,unselect:se,nodeRef:M})}else if(T&&x.selected&&Object.prototype.hasOwnProperty.call(gm,re.key)){re.preventDefault();const{ariaLabelConfig:se}=L.getState();L.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),B({direction:gm[re.key],factor:re.shiftKey?4:1})}}},te=()=>{var Me;if(y||!((Me=M.current)!=null&&Me.matches(":focus-visible")))return;const{transform:re,width:se,height:ee,autoPanOnNodeFocus:ue,setCenter:de}=L.getState();if(!ue)return;Jk(new Map([[e,x]]),{x:0,y:0,width:se,height:ee},re,!0).length>0||de(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:re[2]})};return i.jsx("div",{className:tr(["react-flow__node",`react-flow__node-${N}`,{[h]:T},x.className,{selected:x.selected,selectable:z,parent:S,draggable:T,dragging:V}]),ref:M,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:O?"visible":"hidden",...x.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:A,onMouseMove:Q,onMouseLeave:K,onContextMenu:W,onClick:Z,onDoubleClick:ne,onKeyDown:D?G:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:x.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${gT}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(mH,{value:e,children:i.jsx(I,{id:e,data:x.data,type:N,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:x.selected??!1,selectable:z,draggable:T,deletable:x.deletable??!0,isConnectable:E,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:_.z,parentId:x.parentId,...F})})})}var MH=m.memo(RH);const $H=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function _T(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Gt($H,Pn),a=EH(e.onlyRenderVisibleElements),l=PH();return i.jsx("div",{className:"react-flow__nodes",style:yg,children:a.map(c=>i.jsx(MH,{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))})}_T.displayName="NodeRenderer";const LH=m.memo(_T);function OH(e){return Gt(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&&j4({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Pn)}const DH=({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"})},FH=({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"})},w1={[Ai.Arrow]:DH,[Ai.ArrowClosed]:FH};function zH(e){const t=xn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(w1,e)?w1[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Fi.error009(e)),null)},[e])}const WH=({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=zH(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},CT=({defaultColor:e,rfId:t})=>{const n=Gt(o=>o.edges),r=Gt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>P4(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(WH,{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};CT.displayName="MarkerDefinitions";var BH=m.memo(CT);function AT({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...f}){const[p,d]=m.useState({x:1,y:0,width:0,height:0}),h=tr(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.useEffect(()=>{if(y.current){const v=y.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:h,visibility:p.width?"visible":"hidden",...f,children:[s&&i.jsx("rect",{width:p.width+2*a[0],x:-a[0],y:-a[1],height:p.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}AT.displayName="EdgeText";const HH=m.memo(AT);function wg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...f}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...f,d:e,fill:"none",className:tr(["react-flow__edge-path",f.className])}),u?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&oi(t)&&oi(n)?i.jsx(HH,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function x1({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 ET({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top}){const[a,l]=x1({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=x1({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,d,h]=GP({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}`,f,p,d,h]}function IT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,_]=ET({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),S=e.isInternal?void 0:t;return i.jsx(wg,{id:S,path:k,labelX:x,labelY:_,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const VH=IT({isInternal:!1}),PT=IT({isInternal:!0});VH.displayName="SimpleBezierEdge";PT.displayName="SimpleBezierEdgeInternal";function TT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,sourcePosition:h=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=tb({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}),N=e.isInternal?void 0:t;return i.jsx(wg,{id:N,path:x,labelX:_,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:v,markerStart:b,interactionWidth:k})})}const RT=TT({isInternal:!1}),MT=TT({isInternal:!0});RT.displayName="SmoothStepEdge";MT.displayName="SmoothStepEdgeInternal";function $T(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(RT,{...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 KH=$T({isInternal:!1}),LT=$T({isInternal:!0});KH.displayName="StepEdge";LT.displayName="StepEdgeInternal";function OT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=XP({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(wg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:h,markerStart:y,interactionWidth:v})})}const qH=OT({isInternal:!1}),DT=OT({isInternal:!0});qH.displayName="StraightEdge";DT.displayName="StraightEdgeInternal";function FT(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:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=YP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),N=e.isInternal?void 0:t;return i.jsx(wg,{id:N,path:x,labelX:_,labelY:S,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const UH=FT({isInternal:!1}),zT=FT({isInternal:!0});UH.displayName="BezierEdge";zT.displayName="BezierEdgeInternal";const b1={default:zT,straight:DT,step:LT,smoothstep:MT,simplebezier:PT},k1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},GH=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,YH=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,v1="react-flow__edgeupdater";function S1({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:tr([v1,`${v1}-${l}`]),cx:GH(t,r,e),cy:YH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function JH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:f,onReconnectEnd:p,setReconnecting:d,setUpdateHover:h}){const y=xn(),v=(_,S)=>{if(_.button!==0)return;const{autoPanOnConnect:N,domNode:I,connectionMode:T,connectionRadius:z,lib:E,onConnectStart:D,cancelConnection:L,nodeLookup:O,rfId:M,panBy:V,updateConnection:B}=y.getState(),F=S.type==="target",$=(Q,K)=>{d(!1),p==null||p(Q,n,S.type,K)},H=Q=>u==null?void 0:u(n,Q),A=(Q,K)=>{d(!0),f==null||f(_,n,S.type),D==null||D(Q,K)};sb.onPointerDown(_.nativeEvent,{autoPanOnConnect:N,connectionMode:T,connectionRadius:z,domNode:I,handleId:S.id,nodeId:S.nodeId,nodeLookup:O,isTarget:F,edgeUpdaterType:S.type,lib:E,flowId:M,cancelConnection:L,panBy:V,isValidConnection:(...Q)=>{var K,W;return((W=(K=y.getState()).isValidConnection)==null?void 0:W.call(K,...Q))??!0},onConnect:H,onConnectStart:A,onConnectEnd:(...Q)=>{var K,W;return(W=(K=y.getState()).onConnectEnd)==null?void 0:W.call(K,...Q)},onReconnectEnd:$,updateConnection:B,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},b=_=>v(_,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=_=>v(_,{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(S1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(S1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function XH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:f,onReconnect:p,onReconnectStart:d,onReconnectEnd:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Gt(de=>de.edgeLookup.get(e));const _=Gt(de=>de.defaultEdgeOptions);x=_?{..._,...x}:x;let S=x.type||"default",N=(v==null?void 0:v[S])||b1[S];N===void 0&&(g==null||g("011",Fi.error011(S)),S="default",N=(v==null?void 0:v.default)||b1.default);const I=!!(x.focusable||t&&typeof x.focusable>"u"),T=typeof p<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),z=!!(x.selectable||r&&typeof x.selectable>"u"),E=m.useRef(null),[D,L]=m.useState(!1),[O,M]=m.useState(!1),V=xn(),{zIndex:B,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K}=Gt(m.useCallback(de=>{const me=de.nodeLookup.get(x.source),Me=de.nodeLookup.get(x.target);if(!me||!Me)return{zIndex:x.zIndex,...k1};const Se=I4({id:e,sourceNode:me,targetNode:Me,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:S4({selected:x.selected,zIndex:x.zIndex,sourceNode:me,targetNode:Me,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Se||k1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Pn),W=m.useMemo(()=>x.markerStart?`url('#${nb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),ne=m.useMemo(()=>x.markerEnd?`url('#${nb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||$===null||H===null||A===null)return null;const Z=de=>{var _e;const{addSelectedEdges:me,unselectNodesAndEdges:Me,multiSelectionActive:Se}=V.getState();z&&(V.setState({nodesSelectionActive:!1}),x.selected&&Se?(Me({nodes:[],edges:[x]}),(_e=E.current)==null||_e.blur()):me([e])),s&&s(de,x)},G=o?de=>{o(de,{...x})}:void 0,te=a?de=>{a(de,{...x})}:void 0,re=l?de=>{l(de,{...x})}:void 0,se=c?de=>{c(de,{...x})}:void 0,ee=u?de=>{u(de,{...x})}:void 0,ue=de=>{var me;if(!k&&MP.includes(de.key)&&z){const{unselectNodesAndEdges:Me,addSelectedEdges:Se}=V.getState();de.key==="Escape"?((me=E.current)==null||me.blur(),Me({edges:[x]})):Se([e])}};return i.jsx("svg",{style:{zIndex:B},children:i.jsxs("g",{className:tr(["react-flow__edge",`react-flow__edge-${S}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!z&&!s,updating:D,selectable:z}]),onClick:Z,onDoubleClick:G,onContextMenu:te,onMouseEnter:re,onMouseMove:se,onMouseLeave:ee,onKeyDown:I?ue:void 0,tabIndex:I?0:void 0,role:x.ariaRole??(I?"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":I?`${yT}-${y}`:void 0,ref:E,...x.domAttributes,children:[!O&&i.jsx(N,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:z,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:W,markerEnd:ne,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),T&&i.jsx(JH,{edge:x,isReconnectable:T,reconnectRadius:f,onReconnect:p,onReconnectStart:d,onReconnectEnd:h,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K,setUpdateHover:L,setReconnecting:M})]})})}var QH=m.memo(XH);const ZH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function WT({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Gt(ZH,Pn),_=OH(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(BH,{defaultColor:e,rfId:n}),_.map(S=>i.jsx(QH,{id:S,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:f,reconnectRadius:p,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},S))]})}WT.displayName="EdgeRenderer";const e6=m.memo(WT),t6=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function n6({children:e}){const t=Gt(t6);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function r6(e){const t=tu(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const s6=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function i6(e){const t=Gt(s6),n=xn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function o6(e){return e.connection.inProgress?{...e.connection,to:Pf(e.connection.to,e.transform)}:{...e.connection}}function a6(e){return o6}function l6(e){const t=a6();return Gt(t,Pn)}const c6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function u6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Gt(c6,Pn);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:tr(["react-flow__connection",OP(l)]),children:i.jsx(BT,{style:t,type:n,CustomComponent:r,isValid:l})})})}const BT=({style:e,type:t=Vo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:f,toHandle:p,toPosition:d,pointer:h}=l6();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:d,connectionStatus:OP(r),toNode:f,toHandle:p,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Vo.Bezier:[y]=YP(v);break;case Vo.SimpleBezier:[y]=ET(v);break;case Vo.Step:[y]=tb({...v,borderRadius:0});break;case Vo.SmoothStep:[y]=tb(v);break;default:[y]=XP(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};BT.displayName="ConnectionLine";const d6={};function j1(e=d6){m.useRef(e),xn(),m.useEffect(()=>{},[e])}function f6(){xn(),m.useRef(!1),m.useEffect(()=>{},[])}function HT({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:d,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:I,deleteKeyCode:T,onlyRenderVisibleElements:z,elementsSelectable:E,defaultViewport:D,translateExtent:L,minZoom:O,maxZoom:M,preventScrolling:V,defaultMarkerColor:B,zoomOnScroll:F,zoomOnPinch:$,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:Q,zoomOnDoubleClick:K,panOnDrag:W,onPaneClick:ne,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:te,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:ee,nodeClickDistance:ue,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:Me,onEdgeMouseLeave:Se,reconnectRadius:_e,onReconnect:Fe,onReconnectStart:at,onReconnectEnd:mt,noDragClassName:Te,noWheelClassName:it,noPanClassName:jt,disableKeyboardA11y:Vt,nodeExtent:kt,rfId:Mt,viewport:ae,onViewportChange:ke}){return j1(e),j1(t),f6(),r6(n),i6(ae),i.jsx(CH,{onPaneClick:ne,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:te,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:ee,deleteKeyCode:T,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:I,elementsSelectable:E,zoomOnScroll:F,zoomOnPinch:$,zoomOnDoubleClick:K,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:Q,panOnDrag:W,defaultViewport:D,translateExtent:L,minZoom:O,maxZoom:M,onSelectionContextMenu:p,preventScrolling:V,noDragClassName:Te,noWheelClassName:it,noPanClassName:jt,disableKeyboardA11y:Vt,onViewportChange:ke,isControlledViewport:!!ae,children:i.jsxs(n6,{children:[i.jsx(e6,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:Fe,onReconnectStart:at,onReconnectEnd:mt,onlyRenderVisibleElements:z,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:Me,onEdgeMouseLeave:Se,reconnectRadius:_e,defaultMarkerColor:B,noPanClassName:jt,disableKeyboardA11y:Vt,rfId:Mt}),i.jsx(u6,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(LH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,nodeClickDistance:ue,onlyRenderVisibleElements:z,noPanClassName:jt,noDragClassName:Te,disableKeyboardA11y:Vt,nodeExtent:kt,rfId:Mt}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}HT.displayName="GraphView";const p6=m.memo(HT),N1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:f,nodeExtent:p,zIndexMode:d="basic"}={})=>{const h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=f??[0,0],_=p??ef;eT(v,b,g);const{nodesInitialized:S}=rb(k,h,y,{nodeOrigin:x,nodeExtent:_,zIndexMode:d});let N=[0,0,1];if(a&&s&&o){const I=Ef(h,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:T,y:z,zoom:E}=Xk(I,s,o,c,u,(l==null?void 0:l.padding)??.1);N=[T,z,E]}return{rfId:"1",width:s??0,height:o??0,transform:N,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:ef,nodeExtent:_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Bc.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:{...LP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:y4,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:$P,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},h6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:d})=>R5((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:_,height:S,minZoom:N,maxZoom:I}=y();g&&(await m4({nodes:b,width:_,height:S,panZoom:g,minZoom:N,maxZoom:I},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...N1({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:_,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:I}=y(),{nodesInitialized:T,hasSelectedNodes:z}=rb(b,g,k,{nodeOrigin:x,nodeExtent:p,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:N}),E=I&&z;S&&T?(v(),h({nodes:b,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:E})):h({nodes:b,nodesInitialized:T,nodesSelectionActive:E})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();eT(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:_,nodeOrigin:S,nodeExtent:N,debug:I,fitViewQueued:T,zIndexMode:z}=y(),{changes:E,updatedInternals:D}=D4(b,k,x,_,S,N,z);D&&(M4(k,x,{nodeOrigin:S,nodeExtent:N,zIndexMode:z}),T?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(E==null?void 0:E.length)>0&&(I&&console.log("React Flow: trigger node changes",E),g==null||g(E)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:_,triggerNodeChanges:S,connection:N,updateConnection:I,onNodesChangeMiddlewareMap:T}=y();for(const[z,E]of b){const D=_.get(z),L=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(E!=null&&E.position)),O={id:z,type:"position",position:L?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:g};if(D&&N.inProgress&&N.fromNode.id===D.id){const M=ll(D,N.fromHandle,Ue.Left,!0);I({...N,from:M})}L&&D.parentId&&k.push({id:z,parentId:D.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),x.push(O)}if(k.length>0){const{parentLookup:z,nodeOrigin:E}=y(),D=rv(k,_,z,E);x.push(...D)}for(const z of T.values())x=z(x);S(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=Nd(b,x);k(N)}S&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=mm(b,x);k(N)}S&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(I=>La(I,!0));_(N);return}_(mc(x,new Set([...b]),!0)),S(mc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(I=>La(I,!0));S(N);return}S(mc(k,new Set([...b]))),_(mc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:_,triggerNodeChanges:S,triggerEdgeChanges:N}=y(),I=b||x,T=g||k,z=[];for(const D of I){if(!D.selected)continue;const L=_.get(D.id);L&&(L.selected=!1),z.push(La(D.id,!1))}const E=[];for(const D of T)D.selected&&E.push(La(D.id,!1));S(z),N(E)},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:_}=y();if(!_)return;const S=g.reduce((I,T)=>T.selected?[...I,La(T.id,!1)]:I,[]),N=b.reduce((I,T)=>T.selected?[...I,La(T.id,!1)]:I,[]);k(S),x(N)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:_,elevateNodesOnSelect:S,nodeExtent:N,zIndexMode:I}=y();b[0][0]===N[0][0]&&b[0][1]===N[0][1]&&b[1][0]===N[1][0]&&b[1][1]===N[1][1]||(rb(g,k,x,{nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:I}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:_,translateExtent:S}=y();return F4({delta:b,panZoom:_,transform:g,translateExtent:S,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:_,maxZoom:S,panZoom:N}=y();if(!N)return Promise.resolve(!1);const I=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:S;return await N.setViewport({x:x/2-b*I,y:_/2-g*I,zoom:I},{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:{...LP}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...N1()})}},Object.is);function iv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:f,nodeExtent:p,zIndexMode:d,children:h}){const[y]=m.useState(()=>h6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:d}));return i.jsx(M5,{value:y,children:i.jsx(nH,{children:h})})}function m6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:d,zIndexMode:h}){return m.useContext(mg)?i.jsx(i.Fragment,{children:e}):i.jsx(iv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:f,nodeOrigin:p,nodeExtent:d,zIndexMode:h,children:e})}const g6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function y6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:f,onMoveStart:p,onMoveEnd:d,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,onNodeDragStart:I,onNodeDrag:T,onNodeDragStop:z,onNodesDelete:E,onEdgesDelete:D,onDelete:L,onSelectionChange:O,onSelectionDragStart:M,onSelectionDrag:V,onSelectionDragStop:B,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:H,onBeforeDelete:A,connectionMode:Q,connectionLineType:K=Vo.Bezier,connectionLineStyle:W,connectionLineComponent:ne,connectionLineContainerStyle:Z,deleteKeyCode:G="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:re=!1,selectionMode:se=tf.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ue=rf()?"Meta":"Control",zoomActivationKeyCode:de=rf()?"Meta":"Control",snapToGrid:me,snapGrid:Me,onlyRenderVisibleElements:Se=!1,selectNodesOnDrag:_e,nodesDraggable:Fe,autoPanOnNodeFocus:at,nodesConnectable:mt,nodesFocusable:Te,nodeOrigin:it=wT,edgesFocusable:jt,edgesReconnectable:Vt,elementsSelectable:kt=!0,defaultViewport:Mt=U5,minZoom:ae=.5,maxZoom:ke=2,translateExtent:qe=ef,preventScrolling:tt=!0,nodeExtent:Ee,defaultMarkerColor:Dt="#b1b1b7",zoomOnScroll:nn=!0,zoomOnPinch:Kt=!0,panOnScroll:yt=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:ie=Xa.Free,zoomOnDoubleClick:Ce=!0,panOnDrag:Ge=!0,onPaneClick:Be,onPaneMouseEnter:Et,onPaneMouseMove:vt,onPaneMouseLeave:pe,onPaneScroll:He,onPaneContextMenu:wt,paneClickDistance:bt=1,nodeClickDistance:ln=0,children:Tn,onReconnect:An,onReconnectStart:en,onReconnectEnd:bn,onEdgeContextMenu:nr,onEdgeDoubleClick:fn,onEdgeMouseEnter:kn,onEdgeMouseMove:rr,onEdgeMouseLeave:vs,reconnectRadius:sr=10,onNodesChange:Gn,onEdgesChange:Nr,noDragClassName:_r="nodrag",noWheelClassName:Yn="nowheel",noPanClassName:Lr="nopan",fitView:Or,fitViewOptions:ce,connectOnClick:ge,attributionPosition:et,proOptions:rt,defaultEdgeOptions:Bt,elevateNodesOnSelect:Wn=!0,elevateEdgesOnSelect:Cr=!1,disableKeyboardA11y:Ar=!1,autoPanOnConnect:wr,autoPanOnNodeDrag:ct,autoPanSpeed:Xt,connectionRadius:Qt,isValidConnection:ir,onError:ot,style:xr,id:Ws,nodeDragThreshold:Hi,connectionDragThreshold:Bs,viewport:oe,onViewportChange:ve,width:Re,height:Nt,colorMode:$t="light",debug:rn,onScroll:vn,ariaLabelConfig:Vn,zIndexMode:Ss="basic",...js},U){const we=Ws||"1",$e=X5($t),Ae=m.useCallback(Ze=>{Ze.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),vn==null||vn(Ze)},[vn]);return i.jsx("div",{"data-testid":"rf__wrapper",...js,onScroll:Ae,style:{...xr,...g6},ref:U,className:tr(["react-flow",s,$e]),id:Ws,role:"application",children:i.jsxs(m6,{nodes:e,edges:t,width:Re,height:Nt,fitView:Or,fitViewOptions:ce,minZoom:ae,maxZoom:ke,nodeOrigin:it,nodeExtent:Ee,zIndexMode:Ss,children:[i.jsx(J5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:Fe,autoPanOnNodeFocus:at,nodesConnectable:mt,nodesFocusable:Te,edgesFocusable:jt,edgesReconnectable:Vt,elementsSelectable:kt,elevateNodesOnSelect:Wn,elevateEdgesOnSelect:Cr,minZoom:ae,maxZoom:ke,nodeExtent:Ee,onNodesChange:Gn,onEdgesChange:Nr,snapToGrid:me,snapGrid:Me,connectionMode:Q,translateExtent:qe,connectOnClick:ge,defaultEdgeOptions:Bt,fitView:Or,fitViewOptions:ce,onNodesDelete:E,onEdgesDelete:D,onDelete:L,onNodeDragStart:I,onNodeDrag:T,onNodeDragStop:z,onSelectionDrag:V,onSelectionDragStart:M,onSelectionDragStop:B,onMove:f,onMoveStart:p,onMoveEnd:d,noPanClassName:Lr,nodeOrigin:it,rfId:we,autoPanOnConnect:wr,autoPanOnNodeDrag:ct,autoPanSpeed:Xt,onError:ot,connectionRadius:Qt,isValidConnection:ir,selectNodesOnDrag:_e,nodeDragThreshold:Hi,connectionDragThreshold:Bs,onBeforeDelete:A,debug:rn,ariaLabelConfig:Vn,zIndexMode:Ss}),i.jsx(p6,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:K,connectionLineStyle:W,connectionLineComponent:ne,connectionLineContainerStyle:Z,selectionKeyCode:te,selectionOnDrag:re,selectionMode:se,deleteKeyCode:G,multiSelectionKeyCode:ue,panActivationKeyCode:ee,zoomActivationKeyCode:de,onlyRenderVisibleElements:Se,defaultViewport:Mt,translateExtent:qe,minZoom:ae,maxZoom:ke,preventScrolling:tt,zoomOnScroll:nn,zoomOnPinch:Kt,zoomOnDoubleClick:Ce,panOnScroll:yt,panOnScrollSpeed:Cn,panOnScrollMode:ie,panOnDrag:Ge,onPaneClick:Be,onPaneMouseEnter:Et,onPaneMouseMove:vt,onPaneMouseLeave:pe,onPaneScroll:He,onPaneContextMenu:wt,paneClickDistance:bt,nodeClickDistance:ln,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:H,onReconnect:An,onReconnectStart:en,onReconnectEnd:bn,onEdgeContextMenu:nr,onEdgeDoubleClick:fn,onEdgeMouseEnter:kn,onEdgeMouseMove:rr,onEdgeMouseLeave:vs,reconnectRadius:sr,defaultMarkerColor:Dt,noDragClassName:_r,noWheelClassName:Yn,noPanClassName:Lr,rfId:we,disableKeyboardA11y:Ar,nodeExtent:Ee,viewport:oe,onViewportChange:ve}),i.jsx(q5,{onSelectionChange:O}),Tn,i.jsx(W5,{proOptions:rt,position:et}),i.jsx(z5,{rfId:we,disableKeyboardA11y:Ar})]})})}var VT=bT(y6);function w6(){const e=xn();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 x6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>Nd(s,o)),[]);return[t,n,r]}function b6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>mm(s,o)),[]);return[t,n,r]}function k6({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:tr(["react-flow__background-pattern",n,r])})}function v6({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:tr(["react-flow__background-pattern","dots",t])})}var ia;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ia||(ia={}));const S6={[ia.Dots]:1,[ia.Lines]:1,[ia.Cross]:6},j6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function KT({id:e,variant:t=ia.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:f}){const p=m.useRef(null),{transform:d,patternId:h}=Gt(j6,Pn),y=r||S6[t],v=t===ia.Dots,b=t===ia.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*d[2]||1,g[1]*d[2]||1],x=y*d[2],_=Array.isArray(o)?o:[o,o],S=b?[x,x]:k,N=[_[0]*d[2]||1+S[0]/2,_[1]*d[2]||1+S[1]/2],I=`${h}${e||""}`;return i.jsxs("svg",{className:tr(["react-flow__background",u]),style:{...c,...yg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:p,"data-testid":"rf__background",children:[i.jsx("pattern",{id:I,x:d[0]%k[0],y:d[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?i.jsx(v6,{radius:x/2,className:f}):i.jsx(k6,{dimensions:S,lineWidth:s,variant:t,className:f})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}KT.displayName="Background";const qT=m.memo(KT);function N6(){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 _6(){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 C6(){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 A6(){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 E6(){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 Bp({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:tr(["react-flow__controls-button",t]),...n,children:e})}const I6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function UT({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:f,position:p="bottom-left",orientation:d="vertical","aria-label":h}){const y=xn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Gt(I6,Pn),{zoomIn:x,zoomOut:_,fitView:S}=tu(),N=()=>{x(),o==null||o()},I=()=>{_(),a==null||a()},T=()=>{S(s),l==null||l()},z=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},E=d==="horizontal"?"horizontal":"vertical";return i.jsxs(gg,{className:tr(["react-flow__controls",E,u]),position:p,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Bp,{onClick:N,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(N6,{})}),i.jsx(Bp,{onClick:I,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(_6,{})})]}),n&&i.jsx(Bp,{className:"react-flow__controls-fitview",onClick:T,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(C6,{})}),r&&i.jsx(Bp,{className:"react-flow__controls-interactive",onClick:z,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(E6,{}):i.jsx(A6,{})}),f]})}UT.displayName="Controls";m.memo(UT);function P6({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:f,shapeRendering:p,selected:d,onClick:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:tr(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:p,onClick:h?g=>h(g,e):void 0})}const T6=m.memo(P6),R6=e=>e.nodes.map(t=>t.id),aw=e=>e instanceof Function?e:()=>e;function M6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=T6,onClick:a}){const l=Gt(R6,Pn),c=aw(t),u=aw(e),f=aw(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(d=>i.jsx(L6,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:p},d))})}function $6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:f,y:p,width:d,height:h}=Gt(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:_}=ko(b);return{node:b,x:g,y:k,width:x,height:_}},Pn);return!u||u.hidden||!HP(u)?null:i.jsx(l,{x:f,y:p,width:d,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 L6=m.memo($6);var O6=m.memo(M6);const D6=200,F6=150,z6=e=>!e.hidden,W6=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?BP(Ef(e.nodeLookup,{filter:z6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},B6="react-flow__minimap-desc";function GT({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:f,maskStrokeWidth:p,position:d="bottom-right",onClick:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:_=5}){const S=xn(),N=m.useRef(null),{boundingRect:I,viewBB:T,rfId:z,panZoom:E,translateExtent:D,flowWidth:L,flowHeight:O,ariaLabelConfig:M}=Gt(W6,Pn),V=(e==null?void 0:e.width)??D6,B=(e==null?void 0:e.height)??F6,F=I.width/V,$=I.height/B,H=Math.max(F,$),A=H*V,Q=H*B,K=_*H,W=I.x-(A-I.width)/2-K,ne=I.y-(Q-I.height)/2-K,Z=A+K*2,G=Q+K*2,te=`${B6}-${z}`,re=m.useRef(0),se=m.useRef();re.current=H,m.useEffect(()=>{if(N.current&&E)return se.current=G4({domNode:N.current,panZoom:E,getTransform:()=>S.getState().transform,getViewScale:()=>re.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[E]),m.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:D,width:L,height:O,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,D,L,O]);const ee=h?me=>{var _e;const[Me,Se]=((_e=se.current)==null?void 0:_e.pointer(me))||[0,0];h(me,{x:Me,y:Se})}:void 0,ue=y?m.useCallback((me,Me)=>{const Se=S.getState().nodeLookup.get(Me).internals.userNode;y(me,Se)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(gg,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*H: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:tr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:V,height:B,viewBox:`${W} ${ne} ${Z} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:N,onClick:ee,children:[de&&i.jsx("title",{id:te,children:de}),i.jsx(O6,{onClick:ue,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-K},${ne-K}h${Z+K*2}v${G+K*2}h${-Z-K*2}z
66
- M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}GT.displayName="MiniMap";m.memo(GT);const H6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,V6={[qc.Line]:"right",[qc.Handle]:"bottom-right"};function K6({nodeId:e,position:t,variant:n=qc.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:d,autoScale:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=jT(),x=typeof e=="string"?e:k,_=xn(),S=m.useRef(null),N=n===qc.Handle,I=Gt(m.useCallback(H6(N&&h),[N,h]),Pn),T=m.useRef(null),z=t??V6[n];m.useEffect(()=>{if(!(!S.current||!x))return T.current||(T.current=l5({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:D,transform:L,snapGrid:O,snapToGrid:M,nodeOrigin:V,domNode:B}=_.getState();return{nodeLookup:D,transform:L,snapGrid:O,snapToGrid:M,nodeOrigin:V,paneDomNode:B}},onChange:(D,L)=>{const{triggerNodeChanges:O,nodeLookup:M,parentLookup:V,nodeOrigin:B}=_.getState(),F=[],$={x:D.x,y:D.y},H=M.get(x);if(H&&H.expandParent&&H.parentId){const A=H.origin??B,Q=D.width??H.measured.width??0,K=D.height??H.measured.height??0,W={id:H.id,parentId:H.parentId,rect:{width:Q,height:K,...VP({x:D.x??H.position.x,y:D.y??H.position.y},{width:Q,height:K},H.parentId,M,A)}},ne=rv([W],M,V,B);F.push(...ne),$.x=D.x?Math.max(A[0]*Q,D.x):void 0,$.y=D.y?Math.max(A[1]*K,D.y):void 0}if($.x!==void 0&&$.y!==void 0){const A={id:x,type:"position",position:{...$}};F.push(A)}if(D.width!==void 0&&D.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};F.push(Q)}for(const A of L){const Q={...A,type:"position"};F.push(Q)}O(F)},onEnd:({width:D,height:L})=>{const O={id:x,type:"dimensions",resizing:!1,dimensions:{width:D,height:L}};_.getState().triggerNodeChanges([O])}})),T.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:f},keepAspectRatio:p,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var D;(D=T.current)==null||D.destroy()}},[z,l,c,u,f,p,v,b,g,y]);const E=z.split("-");return i.jsx("div",{className:tr(["react-flow__resize-control","nodrag",...E,n,r]),ref:S,style:{...s,scale:I,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:o})}const ov=m.memo(K6),q6="modulepreload",U6=function(e){return"/"+e},_1={},G6=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=U6(c),c in _1)return;_1[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":q6,u||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((d,h)=>{p.addEventListener("load",d),p.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 Y6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const J6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,X6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q6={};function C1(e,t){return(Q6.jsx?X6:J6).test(e)}const Z6=/[ \t\n\f\r]/g;function e8(e){return typeof e=="object"?e.type==="text"?A1(e.value):!1:A1(e)}function A1(e){return e.replace(Z6,"")===""}class Tf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Tf.prototype.normal={};Tf.prototype.property={};Tf.prototype.space=void 0;function YT(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Tf(n,r,t)}function ab(e){return e.toLowerCase()}class as{constructor(t,n){this.attribute=n,this.property=t}}as.prototype.attribute="";as.prototype.booleanish=!1;as.prototype.boolean=!1;as.prototype.commaOrSpaceSeparated=!1;as.prototype.commaSeparated=!1;as.prototype.defined=!1;as.prototype.mustUseProperty=!1;as.prototype.number=!1;as.prototype.overloadedBoolean=!1;as.prototype.property="";as.prototype.spaceSeparated=!1;as.prototype.space=void 0;let t8=0;const Ct=wl(),Qn=wl(),lb=wl(),Pe=wl(),gn=wl(),Cc=wl(),us=wl();function wl(){return 2**++t8}const cb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ct,booleanish:Qn,commaOrSpaceSeparated:us,commaSeparated:Cc,number:Pe,overloadedBoolean:lb,spaceSeparated:gn},Symbol.toStringTag,{value:"Module"})),lw=Object.keys(cb);class av extends as{constructor(t,n,r,s){let o=-1;if(super(t,n),E1(this,"space",s),typeof r=="number")for(;++o<lw.length;){const a=lw[o];E1(this,lw[o],(r&cb[a])===cb[a])}}}av.prototype.defined=!0;function E1(e,t,n){n&&(e[t]=n)}function nu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new av(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[ab(r)]=r,n[ab(o.attribute)]=r}return new Tf(t,n,e.space)}const JT=nu({properties:{ariaActiveDescendant:null,ariaAtomic:Qn,ariaAutoComplete:null,ariaBusy:Qn,ariaChecked:Qn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:gn,ariaCurrent:null,ariaDescribedBy:gn,ariaDetails:null,ariaDisabled:Qn,ariaDropEffect:gn,ariaErrorMessage:null,ariaExpanded:Qn,ariaFlowTo:gn,ariaGrabbed:Qn,ariaHasPopup:null,ariaHidden:Qn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gn,ariaLevel:Pe,ariaLive:null,ariaModal:Qn,ariaMultiLine:Qn,ariaMultiSelectable:Qn,ariaOrientation:null,ariaOwns:gn,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:Qn,ariaReadOnly:Qn,ariaRelevant:null,ariaRequired:Qn,ariaRoleDescription:gn,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:Qn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function XT(e,t){return t in e?e[t]:t}function QT(e,t){return XT(e,t.toLowerCase())}const n8=nu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Cc,acceptCharset:gn,accessKey:gn,action:null,allow:null,allowFullScreen:Ct,allowPaymentRequest:Ct,allowUserMedia:Ct,alt:null,as:null,async:Ct,autoCapitalize:null,autoComplete:gn,autoFocus:Ct,autoPlay:Ct,blocking:gn,capture:null,charSet:null,checked:Ct,cite:null,className:gn,cols:Pe,colSpan:null,content:null,contentEditable:Qn,controls:Ct,controlsList:gn,coords:Pe|Cc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ct,defer:Ct,dir:null,dirName:null,disabled:Ct,download:lb,draggable:Qn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ct,formTarget:null,headers:gn,height:Pe,hidden:lb,high:Pe,href:null,hrefLang:null,htmlFor:gn,httpEquiv:gn,id:null,imageSizes:null,imageSrcSet:null,inert:Ct,inputMode:null,integrity:null,is:null,isMap:Ct,itemId:null,itemProp:gn,itemRef:gn,itemScope:Ct,itemType:gn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ct,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:Ct,muted:Ct,name:null,nonce:null,noModule:Ct,noValidate:Ct,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:Ct,optimum:Pe,pattern:null,ping:gn,placeholder:null,playsInline:Ct,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ct,referrerPolicy:null,rel:gn,required:Ct,reversed:Ct,rows:Pe,rowSpan:Pe,sandbox:gn,scope:null,scoped:Ct,seamless:Ct,selected:Ct,shadowRootClonable:Ct,shadowRootDelegatesFocus:Ct,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:Qn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:Ct,useMap:null,value:Qn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gn,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ct,declare:Ct,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:Ct,noHref:Ct,noShade:Ct,noWrap:Ct,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:Qn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ct,disableRemotePlayback:Ct,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:QT}),r8=nu({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:us,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:gn,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:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:Ct,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,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:Cc,g2:Cc,glyphName:Cc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:us,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,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:Pe,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:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:us,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:us,rev:us,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:us,requiredFeatures:us,requiredFonts:us,requiredFormats:us,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:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:us,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:us,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:us,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:XT}),ZT=nu({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()}}),eR=nu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:QT}),tR=nu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),s8={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"},i8=/[A-Z]/g,I1=/-[a-z]/g,o8=/^data[-\w.:]+$/i;function a8(e,t){const n=ab(t);let r=t,s=as;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&o8.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(I1,c8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!I1.test(o)){let a=o.replace(i8,l8);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=av}return new s(r,t)}function l8(e){return"-"+e.toLowerCase()}function c8(e){return e.charAt(1).toUpperCase()}const u8=YT([JT,n8,ZT,eR,tR],"html"),lv=YT([JT,r8,ZT,eR,tR],"svg");function d8(e){return e.join(" ").trim()}var cv={},P1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,f8=/\n/g,p8=/^\s*/,h8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,m8=/^:\s*/,g8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,y8=/^[;\s]*/,w8=/^\s+|\s+$/g,x8=`
67
- `,T1="/",R1="*",Da="",b8="comment",k8="declaration";function v8(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(f8);v&&(n+=v.length);var b=y.lastIndexOf(x8);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(p8)}function f(y){var v;for(y=y||[];v=p();)v!==!1&&y.push(v);return y}function p(){var y=o();if(!(T1!=e.charAt(0)||R1!=e.charAt(1))){for(var v=2;Da!=e.charAt(v)&&(R1!=e.charAt(v)||T1!=e.charAt(v+1));)++v;if(v+=2,Da===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:b8,comment:b})}}function d(){var y=o(),v=c(h8);if(v){if(p(),!c(m8))return l("property missing ':'");var b=c(g8),g=y({type:k8,property:M1(v[0].replace(P1,Da)),value:b?M1(b[0].replace(P1,Da)):Da});return c(y8),g}}function h(){var y=[];f(y);for(var v;v=d();)v!==!1&&(y.push(v),f(y));return y}return u(),h()}function M1(e){return e?e.replace(w8,Da):Da}var S8=v8,j8=Td&&Td.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(cv,"__esModule",{value:!0});cv.default=_8;const N8=j8(S8);function _8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,N8.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 xg={};Object.defineProperty(xg,"__esModule",{value:!0});xg.camelCase=void 0;var C8=/^--[a-zA-Z0-9_-]+$/,A8=/-([a-z])/g,E8=/^[^-]+$/,I8=/^-(webkit|moz|ms|o|khtml)-/,P8=/^-(ms)-/,T8=function(e){return!e||E8.test(e)||C8.test(e)},R8=function(e,t){return t.toUpperCase()},$1=function(e,t){return"".concat(t,"-")},M8=function(e,t){return t===void 0&&(t={}),T8(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(P8,$1):e=e.replace(I8,$1),e.replace(A8,R8))};xg.camelCase=M8;var $8=Td&&Td.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},L8=$8(cv),O8=xg;function ub(e,t){var n={};return!e||typeof e!="string"||(0,L8.default)(e,function(r,s){r&&s&&(n[(0,O8.camelCase)(r,t)]=s)}),n}ub.default=ub;var D8=ub;const F8=ma(D8),nR=rR("end"),uv=rR("start");function rR(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 z8(e){const t=uv(e),n=nR(e);if(t&&n)return{start:t,end:n}}function _d(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?L1(e.position):"start"in e||"end"in e?L1(e):"line"in e||"column"in e?db(e):""}function db(e){return O1(e&&e.line)+":"+O1(e&&e.column)}function L1(e){return db(e&&e.start)+"-"+db(e&&e.end)}function O1(e){return e&&typeof e=="number"?e:1}class $r 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=_d(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}}$r.prototype.file="";$r.prototype.name="";$r.prototype.reason="";$r.prototype.message="";$r.prototype.stack="";$r.prototype.column=void 0;$r.prototype.line=void 0;$r.prototype.ancestors=void 0;$r.prototype.cause=void 0;$r.prototype.fatal=void 0;$r.prototype.place=void 0;$r.prototype.ruleId=void 0;$r.prototype.source=void 0;const dv={}.hasOwnProperty,W8=new Map,B8=/[A-Z]/g,H8=new Set(["table","tbody","thead","tfoot","tr"]),V8=new Set(["td","th"]),sR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function K8(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=Z8(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=Q8(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"?lv:u8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=iR(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function iR(e,t,n){if(t.type==="element")return q8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return U8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Y8(e,t,n);if(t.type==="mdxjsEsm")return G8(e,t);if(t.type==="root")return J8(e,t,n);if(t.type==="text")return X8(e,t)}function q8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=lv,e.schema=s),e.ancestors.push(t);const o=aR(e,t.tagName,!1),a=eV(e,t);let l=pv(e,t);return H8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!e8(c):!0})),oR(e,a,o,t),fv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function U8(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)}of(e,t.position)}function G8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);of(e,t.position)}function Y8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=lv,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:aR(e,t.name,!0),a=tV(e,t),l=pv(e,t);return oR(e,a,o,t),fv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function J8(e,t,n){const r={};return fv(r,pv(e,t)),e.create(t,e.Fragment,r,n)}function X8(e,t){return t.value}function oR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function fv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Q8(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 Z8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=uv(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 eV(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&dv.call(t.properties,s)){const o=nV(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&V8.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 tV(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 of(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 of(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function pv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:W8;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=iR(e,o,a);l!==void 0&&n.push(l)}return n}function nV(e,t,n){const r=a8(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Y6(n):d8(n)),r.property==="style"){let s=typeof n=="object"?n:rV(e,String(n));return e.stylePropertyNameCase==="css"&&(s=sV(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?s8[r.property]||r.property:r.attribute,n]}}function rV(e,t){try{return F8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new $r("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=sR+"#cannot-parse-style-attribute",s}}function aR(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=C1(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=C1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return dv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);of(e)}function of(e,t){const n=new $r("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=sR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sV(e){const t={};let n;for(n in e)dv.call(e,n)&&(t[iV(n)]=e[n]);return t}function iV(e){let t=e.replace(B8,oV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function oV(e){return"-"+e.toLowerCase()}const cw={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"]},aV={};function lV(e,t){const n=aV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return lR(e,r,s)}function lR(e,t,n){if(cV(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 D1(e.children,t,n)}return Array.isArray(e)?D1(e,t,n):""}function D1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=lR(e[s],t,n);return r.join("")}function cV(e){return!!(e&&typeof e=="object")}const F1=document.createElement("i");function hv(e){const t="&"+e+";";F1.innerHTML=t;const n=F1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function zi(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 $s(e,t){return e.length>0?(zi(e,e.length,0,t),e):t}const z1={}.hasOwnProperty;function uV(e){const t={};let n=-1;for(;++n<e.length;)dV(t,e[n]);return t}function dV(e,t){let n;for(n in t){const s=(z1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){z1.call(s,a)||(s[a]=[]);const l=o[a];fV(s[a],Array.isArray(l)?l:l?[l]:[])}}}function fV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);zi(e,0,0,r)}function cR(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 Ac(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ei=xa(/[A-Za-z]/),ms=xa(/[\dA-Za-z]/),pV=xa(/[#-'*+\--9=?A-Z^-~]/);function fb(e){return e!==null&&(e<32||e===127)}const pb=xa(/\d/),hV=xa(/[\dA-Fa-f]/),mV=xa(/[!-/:-@[-`{-~]/);function xt(e){return e!==null&&e<-2}function is(e){return e!==null&&(e<0||e===32)}function tn(e){return e===-2||e===-1||e===32}const gV=xa(new RegExp("\\p{P}|\\p{S}","u")),yV=xa(/\s/);function xa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ru(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&ms(e.charCodeAt(n+1))&&ms(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 wn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return tn(c)?(e.enter(n),l(c)):t(c)}function l(c){return tn(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const wV={tokenize:xV};function xV(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"),wn(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 xt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const bV={tokenize:kV},W1={tokenize:vV};function kV(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const _=n[r];return t.containerState=_[1],e.attempt(_[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const _=t.events.length;let S=_,N;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){N=t.events[S][1].end;break}g(r);let I=_;for(;I<t.events.length;)t.events[I][1].end={...N},I++;return zi(t.events,S+1,0,t.events.slice(_)),t.events.length=I,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return d(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(W1,f,p)(x)}function f(x){return s&&k(),g(r),d(x)}function p(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function d(x){return t.containerState={},e.attempt(W1,h,y)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),d(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 xt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,_){const S=t.sliceStream(x);if(_&&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 N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<a&&(!s.events[N][1].end||s.events[N][1].end.offset>a))return;const I=t.events.length;let T=I,z,E;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){E=t.events[T][1].end;break}z=!0}for(g(r),N=I;N<t.events.length;)t.events[N][1].end={...E},N++;zi(t.events,T+1,0,t.events.slice(I)),t.events.length=N}}function g(x){let _=n.length;for(;_-- >x;){const S=n[_];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 vV(e,t,n){return wn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function B1(e){if(e===null||is(e)||yV(e))return 1;if(gV(e))return 2}function mv(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 hb={name:"attention",resolveAll:SV,tokenize:jV};function SV(e,t){let n=-1,r,s,o,a,l,c,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},d={...e[n][1].start};H1(p,-c),H1(d,c),a={type:c>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},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=$s(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=$s(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=$s(u,mv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=$s(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=$s(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,zi(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function jV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=B1(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"),f=B1(c),p=!f||f===2&&s||n.includes(c),d=!s||s===2&&f||n.includes(r);return u._open=!!(o===42?p:p&&(s||!d)),u._close=!!(o===42?d:d&&(f||!p)),t(c)}}function H1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const NV={name:"autolink",tokenize:_V};function _V(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 Ei(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||ms(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||ms(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||fb(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),f):pV(h)?(e.consume(h),u):n(h)}function f(h){return ms(h)?p(h):n(h)}function p(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):d(h)}function d(h){if((h===45||ms(h))&&r++<63){const y=h===45?d:p;return e.consume(h),y}return n(h)}}const bg={partial:!0,tokenize:CV};function CV(e,t,n){return r;function r(o){return tn(o)?wn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||xt(o)?t(o):n(o)}}const uR={continuation:{tokenize:EV},exit:IV,name:"blockQuote",tokenize:AV};function AV(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 tn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function EV(e,t,n){const r=this;return s;function s(a){return tn(a)?wn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(uR,t,n)(a)}}function IV(e){e.exit("blockQuote")}const dR={name:"characterEscape",tokenize:PV};function PV(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 mV(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const fR={name:"characterReference",tokenize:TV};function TV(e,t,n){const r=this;let s=0,o,a;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),c}function c(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=ms,f(p))}function u(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=hV,f):(e.enter("characterReferenceValue"),o=7,a=pb,f(p))}function f(p){if(p===59&&s){const d=e.exit("characterReferenceValue");return a===ms&&!hv(r.sliceSerialize(d))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&s++<o?(e.consume(p),f):n(p)}}const V1={partial:!0,tokenize:MV},K1={concrete:!0,name:"codeFenced",tokenize:RV};function RV(e,t,n){const r=this,s={partial:!0,tokenize:S};let o=0,a=0,l;return c;function c(N){return u(N)}function u(N){const I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(N)}function f(N){return N===l?(a++,e.consume(N),f):a<3?n(N):(e.exit("codeFencedFenceSequence"),tn(N)?wn(e,p,"whitespace")(N):p(N))}function p(N){return N===null||xt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(V1,v,_)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(N))}function d(N){return N===null||xt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(N)):tn(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),wn(e,h,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),d)}function h(N){return N===null||xt(N)?p(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(N))}function y(N){return N===null||xt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(N)):N===96&&N===l?n(N):(e.consume(N),y)}function v(N){return e.attempt(s,_,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),g}function g(N){return o>0&&tn(N)?wn(e,k,"linePrefix",o+1)(N):k(N)}function k(N){return N===null||xt(N)?e.check(V1,v,_)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||xt(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),x)}function _(N){return e.exit("codeFenced"),t(N)}function S(N,I,T){let z=0;return E;function E(V){return N.enter("lineEnding"),N.consume(V),N.exit("lineEnding"),D}function D(V){return N.enter("codeFencedFence"),tn(V)?wn(N,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):L(V)}function L(V){return V===l?(N.enter("codeFencedFenceSequence"),O(V)):T(V)}function O(V){return V===l?(z++,N.consume(V),O):z>=a?(N.exit("codeFencedFenceSequence"),tn(V)?wn(N,M,"whitespace")(V):M(V)):T(V)}function M(V){return V===null||xt(V)?(N.exit("codeFencedFence"),I(V)):T(V)}}}function MV(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 uw={name:"codeIndented",tokenize:LV},$V={partial:!0,tokenize:OV};function LV(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),wn(e,o,"linePrefix",5)(u)}function o(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):xt(u)?e.attempt($V,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||xt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function OV(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):wn(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):xt(a)?s(a):n(a)}}const DV={name:"codeText",previous:zV,resolve:FV,tokenize:WV};function FV(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 zV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function WV(e,t,n){let r=0,s,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),r++,l):(e.exit("codeTextSequence"),c(p))}function c(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),c):p===96?(o=e.enter("codeTextSequence"),s=0,f(p)):xt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||xt(p)?(e.exit("codeTextData"),c(p)):(e.consume(p),u)}function f(p){return p===96?(e.consume(p),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",u(p))}}class BV{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&&qu(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),qu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),qu(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);qu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);qu(this.left,n.reverse())}}}function qu(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 pR(e){const t={};let n=-1,r,s,o,a,l,c,u;const f=new BV(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,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,HV(f,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=f.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.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={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return zi(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function HV(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 f,p,d=-1,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),p&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(v=d+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(),d=b.length;d--;){const g=l.slice(b[d],b[d+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),d=-1;++d<c.length;)u[y+c[d][0]]=y+c[d][1],y+=c[d][1]-c[d][0]-1;return u}const VV={resolve:qV,tokenize:UV},KV={partial:!0,tokenize:GV};function qV(e){return pR(e),e}function UV(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):xt(l)?e.check(KV,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 GV(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),wn(e,o,"linePrefix")}function o(a){if(a===null||xt(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 hR(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let f=0;return p;function p(g){return g===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(g),e.exit(o),d):g===null||g===32||g===41||fb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function d(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),d(g)):g===null||g===60||xt(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!f&&(g===null||g===41||is(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):f<u&&g===40?(e.consume(g),f++,v):g===41?(e.consume(g),f--,v):g===null||g===32||g===40||fb(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 mR(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),f}function f(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):xt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||xt(h)||l++>999?(e.exit("chunkString"),f(h)):(e.consume(h),c||(c=!tn(h)),h===92?d:p)}function d(h){return h===91||h===92||h===93?(e.consume(h),l++,p):p(h)}}function gR(e,t,n,r,s,o){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(s),e.consume(d),e.exit(s),a=d===40?41:d,c):n(d)}function c(d){return d===a?(e.enter(s),e.consume(d),e.exit(s),e.exit(r),t):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),c(a)):d===null?n(d):xt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),wn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===a||d===null||xt(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?p:f)}function p(d){return d===a||d===92?(e.consume(d),f):f(d)}}function Cd(e,t){let n;return r;function r(s){return xt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):tn(s)?wn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const YV={name:"definition",tokenize:XV},JV={partial:!0,tokenize:QV};function XV(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return mR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=Ac(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 is(h)?Cd(e,u)(h):u(h)}function u(h){return hR(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(JV,p,p)(h)}function p(h){return tn(h)?wn(e,d,"whitespace")(h):d(h)}function d(h){return h===null||xt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function QV(e,t,n){return r;function r(l){return is(l)?Cd(e,s)(l):n(l)}function s(l){return gR(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return tn(l)?wn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||xt(l)?t(l):n(l)}}const ZV={name:"hardBreakEscape",tokenize:e9};function e9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return xt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const t9={name:"headingAtx",resolve:n9,tokenize:r9};function n9(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"},zi(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function r9(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),o(f)}function o(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||is(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||xt(f)?(e.exit("atxHeading"),t(f)):tn(f)?wn(e,l,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function u(f){return f===null||f===35||is(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),u)}}const s9=["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"],q1=["pre","script","style","textarea"],i9={concrete:!0,name:"htmlFlow",resolveTo:l9,tokenize:c9},o9={partial:!0,tokenize:d9},a9={partial:!0,tokenize:u9};function l9(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 c9(e,t,n){const r=this;let s,o,a,l,c;return u;function u(W){return f(W)}function f(W){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(W),p}function p(W){return W===33?(e.consume(W),d):W===47?(e.consume(W),o=!0,v):W===63?(e.consume(W),s=3,r.interrupt?t:A):Ei(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function d(W){return W===45?(e.consume(W),s=2,h):W===91?(e.consume(W),s=5,l=0,y):Ei(W)?(e.consume(W),s=4,r.interrupt?t:A):n(W)}function h(W){return W===45?(e.consume(W),r.interrupt?t:A):n(W)}function y(W){const ne="CDATA[";return W===ne.charCodeAt(l++)?(e.consume(W),l===ne.length?r.interrupt?t:L:y):n(W)}function v(W){return Ei(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function b(W){if(W===null||W===47||W===62||is(W)){const ne=W===47,Z=a.toLowerCase();return!ne&&!o&&q1.includes(Z)?(s=1,r.interrupt?t(W):L(W)):s9.includes(a.toLowerCase())?(s=6,ne?(e.consume(W),g):r.interrupt?t(W):L(W)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(W):o?k(W):x(W))}return W===45||ms(W)?(e.consume(W),a+=String.fromCharCode(W),b):n(W)}function g(W){return W===62?(e.consume(W),r.interrupt?t:L):n(W)}function k(W){return tn(W)?(e.consume(W),k):E(W)}function x(W){return W===47?(e.consume(W),E):W===58||W===95||Ei(W)?(e.consume(W),_):tn(W)?(e.consume(W),x):E(W)}function _(W){return W===45||W===46||W===58||W===95||ms(W)?(e.consume(W),_):S(W)}function S(W){return W===61?(e.consume(W),N):tn(W)?(e.consume(W),S):x(W)}function N(W){return W===null||W===60||W===61||W===62||W===96?n(W):W===34||W===39?(e.consume(W),c=W,I):tn(W)?(e.consume(W),N):T(W)}function I(W){return W===c?(e.consume(W),c=null,z):W===null||xt(W)?n(W):(e.consume(W),I)}function T(W){return W===null||W===34||W===39||W===47||W===60||W===61||W===62||W===96||is(W)?S(W):(e.consume(W),T)}function z(W){return W===47||W===62||tn(W)?x(W):n(W)}function E(W){return W===62?(e.consume(W),D):n(W)}function D(W){return W===null||xt(W)?L(W):tn(W)?(e.consume(W),D):n(W)}function L(W){return W===45&&s===2?(e.consume(W),B):W===60&&s===1?(e.consume(W),F):W===62&&s===4?(e.consume(W),Q):W===63&&s===3?(e.consume(W),A):W===93&&s===5?(e.consume(W),H):xt(W)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(o9,K,O)(W)):W===null||xt(W)?(e.exit("htmlFlowData"),O(W)):(e.consume(W),L)}function O(W){return e.check(a9,M,K)(W)}function M(W){return e.enter("lineEnding"),e.consume(W),e.exit("lineEnding"),V}function V(W){return W===null||xt(W)?O(W):(e.enter("htmlFlowData"),L(W))}function B(W){return W===45?(e.consume(W),A):L(W)}function F(W){return W===47?(e.consume(W),a="",$):L(W)}function $(W){if(W===62){const ne=a.toLowerCase();return q1.includes(ne)?(e.consume(W),Q):L(W)}return Ei(W)&&a.length<8?(e.consume(W),a+=String.fromCharCode(W),$):L(W)}function H(W){return W===93?(e.consume(W),A):L(W)}function A(W){return W===62?(e.consume(W),Q):W===45&&s===2?(e.consume(W),A):L(W)}function Q(W){return W===null||xt(W)?(e.exit("htmlFlowData"),K(W)):(e.consume(W),Q)}function K(W){return e.exit("htmlFlow"),t(W)}}function u9(e,t,n){const r=this;return s;function s(a){return xt(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 d9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(bg,t,n)}}const f9={name:"htmlText",tokenize:p9};function p9(e,t,n){const r=this;let s,o,a;return l;function l(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),c}function c(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),S):A===63?(e.consume(A),x):Ei(A)?(e.consume(A),T):n(A)}function u(A){return A===45?(e.consume(A),f):A===91?(e.consume(A),o=0,y):Ei(A)?(e.consume(A),k):n(A)}function f(A){return A===45?(e.consume(A),h):n(A)}function p(A){return A===null?n(A):A===45?(e.consume(A),d):xt(A)?(a=p,F(A)):(e.consume(A),p)}function d(A){return A===45?(e.consume(A),h):p(A)}function h(A){return A===62?B(A):A===45?d(A):p(A)}function y(A){const Q="CDATA[";return A===Q.charCodeAt(o++)?(e.consume(A),o===Q.length?v:y):n(A)}function v(A){return A===null?n(A):A===93?(e.consume(A),b):xt(A)?(a=v,F(A)):(e.consume(A),v)}function b(A){return A===93?(e.consume(A),g):v(A)}function g(A){return A===62?B(A):A===93?(e.consume(A),g):v(A)}function k(A){return A===null||A===62?B(A):xt(A)?(a=k,F(A)):(e.consume(A),k)}function x(A){return A===null?n(A):A===63?(e.consume(A),_):xt(A)?(a=x,F(A)):(e.consume(A),x)}function _(A){return A===62?B(A):x(A)}function S(A){return Ei(A)?(e.consume(A),N):n(A)}function N(A){return A===45||ms(A)?(e.consume(A),N):I(A)}function I(A){return xt(A)?(a=I,F(A)):tn(A)?(e.consume(A),I):B(A)}function T(A){return A===45||ms(A)?(e.consume(A),T):A===47||A===62||is(A)?z(A):n(A)}function z(A){return A===47?(e.consume(A),B):A===58||A===95||Ei(A)?(e.consume(A),E):xt(A)?(a=z,F(A)):tn(A)?(e.consume(A),z):B(A)}function E(A){return A===45||A===46||A===58||A===95||ms(A)?(e.consume(A),E):D(A)}function D(A){return A===61?(e.consume(A),L):xt(A)?(a=D,F(A)):tn(A)?(e.consume(A),D):z(A)}function L(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),s=A,O):xt(A)?(a=L,F(A)):tn(A)?(e.consume(A),L):(e.consume(A),M)}function O(A){return A===s?(e.consume(A),s=void 0,V):A===null?n(A):xt(A)?(a=O,F(A)):(e.consume(A),O)}function M(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||is(A)?z(A):(e.consume(A),M)}function V(A){return A===47||A===62||is(A)?z(A):n(A)}function B(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),$}function $(A){return tn(A)?wn(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):H(A)}function H(A){return e.enter("htmlTextData"),a(A)}}const gv={name:"labelEnd",resolveAll:y9,resolveTo:w9,tokenize:x9},h9={tokenize:b9},m9={tokenize:k9},g9={tokenize:v9};function y9(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&&zi(e,0,e.length,n),e}function w9(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}},f={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=$s(l,e.slice(o+1,o+r+3)),l=$s(l,[["enter",f,t]]),l=$s(l,mv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=$s(l,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),l=$s(l,e.slice(a+1)),l=$s(l,[["exit",c,t]]),zi(e,o,e.length,l),e}function x9(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(d){return o?o._inactive?p(d):(a=r.parser.defined.includes(Ac(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),c):n(d)}function c(d){return d===40?e.attempt(h9,f,a?f:p)(d):d===91?e.attempt(m9,f,a?u:p)(d):a?f(d):p(d)}function u(d){return e.attempt(g9,f,p)(d)}function f(d){return t(d)}function p(d){return o._balanced=!0,n(d)}}function b9(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),s}function s(p){return is(p)?Cd(e,o)(p):o(p)}function o(p){return p===41?f(p):hR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return is(p)?Cd(e,c)(p):f(p)}function l(p){return n(p)}function c(p){return p===34||p===39||p===40?gR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):f(p)}function u(p){return is(p)?Cd(e,f)(p):f(p)}function f(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function k9(e,t,n){const r=this;return s;function s(l){return mR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function v9(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 S9={name:"labelStartImage",resolveAll:gv.resolveAll,tokenize:j9};function j9(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 N9={name:"labelStartLink",resolveAll:gv.resolveAll,tokenize:_9};function _9(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 dw={name:"lineEnding",tokenize:C9};function C9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),wn(e,t,"linePrefix")}}const Ah={name:"thematicBreak",tokenize:A9};function A9(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||xt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),tn(u)?wn(e,l,"whitespace")(u):l(u))}}const Jr={continuation:{tokenize:T9},exit:M9,name:"list",tokenize:P9},E9={partial:!0,tokenize:$9},I9={partial:!0,tokenize:R9};function P9(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:pb(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(Ah,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 pb(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(bg,r.interrupt?n:f,e.attempt(E9,d,p))}function f(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function p(h){return tn(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function T9(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(bg,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,wn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!tn(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(I9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,wn(e,e.attempt(Jr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function R9(e,t,n){const r=this;return wn(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 M9(e){e.exit(this.containerState.type)}function $9(e,t,n){const r=this;return wn(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!tn(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const U1={name:"setextUnderline",resolveTo:L9,tokenize:O9};function L9(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 O9(e,t,n){const r=this;let s;return o;function o(u){let f=r.events.length,p;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){p=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(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"),tn(u)?wn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||xt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const D9={tokenize:F9};function F9(e){const t=this,n=e.attempt(bg,r,e.attempt(this.parser.constructs.flowInitial,s,wn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(VV,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 z9={resolveAll:wR()},W9=yR("string"),B9=yR("text");function yR(e){return{resolveAll:wR(e==="text"?H9: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(f){return u(f)?o(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return u(f)?(n.exit("data"),o(f)):(n.consume(f),c)}function u(f){if(f===null)return!0;const p=s[f];let d=-1;if(p)for(;++d<p.length;){const h=p[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function wR(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 H9(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 V9={42:Jr,43:Jr,45:Jr,48:Jr,49:Jr,50:Jr,51:Jr,52:Jr,53:Jr,54:Jr,55:Jr,56:Jr,57:Jr,62:uR},K9={91:YV},q9={[-2]:uw,[-1]:uw,32:uw},U9={35:t9,42:Ah,45:[U1,Ah],60:i9,61:U1,95:Ah,96:K1,126:K1},G9={38:fR,92:dR},Y9={[-5]:dw,[-4]:dw,[-3]:dw,33:S9,38:fR,42:hb,60:[NV,f9],91:N9,92:[ZV,dR],93:gv,95:hb,96:DV},J9={null:[hb,z9]},X9={null:[42,95]},Q9={null:[]},Z9=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:X9,contentInitial:K9,disable:Q9,document:V9,flow:U9,flowInitial:q9,insideSpan:J9,string:G9,text:Y9},Symbol.toStringTag,{value:"Module"}));function eK(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:I(S),check:I(N),consume:k,enter:x,exit:_,interrupt:I(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:p};let f=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function p(D){return a=$s(a,D),b(),a[a.length-1]!==null?[]:(T(t,0),u.events=mv(o,u.events,u),u.events)}function d(D,L){return nK(h(D),L)}function h(D){return tK(a,D)}function y(){const{_bufferIndex:D,_index:L,line:O,column:M,offset:V}=r;return{_bufferIndex:D,_index:L,line:O,column:M,offset:V}}function v(D){s[D.line]=D.column,E()}function b(){let D;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(D){f=f(D)}function k(D){xt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,E()):D!==-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=D}function x(D,L){const O=L||{};return O.type=D,O.start=y(),u.events.push(["enter",O,u]),l.push(O),O}function _(D){const L=l.pop();return L.end=y(),u.events.push(["exit",L,u]),L}function S(D,L){T(D,L.from)}function N(D,L){L.restore()}function I(D,L){return O;function O(M,V,B){let F,$,H,A;return Array.isArray(M)?K(M):"tokenize"in M?K([M]):Q(M);function Q(G){return te;function te(re){const se=re!==null&&G[re],ee=re!==null&&G.null,ue=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return K(ue)(re)}}function K(G){return F=G,$=0,G.length===0?B:W(G[$])}function W(G){return te;function te(re){return A=z(),H=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?Z():G.tokenize.call(L?Object.assign(Object.create(u),L):u,c,ne,Z)(re)}}function ne(G){return D(H,A),V}function Z(G){return A.restore(),++$<F.length?W(F[$]):B}}}function T(D,L){D.resolveAll&&!o.includes(D)&&o.push(D),D.resolve&&zi(u.events,L,u.events.length-L,D.resolve(u.events.slice(L),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function z(){const D=y(),L=u.previous,O=u.currentConstruct,M=u.events.length,V=Array.from(l);return{from:M,restore:B};function B(){r=D,u.previous=L,u.currentConstruct=O,u.events.length=M,l=V,E()}}function E(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function tK(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 nK(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 rK(e){const r={constructs:uV([Z9,...(e||{}).extensions||[]]),content:s(wV),defined:[],document:s(bV),flow:s(D9),lazy:{},string:s(W9),text:s(B9)};return r;function s(o){return a;function a(l){return eK(r,o,l)}}}function sK(e){for(;!pR(e););return e}const G1=/[\0\t\n\r]/g;function iK(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,f,p,d,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(G1.lastIndex=p,u=G1.exec(o),d=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(d),!u){t=o.slice(p);break}if(h===10&&p===d&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),p<d&&(c.push(o.slice(p,d)),e+=d-p),h){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}p=d+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const oK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function aK(e){return e.replace(oK,lK)}function lK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return cR(n.slice(o?2:1),o?16:10)}return hv(n)||e}const xR={}.hasOwnProperty;function cK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),uK(n)(sK(rK(n).document().write(iK()(e,t,!0))))}function uK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(mt),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(Se),blockQuote:o(ee),characterEscape:z,characterReference:z,codeFenced:o(ue),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ue,a),codeText:o(de,a),codeTextData:z,data:z,codeFlowValue:z,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Me),hardBreakEscape:o(_e),hardBreakTrailing:o(_e),htmlFlow:o(Fe,a),htmlFlowData:z,htmlText:o(Fe,a),htmlTextData:z,image:o(at),label:a,link:o(mt),listItem:o(it),listItemValue:d,listOrdered:o(Te,p),listUnordered:o(Te),paragraph:o(jt),reference:W,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Se),strong:o(Vt),thematicBreak:o(Mt)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:se,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:G,characterReference:te,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:c(g),codeText:c(V),codeTextData:E,data:E,definition:c(),definitionDestinationString:_,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(O),htmlFlowData:E,htmlText:c(M),htmlTextData:E,image:c(F),label:H,labelText:$,lineEnding:D,link:c(B),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:A,resourceTitleString:Q,resource:K,setextHeading:c(T),setextHeadingLineSequence:I,setextHeadingText:N,strong:c(),thematicBreak:c()}};bR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ae){let ke={type:"root",children:[]};const qe={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:f,data:n},tt=[];let Ee=-1;for(;++Ee<ae.length;)if(ae[Ee][1].type==="listOrdered"||ae[Ee][1].type==="listUnordered")if(ae[Ee][0]==="enter")tt.push(Ee);else{const Dt=tt.pop();Ee=s(ae,Dt,Ee)}for(Ee=-1;++Ee<ae.length;){const Dt=t[ae[Ee][0]];xR.call(Dt,ae[Ee][1].type)&&Dt[ae[Ee][1].type].call(Object.assign({sliceSerialize:ae[Ee][2].sliceSerialize},qe),ae[Ee][1])}if(qe.tokenStack.length>0){const Dt=qe.tokenStack[qe.tokenStack.length-1];(Dt[1]||Y1).call(qe,void 0,Dt[0])}for(ke.position={start:Oo(ae.length>0?ae[0][1].start:{line:1,column:1,offset:0}),end:Oo(ae.length>0?ae[ae.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<t.transforms.length;)ke=t.transforms[Ee](ke)||ke;return ke}function s(ae,ke,qe){let tt=ke-1,Ee=-1,Dt=!1,nn,Kt,yt,Cn;for(;++tt<=qe;){const ie=ae[tt];switch(ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ie[0]==="enter"?Ee++:Ee--,Cn=void 0;break}case"lineEndingBlank":{ie[0]==="enter"&&(nn&&!Cn&&!Ee&&!yt&&(yt=tt),Cn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Cn=void 0}if(!Ee&&ie[0]==="enter"&&ie[1].type==="listItemPrefix"||Ee===-1&&ie[0]==="exit"&&(ie[1].type==="listUnordered"||ie[1].type==="listOrdered")){if(nn){let Ce=tt;for(Kt=void 0;Ce--;){const Ge=ae[Ce];if(Ge[1].type==="lineEnding"||Ge[1].type==="lineEndingBlank"){if(Ge[0]==="exit")continue;Kt&&(ae[Kt][1].type="lineEndingBlank",Dt=!0),Ge[1].type="lineEnding",Kt=Ce}else if(!(Ge[1].type==="linePrefix"||Ge[1].type==="blockQuotePrefix"||Ge[1].type==="blockQuotePrefixWhitespace"||Ge[1].type==="blockQuoteMarker"||Ge[1].type==="listItemIndent"))break}yt&&(!Kt||yt<Kt)&&(nn._spread=!0),nn.end=Object.assign({},Kt?ae[Kt][1].start:ie[1].end),ae.splice(Kt||tt,0,["exit",nn,ie[2]]),tt++,qe++}if(ie[1].type==="listItemPrefix"){const Ce={type:"listItem",_spread:!1,start:Object.assign({},ie[1].start),end:void 0};nn=Ce,ae.splice(tt,0,["enter",Ce,ie[2]]),tt++,qe++,yt=void 0,Cn=!0}}}return ae[ke][1]._spread=Dt,qe}function o(ae,ke){return qe;function qe(tt){l.call(this,ae(tt),tt),ke&&ke.call(this,tt)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ae,ke,qe){this.stack[this.stack.length-1].children.push(ae),this.stack.push(ae),this.tokenStack.push([ke,qe||void 0]),ae.position={start:Oo(ke.start),end:void 0}}function c(ae){return ke;function ke(qe){ae&&ae.call(this,qe),u.call(this,qe)}}function u(ae,ke){const qe=this.stack.pop(),tt=this.tokenStack.pop();if(tt)tt[0].type!==ae.type&&(ke?ke.call(this,ae,tt[0]):(tt[1]||Y1).call(this,ae,tt[0]));else throw new Error("Cannot close `"+ae.type+"` ("+_d({start:ae.start,end:ae.end})+"): it’s not open");qe.position.end=Oo(ae.end)}function f(){return lV(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function d(ae){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ae),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ae}function y(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ae}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae.replace(/(\r?\n|\r)$/g,"")}function k(ae){const ke=this.resume(),qe=this.stack[this.stack.length-1];qe.label=ke,qe.identifier=Ac(this.sliceSerialize(ae)).toLowerCase()}function x(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ae}function _(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ae}function S(ae){const ke=this.stack[this.stack.length-1];if(!ke.depth){const qe=this.sliceSerialize(ae).length;ke.depth=qe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function I(ae){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ae).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(ae){const qe=this.stack[this.stack.length-1].children;let tt=qe[qe.length-1];(!tt||tt.type!=="text")&&(tt=kt(),tt.position={start:Oo(ae.start),end:void 0},qe.push(tt)),this.stack.push(tt)}function E(ae){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ae),ke.position.end=Oo(ae.end)}function D(ae){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const qe=ke.children[ke.children.length-1];qe.position.end=Oo(ae.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(z.call(this,ae),E.call(this,ae))}function L(){this.data.atHardBreak=!0}function O(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function M(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function V(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function B(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ke,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function F(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ke,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function $(ae){const ke=this.sliceSerialize(ae),qe=this.stack[this.stack.length-2];qe.label=aK(ke),qe.identifier=Ac(ke).toLowerCase()}function H(){const ae=this.stack[this.stack.length-1],ke=this.resume(),qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,qe.type==="link"){const tt=ae.children;qe.children=tt}else qe.alt=ke}function A(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ae}function Q(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ae}function K(){this.data.inReference=void 0}function W(){this.data.referenceType="collapsed"}function ne(ae){const ke=this.resume(),qe=this.stack[this.stack.length-1];qe.label=ke,qe.identifier=Ac(this.sliceSerialize(ae)).toLowerCase(),this.data.referenceType="full"}function Z(ae){this.data.characterReferenceType=ae.type}function G(ae){const ke=this.sliceSerialize(ae),qe=this.data.characterReferenceType;let tt;qe?(tt=cR(ke,qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):tt=hv(ke);const Ee=this.stack[this.stack.length-1];Ee.value+=tt}function te(ae){const ke=this.stack.pop();ke.position.end=Oo(ae.end)}function re(ae){E.call(this,ae);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ae)}function se(ae){E.call(this,ae);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ae)}function ee(){return{type:"blockquote",children:[]}}function ue(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Me(){return{type:"emphasis",children:[]}}function Se(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function Fe(){return{type:"html",value:""}}function at(){return{type:"image",title:null,url:"",alt:null}}function mt(){return{type:"link",title:null,url:"",children:[]}}function Te(ae){return{type:"list",ordered:ae.type==="listOrdered",start:null,spread:ae._spread,children:[]}}function it(ae){return{type:"listItem",spread:ae._spread,checked:null,children:[]}}function jt(){return{type:"paragraph",children:[]}}function Vt(){return{type:"strong",children:[]}}function kt(){return{type:"text",value:""}}function Mt(){return{type:"thematicBreak"}}}function Oo(e){return{line:e.line,column:e.column,offset:e.offset}}function bR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?bR(e,r):dK(e,r)}}function dK(e,t){let n;for(n in t)if(xR.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 Y1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+_d({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is still open")}function fK(e){const t=this;t.parser=n;function n(r){return cK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function pK(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 hK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function mK(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 gK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=ru(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 xK(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 bK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function kR(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 kK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kR(e,t);const s={src:ru(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 vK(e,t){const n={src:ru(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 SK(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 jK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kR(e,t);const s={href:ru(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 NK(e,t){const n={href:ru(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 _K(e,t,n){const r=e.all(t),s=n?CK(n):vR(t),o={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let p;f&&f.type==="element"&&f.tagName==="p"?p=f:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.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 f=r[l];(s||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),f.type==="element"&&f.tagName==="p"&&!s?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function CK(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=vR(n[r])}return t}function vR(e){const t=e.spread;return t??e.children.length>1}function AK(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 EK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function PK(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TK(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=uv(t.children[1]),c=nR(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 RK(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 p=t.children[c],d={},h=a?a[c]:void 0;h&&(d.align=h);let y={type:"element",tagName:o,properties:d,children:[]};p&&(y.children=e.all(p),e.patch(p,y),y=e.applyData(p,y)),u.push(y)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function MK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const J1=9,X1=32;function $K(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(Q1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(Q1(t.slice(s),s>0,!1)),o.join("")}function Q1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===J1||o===X1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===J1||o===X1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function LK(e,t){const n={type:"text",value:$K(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function OK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const DK={blockquote:pK,break:hK,code:mK,delete:gK,emphasis:yK,footnoteReference:wK,heading:xK,html:bK,imageReference:kK,image:vK,inlineCode:SK,linkReference:jK,link:NK,listItem:_K,list:AK,paragraph:EK,root:IK,strong:PK,table:TK,tableCell:MK,tableRow:RK,text:LK,thematicBreak:OK,toml:Hp,yaml:Hp,definition:Hp,footnoteDefinition:Hp};function Hp(){}const SR=-1,kg=0,Ad=1,ym=2,yv=3,wv=4,xv=5,bv=6,jR=7,NR=8,Z1=typeof self=="object"?self:globalThis,FK=(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 kg:case SR:return n(a,s);case Ad:{const l=n([],s);for(const c of a)l.push(r(c));return l}case ym:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case yv:return n(new Date(a),s);case wv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case xv:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case bv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case jR:{const{name:l,message:c}=a;return n(new Z1[l](c),s)}case NR: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 Z1[o](a),s)};return r},e_=e=>FK(new Map,e)(0),Ul="",{toString:zK}={},{keys:WK}=Object,Uu=e=>{const t=typeof e;if(t!=="object"||!e)return[kg,t];const n=zK.call(e).slice(8,-1);switch(n){case"Array":return[Ad,Ul];case"Object":return[ym,Ul];case"Date":return[yv,Ul];case"RegExp":return[wv,Ul];case"Map":return[xv,Ul];case"Set":return[bv,Ul];case"DataView":return[Ad,n]}return n.includes("Array")?[Ad,n]:n.includes("Error")?[jR,n]:[ym,n]},Vp=([e,t])=>e===kg&&(t==="function"||t==="symbol"),BK=(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]=Uu(a);switch(l){case kg:{let f=a;switch(c){case"bigint":l=NR,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return s([SR],a)}return s([l,f],a)}case Ad:{if(c){let d=a;return c==="DataView"?d=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(d=new Uint8Array(a)),s([c,[...d]],a)}const f=[],p=s([l,f],a);for(const d of a)f.push(o(d));return p}case ym:{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 f=[],p=s([l,f],a);for(const d of WK(a))(e||!Vp(Uu(a[d])))&&f.push([o(d),o(a[d])]);return p}case yv:return s([l,a.toISOString()],a);case wv:{const{source:f,flags:p}=a;return s([l,{source:f,flags:p}],a)}case xv:{const f=[],p=s([l,f],a);for(const[d,h]of a)(e||!(Vp(Uu(d))||Vp(Uu(h))))&&f.push([o(d),o(h)]);return p}case bv:{const f=[],p=s([l,f],a);for(const d of a)(e||!Vp(Uu(d)))&&f.push(o(d));return p}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},t_=(e,{json:t,lossy:n}={})=>{const r=[];return BK(!(t||n),!!t,new Map,r)(e),r},wm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?e_(t_(e,t)):structuredClone(e):(e,t)=>e_(t_(e,t));function HK(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 VK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function KK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||HK,r=e.options.footnoteBackLabel||VK,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 f=e.all(u),p=String(u.identifier).toUpperCase(),d=ru(p.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(p);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-"+d+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=f[f.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 f.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(f,!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:{...wm(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 _R=function(e){if(e==null)return YK;if(typeof e=="function")return vg(e);if(typeof e=="object")return Array.isArray(e)?qK(e):UK(e);if(typeof e=="string")return GK(e);throw new Error("Expected function, string, or object as test")};function qK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=_R(e[n]);return vg(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function UK(e){const t=e;return vg(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function GK(e){return vg(t);function t(n){return n&&n.type===e}}function vg(e){return t;function t(n,r,s){return!!(JK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function YK(){return!0}function JK(e){return e!==null&&typeof e=="object"&&"type"in e}const CR=[],XK=!0,n_=!1,QK="skip";function ZK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=_R(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,f){const p=c&&typeof c=="object"?c:{};if(typeof p.type=="string"){const h=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=CR,y,v,b;if((!t||o(c,u,f[f.length-1]||void 0))&&(h=e7(n(c,f)),h[0]===n_))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==QK)for(v=(r?g.children.length:-1)+a,b=f.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===n_)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function e7(e){return Array.isArray(e)?e:typeof e=="number"?[XK,e]:e==null?CR:[e]}function AR(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),ZK(e,o,l,s);function l(c,u){const f=u[u.length-1],p=f?f.children.indexOf(c):void 0;return a(c,p,f)}}const mb={}.hasOwnProperty,t7={};function n7(e,t){const n=t||t7,r=new Map,s=new Map,o=new Map,a={...DK,...n.handlers},l={all:u,applyData:s7,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:r7,wrap:o7};return AR(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const p=f.type==="definition"?r:s,d=String(f.identifier).toUpperCase();p.has(d)||p.set(d,f)}}),l;function c(f,p){const d=f.type,h=l.handlers[d];if(mb.call(l.handlers,d)&&h)return h(l,f,p);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in f){const{children:v,...b}=f,g=wm(b);return g.children=l.all(f),g}return wm(f)}return(l.options.unknownHandler||i7)(l,f,p)}function u(f){const p=[];if("children"in f){const d=f.children;let h=-1;for(;++h<d.length;){const y=l.one(d[h],f);if(y){if(h&&d[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=r_(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=r_(v.value))}Array.isArray(y)?p.push(...y):p.push(y)}}}return p}}function r7(e,t){e.position&&(t.position=z8(e))}function s7(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,wm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function i7(e,t){const n=t.data||{},r="value"in t&&!(mb.call(n,"hProperties")||mb.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 o7(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 r_(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function s_(e,t){const n=n7(e,t),r=n.one(e,void 0),s=KK(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 a7(e,t){return e&&"run"in e?async function(n,r){const s=s_(n,{file:r,...t});await e.run(s,r)}:function(n,r){return s_(n,{file:r,...e||t})}}function i_(e){if(e)throw e}var Eh=Object.prototype.hasOwnProperty,ER=Object.prototype.toString,o_=Object.defineProperty,a_=Object.getOwnPropertyDescriptor,l_=function(t){return typeof Array.isArray=="function"?Array.isArray(t):ER.call(t)==="[object Array]"},c_=function(t){if(!t||ER.call(t)!=="[object Object]")return!1;var n=Eh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Eh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Eh.call(t,s)},u_=function(t,n){o_&&n.name==="__proto__"?o_(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},d_=function(t,n){if(n==="__proto__")if(Eh.call(t,n)){if(a_)return a_(t,n).value}else return;return t[n]},l7=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,u=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=d_(l,n),s=d_(t,n),l!==s&&(f&&s&&(c_(s)||(o=l_(s)))?(o?(o=!1,a=r&&l_(r)?r:[]):a=r&&c_(r)?r:{},u_(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&u_(l,{name:n,newValue:s}));return l};const fw=ma(l7);function gb(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 c7(){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 f=e[++o];let p=-1;if(c){a(c);return}for(;++p<s.length;)(u[p]===null||u[p]===void 0)&&(u[p]=s[p]);s=u,f?u7(f,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 u7(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 f=u;if(l&&n)throw f;return s(f)}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 Si={basename:d7,dirname:f7,extname:p7,join:h7,sep:"/"};function d7(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Rf(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 f7(e){if(Rf(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 p7(e){Rf(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 h7(...e){let t=-1,n;for(;++t<e.length;)Rf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":m7(n)}function m7(e){Rf(e);const t=e.codePointAt(0)===47;let n=g7(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function g7(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 Rf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const y7={cwd:w7};function w7(){return"/"}function yb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function x7(e){if(typeof e=="string")e=new URL(e);else if(!yb(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 b7(e)}function b7(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 pw=["history","path","basename","stem","extname","dirname"];class IR{constructor(t){let n;t?yb(t)?n={path:t}:typeof t=="string"||k7(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":y7.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<pw.length;){const o=pw[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)pw.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Si.basename(this.path):void 0}set basename(t){mw(t,"basename"),hw(t,"basename"),this.path=Si.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Si.dirname(this.path):void 0}set dirname(t){f_(this.basename,"dirname"),this.path=Si.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Si.extname(this.path):void 0}set extname(t){if(hw(t,"extname"),f_(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=Si.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){yb(t)&&(t=x7(t)),mw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Si.basename(this.path,this.extname):void 0}set stem(t){mw(t,"stem"),hw(t,"stem"),this.path=Si.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 $r(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 hw(e,t){if(e&&e.includes(Si.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Si.sep+"`")}function mw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function f_(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function k7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const v7=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},S7={}.hasOwnProperty;class kv extends v7{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=c7()}copy(){const t=new kv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(fw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(ww("data",this.frozen),this.namespace[t]=n,this):S7.call(this.namespace,t)&&this.namespace[t]||void 0:t?(ww("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=Kp(t),r=this.parser||this.Parser;return gw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),gw("process",this.parser||this.Parser),yw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Kp(t),c=r.parse(l);r.run(c,l,function(f,p,d){if(f||!p||!d)return u(f);const h=p,y=r.stringify(h,d);_7(y)?d.value=y:d.result=y,u(f,d)});function u(f,p){f||!p?a(f):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),gw("processSync",this.parser||this.Parser),yw("processSync",this.compiler||this.Compiler),this.process(t,s),h_("processSync","process",n),r;function s(o,a){n=!0,i_(o),r=a}}run(t,n,r){p_(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=Kp(n);s.run(t,c,u);function u(f,p,d){const h=p||t;f?l(f):a?a(h):r(void 0,h,d)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),h_("runSync","run",r),s;function o(a,l){i_(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Kp(n),s=this.compiler||this.Compiler;return yw("stringify",s),p_(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(ww("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[f,...p]=u;c(f,p)}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=fw(!0,s.settings,u.settings))}function l(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const p=u[f];o(p)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,f){let p=-1,d=-1;for(;++p<r.length;)if(r[p][0]===u){d=p;break}if(d===-1)r.push([u,...f]);else if(f.length>0){let[h,...y]=f;const v=r[d][1];gb(v)&&gb(h)&&(h=fw(!0,v,h)),r[d]=[u,h,...y]}}}}const j7=new kv().freeze();function gw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ww(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 p_(e){if(!gb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function h_(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Kp(e){return N7(e)?e:new IR(e)}function N7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function _7(e){return typeof e=="string"||C7(e)}function C7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const A7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",m_=[],g_={allowDangerousHtml:!0},E7=/^(https?|ircs?|mailto|xmpp)$/i,I7=[{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 PR(e){const t=P7(e),n=T7(e);return R7(t.runSync(t.parse(n),n),e)}function P7(e){const t=e.rehypePlugins||m_,n=e.remarkPlugins||m_,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...g_}:g_;return j7().use(fK).use(n).use(a7,r).use(t)}function T7(e){const t=e.children||"",n=new IR;return typeof t=="string"&&(n.value=t),n}function R7(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||M7;for(const f of I7)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+A7+f.id,void 0);return AR(e,u),K8(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(f,p,d){if(f.type==="raw"&&d&&typeof p=="number")return a?d.children.splice(p,1):d.children[p]={type:"text",value:f.value},p;if(f.type==="element"){let h;for(h in cw)if(Object.hasOwn(cw,h)&&Object.hasOwn(f.properties,h)){const y=f.properties[h],v=cw[h];(v===null||v.includes(f.tagName))&&(f.properties[h]=c(String(y||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):o?o.includes(f.tagName):!1;if(!h&&r&&typeof p=="number"&&(h=!r(f,p,d)),h&&d&&typeof p=="number")return l&&f.children?d.children.splice(p,1,...f.children):d.children.splice(p,1),p}}}function M7(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||E7.test(e.slice(0,t))?e:""}const $7=new Set(["echarts"]),L7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),O7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),D7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function oa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function cl(e,t){if(!oa(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:oa(n[r])&&oa(s)&&(n[r]=cl(n[r],s));return n}function Sg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>oa(n)?cl(n,t):n):oa(e)?cl(e,t):e}function F7(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 wb(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)=>wb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||O7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);wb(r,`${t}.${n}`)}}}function z7(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(!L7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function W7(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:cl(e,t)}function B7(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(!oa(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return cl(o,n)}):oa(e)?cl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function H7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Sg(e,n)}function y_(e,t="rgba(255, 255, 255, 0.62)"){return Sg(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 V7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Sg(e,n)}function K7(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:Sg(e,t)}function q7(e,t,n){const r=B7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>oa(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??D7,textStyle:cl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:W7(e.tooltip),legend:H7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?V7(e.grid,s||o):e.grid,xAxis:y_(e.xAxis),yAxis:y_(e.yAxis),radar:K7(e.radar),series:t}}function U7(e){const t=F7(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(!$7.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");wb(n);const r=z7(n.option.series),s=n.title==null?"":String(n.title),o=q7(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 qp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function G7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function io(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!qp(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==="`"&&!qp(t,o)){const l=G7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!qp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&qp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function TR(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 RR(e){const t=io(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function MR(e){return io(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function Y7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function J7(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 X7({code:e}){const t=m.useMemo(()=>J7(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((f,p)=>{l.set(f.id,{x:28+(n?p*(r+o):p%3*(r+o)),y:28+(n?p%3*(s+a):p*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(f=>f.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(f=>f.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((f,p)=>{const d=l.get(f.from),h=l.get(f.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${f.from}-${f.to}-${p}`)}),t.nodes.map(f=>{const p=l.get(f.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:p.x,y:p.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:p.x+r/2,y:p.y+s/2+5,textAnchor:"middle",children:f.label.slice(0,24)})]},f.id)})]})}function Q7(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 Z7({code:e}){const t=m.useMemo(()=>Q7(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),f=p=>{const d=Math.max(0,n.findIndex(h=>h.id===p));return s+d*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((p,d)=>{const h=s+d*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:p.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},p.id)}),t.rows.map((p,d)=>{const h=o+a+d*l+24;if(p.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:p.text.slice(0,120)})]},`note-${d}`);const y=f(p.from),v=f(p.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:p.text.slice(0,72)})]},`msg-${d}`)})]})}function $R({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(Z7,{code:t}):i.jsx(X7,{code:t})})}function eq(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&&Y7(l)){o();const u=[];for(;a<t.length;){const f=t[a]||"";if(u.length>0&&(!f.trim()||/^-{3,}\s*$/.test(f)||/^#{1,6}\s+/.test(f)))break;u.push(f),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&&io(l).length>1&&RR(t[a+1])){o();const u=io(l),f=MR(t[a+1]),p=[];for(a+=2;a<t.length&&t[a].trim()&&io(t[a]).length>1;)p.push(TR(io(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:f,rows:p});continue}r.push(l),a++}return o(),n}function w_(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 LR(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 f=o;for(;f<r.length&&!/\s|<|>/.test(r[f]);)f+=1;let p=r.slice(o,f),d="";for(;/[.,;:!?)}\]]$/.test(p);)d=p.slice(-1)+d,p=p.slice(0,-1);p?s+=`[${p}](${p})${d}`:s+=r.slice(o,f),o=f}return s}).join(`
87
- `)}function OR(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=w_(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 f;const c=((f=String(a||"").match(/language-(\w+)/i))==null?void 0:f[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?i.jsx($R,{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(w_(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 x_({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(PR,{components:OR(t,!0,n),children:LR(e)})}function vv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>eq(e),[e]),s=m.useMemo(()=>OR(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx($R,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(PR,{components:s,children:LR(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(x_,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((u,f)=>i.jsx("td",{style:{textAlign:o.align[f]||"left"},children:i.jsx(x_,{resolveSrc:t,basePath:n,children:l[f]||""})},f))},c))})]})},`table-${a}`))})}function tq(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 ki(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 nq(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=>ki(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>ki(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)=>ki(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:ki(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:ki(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>ki(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>ki(s[a])):s&&typeof s=="object"?r.map(o=>ki(s[o.key])):r.map((o,a)=>a===0?ki(s):""))}}function rq(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=nq(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&&io(s[0]).length>1&&RR(s[1])){const l=io(s[0]),c=MR(s[1]);return{columns:l.map((u,f)=>({key:String(f),label:u,align:c[f]||"left"})),rows:s.slice(2).map(u=>TR(io(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=tq(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 Sv({content:e}){const t=m.useMemo(()=>rq(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:ki(n[o])},`${s.key}-${o}`))},r))})]})})}function jv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>U7(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:""}),G6(()=>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,f;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(f=a==null?void 0:a.dispose)==null||f.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 DR(e){return typeof e>"u"||e===null}function sq(e){return typeof e=="object"&&e!==null}function iq(e){return Array.isArray(e)?e:DR(e)?[]:[e]}function oq(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 aq(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function lq(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var cq=DR,uq=sq,dq=iq,fq=aq,pq=lq,hq=oq,Nv={isNothing:cq,isObject:uq,toArray:dq,repeat:fq,isNegativeZero:pq,extend:hq};function FR(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 af(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=FR(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}af.prototype=Object.create(Error.prototype);af.prototype.constructor=af;af.prototype.toString=function(t){return this.name+": "+FR(this,t)};var Fa=af,mq=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],gq=["scalar","sequence","mapping"];function yq(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function wq(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(mq.indexOf(n)===-1)throw new Fa('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=yq(t.styleAliases||null),gq.indexOf(this.kind)===-1)throw new Fa('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Tr=wq;function b_(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 xq(){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 xb(e){return this.extend(e)}xb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Tr)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 Fa("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Tr))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Fa("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 Fa("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 Tr))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(xb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=b_(s,"implicit"),s.compiledExplicit=b_(s,"explicit"),s.compiledTypeMap=xq(s.compiledImplicit,s.compiledExplicit),s};var bq=xb,kq=new Tr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),vq=new Tr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Sq=new Tr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),jq=new bq({explicit:[kq,vq,Sq]});function Nq(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function _q(){return null}function Cq(e){return e===null}var Aq=new Tr("tag:yaml.org,2002:null",{kind:"scalar",resolve:Nq,construct:_q,predicate:Cq,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Eq(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 Iq(e){return e==="true"||e==="True"||e==="TRUE"}function Pq(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Tq=new Tr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Eq,construct:Iq,predicate:Pq,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 Rq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Mq(e){return 48<=e&&e<=55}function $q(e){return 48<=e&&e<=57}function Lq(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(!Rq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!Mq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!$q(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function Oq(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 Dq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Nv.isNegativeZero(e)}var Fq=new Tr("tag:yaml.org,2002:int",{kind:"scalar",resolve:Lq,construct:Oq,predicate:Dq,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"]}}),zq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Wq(e){return!(e===null||!zq.test(e)||e[e.length-1]==="_")}function Bq(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 Hq=/^[-+]?[0-9]+e/;function Vq(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(Nv.isNegativeZero(e))return"-0.0";return n=e.toString(10),Hq.test(n)?n.replace("e",".e"):n}function Kq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Nv.isNegativeZero(e))}var qq=new Tr("tag:yaml.org,2002:float",{kind:"scalar",resolve:Wq,construct:Bq,predicate:Kq,represent:Vq,defaultStyle:"lowercase"}),Uq=jq.extend({implicit:[Aq,Tq,Fq,qq]}),Gq=Uq,zR=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),WR=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 Yq(e){return e===null?!1:zR.exec(e)!==null||WR.exec(e)!==null}function Jq(e){var t,n,r,s,o,a,l,c=0,u=null,f,p,d;if(t=zR.exec(e),t===null&&(t=WR.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]&&(f=+t[10],p=+(t[11]||0),u=(f*60+p)*6e4,t[9]==="-"&&(u=-u)),d=new Date(Date.UTC(n,r,s,o,a,l,c)),u&&d.setTime(d.getTime()-u),d}function Xq(e){return e.toISOString()}var Qq=new Tr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Yq,construct:Jq,instanceOf:Date,represent:Xq});function Zq(e){return e==="<<"||e===null}var eU=new Tr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Zq}),_v=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
- \r`;function tU(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=_v;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 nU(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=_v,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 rU(e){var t="",n=0,r,s,o=e.length,a=_v;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 sU(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var iU=new Tr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:tU,construct:nU,predicate:sU,represent:rU}),oU=Object.prototype.hasOwnProperty,aU=Object.prototype.toString;function lU(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,aU.call(s)!=="[object Object]")return!1;for(o in s)if(oU.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 cU(e){return e!==null?e:[]}var uU=new Tr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:lU,construct:cU}),dU=Object.prototype.toString;function fU(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],dU.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function pU(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 hU=new Tr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:fU,construct:pU}),mU=Object.prototype.hasOwnProperty;function gU(e){if(e===null)return!0;var t,n=e;for(t in n)if(mU.call(n,t)&&n[t]!==null)return!1;return!0}function yU(e){return e!==null?e:{}}var wU=new Tr("tag:yaml.org,2002:set",{kind:"mapping",resolve:gU,construct:yU});Gq.extend({implicit:[Qq,eU],explicit:[iU,uU,hU,wU]});function k_(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 xU=new Array(256),bU=new Array(256);for(var Gl=0;Gl<256;Gl++)xU[Gl]=k_(Gl)?1:0,bU[Gl]=k_(Gl);const lf=["requirement","planning","code","test","normal"],v_={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function Cv(e,t){var s,o,a,l,c,u,f,p,d,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]}:{},_=((o=k.data)==null?void 0:o.definitionId)||k.id,S=((a=k.data)==null?void 0:a.inputs)??[],N=((l=k.data)==null?void 0:l.outputs)??[],I=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",T=x.role!=null?String(x.role).trim():"",z=v_[I]||I,E=v_[T]||T,D=lf.includes(z)?z:lf.includes(E)?E:"normal",L=Array.isArray(S)?S.map(n):Array.isArray(x.input)?x.input.map(Z=>n(Z)):[],O=Array.isArray(N)?N.map(n):Array.isArray(x.output)?x.output.map(Z=>n(Z)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,V=(f=k.data)==null?void 0:f.body,B=V!=null?String(V):x.body!=null?String(x.body):"";let F=((p=k.data)==null?void 0:p.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:_,label:M,role:D,model:F,input:L,output:O},H=((d=k.data)==null?void 0:d.marketplaceRef)||x.marketplaceRef;H?$.marketplaceRef=String(H):delete $.marketplaceRef;const A=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;A?$.marketplacePackageId=String(A):delete $.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;Q?$.marketplaceVersion=String(Q):delete $.marketplaceVersion,_.startsWith("provide_")||B.trim()===""?delete $.body:$.body=B;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 W=(b=k.data)==null?void 0:b.script,ne=W!=null?String(W):x.script!=null?String(x.script):"";ne.trim()===""?delete $.script:$.script=ne;for(const Z of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[Z],te=G!=null?String(G):x[Z]!=null?String(x[Z]):"";te.trim()===""?delete $[Z]:$[Z]=te.trim()}delete $.temperature,delete $.maxTokens,delete $.description,r[k.id]=$}return r}function Ed(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function kU(e,t){const n=String(e||"node").replace(/_copy(?:_\d+)?$/i,"");let r=`${n}_copy`,s=2;for(;t.has(r);)r=`${n}_copy_${s}`,s+=1;return t.add(r),r}function vU(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=>Ed(a)),edges:o.map(a=>Ed(a)),instances:Cv(r,n||{})}}function SU(e,t,n,r,s={}){var p;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(d=>d.id)),l=new Map;for(const d of e.nodes)l.set(d.id,kU(d.id,a));const c=e.nodes.map(d=>{var y,v;const h=l.get(d.id);return{...Ed(d),id:h,selected:!0,dragging:!1,position:{x:Number(((y=d.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=d.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(d=>l.has(d.source)&&l.has(d.target)).map((d,h)=>{const y=l.get(d.source),v=l.get(d.target);return{...Ed(d),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),f={...r||{}};for(const[d,h]of l.entries()){const y=(p=e.instances)==null?void 0:p[d];y&&(f[h]={...Ed(y),label:y.label!=null?String(y.label):h})}return{nodes:[...(t||[]).map(d=>({...d,selected:!1})),...c],edges:[...(n||[]).map(d=>({...d,selected:!1})),...u],instances:f,pastedNodeIds:c.map(d=>d.id)}}function Dn(e){switch(xm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function xm(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 jU(e,t){const n=xm(e),r=xm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const NU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function bb(e){const t=xm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&NU.has(n)?`${t}+${n}`:t}function _U(e){return bb(e)}function cf(e,t){if(!e||!t||!jU(e.type,t.type))return!1;const n=bb(e),r=bb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function CU(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 kb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=CU(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 bm=/\[image\s+(\d+)\]/gi;function vo(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 AU(e){return`image ${vo(e).length+1}`}function EU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function IU(e,t){const n=vo(e),r=String(t||""),s=new Set;bm.lastIndex=0;let o;for(;o=bm.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function PU(e){return new Promise((t,n)=>{if(!e||!String(e.type||"").startsWith("image/")){n(new Error("Only image files are supported"));return}const r=new FileReader;r.onload=()=>{t({name:e.name||"image",mimeType:e.type||"image/png",dataUrl:String(r.result||"")})},r.onerror=()=>n(r.error||new Error("Failed to read image")),r.readAsDataURL(e)})}function BR(e){var n;return Array.from(((n=e==null?void 0:e.clipboardData)==null?void 0:n.items)||[]).filter(r=>r.kind==="file"&&String(r.type||"").startsWith("image/")).map(r=>r.getAsFile()).filter(Boolean)}function Id(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 HR({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=vo(n);for(const a of r){const l=await PU(a),c=AU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=EU(s,c)}return{body:s,images:o}}function Es(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function TU(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 RU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function an(e){e.stopPropagation()}function MU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $U(e,t){const n=`\\[${MU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
- `).replace(/\n{3,}/g,`
97
-
98
- `).trimEnd()}function xw(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LU(e){const t=String(e||"");let n="",r=0;bm.lastIndex=0;let s;for(;s=bm.exec(t);)n+=xw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${xw(s[0])}</span>`,r=s.index+s[0].length;return n+=xw(t.slice(r)),n||" "}function OU(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 DU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:f=!1}){var Lr,Or;const{t:p}=qr(),d=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=TU(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,_=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,N=(e==null?void 0:e.definitionId)||"",I=N.startsWith("provide_"),T=N==="provide_bool",z=N==="provide_str",E=N==="provide_file",D=N==="provide_password",L=N==="agent_subAgent",O=N==="control_agent_toBool",M=(L||O)&&!b,V=T?RU(h[0]):!1,B=I?String(((Lr=h[0])==null?void 0:Lr.value)??((Or=h[0])==null?void 0:Or.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)||p("flow:node.fallbackLabel"),H=!I&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",A=vo(e==null?void 0:e.images),Q=T||z||E||D||M||!!H,K=m.useRef(!1),W=m.useRef(!1),ne=m.useRef(null),Z=m.useRef(null),G=m.useRef(null),te=m.useRef(null),re=m.useRef(null),[se,ee]=m.useState(B),[ue,de]=m.useState(!1),[me,Me]=m.useState(F),[Se,_e]=m.useState(!1),[Fe,at]=m.useState({visible:!1,top:0,height:100}),[mt,Te]=m.useState(!1),it=m.useCallback(()=>{const ce=Z.current;if(!ce)return;const ge=Math.max(1,ce.scrollHeight),et=Math.max(1,ce.clientHeight),rt=ge>et+1,Bt=rt?Math.max(12,et/ge*100):100,Wn=Math.max(0,100-Bt),Cr=rt?Math.min(Wn,ce.scrollTop/Math.max(1,ge-et)*Wn):0;at({visible:rt,top:Cr,height:Bt})},[]);m.useEffect(()=>{K.current||ee(B)},[n,B]),m.useEffect(()=>{W.current||Me(F)},[n,F]),m.useEffect(()=>{const ce=Z.current;if(!ce)return;if(M){ce.style.minHeight="",ce.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const ge=OU(ce,me);ce.style.minHeight=`${ge}px`,ce.style.height="",G.current&&(G.current.style.minHeight=`${ge}px`,G.current.style.height="")},[me,M]),m.useEffect(()=>{if(!M)return;const ce=window.requestAnimationFrame(it),ge=Z.current;if(!ge||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ce);const et=new ResizeObserver(it);return et.observe(ge),()=>{window.cancelAnimationFrame(ce),et.disconnect()}},[me,M,it]),m.useEffect(()=>{const ce=ne.current,ge=e==null?void 0:e.onNodeContentResize;if(!M||!ce||!ge||typeof ResizeObserver>"u")return;let et=0;const rt=()=>{window.cancelAnimationFrame(et),et=window.requestAnimationFrame(()=>ge(n))},Bt=new ResizeObserver(rt);return Bt.observe(ce),rt(),()=>{window.cancelAnimationFrame(et),Bt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!mt)return;const ce=window.setTimeout(()=>{const ge=re.current;if(!ge)return;ge.focus();const et=ge.value.length;ge.setSelectionRange(et,et)},0);return()=>window.clearTimeout(ce)},[mt]);const jt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],Vt=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],kt=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Mt=Array.isArray(c==null?void 0:c.codex)?c.codex:[],ae=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!N.startsWith("tool_nodejs"),qe=new Set(jt.map(Es)),tt=new Set(Vt.map(Es)),Ee=new Set(kt.map(Es)),Dt=new Set(Mt.map(Es)),nn=ae?ae.startsWith("cursor:")||ae.startsWith("opencode:")||ae.startsWith("codex:")||ae.startsWith("claude-code:")?ae:Ee.has(ae)?`claude-code:${ae}`:Dt.has(ae)?`codex:${ae}`:tt.has(ae)?`opencode:${ae}`:qe.has(ae)?`cursor:${ae}`:ae:"",Kt=ae&&!nn.startsWith("cursor:")&&!nn.startsWith("opencode:")&&!nn.startsWith("codex:")&&!nn.startsWith("claude-code:")&&!qe.has(ae)&&!tt.has(ae)&&!Ee.has(ae)&&!Dt.has(ae),yt=ae.startsWith("cursor:")?ae.slice(7):ae.startsWith("opencode:")?ae.slice(9):ae.startsWith("codex:")?ae.slice(6):ae.startsWith("claude-code:")?ae.slice(12):ae,Cn=ce=>{if(g)return;const ge=ce.target.value;u&&u(n,ge)},ie=ce=>{ce.stopPropagation(),!g&&r&&r(n)},Ce=ce=>{ce.stopPropagation(),s&&s()},Ge=ce=>{ce.stopPropagation(),!g&&(o==null||o(n,ce.target.value==="true"?"true":"false"))},Be=ce=>{if(ce.stopPropagation(),g)return;const ge=ce.target.value;ee(ge),!f&&!K.current&&(o==null||o(n,ge))},Et=ce=>{ce.stopPropagation(),K.current=!0},vt=ce=>{if(ce.stopPropagation(),g)return;K.current=!1;const ge=ce.currentTarget.value;ee(ge),f||o==null||o(n,ge)},pe=()=>{g||f&&se===B||o==null||o(n,se)},He=ce=>{if(ce.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,se);return}const ge=window.prompt("文件路径",se);ge!=null&&(ee(ge),o==null||o(n,ge))},wt=ce=>{ce.stopPropagation(),de(ge=>!ge)},bt=ce=>{if(Me(ce),a==null||a(n,ce),l){const ge=IU(A,ce);(ge.length!==A.length||ge.some((et,rt)=>{var Bt;return et.id!==((Bt=A[rt])==null?void 0:Bt.id)}))&&l(n,ge)}},ln=ce=>{if(ce.stopPropagation(),g)return;const ge=ce.target.value;f||W.current?Me(ge):bt(ge)},Tn=ce=>{ce.stopPropagation(),!g&&(W.current=!0,_e(!0))},An=ce=>{if(ce.stopPropagation(),g)return;W.current=!1,_e(!1);const ge=ce.currentTarget.value;f?Me(ge):bt(ge)},en=()=>{g||(W.current=!1,_e(!1),!(f&&me===F)&&bt(me))},bn=ce=>{ce.stopPropagation(),ce.preventDefault(),!g&&Te(!0)},nr=()=>{Te(!1),en()},fn=ce=>{ce.stopPropagation(),ce.key==="Escape"&&(ce.preventDefault(),nr())},kn=m.useCallback(ce=>{const ge=Z.current;if(!ge)return;const et=Math.max(0,ge.scrollHeight-ge.clientHeight);ge.scrollTop=Math.min(1,Math.max(0,ce))*et,it()},[it]),rr=m.useCallback((ce,ge=0)=>{const et=te.current;if(!et)return 0;const rt=et.getBoundingClientRect(),Bt=Fe.height/100*rt.height,Wn=Math.max(1,rt.height-Bt);return(ce-rt.top-ge)/Wn},[Fe.height]),vs=m.useCallback(ce=>{var Xt,Qt;if(!Fe.visible)return;ce.preventDefault(),ce.stopPropagation();const ge=te.current;if(!ge)return;const et=ge.getBoundingClientRect(),rt=Fe.top/100*et.height,Bt=Fe.height/100*et.height,Cr=ce.clientY>=et.top+rt&&ce.clientY<=et.top+rt+Bt?ce.clientY-et.top-rt:Bt/2;kn(rr(ce.clientY,Cr));const Ar=ce.pointerId;(Qt=(Xt=ce.currentTarget).setPointerCapture)==null||Qt.call(Xt,Ar);const wr=ir=>{ir.preventDefault(),kn(rr(ir.clientY,Cr))},ct=()=>{window.removeEventListener("pointermove",wr),window.removeEventListener("pointerup",ct),window.removeEventListener("pointercancel",ct)};window.addEventListener("pointermove",wr),window.addEventListener("pointerup",ct),window.addEventListener("pointercancel",ct)},[rr,Fe.height,Fe.top,Fe.visible,kn]),sr=async ce=>{if(g)return;const ge=await HR({files:ce,body:me,images:A});ge&&(Me(ge.body),a==null||a(n,ge.body),l==null||l(n,ge.images))},Gn=(ce,ge)=>{if(ce.stopPropagation(),g)return;const et=A.filter(Bt=>Bt.id!==ge.id),rt=$U(me,ge.label);Me(rt),a==null||a(n,rt),l==null||l(n,et)},Nr=ce=>{if(g)return;const ge=BR(ce);ge.length!==0&&(ce.preventDefault(),ce.stopPropagation(),sr(ge).catch(()=>{}))},_r=ce=>{if(g)return;const ge=Id(ce);ge.length!==0&&(ce.preventDefault(),ce.stopPropagation(),sr(ge).catch(()=>{}))},Yn=()=>{const ce=Z.current,ge=G.current;!ce||!ge||(ge.scrollTop=ce.scrollTop,ge.scrollLeft=ce.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(_==="success"?" af-flow-node--done":"")+(_==="failed"?" af-flow-node--failed":"")+(_==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(z?" af-flow-node--provide-text":"")+(D?" 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:an,onMouseDown:an,onClick:an,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:nn,onChange:Cn,onPointerDown:an,onMouseDown:an,onClick:an,"aria-label":p("flow:node.model"),title:yt||p("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),Kt&&i.jsx("option",{value:ae,children:ae}),jt.length>0&&i.jsx("optgroup",{label:"Cursor",children:jt.map(ce=>i.jsx("option",{value:`cursor:${Es(ce)}`,children:Es(ce)},`c-${ce}`))}),Vt.length>0&&i.jsx("optgroup",{label:"OpenCode",children:Vt.map(ce=>i.jsx("option",{value:`opencode:${Es(ce)}`,children:Es(ce)},`o-${ce}`))}),Mt.length>0&&i.jsx("optgroup",{label:"Codex",children:Mt.map(ce=>i.jsx("option",{value:`codex:${Es(ce)}`,children:Es(ce)},`codex-${ce}`))}),kt.length>0&&i.jsx("optgroup",{label:"Claude Code",children:kt.map(ce=>i.jsx("option",{value:`claude-code:${Es(ce)}`,children:Es(ce)},`cc-${ce}`))})]}),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"}),_==="running"&&!k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),_==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),_==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&I&&!T&&!z&&!E&&!D&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Ce,"aria-label":p("flow:node.expandProvide"),title:p("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:ie,"aria-label":p("flow:node.deleteNode"),title:p("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:d.map((ce,ge)=>{if(ce.showOnNode===!1)return null;const et=p("flow:node.inputTooltip",{name:ce.name||`#${ge}`,type:ce.type})+(ce.default!=null&&ce.default!==""?p("flow:node.defaultSuffix",{value:ce.default}):""),rt=ce.name||`#${ge+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:et,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[rt,ce.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${ge}`,className:"af-flow-node__handle",style:{background:Dn(ce.type)},title:et})]},`in-${ge}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[T?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(V?" af-flow-node__bool-select--true":""),value:V?"true":"false",onChange:Ge,onPointerDown:an,onMouseDown:an,onClick:an,"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"})]}):z?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:se,onChange:Be,onCompositionStart:Et,onCompositionEnd:vt,onBlur:pe,onPointerDown:an,onMouseDown:an,onClick:an,placeholder:"输入文本",rows:2,readOnly:g}):E?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:an,onMouseDown:an,onClick:an,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:se,onChange:Be,onCompositionStart:Et,onCompositionEnd:vt,onBlur:pe,placeholder:"选择或输入文件路径",title:se||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:He,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):D?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:an,onMouseDown:an,onClick:an,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ue?"text":"password",value:se,onChange:Be,onCompositionStart:Et,onCompositionEnd:vt,onBlur:pe,placeholder:"输入密码或密钥",title:ue?se:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:wt,"aria-label":ue?"隐藏密码":"预览密码",title:ue?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ue?"visibility_off":"visibility"})})]}):M?i.jsxs("div",{ref:ne,className:"af-flow-node__prompt-stack nodrag"+(Se?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:LU(me)+`
99
- `}}),i.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:me,onChange:ln,onCompositionStart:Tn,onCompositionEnd:An,onBlur:en,onPaste:Nr,onDrop:_r,onScroll:ce=>{Yn(),it()},onPointerDown:an,onMouseDown:an,onClick:an,onKeyDown:an,onDragOver:ce=>{Id(ce).length>0&&ce.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:an,onMouseDown:an,onClick:bn,"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"+(Fe.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:vs,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${Fe.height}%`,top:`${Fe.top}%`}})})]}):null,M&&A.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:A.map((ce,ge)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:ce.name,children:[i.jsx("img",{src:ce.dataUrl,alt:""}),i.jsxs("span",{children:["[",ce.label||`image ${ge+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:et=>Gn(et,ce),onPointerDown:an,onMouseDown:an,"aria-label":`删除 ${ce.label||`image ${ge+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ce.id||ge))}):null,H?i.jsx("span",{className:"af-flow-node__prompt-preview",title:H,children:H}):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((ce,ge)=>{if(ce.showOnNode===!1)return null;const et=p("flow:node.outputTooltip",{name:ce.name||`#${ge}`,type:ce.type})+(ce.default!=null&&ce.default!==""?p("flow:node.defaultSuffix",{value:ce.default}):""),rt=ce.name||`#${ge+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:et,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[rt,ce.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${ge}`,className:"af-flow-node__handle",style:{background:Dn(ce.type)},title:et})]},`out-${ge}`)})})]}),mt?pr.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:an,onMouseDown:an,onClick:an,onWheel:an,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:nr,"aria-label":"关闭",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("textarea",{ref:re,className:"af-flow-node-full-editor__textarea",value:me,onChange:ln,onCompositionStart:Tn,onCompositionEnd:An,onPaste:Nr,onDrop:_r,onKeyDown:fn,onDragOver:ce=>{Id(ce).length>0&&ce.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const Ec="flowNode";function vb(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 FU={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 zU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(FU[e]||[]).includes(s)?r:s}const WU={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"])},BU={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"])},HU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},VU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function KU(e,t){if(!VU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function qU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function UU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function VR(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function GU(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 YU(e){const t=String(e??"").trim();return t?t.includes("${")?t:VR(t):""}function JU(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(YU).filter(Boolean):[];return[GU(t,n),VR(s),...o].join(" ")}return String(t.command||"").trim()}function S_(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,f,p;const o=n[s],l=n.find(d=>(d==null?void 0:d.name)&&d.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=WU[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&&KU(e,r)?{showOnNode:!0}:{},...(f=HU[e])!=null&&f.has(r.name)?{showOnNode:!0}:{},...(p=BU[e])!=null&&p.has(r.name)?{showOnNode:!1}:{}}})}function XU(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=vb(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 Sb(e,t,n,r,s){var $,H,A,Q,K,W,ne,Z,G,te,re,se,ee,ue,de,me,Me,Se,_e,Fe,at,mt;const o=(($=e.data)==null?void 0:$.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Te=>Te.id===o),l=t[e.id];let c=[],u=[],f=((H=e.data)==null?void 0:H.label)??e.id,p,d,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(vb)),Array.isArray(l.output)&&(u=l.output.map(vb)),l.label&&(f=String(l.label)),l.role&&typeof l.role=="string"&&(p=l.role),l.model!=null&&(d=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=p??(typeof((A=e.data)==null?void 0:A.role)=="string"?e.data.role:"普通"),k=d??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",_=x!==""?x:void 0,S=h??((K=e.data)==null?void 0:K.body)??"",N=Array.isArray(y)?y:Array.isArray((W=e.data)==null?void 0:W.images)?e.data.images:[],I=JU(a),T=v!==void 0?v:((ne=e.data)==null?void 0:ne.script)!=null?String(e.data.script):I,z=String(e.id),E=(Z=r==null?void 0:r[s])==null?void 0:Z[z],D=(G=E==null?void 0:E.label)==null?void 0:G.label,L=E==null?void 0:E.body,O=E==null?void 0:E.description;b||(c.length===0&&((te=a==null?void 0:a.inputs)!=null&&te.length)&&(c=a.inputs.map(Te=>({...Te}))),u.length===0&&((re=a==null?void 0:a.outputs)!=null&&re.length)&&(u=a.outputs.map(Te=>({...Te}))));const M=UU(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((se=e.data)==null?void 0:se.marketplaceRef)||qU(a);if(M==="agent_subAgent"&&!u.some(Te=>(Te==null?void 0:Te.name)==="result")){const Te=(ee=a==null?void 0:a.outputs)==null?void 0:ee.find(it=>(it==null?void 0:it.name)==="result");u=[...u,Te?{...Te}:{type:"text",name:"result",default:""}]}if(M==="agent_subAgent"&&!c.some(Te=>(Te==null?void 0:Te.name)==="knowledgeContext")){const Te=(ue=a==null?void 0:a.inputs)==null?void 0:ue.find(it=>(it==null?void 0:it.name)==="knowledgeContext");c=[...c,Te?{...Te}:{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(Te=>(Te==null?void 0:Te.name)==="next")){const Te=(de=a==null?void 0:a.outputs)==null?void 0:de.find(it=>(it==null?void 0:it.name)==="next");u=[...u,Te?{...Te}:{type:"node",name:"next",default:""}]}if(M==="workspace_run"){if(!c.some(Te=>(Te==null?void 0:Te.name)==="prev")){const Te=(me=a==null?void 0:a.inputs)==null?void 0:me.find(it=>(it==null?void 0:it.name)==="prev");c=[Te?{...Te}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Te=>(Te==null?void 0:Te.name)==="next")){const Te=(Me=a==null?void 0:a.outputs)==null?void 0:Me.find(it=>(it==null?void 0:it.name)==="next");u=[...u,Te?{...Te}:{type:"node",name:"next",default:""}]}}c=S_(M,c,a==null?void 0:a.inputs),u=S_(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((Te,it)=>it===0?{...Te,default:S,value:S}:Te));const B=zU(M,f,a),F=M==="tool_nodejs"||String(T).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:D||f,displayLabel:B,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...V?{marketplaceRef:V}:{},...l!=null&&l.marketplacePackageId||(Se=e.data)!=null&&Se.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((_e=e.data)==null?void 0:_e.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(Fe=e.data)!=null&&Fe.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((at=e.data)==null?void 0:at.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((mt=e.data)==null?void 0:mt.schemaType)??e.type??"agent",role:g,model:k,body:L||S,images:N,script:T,inputs:c,outputs:u,description:O||_,originalLabel:f,originalBody:S,...F?{script:T}:{}}}}function QU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var f,p,d,h;const s=n.get(r.source),o=n.get(r.target),a=((p=(f=s==null?void 0:s.data)==null?void 0:f.outputs)==null?void 0:p.length)??0,l=((h=(d=o==null?void 0:o.data)==null?void 0:d.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&c>=0&&c<a&&u>=0&&u<l})}function j_(e,t){const n=new RegExp(`^${t}-(\\d+)$`).exec(String(e||""));if(!n)return 0;const r=Number.parseInt(n[1],10);return Number.isFinite(r)&&r>=0?r:0}function N_(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function bw(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=j_(t==null?void 0:t.sourceHandle,"output"),o=j_(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,f,p,d;if(c.id===n){const h=N_((u=c.data)==null?void 0:u.outputs,s);if(h!==((f=c.data)==null?void 0:f.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=N_((p=c.data)==null?void 0:p.inputs,o);if(h!==((d=c.data)==null?void 0:d.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function ZU(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 __(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function eG(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function tG({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Zs({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(tG,{children:t})]},n))})}function nG({open:e,onClose:t}){const{t:n}=qr(),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=eG()?"⌘":"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(Zs,{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(Zs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Zs,{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(Zs,{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(Zs,{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(Zs,{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(Zs,{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(Zs,{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(Zs,{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(Zs,{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(Zs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function rG(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 sG({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=qr(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),f=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 p=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,_;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((_=g.data)==null?void 0:_.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:rG(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>=p.length&&c(0)},[p.length,l]),m.useEffect(()=>{var v;const y=(v=f.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const d=y=>{const v=p[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(p.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),d(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:p.length})]}),p.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:p.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(),d(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 C_(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 iG(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 A_(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 kw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function E_(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 oG({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[f,p]=m.useState(null),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),_=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const T=new URLSearchParams;T.set("flowId",e.flowId),T.set("flowSource",e.flowSource||"user"),t?T.set("scheduleNodeId",t):n&&T.set("runNodeId",n),T.set("limit","80");const z=await fetch(`/api/workspace/run-logs?${T.toString()}`),E=await z.json().catch(()=>({}));if(!z.ok)throw new Error(E.error||"读取日志失败");const D=Array.isArray(E.runs)?E.runs:[];l(D),u(L=>{const O=D[0]||null;return O&&String(O.status||"")==="running"&&O.runId!==L?O.runId:L&&D.some(M=>M.runId===L)?L:r&&D.some(M=>M.runId===r)?r:(O==null?void 0:O.runId)||""})}catch(T){g(String(T.message||T)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),S=m.useCallback(async T=>{if(!T){p(null);return}v(!0);try{const z=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&z.set("archived","1");const E=await fetch(`/api/workspace/run-logs/${encodeURIComponent(T)}?${z.toString()}`),D=await E.json().catch(()=>({}));if(!E.ok)throw new Error(D.error||"读取日志详情失败");p(D)}catch(z){p({error:String(z.message||z),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{_()},[_]),m.useEffect(()=>{S(c)},[S,c]),m.useEffect(()=>{const T=a.find(E=>E.runId===c),z=window.setInterval(()=>{_(),(!T||T.status==="running")&&c&&S(c)},2e3);return()=>window.clearInterval(z)},[S,_,a,c]);const N=m.useMemo(()=>{const T=Array.isArray(f==null?void 0:f.events)?f.events:[],z=k.trim().toLowerCase();return z?T.filter(E=>String(E.type||"").toLowerCase().includes(z)||kw(E).toLowerCase().includes(z)||A_(E).toLowerCase().includes(z)):T},[f==null?void 0:f.events,k]),I=(f==null?void 0:f.run)||a.find(T=>T.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 _(),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:"最近执行"}),d?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!d&&a.length===0?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(T=>i.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(T.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(T.runId),title:T.runId,children:[i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${E_(T.status)}`,children:T.status||"unknown"}),i.jsx("span",{className:"af-work-run-logs__run-label",children:T.label||T.runNodeId||T.scheduleNodeId||"Workspace Run"}),i.jsx("span",{children:C_(T.startedAt)}),i.jsx("span",{children:iG(T.durationMs)})]},T.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:"详情"}),I!=null&&I.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:I.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(I==null?void 0:I.runId)||"-"})]}),I?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${E_(I.status)}`,children:I.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:T=>x(T.target.value),placeholder:"搜索事件、节点、错误"})]}),y?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,f!=null&&f.error?i.jsx("div",{className:"af-work-run-logs__error",children:f.error}):null,!y&&!N.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:N.map((T,z)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:C_(T.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:T.type||"event"}),kw(T)?i.jsx("span",{className:"af-work-run-logs__event-node",children:kw(T)}):null,i.jsx("pre",{children:A_(T)})]},`${T.ts||z}-${z}`))})]})]})]})}function aG(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 KR(e){const t=aG(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 lG(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 cG(e){return String(e).replace(/<\/script/gi,"<\\/script")}function jg(e){const t=KR(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 Av(e,t=""){const n=KR(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(d=>/(?:^|\/)App\.[jt]sx$/i.test(d))||Object.keys(r).find(d=>/\.[jt]sx?$/i.test(d))||n.entry,o=lG(r[s]||""),a=Object.entries(r).filter(([d])=>/\.css$/i.test(d)).map(([,d])=>String(d||"")).join(`
101
-
102
- `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),f=cG(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),p=a||`
103
- * { box-sizing: border-box; }
104
- body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
105
- main { min-height: 100vh; padding: 24px; }
106
- button, input, select, textarea { font: inherit; }
107
- `;return`<!doctype html>
108
- <html>
109
- <head>
110
- <meta charset="utf-8" />
111
- <meta name="viewport" content="width=device-width, initial-scale=1" />
112
- <base target="_blank" />
113
- <title>${l.replace(/[<&>]/g,d=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[d])}</title>
114
- <style>${p.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
- ${f}
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 qR=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),uG=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function dG(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 fG(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 I_(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 UR(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(qR.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 GR(e){return{inputNames:I_(e==null?void 0:e.inputs),outputNames:I_(e==null?void 0:e.outputs)}}function pG(e,t,n){const r=GR(t),s=fG(e),o=[];for(const a of s)if(!UR(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 hG(e,t){const n=GR(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=UR(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 mG(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function gG(e){return e.map(t=>{const n=mG(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 yG(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 uG)qR.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function wG(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 xG(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 Up({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:f}=qr(),p=m.useId(),d=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),_=m.useMemo(()=>vo(c),[c]),S=m.useMemo(()=>pG(e,a,f),[e,a,f]),N=S.length>0,I=m.useMemo(()=>hG(e,a),[e,a]),T=m.useMemo(()=>gG(I),[I]),z=m.useMemo(()=>n?null:dG(e,y),[e,y,n]),E=m.useMemo(()=>{if(!z)return[];const B=yG(a,f);return wG(B,z.query)},[z,a,f]);m.useEffect(()=>{g(B=>{const F=Math.max(0,E.length-1);return Math.min(Math.max(0,B),F)})},[E.length]);const D=m.useCallback(()=>{const B=d.current;if(!B||!z||E.length===0){x(null);return}const F=xG(B,y);if(!F){x(null);return}const $=4,H=44,A=13.5*16,Q=Math.min(E.length*H+8,A);let K=F.bottom+$;K+Q>window.innerHeight-8&&(K=Math.max(8,F.top-Q-$));const W=288;let ne=F.left;ne=Math.max(8,Math.min(ne,window.innerWidth-W-8)),x({top:K,left:ne})},[z,E.length,y]);m.useLayoutEffect(()=>{if(!z||E.length===0){x(null);return}const B=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(B)},[z,E.length,y,e,D]),m.useEffect(()=>{if(!z||E.length===0)return;const B=()=>D();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[z,E.length,D]);const L=m.useCallback(B=>{if(!z)return;const{atIndex:F}=z,$=e.slice(0,F)+"${"+B+"}"+e.slice(y);t($);const H=F+B.length+3;queueMicrotask(()=>{const A=d.current;A&&(A.focus(),A.setSelectionRange(H,H)),v(H)})},[z,e,y,t]),O=m.useCallback(()=>{const B=d.current,F=h.current;!B||!F||(F.scrollTop=B.scrollTop,F.scrollLeft=B.scrollLeft,z&&E.length>0&&queueMicrotask(()=>D()))},[z,E.length,D]),M=m.useCallback(B=>{if(!n&&z&&E.length>0&&(B.key==="ArrowDown"||B.key==="ArrowUp"||B.key==="Enter")){if(B.key==="ArrowDown")B.preventDefault(),g(F=>(F+1)%E.length);else if(B.key==="ArrowUp")B.preventDefault(),g(F=>(F-1+E.length)%E.length);else if(B.key==="Enter"&&!B.shiftKey){B.preventDefault();const F=E[b];F&&L(F.insert)}}},[n,z,E,b,L]),V=m.useCallback(async B=>{if(n||typeof u!="function")return!1;const F=await HR({files:B,body:e,images:_});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=d.current;if(!$)return;$.focus();const H=F.body.length;$.setSelectionRange(H,H),v(H)}),!0):!1},[n,_,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[_.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:_.map((B,F)=>i.jsxs("span",{className:"af-body-image-chip",title:B.name,children:[i.jsx("img",{src:B.dataUrl,alt:""}),i.jsxs("span",{children:["[",B.label||`image ${F+1}`,"]"]})]},B.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:T+`
182
- `}}),i.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?p:void 0,onChange:B=>{t(B.target.value),v(B.target.selectionStart??B.target.value.length)},onSelect:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:B=>{const F=BR(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onDragOver:B=>{Id(B).length>0&&B.preventDefault()},onDrop:B=>{const F=Id(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onScroll:O})]}),z&&E.length>0&&k?pr.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:E.map((B,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:()=>L(B.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${B.insert}}`}),B.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:B.subtitle}):null]})},`${B.section}-${B.insert}`))}),document.body):null,N?i.jsx("p",{id:p,className:"af-body-ph-issues",role:"status",children:S.map(B=>B.message).join(" · ")}):null]})}const bG=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Gu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function P_({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=qr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=p=>r(n.filter((d,h)=>h!==p)),u=(p,d,h)=>{const y=n.map((v,b)=>{if(b!==p)return v;const g={...v,[d]:h};return d==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},f=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:f})}),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((p,d)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${d}`,children:[f,"-",d]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:p.type,onChange:h=>u(d,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.name,onChange:h=>u(d,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.default,onChange:h=>u(d,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.description||"",onChange:h=>u(d,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!p.required,onChange:h=>{o||u(d,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:p.showOnNode!==!1,onChange:h=>u(d,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${d}`))]}):null]})}function kG({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:f,ioSlots:p}){const{t:d}=qr(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(O=>{t(M=>M&&{...M,...O})},[t]),{cursorList:_,opencodeList:S,claudeCodeList:N,codexList:I,currentNotInLists:T}=m.useMemo(()=>{const O=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:[],B=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...O,...M,...V,...B].map(Gu)),$=((e==null?void 0:e.model)??"").trim(),H=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,A=$&&!F.has(H)?$:"";return{cursorList:O,opencodeList:M,claudeCodeList:V,codexList:B,currentNotInLists:A}},[s,e==null?void 0:e.model]);if(!e)return null;const z=String(e.script??""),E=n==="tool_nodejs"||z.trim()!=="",D=typeof c=="function"&&!o&&(e==null?void 0:e.newId),L=async()=>{if(D){k({status:"running",message:d("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(O){k({status:"error",message:String((O==null?void 0:O.message)||O)})}}};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:d("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:L,disabled:!D||g.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?i.jsx("p",{className:"af-err af-node-props-err",children:f}):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:d("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:[d("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>x({newId:O.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":d("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:[d("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:O=>x({label:O.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:[d("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:lf.includes(e.role)?e.role:d("flow:roles.normal"),onChange:O=>x({role:O.target.value}),disabled:o,children:lf.map(O=>i.jsx("option",{value:O,children:O},O))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?T||O:""})(),onChange:O=>x({model:O.target.value}),disabled:o,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:d("flow:node.defaultModel")}),T?i.jsxs("option",{value:T,children:[T,d("flow:nodeProps.yamlValueNotInList")]}):null,_.length>0?i.jsx("optgroup",{label:"Cursor",children:_.map(O=>i.jsx("option",{value:Gu(O),children:O},`c-${O}`))}):null,S.length>0?i.jsx("optgroup",{label:"OpenCode",children:S.map(O=>i.jsx("option",{value:`opencode:${Gu(O)}`,children:O},`o-${O}`))}):null,I.length>0?i.jsx("optgroup",{label:"Codex",children:I.map(O=>i.jsx("option",{value:`codex:${Gu(O)}`,children:O},`codex-${O}`))}):null,N.length>0?i.jsx("optgroup",{label:"Claude Code",children:N.map(O=>i.jsx("option",{value:`claude-code:${Gu(O)}`,children:O},`cc-${O}`))}):null]})]}),i.jsx(P_,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>x({inputs:O}),disabled:o,requiredReadonly:!u}),i.jsx(P_,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>x({outputs:O}),disabled:o,requiredReadonly:!u}),E?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:[d("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Up,{value:z,onChange:O=>x({script:O}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:p,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:O=>x({scriptRef:O.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:O=>x({implementationRef:O.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:O=>x({implementationMode:O.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:d("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Up,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:p,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:d("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:O=>{O.target===O.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:d("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":d("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Up,{value:z,onChange:O=>x({script:O}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:p,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editUserPrompt"),onMouseDown:O=>{O.target===O.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:d("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":d("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Up,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:p,variant:"expand"})]})}):null]})}function vG({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=qr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[f,p]=m.useState(!1),[d,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),p(!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||f)){p(!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{p(!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})]}),d?i.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||f,children:o(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function SG({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=qr(),u=m.useId(),f=m.useRef(null),[p,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),b(""),y(!1);const _=requestAnimationFrame(()=>{var S;return(S=f.current)==null?void 0:S.focus()});return()=>cancelAnimationFrame(_)},[e,n]),!e)return null;const g=p.trim(),k=a||g===n;async function x(_){if(_.preventDefault(),!k||h)return;y(!0),b("");let S=null;try{const N=new AbortController;S=setTimeout(()=>N.abort(),15e3);const I=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:N.signal}),T=await I.json().catch(()=>({}));if(!I.ok){b(typeof T.error=="string"?T.error:c("project:deleteModal.deleteFailed"));return}try{for(let z=localStorage.length-1;z>=0;z--){const E=localStorage.key(z);E&&(E.startsWith(`af:composer-sessions:${n}:${r}`)||E.startsWith(`af:composer-active-session:${n}:${r}`)||E.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(E)}}catch{}await l()}catch(N){if((N==null?void 0:N.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((N==null?void 0:N.message)||N))}finally{S&&clearTimeout(S),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:i.jsxs("div",{ref:f,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:_=>_.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:p,onChange:_=>d(_.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 T_=80,jG=220;function NG(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 _G(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Gp(e,t,n){const r={nodes:Array.isArray(e)?e.map(NG):[],edges:Array.isArray(t)?t.map(_G):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function vw(e,t){const n=[...e,t];return n.length>T_?n.slice(n.length-T_):n}function CG({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),f=m.useRef(null),p=m.useRef(null),d=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(S=>S+1),[]),v=m.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),b=m.useCallback(()=>{v();const S=f.current,N=p.current;return f.current=null,p.current=null,!S||!N||S.signature===N.signature?(N&&(u.current=N),!1):(l.current=vw(l.current,S),c.current=[],u.current=N,y(),!0)},[y,v]),g=m.useCallback((S=[],N=[],I={})=>{v(),l.current=[],c.current=[],f.current=null,p.current=null,u.current=Gp(S,N,I),h.current=!1,y()},[y,v]),k=m.useCallback(S=>{h.current=!0,u.current=S,f.current=null,p.current=null,v(),s==null||s(S.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const S=u.current||Gp(e,t,n),N=l.current.pop();return N?(c.current=vw(c.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]),_=m.useCallback(()=>{b();const S=u.current||Gp(e,t,n),N=c.current.pop();return N?(l.current=vw(l.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const S=Gp(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&&(f.current||(f.current=u.current),p.current=S,v(),d.current=window.setTimeout(()=>{b()},jG))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!f.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:_,version:o}}function yo(e){return String(e??"").trim()}function R_(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(yo(e).toLowerCase())}function AG(e){return e===!1?!0:["false","no","not_required","waived"].includes(yo(e).toLowerCase())}function EG(e,t=""){return yo((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 YR(e){return yo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function JR(e){return YR(e)==="all"}function IG(e,t=[]){const n=yo((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=YR(e),s=EG(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=>yo(l))).has(a)?a:""}function km(e){const t=yo(e==null?void 0:e.label).toLowerCase(),n=yo((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 PG(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[km(n)]-t[km(r)])}function TG(e){const t=yo((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 RG(e,t=[]){if(JR(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(km);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 R_(e==null?void 0:e.implementationNotRequired)||R_(e==null?void 0:e.implementation_not_required)||AG(r)?{kind:"not-required",label:TG(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function jb(e=[]){return e.reduce((t,n)=>t+1+jb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function mr(e){return String(e||"").trim()}function Ko(e){return mr(e).toLowerCase()}function vm(e){return typeof e=="string"?Ko(e):!e||typeof e!="object"||Array.isArray(e)?"":Ko(e.kind||e.type||e.persistence||e.durability)}function XR(e,t="http://localhost"){const n=mr(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 QR(e={}){const t=mr(e.href||e.url);if(!t)return!1;const n=Ko(e.kind||e.type),r=Ko(e.durability),s=Ko(e.persistence),o=Ko(e.truth||e.stateTruth||e.state_truth),a=Ko(e.authority),l=vm(e.source)||vm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(mr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(mr).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 d=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&d,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function ZR(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(mr).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 MG(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=mr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(mr(t)?mr(t):ZR(e)==="tech-design"&&mr(n)?mr(n):mr(e.title||e.label))}function $G(e={},t="http://localhost"){const n=mr(e.issueKey||e.issue_key||e.issue),r=ZR(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=mr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${XR(e.href||e.url,t)}`}function M_(e={}){const t=mr(e.href||e.url),n=Ko(e.kind||e.type),r=vm(e.source)||vm(e.sourceArtifact||e.source_artifact),s=mr(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 LG(e,t){const n=M_(t)>M_(e)?t:e,r=n===t?e:t;return{...r,...n,title:$_(e.title)>=$_(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 $_(e){const t=mr(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 Sw(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]=LG(r[a],s)}return r}function OG(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>QR(o)),r=Sw(n,o=>XR(o.href||o.url,t)),s=Sw(r,o=>mr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return Sw(s,o=>$G(o,t))}function Rt(e){return String(e||"").trim()}function wo(e){return typeof e=="string"?Rt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Rt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function gc(e){return Rt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function eM(e){return Rt((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 tM(e){const t=Rt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function DG(e){const t=Rt(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 FG(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Rt(e.issueKey||e.issue_key||e.issue),n=Rt(e.action||e.actionId||e.action_id),r=Rt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),s=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Rt(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 zG(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Rt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Rt(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=Rt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",s=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||s===!1)}function Gc(e){const t=gc(e);if(/^prd-review:/i.test(t)||Rt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(eM(e)))return!0;const n=Rt((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=Rt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=Rt(e==null?void 0:e.durability).toLowerCase(),o=wo(e==null?void 0:e.source)||wo((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 L_(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,wo(e==null?void 0:e.source)].map(Rt).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function O_(e){const t=[],n=gc(e);if(n&&t.push(`key:${n}`),Gc(e)){const s=tM(eM(e));s&&t.push(`review:${s}`)}const r=DG((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Rt(e==null?void 0:e.label)}
183
- ${r}`),t}function WG(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=O_(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=L_(r)>=L_(a)?Rt(r==null?void 0:r.label)||Rt(a==null?void 0:a.label):Rt(a==null?void 0:a.label)||Rt(r==null?void 0:r.label),c=!!gc(a),u=!!gc(r),f=c&&!u?a:r,p=f===a?r:a,d=gc(f)&&!gc(p)&&Rt(f==null?void 0:f.label)||l;t[o]={...p,...f,...d?{label:d}:{}},O_(t[o]).forEach(h=>n.set(h,o))}return t}function nM(e){const t=Rt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Rt(e==null?void 0:e.durability).toLowerCase(),r=Rt(e==null?void 0:e.persistence).toLowerCase(),s=wo(e==null?void 0:e.source)||wo((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(Rt).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function BG(e){if(!Gc(e)||nM(e))return!1;const t=Rt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Rt(e==null?void 0:e.durability).toLowerCase(),r=Rt(e==null?void 0:e.persistence).toLowerCase(),s=wo(e==null?void 0:e.source)||wo((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(Rt).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function HG(e){if(Gc(e))return!1;const t=Rt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Rt(e==null?void 0:e.persistence).toLowerCase(),r=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(Rt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function VG(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Rt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function KG(e=[],t={}){const n=WG(Array.isArray(e)?e:[]);if(!VG(t))return n;const r=n.filter(Gc);if(r.length===0)return n;const s=r.filter(BG),a=s.length>0||n.some(HG)?s.at(-1):r.filter(nM).at(-1);return n.filter(l=>!Gc(l)||l===a)}function Ii(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=Rt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=tM(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const f=Rt(a.path);return f&&l.push(`path:${f}`),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(f=>r.set(f,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 Qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Sm(e){return Array.isArray(e)?e.map(Sm):Qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,Sm(e[t])])):e}function lo(e,t){return JSON.stringify(Sm(e))===JSON.stringify(Sm(t))}function rM(e){return Qr(e==null?void 0:e.instances)?e.instances:{}}function uf(e){return Qr(e==null?void 0:e.ui)?e.ui:{}}function Yp(e,t){if(!Qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function qG(e,t){if(!Qr(e)||!Qr(t)||!Qr(e.instances)||!Qr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!Qr(e.ui)||!Qr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Yp(e,["version","instances","edges","ui"]),r=Yp(t,["version","instances","edges","ui"]);if(!lo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return lo(Yp(e.ui,s),Yp(t.ui,s))}function sM(e){const t=Array.isArray(uf(e).groups)?uf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function D_(e){const t=new Set(Object.keys(rM(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 sM(e).keys())t.add(n);return t}function F_(e,t){const n=rM(e),r=uf(e),s=sM(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:Qr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:Qr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function z_(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 UG(e,t){if(!qG(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...D_(e),...D_(t)]),r=Array.from(n).filter(s=>!lo(F_(e,s),F_(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!lo(z_(e),z_(t)),displayPageChanged:!lo(uf(e).displayPage||null,uf(t).displayPage||null)}}function GG(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 W_(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 B_(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function YG(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[W_(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(W_(r));return s?lo(B_(s),B_(r))?s:{...r,selected:s.selected===!0}:r})}function JG(e,t,n){const r=Qr(e)?e:{},s=Qr(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 XG({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 QG({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function iM(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 ZG({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function eY(e=[]){const t=iM(e);return t.mutated&&!t.active}function tY(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 nY(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 rY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(tY(s)){t.push(s);continue}n.push(s),nY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function Nb(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 sY(e=[]){return Nb(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 H_(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 iY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function oY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const aY="af:workspace-graph:v2",V_="agentflow.workspace.sidebarCollapsed",Ql=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],lY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),cY={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:""}]},uY={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:""}]},dY={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}]},fY={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}]},pY={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}]},hY={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}]},mY=new Set(["png","jpg","jpeg","gif","webp","svg"]),oM=320,aM=180,lM=960,jm=96,cM=900,_b=520,Cb=320,Jp=52,ul=240,dl=160,Ab="display-ref:",df="0 9 * * *",gY="Asia/Shanghai",yY="0.1.137";function wY(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();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",returnTo:t==="/workflows"?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function Wr(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"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function xY(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Ev(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 bY(e){const t=Ev(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 Iv(e,t=80){return(Array.isArray(e)?e:[]).map(bY).filter(Boolean).slice(-t)}function kY(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=Iv(s.messages,40),l=Ev(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 vY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Iv(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:Ev((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function K_(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:Iv(n.messages,100),runSessions:vY(n.runSessions)},nodeChats:kY(t.nodeChats)}}function Nm(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 mY.has(n)}function ff(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=Wr(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function SY(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 jY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${V_}:${t}`:V_}function NY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function q_(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function _Y(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 CY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!_Y(e)}function AY(e){const t=String(e||"").trim();if(!t||EY(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 EY(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 IY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function jw(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 Nw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function za(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 U_(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 PY(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 TY(e){const t=PY(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 pf(e){const t=String(e||"").trim();if(!t)return"";if(t.startsWith("/")&&!t.startsWith("//")||t.startsWith("#"))return t;if(!/^https?:\/\//i.test(t))return"";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 Ic(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return pf(t);const n=String((e==null?void 0:e.path)||"").trim();return n&&/^https?:\/\//i.test(n)?pf(n):""}function ba(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 ua(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 Pv(e){return ba(e==null?void 0:e.status)==="done"&&ua(e)!=="observation"}function co(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 Ih(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function Tv(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 RY(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 MY(e,t){const n=co(e,t),r=ba(e==null?void 0:e.status),s=Pv(e),a=`${fl(e)} ${Tv(e)}`,l=RY(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"||ua(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"||ua(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function $Y(e){if(!e||typeof e!="object")return"";const t=ba(e.status),n=ua(e),r=Pv(e),o=`${fl(e)} ${Tv(e)}`,a=Rv(e),l=a.some(p=>/方案|plan|markdown|review|预览/i.test(String(p.label||""))),c=a.some(p=>/gitlab issue/i.test(String(p.label||""))),u=a.some(p=>/gitlab epic/i.test(String(p.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 f=Ih(e);return f?f.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":f:""}function _m(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 uM="Asia/Shanghai",LY=new Intl.DateTimeFormat("zh-CN",{timeZone:uM,year:"numeric",month:"2-digit",day:"2-digit"}),OY=new Intl.DateTimeFormat("zh-CN",{timeZone:uM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function dM(e){const t=_m(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function DY(e){const t=dM(e);return t?LY.format(t).replace(/\//g,"-"):"无时间"}function FY(e){const t=dM(e);return t?OY.format(t):""}function zY(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=DY(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 fM(e){const t=ba(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function qo(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 WY(e){const t=ba(e==null?void 0:e.status);return ua(e)==="observation"&&t==="done"?"已观察":fM(t)}function pM(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=ba(e.status),s=ua(e)==="observation"&&r==="done"?"observed":r;return n("status",fM(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",qo(e.platform),e.platform),t}function BY(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{pM(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 HY(e,t){const n=String(t||"all");return!n||n==="all"?!0:pM(e).some(r=>r.key===n)}function VY(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("平台",qo(e.platform)),t}function Rv(e){const t=[],n=(c,u,f={})=>{const p=pf(u);p&&t.push({...f,label:String(c||p).trim()||p,href:p})},r=(c,u="链接",f=0)=>{if(f>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((d,h)=>r(d,`${u} ${h+1}`,f+1));return}if(typeof c!="object")return;const p=c.label||c.title||c.name||c.kind||c.type||u;n(p,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const d of["links","urls","artifacts","outputs","output","results","result","files"])c[d]!=null&&r(c[d],d,f+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",Ic(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 f=new URL(u,window.location.origin);return`${f.origin}${f.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=Gc(c),f=String(c.key||c.artifactKey||c.artifact_key||"").trim(),p=f?`key:${f}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
185
- ${c.href}`,d=l.get(p);if(!d){l.set(p,c);continue}if(u){const h=a(d.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(d.label||"").length)&&l.set(p,c)}}return KG(Array.from(l.values()),e)}function KY(e,t=[]){var l,c,u,f,p;const n=[],r=new Map,s=String(((c=(l=e==null?void 0:e.overall)==null?void 0:l.requirement)==null?void 0:c.title)||((f=(u=e==null?void 0:e.overall)==null?void 0:u.requirement)==null?void 0:f.name)||"").trim();for(const d of Eb(e)){const h=$i(d),y=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();h&&y&&r.set(h,y)}const o=(d,h={})=>{if(!d||typeof d!="object")return;const y=(b,g={})=>{if(!b||typeof b!="object")return;const k=String(h.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),x=b.source||b.sourceArtifact||b.source_artifact||d.sourceArtifact||d.source_artifact||d.source||h.source||null,_=MG({...b,title:b.title||h.documentTitle||(d==null?void 0:d.title)||"",documentTitle:b.documentTitle||b.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(k)||"",requirementTitle:s}),S={label:String(b.label||"ai-doc").trim()||"ai-doc",href:String(b.href||b.url||"").trim(),kind:String(b.kind||b.type||d.kind||d.type||"").trim(),title:_,issueKey:k,platform:h.platform||qo(d.platform),durability:b.durability||d.durability||h.durability||"",persistence:b.persistence||d.persistence||h.persistence||"",truth:b.truth||b.stateTruth||b.state_truth||ua(d)||h.truth||"",authority:b.authority||d.authority||h.authority||"",confirmed:b.confirmed??d.confirmed??h.confirmed,source:x,documentPath:b.documentPath||b.document_path||b.path||g.documentPath||(x==null?void 0:x.path)||(x==null?void 0:x.documentPath)||(x==null?void 0:x.document_path)||""};S.href&&n.push(S)};for(const b of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});for(const b of Array.isArray(d==null?void 0:d.links)?d.links:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});const v=Ic(d);v&&y({...d,label:d.label||d.title||d.kind||"ai-doc",href:v},{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:qo(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 h of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(h,{issueKey:String((h==null?void 0:h.issueKey)||(h==null?void 0:h.issue_key)||(h==null?void 0:h.issue)||"").trim(),platform:qo(h==null?void 0:h.platform),documentTitle:String((h==null?void 0:h.documentTitle)||(h==null?void 0:h.document_title)||(h==null?void 0:h.title)||"").trim()});for(const d of Eb(e))o(d,{issueKey:$i(d),platform:qo(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()});const a=(p=e==null?void 0:e.extensions)!=null&&p["prd-flow"]&&typeof e.extensions["prd-flow"]=="object"?e.extensions["prd-flow"]:{};for(const d of[...Array.isArray(e==null?void 0:e.aiDocs)?e.aiDocs:[],...Array.isArray(e==null?void 0:e.ai_docs)?e.ai_docs:[],...Array.isArray(a.aiDocs)?a.aiDocs:[],...Array.isArray(a.ai_docs)?a.ai_docs:[]])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||"").trim(),platform:qo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.label)||"").trim()});return OG(n,window.location.origin)}function qY(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 $i(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 UY(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)||$i(e,t)||`Issue ${t+1}`).trim()}function GY(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 YY(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 JY(e){const t=Rv(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 XY(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 f of u)f&&typeof f=="object"&&c.issues.push({...f,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(GY(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((f,p)=>$i(f,p));return a.forEach((f,p)=>{const d=$i(f,p);l.set(d,{issue:f,children:[]})}),a.forEach((f,p)=>{const d=$i(f,p),h=YY(f)||IG(f,u),y=l.get(d);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 Cm(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 fl(e){return FG(e)}function Am(e){const t=_m(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 Eb(e){var s,o,a,l,c,u,f,p,d,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,(p=(f=e==null?void 0:e.raw)==null?void 0:f.prd)==null?void 0:p.epics,(h=(d=e==null?void 0:e.raw)==null?void 0:d.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 QY(e,t){const n=String(t||"").trim();return n&&Eb(e).find((r,s)=>$i(r,s)===n)||null}function ZY(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 eJ(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=QY(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=ZY(e);if(!a&&!l)return o;const c=fl(o),u=`${c} ${Tv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const p=[];a&&p.push({key:`gitlab-issue:${n}:${(s||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&p.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const d=ba(o.status),h=a&&d==="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:Ii(o.artifacts,p)}}function G_(e,t){const n=Am(t),r=Am(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:co(s,0)||co(t,0)||co(e,0),detail:Ih(s)||Ih(t)||Ih(e),status:o,links:Ii(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Ii(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Ii(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Ii(e==null?void 0:e.results,t==null?void 0:t.results),events:Ii(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 tJ(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=p=>{var d,h;return!!(!p||typeof p!="object"||p.auxiliary===!0||p.auxiliary_event===!0||zG(p)||String(p.type||"")==="review-link"||String(p.type||"")==="action-preview"||p.preview===!0||String(p.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((d=p.conflict)==null?void 0:d.previousArtifact)||((h=p.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(p,d)=>({...p,links:Ii(p==null?void 0:p.links,d==null?void 0:d.links),artifacts:Ii(p==null?void 0:p.artifacts,d==null?void 0:d.artifacts),outputs:Ii(p==null?void 0:p.outputs,d==null?void 0:d.outputs),results:Ii(p==null?void 0:p.results,d==null?void 0:d.results)}),c=(p,d)=>{if(!p)return;const h=r.get(p);if(h!=null){n[h]=l(n[h],d);return}o.set(p,l(o.get(p)||{},d))},u=(p,d)=>p&&o.has(p)?l(d,o.get(p)):d,f=p=>{if(Array.isArray(p))for(const d of p){const h=fl(d);if(a(d)){c(h,d);continue}const y=String(d.id||d.eventId||d.event_id||d.actionId||d.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,G_(n[b],d)),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,d)))}};if(f(e==null?void 0:e.actions),f(e==null?void 0:e.workflowActions),f(e==null?void 0:e.workflow_actions),f(e==null?void 0:e.timeline),f(e==null?void 0:e.history),f(e==null?void 0:e.events),f(e==null?void 0:e.runtimeEvents),f(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const p=Cm(t),d=fl(t),h=d?r.get(d):p?s.get(p):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=G_(n[h],y))}return n.map((p,d)=>({item:p,index:d,ts:Am(p)})).filter(p=>Number.isFinite(p.ts)).sort((p,d)=>d.ts-p.ts||p.index-d.index).map(p=>eJ(e,p.item))}function nJ(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:Am(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 rJ(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 sJ(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)?`(+${za(r)} / 总 ${za(s)})`:"";return`${t+1}. ${n}${o}`}function hM(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 Zl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function iJ(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 oJ(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 aJ(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 lJ(e){var o,a,l;const t=hM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Zl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=oJ(t),u=iJ(t),f=Zl(t.startedAtMs,c==null?void 0:c.startedAtMs),p=Zl(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((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(f)&&Number.isFinite(p)?Math.max(0,p-f):Zl(d.executionTime,d.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),v=y?y.split(`
187
- `).find(Boolean)||y:"";return{kind:"tool",label:aJ(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Zl(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 Y_(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=Zl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),f=s.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),p=o.filter(b=>(b==null?void 0:b.kind)==="tool"),d=p.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 间隔"})),...p.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(`- 当前总耗时:${za(u)}`),f>0&&v.push(`- 模型相关间隔:约 ${za(f)}(按 Activity 间隔估算)`),p.length>0&&v.push(`- 工具实际执行:${za(d)}(${p.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}:${za(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(sJ(b,g))})),p.length>0&&(v.push(""),v.push("最近工具完成"),p.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${za(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
188
- `)}function J_(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=hM(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 mM(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 gM(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Mv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function yM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function cJ(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 uJ(e){const t=String(e??"").trim();return t?t.includes("${")?t:yM(t):""}function wM(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(uJ).filter(Boolean):[];return[cJ(t,n),yM(o),...a].join(" ")}return String(t.command||"").trim()}function ad(e){const t=String(Mv(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 X_(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Em(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ld(e){return Em(e)}function Ib(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Xp(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 Q_(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 Z_(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 _w(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=kb(s.get(n),e.sourceHandle||"output-0","source"),a=kb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&cf(o,a))}function dJ(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=kb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:_U(a)}:null}function fJ(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"?cf(t.slot,a):cf(a,t.slot)))continue;const c=ad(n);return{def:n,order:r,category:c,categoryRank:Ql.indexOf(c),slot:a,slotIndex:o,displayLabel:ld(n),description:Ib(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 pJ(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 f=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 p=0;p<f.length;p+=1){const d=f[p];if((d==null?void 0:d.showOnNode)===!1||!(s?cf(n.slot,d):cf(d,n.slot)))continue;const y=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${p}`}:{source:u.id,sourceHandle:`output-${p}`,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:d,slotIndex:p,handleId:s?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,f)=>{var v,b,g,k,x,_,S,N;const p=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),d=Number(((k=(g=f.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((_=(x=u.node)==null?void 0:x.position)==null?void 0:_.x)||0),y=Number(((N=(S=f.node)==null?void 0:S.position)==null?void 0:N.x)||0);return p-d||h-y||u.slotIndex-f.slotIndex||String(u.nodeId).localeCompare(String(f.nodeId))})}function yc(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 hJ(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 mJ(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function gJ(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return df;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} * * *`:df}function Yo(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 $v(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Yo(t[1],9,0,23)}:${Yo(t[2],0,0,59)}`:"09:00"}function cd(e,t,n,r,s){const o=$v(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()||df:`${l} ${a} * * *`}function yJ(e){const n=String(e||df).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),f=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),p=f?`${Yo(u,9,0,23)}:${Yo(c,0,0,59)}`:"09:00";return f&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:p,weekday:1,monthDay:1}:f&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:p,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:f&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:p,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:p,weekday:1,monthDay:1}}function Lv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=gJ(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=yJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=$v(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),f=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),p=cd(l,c,u,f,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:f,cron:p,timezone:gY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function wJ(e){const t=Lv(JSON.stringify(e||{}));return JSON.stringify(t)}function xJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function bJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function eC(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:eC(n.nextRunAt),lastAt:eC(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 Im(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Pm(e){return e>0?`Group ${e+1}`:"Group"}function kJ(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)||Pm(r)).trim()||Pm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(ul,Math.round(l)),height:Math.max(dl,Math.round(c))}}).filter(Boolean)}function vJ(e){var n;return kJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Ec,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 Pb(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(ul,Math.round(t)),height:Math.max(dl,Math.round(n))}}function ud(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:mJ(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 xM(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 SJ(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=Ng(t);return[xM(e),Ln(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 tC(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 jJ=new Map,NJ=[];function Yu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=vM(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(L=>L.id===g),x=Mv(k)||g,_=t.find(L=>L.id===x)||k,S=b.marketplaceRef||gM(k),N=wM(k),I=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},T=!!Ln({definitionId:x,inputs:b.input,outputs:b.output}),z=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,E=Qa(z,{display:T}),D=E&&!ui(x);return{id:v,type:Ec,position:I,...D?{width:E.width,height:E.height}:{},data:{label:b.label||Em(k)||Em(_)||v,definitionId:x,...S?{marketplaceRef:S}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:mM(x,_||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||N||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...D?{nodeSize:E}:{},...T&&D?{displaySize:E}:{}}}}).map(v=>Sb(v,r,t)),f=vJ(e),p=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!f.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:Ai.ArrowClosed}})),d=[...f,...u];return{nodes:d,edges:QU(p,d),instances:r}}function nC(e){return`${Ab}${e}`}function Zp(e){const t=String(e||"");return t.startsWith(Ab)?t.slice(Ab.length):t}function Tb(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 Ph(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(p=>{var d;return pl((d=p==null?void 0:p.data)==null?void 0:d.definitionId)}).map(p=>[p.id,p])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const p of r){const d=String(p||"").trim();!d||o.has(d)||!n.has(d)||(o.add(d),s.push(d))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((p,d)=>{const h=l[p];a[p]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+d*36,y:120+d*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(p=>{const d=Qa(u[p],{display:!0});d&&(c[p]=d)});const f=Tb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function rC(e,t=[]){return Ph(e,t)}const Cw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function Aw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function sC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function iC(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 _J(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function oC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const bM="af:workspace:canvas-clipboard",kM="agentflow.workspace.canvas-clipboard";function CJ(e){return JSON.stringify({type:kM,version:1,clipboard:e})}function AJ(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==kM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function EJ(e){try{localStorage.setItem(bM,CJ(e))}catch{}}function IJ(){try{return AJ(localStorage.getItem(bM))}catch{return null}}function PJ(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Rb(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 aC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Qa(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:aC(n,aM,lM)||oM,height:aC(r,jm,cM)||jm}}function Tm(e){const t=Qa(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function TJ(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:_b,height:Cb}}function RJ(e,t=""){const n=Tm(e==null?void 0:e.displaySize);if(n)return n;const r=Tm(e==null?void 0:e.nodeSize);if(r)return r;const s=pl(t)||Mf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return TJ(s)}function ec(e){var s,o,a,l,c,u,f,p,d,h,y;if(ui((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!Ln(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(((p=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:p.height)||((h=(d=e==null?void 0:e.data)==null?void 0:d.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Qa({width:n,height:r},{display:t})}function Yl(e,t,n){var f,p,d,h,y,v,b,g,k,x,_,S,N;const r=(e||[]).filter(I=>!Im(I)),s=(e||[]).filter(Im),o=vM(Cv(r,n||{})),a=t.map(I=>({source:I.source,target:I.target,sourceHandle:I.sourceHandle??null,targetHandle:I.targetHandle??null})).filter(I=>!s.some(T=>T.id===I.source||T.id===I.target)),l={},c={},u=[];for(const I of r){l[I.id]={x:((f=I.position)==null?void 0:f.x)||0,y:((p=I.position)==null?void 0:p.y)||0};const T=ec(I);T&&(c[I.id]=T)}for(const I of s){const T=Number(((h=(d=I.data)==null?void 0:d.nodeSize)==null?void 0:h.width)||I.width||((y=I.measured)==null?void 0:y.width)||0),z=Number(((b=(v=I.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||I.height||((g=I.measured)==null?void 0:g.height)||0);u.push({id:I.id,title:String(((k=I.data)==null?void 0:k.title)||((x=I.data)==null?void 0:x.label)||"Group"),color:String(((_=I.data)==null?void 0:_.color)||"purple"),x:Number(((S=I.position)==null?void 0:S.x)||0),y:Number(((N=I.position)==null?void 0:N.y)||0),width:Math.max(ul,Math.round(T||ul)),height:Math.max(dl,Math.round(z||dl))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function vM(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!pl(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 pl(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 Ln(e){const t=pl(e==null?void 0:e.definitionId);return t||(ui(e==null?void 0:e.definitionId)&&Ng(e)?Mf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function uo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=Ln(e),r=ui(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 da(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 MJ(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 Li(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=MJ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
193
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
194
- `).replace(/\s+$/g,""):f.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 hl(e,t){const n=Wr(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 Mb(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 $J(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 su(e){let t=Li(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 LJ(e){const t=su(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ka(e,t){return e==="html"?LJ(t):""}function SM(e,t=""){const n=su(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 OJ(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 DJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function FJ(e,t){const n=URL.createObjectURL(e);try{DJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function jM(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 zJ(e){const t=jM(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 Ew(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 WJ(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=jM(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,f=(r==null?void 0:r.scroller)||null,p=(r==null?void 0:r.displaySize)||null,d={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((p==null?void 0:p.width)||0)||null,displaySizeHeight:Number((p==null?void 0:p.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:Ew(c),displayBody:Ew(u),scroller:Ew(f)},h=[Number(t)||0,Number((p==null?void 0:p.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((f==null?void 0:f.clientWidth)||0),Number((f==null?void 0:f.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(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:d}}async function BJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=WJ(r,s,o,{...l||{},displaySize:c}),f=zJ(r),p=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:f||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!p.ok){const h=await p.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const d=await p.blob();FJ(d,a)}function HJ(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 NM(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 VJ(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 _M({code:e}){const t=m.useMemo(()=>VJ(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((f,p)=>{l.set(f.id,{x:24+(n?p*(r+o):p%3*(r+o)),y:24+(n?p%3*(s+a):p*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(f=>f.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(f=>f.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((f,p)=>{const d=l.get(f.from),h=l.get(f.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${f.from}-${f.to}-${p}`)}),t.nodes.map(f=>{const p=l.get(f.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:p.x,y:p.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:p.x+r/2,y:p.y+s/2+5,textAnchor:"middle",children:f.label.slice(0,22)})]},f.id)})]})})}function bi({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 f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),h=p>d+1,y=h?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=h?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const f=requestAnimationFrame(a),p=n.current;if(!p||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const d=new ResizeObserver(a);d.observe(p);for(const h of Array.from(p.children))d.observe(h);return()=>{cancelAnimationFrame(f),d.disconnect()}},[t,a]);const l=m.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=m.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(f-h.top-p)/v},[s.height]),u=m.useCallback(f=>{var _,S;if(!s.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=f.clientY>=d.top+h&&f.clientY<=d.top+h+y?f.clientY-d.top-h:y/2;l(c(f.clientY,b));const g=f.pointerId;(S=(_=f.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.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 CM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Ln(e),o=uo(e),a=s==="image"?o:Li(o),l=s==="image"?"":da(a,s),[c,u]=m.useState(""),[f,p]=m.useState(""),[d,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),p(""),u(""),hl(t,l).then(x=>{k||u(x)}).catch(x=>{k||p(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),p(""),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"?su(y):s==="react"?jg(y):Li(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=Ka(s,v);if(d)return i.jsxs(bi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(f)return i.jsx(bi,{className:"af-work-display-empty",children:f});if(g)return i.jsx(bi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(bi,{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"?Av(v,b.current):SM(v,b.current)},r)});if(s==="image"){const k=ff(v,t);return i.jsx(bi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:HJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(vv,{content:v,basePath:l,resolveSrc:(k,x)=>ff(k,t,x)})}):s==="chart"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(jv,{content:v})}):s==="table"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(Sv,{content:v})}):s==="mermaid"?i.jsxs(bi,{className:"af-work-display-body",children:[i.jsx(_M,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(bi,{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 KJ({node:e,onClose:t}){var k,x,_,S,N,I,T,z,E,D,L;const n=m.useRef(null),r=Ln(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(""),[f,p]=m.useState(""),[d,h]=m.useState(!1),y=uo(e==null?void 0:e.data),v=r==="markdown"?Li(y):"",b=r==="markdown"?da(v,"markdown"):"",g=r==="markdown"?b?f:v:"";return m.useEffect(()=>{const O=M=>{if(M.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[g,a,t]),m.useEffect(()=>{var M;let O=!1;return r!=="markdown"||!b?(p(""),h(!1),()=>{O=!0}):(h(!0),hl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(V=>{O||p(V)}).catch(V=>{var B,F;O||(p(""),(F=(B=e==null?void 0:e.data)==null?void 0:B.onStatus)==null||F.call(B,String(V.message||V)))}).finally(()=>{O||h(!1)}),()=>{O=!0})},[r,b,(S=(_=e==null?void 0:e.data)==null?void 0:_.flowParams)==null?void 0:S.flowId,(I=(N=e==null?void 0:e.data)==null?void 0:N.flowParams)==null?void 0:I.flowSource,(z=(T=e==null?void 0:e.data)==null?void 0:T.flowParams)==null?void 0:z.archived,(E=e==null?void 0:e.data)==null?void 0:E.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?pr.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:NM(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||d,onClick:async()=>{var O,M;try{await EM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:p}),l(!1)}catch(V){(M=(O=e==null?void 0:e.data)==null?void 0:O.onStatus)==null||M.call(O,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||d,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(AM,{value:c,onChange:u,onUploadImage:(D=e.data)==null?void 0:D.onUploadWorkspaceImage,readOnly:o}):i.jsx(CM,{data:e.data,flowParams:(L=e.data)==null?void 0:L.flowParams,htmlFrameRef:n})})]})}),document.body):null}function qJ({node:e}){var d,h,y,v,b,g,k,x,_,S;const t=Ln(e==null?void 0:e.data),n=uo(e==null?void 0:e.data),r=t==="image"?n:Li(n),s=t==="image"?"":da(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var I;let N=!1;return s?(c(!0),a(""),hl(((I=e==null?void 0:e.data)==null?void 0:I.flowParams)||{},s).then(T=>{N||a(T)}).catch(()=>{N||a("")}).finally(()=>{N||c(!1)}),()=>{N=!0}):(a(""),c(!1),()=>{N=!0})},[s,(h=(d=e==null?void 0:e.data)==null?void 0:d.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,f=t==="html"?su(u):t==="react"?jg(u):Li(u),p=Ka(t,f);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):p?i.jsx("div",{className:"af-display-picker-preview__empty",children:p}):f.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"?Av(f):SM(f)}):t==="image"?i.jsx("img",{src:ff(f,(_=e==null?void 0:e.data)==null?void 0:_.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(vv,{content:f,basePath:s,resolveSrc:(N,I)=>{var T;return ff(N,(T=e==null?void 0:e.data)==null?void 0:T.flowParams,I)}})}):t==="chart"?i.jsx(jv,{content:f}):t==="table"?i.jsx(Sv,{content:f}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(_M,{code:f}),i.jsx("pre",{children:f})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:f}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function AM({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,f]=m.useState({visible:!1,top:0,height:100}),p=m.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),_=k>x+1,S=_?Math.max(12,x/k*100):100,N=Math.max(0,100-S),I=_?Math.min(N,g.scrollTop/Math.max(1,k-x)*N):0;f({visible:_,top:I,height:S})},[]);m.useEffect(()=>{const g=requestAnimationFrame(p),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(p);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[p,e]);const d=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,p()},[p]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const _=x.getBoundingClientRect(),S=u.height/100*_.height,N=Math.max(1,_.height-S);return(g-_.top-k)/N},[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(),_=u.top/100*x.height,S=u.height/100*x.height,I=g.clientY>=x.top+_&&g.clientY<=x.top+_+S?g.clientY-x.top-_:S/2;d(h(g.clientY,I));const T=E=>{E.preventDefault(),d(h(E.clientY,I))},z=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z)},[h,d,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=s.current,_=Number((x==null?void 0:x.selectionStart)??k.length),S=Number((x==null?void 0:x.selectionEnd)??_),N=k.slice(0,_),I=k.slice(S),T=N&&!N.endsWith(`
243
- `)?`
244
- `:"",z=I&&!I.startsWith(`
245
- `)?`
246
- `:"",E=`${N}${T}${g}${z}${I}`;t==null||t(E),window.requestAnimationFrame(()=>{var L,O;const D=N.length+T.length+g.length;(L=s.current)==null||L.focus(),(O=s.current)==null||O.setSelectionRange(D,D)})},[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 _=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(`![${_}](${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(_=>String((_==null?void 0:_.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(Nm);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:p,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 UJ({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),f=String(s.candidateContent||""),p=!!s.running,d=!!(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||p||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}`)),p?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:p||d,"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:p||d,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:p||d||!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"})})]}),f.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:f})]})}):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 GJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function YJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function JJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function lC(e,t=""){const n=da(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function XJ(e,t){const n=JJ(e),r=new Set,s=Ln(t)||"";ui(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=lC(uo(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(/^\/+/,""),f=lC(u,s);return f&&r.add(f),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function cC(e,t){const n=Ln(t)||"markdown";return`outputs/${YJ((t==null?void 0:t.label)||e||n)}.${GJ(n)}`}async function EM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await Mb((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 IM({id:e,data:t,selected:n,deleteNode:r}){var te,re,se;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((ee,ue)=>({slot:ee,idx:ue})).sort((ee,ue)=>{var _e,Fe,at,mt;const de=String(((_e=ee.slot)==null?void 0:_e.name)||"").trim(),me=String(((Fe=ue.slot)==null?void 0:Fe.name)||"").trim();if(de==="next"&&me!=="next")return-1;if(me==="next"&&de!=="next")return 1;const Me=String(((at=ee.slot)==null?void 0:at.type)||"").trim(),Se=String(((mt=ue.slot)==null?void 0:mt.type)||"").trim();return Me==="node"&&Se!=="node"?-1:Se==="node"&&Me!=="node"?1:ee.idx-ue.idx}),l=Ln(t),c=m.useRef(null),u=m.useRef(null),[f,p]=m.useState(0),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[_,S]=m.useState(""),[N,I]=m.useState(!1),[T,z]=m.useState(!1),E=m.useRef(null),D=uo(t),L=l==="markdown"?Li(D):"",O=l==="markdown"?da(L,"markdown"):"",M=l==="markdown"?O?_:L:"",V=!!(t!=null&&t.readOnly),B=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let ee=!1;return l!=="markdown"||!O?(S(""),I(!1),()=>{ee=!0}):(I(!0),hl((t==null?void 0:t.flowParams)||{},O).then(ue=>{ee||S(ue)}).catch(ue=>{var de;ee||(S(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ue.message||ue)))}).finally(()=>{ee||I(!1)}),()=>{ee=!0})},[l,O,(te=t==null?void 0:t.flowParams)==null?void 0:te.flowId,(re=t==null?void 0:t.flowParams)==null?void 0:re.flowSource,(se=t==null?void 0:t.flowParams)==null?void 0:se.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const ee=()=>v(!1);return window.addEventListener("pointerup",ee,!0),window.addEventListener("pointercancel",ee,!0),window.addEventListener("mouseup",ee,!0),window.addEventListener("blur",ee),()=>{window.removeEventListener("pointerup",ee,!0),window.removeEventListener("pointercancel",ee,!0),window.removeEventListener("mouseup",ee,!0),window.removeEventListener("blur",ee)}},[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),H=(t==null?void 0:t.sharingDisplayNodeId)===$,A=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Te,it,jt,Vt,kt,Mt,ae,ke,qe,tt;if(l!=="html"||d)return;const ee=uo(t),ue=da(ee,l);let de=ee;if(ue)try{de=await hl((t==null?void 0:t.flowParams)||{},ue)}catch(Ee){h(!1),console.warn("Failed to read HTML display file before saving image.",Ee);return}const me=su(de);if(!me.trim())return;const Me=Ka(l,me);if(Me){console.warn(Me);return}const Se=(it=(Te=u.current)==null?void 0:Te.getBoundingClientRect)==null?void 0:it.call(Te),_e=(Vt=(jt=c.current)==null?void 0:jt.querySelector)==null?void 0:Vt.call(jt,".af-work-display-body"),Fe=(Mt=(kt=c.current)==null?void 0:kt.querySelector)==null?void 0:Mt.call(kt,".af-visible-scroll-frame__scroller"),at=Math.round(Math.max(Number((Se==null?void 0:Se.width)||0),Number((A==null?void 0:A.width)||0),Number(((ae=c.current)==null?void 0:ae.clientWidth)||0),Number((_e==null?void 0:_e.clientWidth)||0),Number((Fe==null?void 0:Fe.clientWidth)||0),Math.max(320,Number((A==null?void 0:A.width)||960)-2))),mt=Math.round(Math.max(Number((Se==null?void 0:Se.height)||0),Number((A==null?void 0:A.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((_e==null?void 0:_e.clientHeight)||0),Number((Fe==null?void 0:Fe.clientHeight)||0),Math.max(180,Number((A==null?void 0:A.height)||640)-46)));h(!0);try{await BJ({flowParams:(t==null?void 0:t.flowParams)||{},content:me,sourceFilePath:ue,iframe:u.current,width:at,height:mt,filename:OJ((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:_e,scroller:Fe},displaySize:A}),(qe=t==null?void 0:t.onStatus)==null||qe.call(t,"已导出 HTML 展示截图")}catch(Ee){const Dt=String((Ee==null?void 0:Ee.message)||Ee||"截图失败");(tt=t==null?void 0:t.onStatus)==null||tt.call(t,`HTML 截图失败:${Dt}`),console.warn("Failed to save HTML display as PNG.",Ee)}finally{h(!1)}},[t,A==null?void 0:A.height,A==null?void 0:A.width,e,l,d]),K=m.useCallback(ee=>{var ue;V||!ee||l!=="image"||(ue=t==null?void 0:t.onUploadImageToDisplayNode)==null||ue.call(t,e,ee)},[t,e,l,V]),W=m.useCallback(ee=>{var ue,de;(ue=ee==null?void 0:ee.stopPropagation)==null||ue.call(ee),!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]),ne=m.useCallback(ee=>{var me,Me;V||l!=="image"||!(Array.from(((me=ee.dataTransfer)==null?void 0:me.files)||[]).some(Nm)||Array.from(((Me=ee.dataTransfer)==null?void 0:Me.items)||[]).some(Se=>String((Se==null?void 0:Se.type)||"").startsWith("image/")))||(ee.preventDefault(),ee.stopPropagation(),ee.dataTransfer.dropEffect="copy",z(!0))},[l,V]),Z=m.useCallback(ee=>{l==="image"&&(ee.currentTarget.contains(ee.relatedTarget)||z(!1))},[l]),G=m.useCallback(ee=>{var de;if(l!=="image")return;const ue=Array.from(((de=ee.dataTransfer)==null?void 0:de.files)||[]).find(Nm);ue&&(ee.preventDefault(),ee.stopPropagation(),z(!1),K(ue))},[l,K]);return i.jsxs("div",{className:"af-work-display-card"+(A?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(T?" af-work-display-card--image-drop":"")+(B?" 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:A?{width:A.width,height:A.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:ne,onDragLeave:Z,onDrop:G,children:[i.jsx(ov,{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((ee,ue)=>{if(ee.showOnNode===!1)return null;const de=`${4.15+ue*1.75}rem`,me=ee.name||`#${ue+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:me}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${ue}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:Dn(ee.type)},title:`${me} · ${ee.type}`})]},`in-${ue}`)}),a.map(({slot:ee,idx:ue},de)=>{if(ee.showOnNode===!1)return null;const me=`${4.15+de*1.75}rem`,Me=ee.name||`#${ue+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:me},children:Me}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${ue}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:me,background:Dn(ee.type)},title:`${Me} · ${ee.type}`})]},`out-${ue}`)}),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:NM(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:ee=>ee.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var ee,ue,de,me;try{(me=(de=(ue=(ee=u.current)==null?void 0:ee.contentWindow)==null?void 0:ue.history)==null?void 0:de.back)==null||me.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 ee,ue,de,me;try{(me=(de=(ue=(ee=u.current)==null?void 0:ee.contentWindow)==null?void 0:ue.history)==null?void 0:de.forward)==null||me.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:()=>p(ee=>ee+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:d,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:d?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:ee=>ee.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:V||N,onClick:async()=>{var ee;try{await EM({nodeId:e,data:t,filePath:O,content:k,setFileContent:S}),g(!1)}catch(ue){(ee=t==null?void 0:t.onStatus)==null||ee.call(t,String(ue.message||ue))}},"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||N,onClick:ee=>{ee.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:E,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:ee=>{var de;const ue=(de=ee.target.files)==null?void 0:de[0];ee.target.value="",ue&&K(ue)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:ee=>{var ue;ee.stopPropagation(),(ue=E.current)==null||ue.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:ee=>{var ue;ee.stopPropagation(),(ue=t==null?void 0:t.onOpenDisplayPreview)==null||ue.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:H,onClick:ee=>{var ue;ee.stopPropagation(),(ue=t==null?void 0:t.onShareDisplayNode)==null||ue.call(t,$)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:H?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:W,"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 ee;return(ee=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:ee.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(AM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):i.jsx(CM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:f}),i.jsx(UJ,{nodeId:e,data:t})]})}function QJ({id:e,data:t,selected:n,deleteNode:r}){var f,p,d;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((p=(f=t==null?void 0:t.runningRunNodeIds)==null?void 0:f.has)==null?void 0:p.call(f,e))||((d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return 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(er,{type:"target",position:Ue.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:Dn(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(er,{type:"source",position:Ue.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:Dn(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 ZJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var tt,Ee,Dt,nn,Kt,yt,Cn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=mX(t),[f,p]=m.useState(u.task),d=m.useRef(!1),h=m.useRef(u.task),y=((Ee=(tt=t==null?void 0:t.runningRunNodeIds)==null?void 0:tt.has)==null?void 0:Ee.call(tt,e))||((Dt=t==null?void 0:t.runningRunNodeIds)==null?void 0:Dt[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(ie=>({id:String((ie==null?void 0:ie.id)||""),label:String((ie==null?void 0:ie.label)||(ie==null?void 0:ie.name)||"知识库"),kind:(ie==null?void 0:ie.kind)==="git"?"git":"local",path:String((ie==null?void 0:ie.path)||""),repoUrl:String((ie==null?void 0:ie.repoUrl)||""),branch:String((ie==null?void 0:ie.branch)||""),mountPath:String((ie==null?void 0:ie.mountPath)||""),builtin:(ie==null?void 0:ie.builtin)===!0,exists:(ie==null?void 0:ie.exists)!==!1,type:String((ie==null?void 0:ie.type)||"")})).filter(ie=>ie.path),[a]),[_,S]=m.useState(!1),[N,I]=m.useState(""),[T,z]=m.useState(()=>new Set),[E,D]=m.useState(!1),[L,O]=m.useState(""),[M,V]=m.useState("config"),B=Ng(t),F=!!B,$=OM(u.displayType),H=m.useMemo(()=>RJ(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,$]),A=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:$,displaySize:H,nodeSize:H,body:B,inputs:[{type:"text",name:$==="display_image"?"src":"content",value:B,default:B}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,$,e,B,c,H]),Q=Array.isArray((nn=t==null?void 0:t.modelLists)==null?void 0:nn.cursor)?t.modelLists.cursor:[],K=Array.isArray((Kt=t==null?void 0:t.modelLists)==null?void 0:Kt.opencode)?t.modelLists.opencode:[],W=Array.isArray((yt=t==null?void 0:t.modelLists)==null?void 0:yt.claudeCode)?t.modelLists.claudeCode:[],ne=Array.isArray((Cn=t==null?void 0:t.modelLists)==null?void 0:Cn.codex)?t.modelLists.codex:[],Z=m.useMemo(()=>new Set(Q.map(Is)),[Q]),G=m.useMemo(()=>new Set(K.map(Is)),[K]),te=m.useMemo(()=>new Set(W.map(Is)),[W]),re=m.useMemo(()=>new Set(ne.map(Is)),[ne]),se=u.model,ee=m.useMemo(()=>se?se.startsWith("cursor:")||se.startsWith("opencode:")||se.startsWith("codex:")||se.startsWith("claude-code:")?se:te.has(se)?`claude-code:${se}`:re.has(se)?`codex:${se}`:G.has(se)?`opencode:${se}`:Z.has(se)?`cursor:${se}`:se:"",[te,re,Z,G,se]),ue=se.startsWith("cursor:")?se.slice(7):se.startsWith("opencode:")?se.slice(9):se.startsWith("codex:")?se.slice(6):se.startsWith("claude-code:")?se.slice(12):se,de=ue,me=!!se&&!Z.has(de)&&!G.has(de)&&!te.has(de)&&!re.has(de),Me=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Se=m.useMemo(()=>new Map(g.map(ie=>[ie.key,ie])),[g]),_e=m.useMemo(()=>{const ie=new Set,Ce=k.map(Be=>{const Et=ca(Be,g).map(vt=>Se.get(vt)).filter(Boolean);for(const vt of Et)ie.add(vt.key);return{...Be,skills:Et}}).filter(Be=>Be.skills.length>0),Ge=g.filter(Be=>!ie.has(Be.key));return{collectionGroups:Ce,ungrouped:Ge}},[k,Se,g]);m.useEffect(()=>{z(ie=>{let Ce=!1;const Ge=new Set(ie);for(const Be of _e.collectionGroups)Ge.has(Be.id)||(Ge.add(Be.id),Ce=!0);return Ce?Ge:ie})},[_e.collectionGroups]);const Fe=m.useMemo(()=>{const ie=N.trim().toLowerCase();if(!ie)return _e;const Ce=Be=>[Be==null?void 0:Be.key,Be==null?void 0:Be.name,Be==null?void 0:Be.description].map(Et=>String(Et||"").toLowerCase()).join(" ").includes(ie);return{collectionGroups:_e.collectionGroups.map(Be=>{const Et=[Be==null?void 0:Be.id,Be==null?void 0:Be.name,Be==null?void 0:Be.description].map(vt=>String(vt||"").toLowerCase()).join(" ").includes(ie);return{...Be,skills:Et?Be.skills:Be.skills.filter(Ce)}}).filter(Be=>Be.skills.length>0),ungrouped:_e.ungrouped.filter(Ce)}},[_e,N]),at=$b(_,[Fe.collectionGroups.length,Fe.ungrouped.length,T.size,u.skillKeys.length,N]),mt=m.useMemo(()=>{const ie=L.trim().toLowerCase();return ie?x.filter(Ce=>[Ce.id,Ce.label,Ce.path,Ce.repoUrl,Ce.branch,Ce.mountPath,Ce.type].join(" ").toLowerCase().includes(ie)):x},[x,L]),Te=m.useMemo(()=>WM(u.knowledgeContext),[u.knowledgeContext]),it=m.useMemo(()=>new Set(Te.map(ie=>ie.id||ie.path||ie.repoPath).filter(Boolean)),[Te]),jt=$b(E,[mt.length,Te.length,L]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,d.current||p(u.task))},[u.task]),m.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,B,y]),m.useEffect(()=>{var Ce,Ge;if(!(M==="result"&&F))return;(Ce=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Ce.call(t,e,H),(Ge=t==null?void 0:t.onRefreshNodeInternals)==null||Ge.call(t,e);const ie=window.setTimeout(()=>{var Be;return(Be=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:Be.call(t,e)},120);return()=>window.clearTimeout(ie)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,$,F,e,B,H,M]);const Vt=ie=>{var Ce;(Ce=t==null?void 0:t.onChangeContextRunConfig)==null||Ce.call(t,e,{...u,task:f,...ie})},kt=(ie=f)=>{var Ge;const Ce=String(ie??"");Ce!==u.task&&(h.current=Ce,(Ge=t==null?void 0:t.onChangeContextRunConfig)==null||Ge.call(t,e,{...u,task:Ce}))},Mt=(ie,Ce)=>{const Ge=new Set(u.skillKeys);for(const Be of ie){const Et=String(Be||"").trim();Et&&(Ce?Ge.add(Et):Ge.delete(Et))}Vt({skillKeys:Array.from(Ge)})},ae=ie=>{z(Ce=>{const Ge=new Set(Ce);return Ge.has(ie)?Ge.delete(ie):Ge.add(ie),Ge})},ke=(ie,Ce)=>{const Ge=(ie==null?void 0:ie.id)||(ie==null?void 0:ie.path)||"";if(!Ge)return;const Be=x.filter(Et=>{const vt=Et.id||Et.path||"";return vt===Ge?Ce:it.has(vt)});Vt({knowledgeContext:_g(Be)})},qe=()=>{Vt({knowledgeContext:null})};return M==="result"&&F?i.jsx(IM,{id:e,data:{...A,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((ie,Ce)=>{if(ie.showOnNode===!1)return null;const Ge=`${2.25+Ce*1.75}rem`,Be=ie.name||`#${Ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Ge},children:Be}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${Ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Ge,background:Dn(ie.type)},title:`${Be} · ${ie.type}`})]},`in-${Ce}`)}),c.map((ie,Ce)=>{if(ie.showOnNode===!1)return null;const Ge=`${2.25+Ce*1.75}rem`,Be=ie.name||`#${Ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Ge},children:Be}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${Ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Ge,background:Dn(ie.type)},title:`${Be} · ${ie.type}`})]},`out-${Ce}`)}),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:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),children:[i.jsxs("select",{className:"af-work-context-run-card__model",value:ee,disabled:b,"aria-label":"模型",title:ue||"默认模型",onChange:ie=>Vt({model:ie.target.value}),children:[i.jsx("option",{value:"",children:"默认"}),me?i.jsx("option",{value:se,children:se}):null,Q.length?i.jsx("optgroup",{label:"Cursor",children:Q.map(ie=>i.jsx("option",{value:`cursor:${Is(ie)}`,children:Is(ie)},`context-cursor-${ie}`))}):null,K.length?i.jsx("optgroup",{label:"OpenCode",children:K.map(ie=>i.jsx("option",{value:`opencode:${Is(ie)}`,children:Is(ie)},`context-opencode-${ie}`))}):null,ne.length?i.jsx("optgroup",{label:"Codex",children:ne.map(ie=>i.jsx("option",{value:`codex:${Is(ie)}`,children:Is(ie)},`context-codex-${ie}`))}):null,W.length?i.jsx("optgroup",{label:"Claude Code",children:W.map(ie=>i.jsx("option",{value:`claude-code:${Is(ie)}`,children:Is(ie)},`context-claude-${ie}`))}):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:ui(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:ie=>ie.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:f,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{d.current=!0},onCompositionEnd:ie=>{d.current=!1,p(ie.currentTarget.value),kt(ie.currentTarget.value)},onChange:ie=>{p(ie.target.value)},onBlur:ie=>kt(ie.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:ie=>{var Ce;ie.stopPropagation(),_||(Ce=t==null?void 0:t.onRefreshSkills)==null||Ce.call(t),S(Ge=>!Ge)},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"})]}),_?i.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:ie=>ie.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:N,onChange:ie=>I(ie.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),N?i.jsx("button",{type:"button",onClick:()=>I(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:at.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:at.updateMenuScrollbar,children:[Fe.collectionGroups.map(ie=>{const Ce=ie.skills.map(vt=>vt.key),Ge=Ce.filter(vt=>Me.has(vt)).length,Be=Ce.length>0&&Ge===Ce.length,Et=T.has(ie.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Et?" 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:Be,disabled:b,onChange:vt=>Mt(Ce,vt.target.checked),"aria-label":`选择 ${ie.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>ae(ie.id),"aria-expanded":!Et,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:ie.name}),ie.description?i.jsx("em",{children:ie.description}):null]})}),i.jsxs("small",{children:[Ge,"/",Ce.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>ae(ie.id),"aria-label":Et?`展开 ${ie.name}`:`收起 ${ie.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Et?"chevron_right":"expand_more"})})]}),Et?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:ie.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:pe=>Mt([vt.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:vt.name}),vt.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:vt.description}):null]})]},`${ie.id}:${vt.key}`))})]},ie.id)}),Fe.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:Fe.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:Fe.ungrouped.map(ie=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:Me.has(ie.key),disabled:b,onChange:Ce=>Mt([ie.key],Ce.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:ie.name}),ie.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:ie.description}):null]})]},`ungrouped:${ie.key}`))})]}):null,Fe.collectionGroups.length===0&&Fe.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:()=>Vt({skillKeys:[]}),children:"清空"})]}),i.jsx("div",{ref:at.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(at.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:at.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${at.scrollbar.height}%`,top:`${at.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:ie=>{var Ce;ie.stopPropagation(),E||(Ce=t==null?void 0:t.onRefreshWorkspaces)==null||Ce.call(t),D(Ge=>!Ge)},children:[i.jsx("span",{className:"material-symbols-outlined",children:Te.length?"folder_open":"folder_off"}),i.jsx("span",{children:Te.length?`${Te.length} 知识库`:"知识库"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),E?i.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:ie=>ie.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:L,onChange:ie=>O(ie.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),L?i.jsx("button",{type:"button",onClick:()=>O(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:jt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:jt.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:mt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:mt.map(ie=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:it.has(ie.id||ie.path),disabled:b,onChange:Ce=>ke(ie,Ce.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:ie.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[ie.kind==="git"&&ie.repoUrl?`${ie.repoUrl}${ie.branch?` · ${ie.branch}`:""}${ie.mountPath?` · ${ie.mountPath}`:""}`:ie.path,ie.exists?"":" · 路径未就绪"]})]})]},`${ie.id}:${ie.path}`))})]}),mt.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:qe,children:"清空知识库"})]}),i.jsx("div",{ref:jt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(jt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:jt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${jt.scrollbar.height}%`,top:`${jt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:b,onChange:ie=>Vt({displayType:ie.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"})]})]}),B?i.jsx("pre",{className:"af-work-context-run-card__preview",children:B.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:ie=>{var Ce,Ge;ie.stopPropagation(),kt(),y?(Ce=t==null?void 0:t.onStopWorkspaceNode)==null||Ce.call(t,e):(Ge=t==null?void 0:t.onRunWorkspaceNode)==null||Ge.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:ie=>{var Ce;ie.stopPropagation(),(Ce=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Ce.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 eX({id:e,data:t,selected:n,deleteNode:r}){var I,T,z;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=Lv((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},f=((T=(I=t==null?void 0:t.runningRunNodeIds)==null?void 0:I.has)==null?void 0:T.call(I,e))||((z=t==null?void 0:t.runningRunNodeIds)==null?void 0:z[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",p=(t==null?void 0:t.optimizingRun)===!0,d=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=E=>{var D;(D=t==null?void 0:t.onChangeScheduledRunConfig)==null||D.call(t,e,{...a,...E})},v=E=>{y({scheduleType:E,cron:cd(E,a.time,a.weekday,a.monthDay,a.cron)})},b=E=>{y({time:E,cron:cd(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[g,k]=$v(a.time).split(":"),x=(E,D)=>{b(`${Yo(E,9,0,23)}:${Yo(D,0,0,59)}`)},_=E=>{y({weekday:E,cron:cd(a.scheduleType,a.time,E,a.monthDay,a.cron)})},S=E=>{y({monthDay:E,cron:cd(a.scheduleType,a.time,a.weekday,E,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const N=()=>{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":"")+(f?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((E,D)=>{if(E.showOnNode===!1)return null;const L=`${2.25+D*1.75}rem`,O=E.name||`#${D+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:L},children:O}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${D}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:L,background:Dn(E.type)},title:`${O} · ${E.type}`})]},`in-${D}`)}),o.map((E,D)=>{if(E.showOnNode===!1)return null;const L=`${2.25+D*1.75}rem`,O=E.name||`#${D+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:L},children:O}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${D}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:L,background:Dn(E.type)},title:`${O} · ${E.type}`})]},`out-${D}`)}),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:E=>y({enabled:E.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:E=>v(E.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:E=>x(E.target.value,k),children:Array.from({length:24},(E,D)=>Yo(D,0,0,23)).map(E=>i.jsxs("option",{value:E,children:[E," 时"]},E))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:E=>x(g,E.target.value),children:Array.from({length:12},(E,D)=>Yo(D*5,0,0,59)).map(E=>i.jsxs("option",{value:E,children:[E," 分"]},E))})]})]}):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:E=>_(E.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:E=>S(E.target.value),children:Array.from({length:31},(E,D)=>D+1).map(E=>i.jsxs("option",{value:E,children:[E," 日"]},E))})]}):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:df,onChange:E=>c(E.target.value),onBlur:N,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[bJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",xJ(u.nextAt)]}),i.jsx("span",{children:f?"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"+(f?" af-work-run-card__button--stop":""),disabled:h||p,onClick:E=>{var D,L;E.stopPropagation(),f?(D=t==null?void 0:t.onStopWorkspaceNode)==null||D.call(t,e):(L=t==null?void 0:t.onRunWorkspaceNode)==null||L.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:f?"stop_circle":"play_arrow"}),i.jsx("span",{children:f?"停止":"立即运行"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(p?" af-work-schedule-card__optimize--running":""),disabled:h||f||p,title:"为下游节点提前生成 implementation",onClick:E=>{var D;E.stopPropagation(),(D=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||D.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:p?"sync":"auto_fix_high"}),i.jsx("span",{children:p?"优化中":"优化"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:E=>{var D;E.stopPropagation(),(D=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||D.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 tX({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=tu(),o=!!(t!=null&&t.readOnly),a=Pb(t==null?void 0:t.nodeSize)||{width:ul,height:dl},l=m.useCallback(c=>{var u,f;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(f=(u=c.target)==null?void 0:u.closest)!=null&&f.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(p=>RM(p,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(ov,{className:"af-work-group-node__resize nodrag",minWidth:ul,minHeight:dl,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 nX(e){var y,v,b,g,k,x,_,S,N,I,T,z,E,D,L,O,M,V,B,F,$,H,A,Q,K,W,ne,Z;const{setEdges:t,setNodes:n}=tu(),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 se,ee,ue;if(s)return;(ee=(se=e.data)==null?void 0:se.onCleanupWorkspaceNodeOutputs)==null||ee.call(se,G,e.data);const te=ui((ue=e.data)==null?void 0:ue.definitionId)?DM(G):"",re=new Set([G,te].filter(Boolean));n(de=>de.filter(me=>!re.has(me.id))),t(de=>de.filter(me=>!re.has(me.source)&&!re.has(me.target)))},[e.data,s,t,n]),u=m.useCallback(G=>{var te,re;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(re=(te=G.target)==null?void 0:te.closest)!=null&&re.call(te,".react-flow__handle, .af-work-display-resize")||(n(se=>RM(se,e.id)),t(se=>oX(se)))},[e.id,t,n]),f=m.useCallback((G,te)=>{s||(n(re=>re.map(se=>se.id===G?{...se,data:{...se.data,model:te}}:se)),r==null||r(G,{model:te}))},[s,n,r]),p=m.useCallback((G,te)=>{s||(n(re=>re.map(se=>{var ue;if(se.id!==G)return se;const ee=Array.isArray((ue=se.data)==null?void 0:ue.outputs)&&se.data.outputs.length?se.data.outputs.map((de,me)=>me===0?{...de,default:te,value:te}:de):[{type:"bool",name:"value",default:te,value:te}];return{...se,data:{...se.data,body:"",outputs:ee}}})),r==null||r(G,re=>({body:"",outputs:Array.isArray(re==null?void 0:re.outputs)&&re.outputs.length?re.outputs.map((ee,ue)=>ue===0?{...ee,default:te,value:te}:ee):[{type:"bool",name:"value",default:te,value:te}]})))},[s,n,r]),d=m.useCallback((G,te)=>{s||(n(re=>re.map(se=>se.id===G?{...se,data:{...se.data,body:te}}:se)),r==null||r(G,{body:te}))},[s,n,r]),h=m.useCallback((G,te)=>{if(s)return;const re=vo(te);n(se=>se.map(ee=>ee.id===G?{...ee,data:{...ee.data,images:re}}:ee)),r==null||r(G,{images:re})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(tX,{...e,deleteNode:c}):pl((k=e.data)==null?void 0:k.definitionId)?i.jsx(IM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(QJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((_=e.data)==null?void 0:_.definitionId)==="workspace_scheduled_run"?i.jsx(eX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ui((S=e.data)==null?void 0:S.definitionId)?i.jsx(ZJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(N=e.data)==null?void 0:N.skills,skillCollections:(I=e.data)==null?void 0:I.skillCollections,workspaces:(T=e.data)==null?void 0:T.workspaceTargets}):((z=e.data)==null?void 0:z.definitionId)==="control_load_skills"?i.jsx(vX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(E=e.data)==null?void 0:E.skills,skillCollections:(D=e.data)==null?void 0:D.skillCollections,onChangeSkillKeys:(L=e.data)==null?void 0:L.onChangeLoadSkillKeys}):((O=e.data)==null?void 0:O.definitionId)==="control_load_mcp"?i.jsx(SX,{...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}):((B=e.data)==null?void 0:B.definitionId)==="control_cd_workspace"?i.jsx(jX,{...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:(H=e.data)==null?void 0:H.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((A=e.data)!=null&&A.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":"")+(((W=e.data)==null?void 0:W.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((ne=e.data)==null?void 0:ne.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:i.jsx(ov,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:aM,minHeight:jm,maxWidth:lM,maxHeight:cM,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(DU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(Z=e.data)==null?void 0:Z.modelLists,onModelChange:f,onProvideValueChange:p,onNodeBodyChange:d,onNodeImagesChange:h})]})}const rX={[Ec]:m.memo(nX)};function Ov(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Ov(n.children,t);return t}function PM(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)?PM(r.children,n):null;if(s)return s}return null}function sX(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function TM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&TM(n.children,t));return t}function eh(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 iX(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 RM(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:iX(e,n)}function oX(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function aX(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function lX(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,f=a===r.length-1;let p=!1;const d=(Array.isArray(o)?o:[]).map(h=>h.name!==c?h:(p=!0,f?{...h,type:"file",name:c,path:u,icon:yc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:yc(c,!0),children:s(h.children||[],a+1,u)}));return p||d.push(f?{type:"file",name:c,path:u,icon:yc(c),size:n}:{type:"directory",name:c,path:u,icon:yc(c,!0),children:s([],a+1,u)}),aX(d)};return s(e||[],0,"")}function cX(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 MM({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 f=u.type==="directory",p=f&&(r==null?void 0:r.has(u.path)),d=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+(d?" af-work-file--selected":""),draggable:!f,onDragStart:y=>{f||a==null||a(y,u)},onClick:()=>{o==null||o(u),f&&(s==null||s(u.path))},onDoubleClick:()=>{f||t(u)},title:u.path,children:[f?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:p?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:u.icon||yc(u.name,f)}),i.jsx("span",{children:u.name})]}),d?i.jsxs("div",{className:"af-work-file-actions",children:[f?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]}),f&&!p&&((h=u.children)!=null&&h.length)?i.jsx(MM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function uX({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>Ov(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||yc(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:cX(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function uC({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 $M(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function dX(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!$M(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 fX(e){return(Array.isArray(e)?e:[]).filter($M)}function hf(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 pX(e){const t=hf((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 hf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function hX(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 hf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function LM(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 dC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function fa(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 Rm(e,t){const n=fa(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 Mf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Is(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function OM(e){const t=Mf(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 DM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function FM(e){return e==="display_image"?"src":"content"}function fC(e,t,n){const r=FM(t),s=ud(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 pC(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 hC(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 Ng(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 mX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=fa(t,"includeWorkspaceContext","true").toLowerCase(),r=Rm(t,"knowledgeContext"),s=Rm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:hX(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?_g([s]):null),workspaceContext:s,displayType:Mf(fa(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ui(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function gX(e){const t=hf((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 hf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function yX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function zM(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 _g(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>zM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function WM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>zM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function wX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Rm(t,"knowledgeContext"),r=Rm(t,"workspaceContext");return{sources:WM(n||(r?_g([r]):null)),path:fa(t,"path",""),label:fa(t,"label","")}}function mC(e){var r,s,o,a,l,c,u,f,p;if(!e)return null;const{inputs:t,outputs:n}=XU(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:vo((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(((f=e.data)==null?void 0:f.implementationRef)??""),implementationMode:String(((p=e.data)==null?void 0:p.implementationMode)??""),inputs:t,outputs:n}}function gC(e,t,n,r=""){var c,u;const s=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(f=>String((f==null?void 0:f.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 yC(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 xX(e,t,n){var f,p;const r=String(((f=e==null?void 0:e.data)==null?void 0:f.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=lf.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?[]:vo(t==null?void 0:t.images),inputs:yC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((p=e.data)==null?void 0:p.outputs)?e.data.outputs:yC(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const d of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[d])??"").trim();h?c[d]=h:delete c[d]}return c}function wC({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(!bG.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=xX(r,s,c),f=r.data||{};if(!(c!==a||f.label!==u.label||f.role!==u.role||f.model!==u.model||f.body!==u.body||JSON.stringify(vo(f.images))!==JSON.stringify(u.images)||(f.script??void 0)!==(u.script??void 0)||(f.scriptRef??void 0)!==(u.scriptRef??void 0)||(f.implementationRef??void 0)!==(u.implementationRef??void 0)||(f.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(f.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(f.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const d=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:d,edges:h,instances:y}}function bX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function kX(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"])bX(e[s],t[s])&&(r[s]=n[s]);return r}function $b(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 f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),h=p>d+1,y=h?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=h?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const f=requestAnimationFrame(a);return()=>cancelAnimationFrame(f)},[e,a,...t]);const l=m.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=m.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(f-h.top-p)/v},[s.height]),u=m.useCallback(f=>{var _,S;if(!s.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=f.clientY>=d.top+h&&f.clientY<=d.top+h+y?f.clientY-d.top-h:y/2;l(c(f.clientY,b));const g=f.pointerId;(S=(_=f.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.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 vX({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:[],f=Array.isArray(o)?o:[],[p,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,_]=m.useState({visible:!1,top:0,height:100}),S=m.useMemo(()=>new Set(pX(t)),[t]),N=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),I=m.useMemo(()=>Array.from(S).map(F=>{var $;return(($=N.get(F))==null?void 0:$.name)||F}),[N,S]),T=m.useMemo(()=>LM(I,"选择 Skills"),[I]),z=m.useMemo(()=>{const F=new Set,$=f.map(A=>{const Q=ca(A,u).map(K=>N.get(K)).filter(Boolean);for(const K of Q)F.add(K.key);return{...A,skills:Q}}).filter(A=>A.skills.length>0),H=u.filter(A=>!F.has(A.key));return{collectionGroups:$,ungrouped:H}},[N,f,u]);m.useEffect(()=>{b(F=>{let $=!1;const H=new Set(F);for(const A of z.collectionGroups)H.has(A.id)||(H.add(A.id),$=!0);return $?H:F})},[z.collectionGroups]);const E=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return z;const $=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(K=>String(K||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:z.collectionGroups.map(A=>{const K=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(W=>String(W||"").toLowerCase()).join(" ").includes(F)?A.skills:A.skills.filter($);return{...A,skills:K}}).filter(A=>A.skills.length>0),ungrouped:z.ungrouped.filter($)}},[z,h]),D=m.useCallback((F,$)=>{const H=new Set(S);for(const A of F)$?H.add(A):H.delete(A);a==null||a(e,Array.from(H))},[e,S,a]),L=m.useCallback(F=>{b($=>{const H=new Set($);return H.has(F)?H.delete(F):H.add(F),H})},[]),O=m.useCallback(()=>{const F=g.current;if(!F)return;const $=Math.max(1,F.scrollHeight),H=Math.max(1,F.clientHeight),A=$>H+1,Q=A?Math.max(12,H/$*100):100,K=Math.max(0,100-Q),W=A?Math.min(K,F.scrollTop/Math.max(1,$-H)*K):0;_({visible:A,top:W,height:Q})},[]);m.useEffect(()=>{if(!p)return;const F=requestAnimationFrame(O);return()=>cancelAnimationFrame(F)},[v,E,S.size,p,O]);const M=m.useCallback(F=>{const $=g.current;if(!$)return;const H=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,F))*H,O()},[O]),V=m.useCallback((F,$=0)=>{const H=k.current;if(!H)return 0;const A=H.getBoundingClientRect(),Q=x.height/100*A.height,K=Math.max(1,A.height-Q);return(F-A.top-$)/K},[x.height]),B=m.useCallback(F=>{var te,re;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const $=k.current;if(!$)return;const H=$.getBoundingClientRect(),A=x.top/100*H.height,Q=x.height/100*H.height,W=F.clientY>=H.top+A&&F.clientY<=H.top+A+Q?F.clientY-H.top-A:Q/2;M(V(F.clientY,W));const ne=F.pointerId;(re=(te=F.currentTarget).setPointerCapture)==null||re.call(te,ne);const Z=se=>{se.preventDefault(),M(V(se.clientY,W))},G=()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",Z),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":"")+(p?" 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 H=`${2.6+$*1.7}rem`,A=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:H},children:A}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:H,background:Dn(F.type)},title:`${A} · ${F.type}`})]},`in-${$}`)}),c.map((F,$)=>{if(F.showOnNode===!1)return null;const H=`${2.6+$*1.7}rem`,A=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:H},children:A}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:H,background:Dn(F.type)},title:`${A} · ${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(),p||($=t==null?void 0:t.onRefreshSkills)==null||$.call(t),d(H=>!H)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:T.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:T.head}),T.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:T.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:p?"expand_less":"expand_more"})]}),p?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:O,children:[E.collectionGroups.map(F=>{const $=F.skills.map(K=>K.key),H=$.filter(K=>S.has(K)).length,A=$.length>0&&H===$.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:A,onChange:K=>D($,K.target.checked),"aria-label":`选择 ${F.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>L(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:[H,"/",$.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>L(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:W=>D([K.key],W.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)}),E.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:E.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:E.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:$=>D([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,E.collectionGroups.length===0&&E.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:B,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function SX({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),[f,p]=m.useState(""),d=m.useMemo(()=>new Set(gX(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=f.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[f,h]),v=m.useCallback((b,g)=>{const k=new Set(d);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,d,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(er,{type:"target",position:Ue.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Dn(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(er,{type:"source",position:Ue.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Dn(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:d.size>0?`${d.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:f,onChange:b=>p(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),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",{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:d.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 jX({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,f]=m.useState(!1),[p,d]=m.useState(""),h=wX(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=p.trim().toLowerCase();return S?y.filter(N=>[N.id,N.label,N.path,N.repoUrl,N.branch,N.mountPath].join(" ").toLowerCase().includes(S)):y},[p,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(()=>LM(g,"选择知识库"),[g]),x=$b(u,[v.length,g.length,p]),_=(S,N)=>{const I=(S==null?void 0:S.id)||(S==null?void 0:S.path)||"",T=y.filter(z=>{const E=z.id||z.path||"";return E===I?N:b.has(E)});o==null||o(e,T)};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,N)=>{if(S.showOnNode===!1)return null;const I=`${2.6+N*1.7}rem`,T=S.name||`#${N+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:I},children:T}),i.jsx(er,{type:"target",position:Ue.Left,id:`input-${N}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:I,background:Dn(S.type)},title:`${T} · ${S.type}`})]},`in-${N}`)}),c.map((S,N)=>{if(S.showOnNode===!1)return null;const I=`${2.6+N*1.7}rem`,T=S.name||`#${N+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:I},children:T}),i.jsx(er,{type:"source",position:Ue.Right,id:`output-${N}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:I,background:Dn(S.type)},title:`${T} · ${S.type}`})]},`out-${N}`)}),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(),f(N=>!N)},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:p,onChange:S=>d(S.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),p?i.jsx("button",{type:"button",onClick:()=>d(""),"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:N=>_(S,N.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 BM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=JR(r),o=PG(JY(r)),a=s?o.filter(d=>!["issue","mr"].includes(km(d))):o,l=RG(r,o),c=$i(r,t),u=s?"":qo(r.platform),f=Array.isArray(e==null?void 0:e.children)?e.children.length:0,p=[c,s&&f?`${f} 个端侧 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:UY(r,t)}),i.jsx("small",{children:p.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(d=>i.jsx("a",{href:d.href,target:"_blank",rel:"noreferrer",children:d.label},`${d.label}-${d.href}`))}):null,f?i.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((d,h)=>i.jsx(BM,{row:d,index:h,child:!0},$i((d==null?void 0:d.issue)||{},h)))}):null]})}function HM(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 VM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>HM(n)).filter(Boolean)}function NX({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=VM(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=pf(t.href||t.url||a.href||a.url||"");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 _X({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"&&VM(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(NX,{fieldKey:o,field:a},o))})]})}function CX({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=pf(n.url||""),l=HM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([p,d])=>p&&d&&typeof d=="object"&&!Array.isArray(d)),f=!!(o||a||l||u.length);return!c&&!f?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,f?i.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([p,d])=>i.jsx(_X,{sectionKey:p,section:d},p))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function AX({flowParams:e={},tapdId:t,setTapdId:n,collaborationOpenRequest:r=0,snapshot:s,loading:o,error:a,actionRunning:l,actionOutput:c,pendingConfirm:u,conflict:f,reviewPublishing:p,onRefresh:d,onRunDryRun:h,onConfirmAction:y,onRetryConflict:v,onPublishReview:b}){var Be,Et,vt;const[g,k]=m.useState("all"),[x,_]=m.useState("all"),[S,N]=m.useState(!1),[I,T]=m.useState(!1),[z,E]=m.useState(!1),[D,L]=m.useState(""),[O,M]=m.useState(!1),[V,B]=m.useState(""),[F,$]=m.useState(null),[H,A]=m.useState(null),[Q,K]=m.useState(""),[W,ne]=m.useState("reporter"),[Z,G]=m.useState(!1),[te,re]=m.useState(""),se=String((s==null?void 0:s.phase)||(t?"unavailable":"unselected")),ee=Array.isArray(s==null?void 0:s.issues)?s.issues:[],ue=XY(s),de=ue.reduce((pe,He)=>pe+jb(He.issues),0),me=Array.isArray(s==null?void 0:s.artifacts)?s.artifacts:[];Array.isArray(s==null?void 0:s.optionalGaps)&&s.optionalGaps;const Me=s!=null&&s.nextAction&&typeof s.nextAction=="object"?s.nextAction:null,Se=tJ(s,Me),_e=KY(s,Se),Fe=me.filter(pe=>!QR({...pe,href:Ic(pe)})),at=m.useMemo(()=>BY(Se),[Se]);m.useEffect(()=>{x!=="all"&&(at.some(pe=>pe.key===x)||_("all"))},[x,at]);const mt=Se.filter(pe=>HY(pe,x)),Te=zY(mt),it=nJ(s),jt=it.filter(pe=>rJ(pe,g)),Vt=mt.filter(pe=>Pv(pe)).length,kt=s!=null&&s.collaboration&&typeof s.collaboration=="object"?s.collaboration:{},Mt=kt.activeAction&&typeof kt.activeAction=="object"?kt.activeAction:null;Array.isArray(s==null?void 0:s.clientObservations)&&s.clientObservations;const ae=String((s==null?void 0:s.rawOutput)||""),ke=s!=null&&s.globalState&&typeof s.globalState=="object"?s.globalState:null,qe=TY(se),tt=m.useCallback(async()=>{const pe=String(t||"").trim();if(!pe){$(null),A(null);return}T(!0),L(""),B("");try{const He=new URLSearchParams({tapdId:pe});e.workflowShare&&He.set("workflowShare",e.workflowShare);const[wt,bt]=await Promise.all([fetch(`/api/prd-workflow/share?${He.toString()}`),fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(pe)}`)]),[ln,Tn]=await Promise.all([wt.json().catch(()=>({})),bt.json().catch(()=>({}))]);if(!wt.ok)throw new Error(ln.error||"读取 Workflow 分享状态失败");bt.ok&&A(Tn.collaboration||null);let An=ln.share||null;const en=ln.canCreate===!0&&!e.workflowShare;if(M(en),!An&&en){const bn=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:pe})}),nr=await bn.json().catch(()=>({}));if(!bn.ok)throw new Error(nr.error||"生成 Workflow 分享链接失败");if(An=nr.share||null,!Tn.collaboration){const fn=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(pe)}`),kn=await fn.json().catch(()=>({}));fn.ok&&A(kn.collaboration||null)}}$(An)}catch(He){L(String(He.message||He))}finally{T(!1)}},[e,t]),Ee=m.useRef(0),Dt=m.useCallback(()=>{N(!0),tt()},[tt]);m.useEffect(()=>{!r||r===Ee.current||(Ee.current=r,Dt())},[r,Dt]);const nn=async()=>{if(!(!t||z||e.workflowShare)){E(!0),L(""),B("");try{const pe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),He=await pe.json().catch(()=>({}));if(!pe.ok)throw new Error(He.error||"生成 Workflow 分享链接失败");$(He.share||null),M(!0);const wt=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(t)}`),bt=await wt.json().catch(()=>({}));wt.ok&&A(bt.collaboration||null)}catch(pe){L(String(pe.message||pe))}finally{E(!1)}}},Kt=async()=>{const pe=await Rb((F==null?void 0:F.shortUrl)||(F==null?void 0:F.url)||"");B(pe?"已复制":"复制失败")},yt=async()=>{if(!(!t||z||!(F!=null&&F.canManage))){E(!0),L(""),B("");try{const pe=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),He=await pe.json().catch(()=>({}));if(!pe.ok)throw new Error(He.error||"取消 Workflow 分享链接失败");$(null),M(!0)}catch(pe){L(String(pe.message||pe))}finally{E(!1)}}},Cn=async(pe=Q,He=W)=>{const wt=String(pe||"").trim();if(!(!t||!wt||Z)){G(!0),L("");try{const bt=await fetch("/api/prd-workflow/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,username:wt,role:He})}),ln=await bt.json().catch(()=>({}));if(!bt.ok)throw new Error(ln.error||"更新成员权限失败");A(ln.collaboration||null),K("")}catch(bt){L(String(bt.message||bt))}finally{G(!1)}}},ie=async pe=>{const He=String((pe==null?void 0:pe.userId)||"").trim();if(!(!t||!He||te)){re(He),L("");try{const wt=await fetch("/api/prd-workflow/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,memberUserId:He})}),bt=await wt.json().catch(()=>({}));if(!wt.ok)throw new Error(bt.error||"移除成员授权失败");A(bt.collaboration||null)}catch(wt){L(String(wt.message||wt))}finally{re("")}}},Ce=(F==null?void 0:F.shortUrl)||(F==null?void 0:F.url)||"",Ge=(H==null?void 0:H.role)==="owner";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--${se.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:U_(se)}),i.jsx("h1",{children:(s==null?void 0:s.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})," · ",e.workflowDemo?"本地只读示例":"独立需求 Workflow"]}):i.jsx(i.Fragment,{children:"尚未选择 TAPD 需求"})}),a?i.jsx("p",{className:"af-prd-workflow-error",children:a}):null,Mt||kt.subscribers?i.jsxs("div",{className:"af-prd-workflow-collab",children:[Mt?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),Mt.title||Mt.action||"Workflow action"," 执行中",Mt.userId?i.jsx("small",{children:Mt.userId}):null]}):null,kt.subscribers?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),kt.subscribers," 个连接"]}):null]}):null]}),i.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:pe=>{pe.preventDefault(),d==null||d()},children:[i.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:qe.map(pe=>i.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${pe.status}`,children:[i.jsx("span",{"aria-hidden":"true"}),i.jsx("small",{children:pe.label})]},pe.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:pe=>n(pe.target.value),readOnly:e.workflowDemo,placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),i.jsxs("button",{type:"submit",disabled:o,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:o?"hourglass_empty":"sync"}),o?"读取中":t?"刷新":"读取"]})]})]})]}),f?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:f.message||"当前 workflow 状态和执行前不一致。"})]})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"执行时 revision"}),i.jsx("dd",{children:f.expectedRevision||"空"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前 revision"}),i.jsx("dd",{children:f.currentRevision||"未知"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前状态"}),i.jsx("dd",{children:[U_(f.currentPhase),f.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),i.jsx("div",{className:"af-prd-workflow-conflict__actions",children:i.jsx("button",{type:"button",onClick:()=>d==null?void 0:d(),disabled:o||l,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:Se.length?`${Vt}/${mt.length} 已完成${x!=="all"?` · 共 ${Se.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),Me&&Cm(Me)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:Me.command||co(Me,0)})]}):null]}),at.length?i.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[i.jsxs("button",{type:"button",className:x==="all"?"is-active":"","aria-pressed":x==="all",onClick:()=>_("all"),children:["全部 ",i.jsx("span",{children:Se.length})]}),at.map(pe=>i.jsxs("button",{type:"button",className:x===pe.key?"is-active":"","aria-pressed":x===pe.key,onClick:()=>_(pe.key),children:[pe.label," ",i.jsx("span",{children:pe.count})]},pe.key))]}):null,i.jsx("div",{className:"af-prd-workflow-action-list",children:mt.length?Te.map(pe=>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:pe.day}),i.jsx("small",{children:"北京时间"})]}),i.jsx("div",{className:"af-prd-workflow-action-day__items",children:pe.items.map(({item:He,index:wt})=>{const bt=ba(He.status),ln=ua(He)==="observation"&&bt==="done"?"observed":bt,Tn=Rv(He),An=FY(He),en=VY(He),bn=MY(He,wt),nr=$Y(He);return i.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${ln}`,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:[An?i.jsx("time",{dateTime:_m(He),children:An}):null,i.jsx("strong",{children:bn})]}),nr?i.jsx("p",{children:nr}):null,en.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:en.map(fn=>i.jsxs("span",{className:`af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--${fn.label==="Issue"?"issue":"platform"}`,title:`${fn.label} · ${fn.value}`,children:[i.jsx("b",{children:fn.label}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:fn.value})]},`${fn.label}-${fn.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:WY(He)})]}),Tn.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Tn.map(fn=>i.jsxs("a",{href:fn.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:fn.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${fn.label}-${fn.href}`))}):null]})]},He.id||He.actionId||`${co(He,wt)}-${wt}`)})})]},pe.day)):i.jsxs("div",{className:"af-prd-workflow-action-empty",children:[i.jsx("strong",{children:t?Se.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),i.jsx("p",{children:t?Se.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(CX,{globalState:ke,tapdId:t}),Fe.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:Fe.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:Fe.map((pe,He)=>{const wt=Ic(pe),bt=String(pe.label||pe.title||pe.kind||wt||`Artifact ${He+1}`);return wt?i.jsxs("a",{href:wt,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:bt}),i.jsx("small",{children:pe.kind||wt})]},`${wt}-${He}`):i.jsxs("div",{children:[i.jsx("span",{children:bt}),i.jsx("small",{children:pe.kind||""})]},`${bt}-${He}`)})})]}):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:_e.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:_e.length?_e.map(pe=>{const He=String(pe.title||pe.label||"ai-doc").trim(),wt=[pe.label&&pe.label!==He?pe.label:"",pe.platform,pe.issueKey].filter(Boolean);return i.jsxs("a",{className:"af-prd-ai-doc",href:pe.href,target:"_blank",rel:"noreferrer",title:He,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:He}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:wt.join(" · ")||pe.kind||"ai-doc"})]},pe.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:de||ee.length})]}),i.jsx("div",{className:"af-prd-workflow-issues",children:ue.length?ue.map(pe=>i.jsxs("div",{className:"af-prd-workflow-epic",children:[i.jsxs("div",{className:"af-prd-workflow-epic__head",children:[i.jsx("strong",{children:pe.title||pe.key}),i.jsx("small",{children:jb(pe.issues)})]}),pe.issues.map((He,wt)=>i.jsx(BM,{row:He,index:wt},$i((He==null?void 0:He.issue)||{},wt)))]},pe.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:[jt.length,"/",it.length]})]}),i.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([pe,He])=>i.jsx("button",{type:"button",className:g===pe?"is-active":"",onClick:()=>k(pe),children:He},pe))}),i.jsx("div",{className:"af-prd-workflow-audit",children:jt.length?jt.map((pe,He)=>i.jsxs("div",{children:[i.jsx("strong",{children:co(pe,He)}),i.jsx("small",{children:[pe.status,pe.type,_m(pe)].filter(Boolean).join(" · ")})]},pe.id||`${pe.type}-${He}`)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),ae||c?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:c||ae})]}):null]})]}),S?pr.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":"需求协作",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:()=>N(!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("section",{className:"af-prd-workflow-access-panel","aria-label":"Workflow 成员权限",children:[i.jsxs("div",{className:"af-prd-workflow-access-panel__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"成员权限"}),i.jsx("small",{children:"TAPD Owner 自动管理;TAPD 参与人默认只读"})]}),((Be=H==null?void 0:H.authority)==null?void 0:Be.type)==="tapd"?i.jsx("span",{children:"TAPD 已同步"}):i.jsx("span",{children:"待 TAPD 同步"})]}),Ge?i.jsxs("div",{className:"af-workspace-member-add af-prd-workflow-member-add",children:[i.jsx("input",{type:"text",value:Q,onChange:pe=>K(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"&&Q.trim()&&!Z&&(pe.preventDefault(),Cn())},placeholder:"输入 AgentFlow 用户名","aria-label":"成员用户名"}),i.jsxs("select",{value:W,onChange:pe=>ne(pe.target.value),"aria-label":"成员权限",children:[i.jsx("option",{value:"reporter",children:"可上报"}),i.jsx("option",{value:"viewer",children:"只读"})]}),i.jsx("button",{type:"button",disabled:Z||!Q.trim(),onClick:()=>void Cn(),children:Z?"保存中...":"保存权限"})]}):null,i.jsx("div",{className:"af-workspace-member-list",children:((H==null?void 0:H.members)||[]).map(pe=>{const He=pe.role==="owner"||pe.userId===(H==null?void 0:H.ownerId),wt=pe.source==="explicit",bt=He?"需求 Owner":pe.role==="reporter"?"可上报":pe.source==="tapd"?"TAPD 参与人 · 只读":"只读";return i.jsxs("div",{className:"af-workspace-member-row",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:He?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:pe.username||pe.userId}),i.jsx("small",{children:bt})]}),Ge&&!He?i.jsxs("div",{className:"af-prd-workflow-member-actions",children:[i.jsxs("select",{value:pe.role==="reporter"?"reporter":"viewer",disabled:Z||!!te,onChange:ln=>void Cn(pe.username||pe.userId,ln.target.value),"aria-label":`${pe.username||pe.userId} 的权限`,children:[i.jsx("option",{value:"reporter",children:"可上报"}),i.jsx("option",{value:"viewer",children:"只读"})]}),wt?i.jsx("button",{type:"button",disabled:te===pe.userId,onClick:()=>void ie(pe),children:te===pe.userId?"移除中...":"移除授权"}):null]}):null]},pe.userId)})}),(vt=(Et=H==null?void 0:H.authority)==null?void 0:Et.unresolvedParticipants)!=null&&vt.length?i.jsxs("p",{className:"af-prd-workflow-access-panel__unresolved",children:["尚未匹配 AgentFlow 账号:",H.authority.unresolvedParticipants.join("、")]}):null]}),i.jsx("div",{className:"af-prd-workflow-share-divider",children:i.jsx("span",{children:"只读链接"})}),i.jsxs("p",{className:"af-display-link-modal__empty",children:["通过链接分享 TAPD ",t,";不会授予上报权限,也不会分享当前 Project、画布或项目文件。"]}),I?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!I&&Ce?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:Ce,readOnly:!0,onFocus:pe=>pe.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:z,onClick:()=>void Kt(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),V||"复制链接"]}),F.canManage?i.jsx("button",{type:"button",disabled:z,onClick:()=>void yt(),children:z?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!I&&!Ce&&O?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:z,onClick:()=>void nn(),children:z?"生成中...":"生成分享链接"}):null,D?i.jsx("div",{className:"af-flow-snippet-error",children:D}):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:()=>N(!1),children:"完成"})})]})}),document.body):null]})}function xC(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 Ju(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function EX(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],f=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(f)?[]:{}),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 IX(){var Wj,Bj,Hj,Vj;const{t:e,i18n:t}=qr(),{navigate:n}=os(),r=tu(),s=xn(),o=w6(),a=m.useMemo(wY,[]),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]),[f,p]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=x6([]),[k,x]=b6([]),_=m.useRef([]),S=m.useRef([]),N=m.useRef(null),[I,T]=m.useState(()=>Ph(null,[])),z=m.useRef(I),[E,D]=m.useState(null),L=m.useRef(null),O=m.useRef(!1),[M,V]=m.useState([]),B=m.useRef(new Map),F=m.useRef(new Map),$=m.useRef(new Set),H=m.useRef(new Set),A=m.useRef(null),Q=m.useRef(null),K=m.useRef([]),W=m.useRef(null),ne=m.useRef(null),Z=m.useRef(null),[G,te]=m.useState(null),[re,se]=m.useState({}),ee=m.useRef({}),ue=m.useRef(!1),de=m.useRef(null),me=m.useRef(""),Me=m.useRef(null),Se=m.useRef(Promise.resolve()),_e=m.useRef({running:!1,pending:null}),Fe=m.useRef(0),at=m.useRef(!1),mt=m.useRef(0),Te=m.useRef(null),it=m.useRef(!1),jt=m.useRef(!1),Vt=m.useRef(""),kt=m.useRef(!1),Mt=m.useRef(null),ae=m.useRef(!1),ke=m.useRef(new Set),qe=m.useRef(!1),tt=m.useRef(!1),Ee=m.useCallback(()=>ZG({nodeInteraction:ae.current,pointerCount:ke.current.size,viewportInteraction:qe.current}),[]),Dt=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),nn=m.useRef(!1),Kt=m.useRef(null),[yt,Cn]=m.useState([]),ie=m.useRef([]),[Ce,Ge]=m.useState(""),[Be,Et]=m.useState("nodes"),[vt,pe]=m.useState([]),[He,wt]=m.useState(!1),[bt,ln]=m.useState(""),[Tn,An]=m.useState(!1),[en,bn]=m.useState({name:"",id:"",description:""}),[nr,fn]=m.useState(!1),[kn,rr]=m.useState(""),[vs,sr]=m.useState(""),Gn=m.useRef(null),[Nr,_r]=m.useState(!1),[Yn,Lr]=m.useState(!1),[Or,ce]=m.useState(""),[ge,et]=m.useState(null),[rt,Bt]=m.useState(()=>Aw()),[Wn,Cr]=m.useState(""),[Ar,wr]=m.useState(!1),[ct,Xt]=m.useState(""),[Qt,ir]=m.useState(!1),[ot,xr]=m.useState([]),[Ws,Hi]=m.useState(!1),[Bs,oe]=m.useState(""),[ve,Re]=m.useState(""),[Nt,$t]=m.useState(""),[rn,vn]=m.useState(!1),[Vn,Ss]=m.useState(""),[js,U]=m.useState(""),[we,$e]=m.useState(!1),[Ae,Ze]=m.useState("nodes"),[En,Ft]=m.useState(""),[Rn,cr]=m.useState(0),[br,sn]=m.useState(""),Qv=m.useRef(""),[gt,Ns]=m.useState(null),Zv=m.useRef(null),[W$,xl]=m.useState(""),[bl,eS]=m.useState([]),[tS,B$]=m.useState(""),[je,H$]=m.useState(!a.adminOwnerId),[zf,V$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Lt,Wf]=m.useState(null),[K$,Rg]=m.useState(!1),[Mg,nS]=m.useState(!1),[rS,jo]=m.useState(""),[uu,sS]=m.useState(""),[iS,oS]=m.useState(""),[Hs,q$]=m.useState(null),[$g,aS]=m.useState("viewer"),[du,lS]=m.useState(!1),[U$,G$]=m.useState(0),[Mn,kl]=m.useState(null),[Y$,ka]=m.useState(!1),[Lg,vl]=m.useState({}),[Bf,cS]=m.useState(!1),[uS,fu]=m.useState(""),[Og,J$]=m.useState(""),[X$,Sl]=m.useState(()=>new Set),[Dg,Fg]=m.useState(""),[pu,zg]=m.useState({nodeId:"",query:""}),[dS,fS]=m.useState(!1),Wg=m.useRef(null),pS=m.useRef(null),hS=m.useRef(""),[Bg,mS]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[Q$,gS]=m.useState(!1),[va,Z$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Vi,eL]=m.useState(""),[Vs,tL]=m.useState([]),[yS,wS]=m.useState(!1),[Ks,hu]=m.useState([]),[jl,nL]=m.useState([]),[xS,rL]=m.useState(!1),[bS,kS]=m.useState([]),[vS,SS]=m.useState([]),[Jn,sL]=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""}}),[dn,mu]=m.useState(null),[iL,jS]=m.useState(!1),[oL,Nl]=m.useState(""),[Hg,NS]=m.useState(!1),[Vg,gu]=m.useState(""),[_s,yu]=m.useState(null),[Kg,_S]=m.useState(!1),[wu,_l]=m.useState(null),CS=m.useCallback(w=>{Gn.current&&window.clearTimeout(Gn.current),sr(w),Gn.current=window.setTimeout(()=>{sr(""),Gn.current=null},3800)},[]),Ur=m.useCallback(w=>{const j=Array.isArray(w)||w instanceof Set?w:[w];for(const C of j){const P=String(C||"").trim();P&&($.current.add(P),H.current.add(P))}$.current.size!==0&&(A.current==null&&(A.current=window.requestAnimationFrame(()=>{A.current=null;const C=Array.from($.current);$.current.clear(),C.forEach(P=>o(P))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const C=Array.from(H.current);H.current.clear(),C.forEach(P=>o(P))},80))},[o]);m.useEffect(()=>()=>{A.current!=null&&window.cancelAnimationFrame(A.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),H.current.clear()},[]);const AS=m.useCallback((w,j)=>{const C=String(w||"").trim(),P=Tm(j);!C||!P||(g(R=>R.map(q=>{var le;if(q.id!==C)return q;const X=Tm((le=q.data)==null?void 0:le.displaySize),J=X&&X.width===P.width&&X.height===P.height,Y=Math.round(Number(q.width||0))===P.width&&Math.round(Number(q.height||0))===P.height;return J&&Y?q:{...q,width:P.width,height:P.height,data:{...q.data,nodeSize:P,displaySize:P}}})),Ur(C))},[Ur,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Bg)))}catch{}},[Bg]);const qg=m.useCallback(w=>{const j=Wg.current;if(!j)return null;const C=j.getBoundingClientRect(),P=16,R=150,q=230,X=C.top+P,J=C.bottom-P,Y=Math.max(R,J-X-q);return Math.min(Math.max(w-X,R),Y)},[]),aL=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const j=Wg.current;if(!j)return;let C=qg(w.clientY);if(!Number.isFinite(C))return;gS(!0),mS(C);const P=q=>{q.preventDefault();const X=qg(q.clientY);Number.isFinite(X)&&(C=X,j.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},R=()=>{mS(C),gS(!1),window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",R,!0),window.removeEventListener("pointercancel",R,!0)};window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",R,!0),window.addEventListener("pointercancel",R,!0)},[qg]);m.useEffect(()=>()=>{Gn.current&&window.clearTimeout(Gn.current),Kt.current&&window.clearTimeout(Kt.current)},[]);const[lL,ES]=m.useState(()=>new Set),[Hf,Ug]=m.useState(!1),Gg=m.useRef(null),IS=m.useRef(null),PS=m.useRef(null),[cL,uL]=m.useState({}),[Sa,Yg]=m.useState(""),[ls,TS]=m.useState(!1),[ja,Cl]=m.useState([]),[qs,Xn]=m.useState([]),[Gr,Cs]=m.useState("workspace"),[xu,Al]=m.useState(!1),RS=m.useRef(null),Jg=m.useRef(null),[bu,El]=m.useState(null),[dL,Xg]=m.useState(!0),[MS,$S]=m.useState(""),[Na,No]=m.useState({}),[Dr,Qg]=m.useState(null),[LS,Zg]=m.useState(!1),Il=m.useMemo(()=>LS?jY(Dr):"",[LS,Dr]),[ku,Vf]=m.useState(!0);m.useEffect(()=>{Il&&Vf(NY(Il))},[Il]),m.useEffect(()=>{if(Il)try{window.localStorage.setItem(Il,ku?"true":"false")}catch{}},[ku,Il]);const[ey,Kf]=m.useState(!1),[ty,OS]=m.useState(!1),[ny,DS]=m.useState("pan"),[FS,fL]=m.useState({}),vu=m.useRef({}),[zS,_a]=m.useState({}),Su=m.useRef(new Map),ju=m.useRef(new Set),[WS,Pl]=m.useState(()=>new Set),[ry,Tl]=m.useState({}),[BS,HS]=m.useState(""),[ude,ye]=m.useState(""),[VS,Us]=m.useState("loading"),[KS,Gs]=m.useState("正在载入 Project"),Ki=m.useMemo(()=>SY(a),[a]),[qS,US]=m.useState(""),Nu=a.flowSource||"user",GS=m.useMemo(()=>new Set(Object.values(FS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[FS]),qi=m.useCallback(w=>{const j=vu.current||{},C=typeof w=="function"?w(j):w,P=C&&typeof C=="object"&&!Array.isArray(C)?C:{};return vu.current=P,fL(P),P},[]),YS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Lt!=null&&Lt.role?Lt.role==="owner":Nu==="user"||Nu==="workspace")),_u=!!(!a.adminOwnerId&&Nu==="workspace"&&(Lt!=null&&Lt.role)&&Lt.role!=="owner"),JS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[VS]||"同步状态",gi=m.useCallback(()=>{!ue.current||!je||(kt.current=!1,Fe.current+=1,at.current=!0,Us("dirty"),Gs("本地修改等待同步"))},[je]);m.useEffect(()=>{a.flowId&&tz(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{p(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{Cl([]),Xn([]),Cs("workspace"),Xg(!0)},[a]);const $n=m.useCallback(async()=>{const w=Wr(a),j=await fetch(`/api/workspace/files?${w.toString()}`),C=await j.json();if(!j.ok)throw new Error(C.error||"读取 workspace 失败");const P=C.files||[];eS(P),Sl(new Set(TM(P))),B$(C.root||"")},[a]),qf=m.useCallback(async()=>{wt(!0),ln("");try{const w=await fetch("/api/marketplace/flow-snippets"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取流程片段失败");pe(Array.isArray(j.snippets)?j.snippets:[])}catch(w){ln(String(w.message||w)),pe([])}finally{wt(!1)}},[]),XS=m.useCallback(async(w,j,C)=>{var Y,le,he;if(!ue.current)return;if(!je)throw ye("Readonly workspace"),Us("readonly"),Gs("只读 Project"),new Error("Readonly workspace");Us("saving"),Gs("正在同步修改");const P=Yl(w,j,ee.current);P.ui={...P.ui||{},displayPage:rC(z.current,w)};const R=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:P,baseRevision:me.current,baseGraph:Me.current,clientId:Dt.current})}),q=await R.json().catch(()=>({}));if(!R.ok){if(R.status===409||R.status===428){const Ne=Array.isArray(q.conflictItems)?q.conflictItems:[];kl({currentRevision:String(q.currentRevision||""),message:q.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(q.conflictPaths)?q.conflictPaths:[],conflictItems:Ne,mergeGraph:q.mergeGraph||null,currentGraph:q.currentGraph||null}),vl(Object.fromEntries(Ne.map((We,Le)=>[String(Le),{mode:"local",manual:Ju(We)}]))),fu(""),ka(Ne.length>0),Us("conflict"),Gs(q.error||"存在需要处理的字段冲突");const Ve=Array.isArray(q.conflictPaths)?q.conflictPaths:[],ze=Ve.length?`${q.error||"Workspace 已被其他成员更新"}:${Ve.join("、")}`:q.error||"Workspace 已被其他成员更新",Ke=new Error(ze);throw Ke.code="WORKSPACE_REVISION_CONFLICT",Ke.currentRevision=q.currentRevision||"",Ke}const fe=new Error(q.error||"保存 workspace graph 失败");throw Us("error"),Gs(fe.message),fe}const X=Fe.current!==C,J=QG({savedGraph:q.graph,sentGraph:P,savedRevision:q.revision,currentRevision:me.current});if(me.current=J.revision,Me.current=J.graph,!X){if(ee.current=((Y=q.graph)==null?void 0:Y.instances)||P.instances,se(ee.current),q.merged&&q.graph){const fe=Yu(q.graph,yt),Ne=Ph((he=(le=q.graph)==null?void 0:le.ui)==null?void 0:he.displayPage,fe.nodes);ee.current=fe.instances,se(fe.instances),g(fe.nodes),x(fe.edges),z.current=Ne,T(Ne)}at.current=!1}return _a(Qp(q.workspaceSchedules||[])),kl(null),ka(!1),Us(X?"dirty":"synced"),Gs(X?"本地仍有修改等待同步":"所有修改已同步"),ye(X?"已保存上一版,本地新修改正在排队":q.merged?"Workspace graph merged and saved":"Workspace graph saved"),q},[a,yt,x,g,je]),on=m.useCallback((w=b,j=k)=>{const C=_e.current,P={nextNodes:w,nextEdges:j,saveEditVersion:Fe.current,waiters:[]},R=new Promise((J,Y)=>{P.waiters.push({resolve:J,reject:Y})});if(C.running)return C.pending=H_(C.pending,P),R;C.running=!0;const q=async()=>{let J=P;for(;J;){C.pending&&(J=H_(J,C.pending),C.pending=null);try{const Y=await XS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:le})=>le(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Us("error"),Gs(String(Y.message||Y))),J.waiters.forEach(({reject:le})=>le(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&C.pending&&(C.pending.waiters.forEach(({reject:le})=>le(Y)),C.pending=null)}J=C.pending,C.pending=null}C.running=!1},X=Se.current.catch(()=>{}).then(q);return Se.current=X,R},[k,b,XS]),pL=m.useCallback(w=>{var C;const j=(C=w==null?void 0:w.extra)!=null&&C.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};ee.current=j,se(j),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),sn(""),te(null)},[x,g]),hL=m.useMemo(()=>({instances:re}),[re]),mL=CG({nodes:b,edges:k,extra:hL,enabled:ue.current,onRestore:pL}),{resetHistory:Cu,undo:QS,redo:ZS}=mL,As=m.useCallback(async(w={})=>{var Oe,zt;const j=(w==null?void 0:w.background)===!0,C=mt.current+1;mt.current=C;const P=Fe.current,R=me.current;j||(ue.current=!1);const q=iY({background:j}),X=Wr(a);let J=null,Y;if(!q.nodes&&!q.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const De=Wr(a);De.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[dt,Pt]=await Promise.all([fetch(`/api/nodes?${De.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),$n()]);if(J=await dt.json(),!dt.ok)throw new Error(J.error||"读取节点定义失败");Y=Pt}const le=await Y.json();if(!Y.ok)throw new Error(le.error||"读取 workspace graph 失败");const he=XG({background:j,requestId:C,currentRequestId:mt.current,dirty:at.current,startedEditVersion:P,currentEditVersion:Fe.current,startedRevision:R,currentRevision:me.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return ye("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const fe=j?ie.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(De=>!lY.has(De.id)),hY,pY,dY,fY,cY,uY];j||(ie.current=fe,Cn(fe));const Ne=le.graph||JSON.parse(localStorage.getItem(aY)||"null")||{},Ve=Yu(Ne,fe),ze=Ph((Oe=Ne==null?void 0:Ne.ui)==null?void 0:Oe.displayPage,Ve.nodes),Ke=!O.current;let We=L.current;if(Ke){let De=null;try{De=JSON.parse(window.localStorage.getItem(u)||"null")}catch{De=null}We=Tb(De)||Tb((zt=Ne==null?void 0:Ne.ui)==null?void 0:zt.viewport)}const Le=j?UG(Me.current,Ne):null;if(j&&(Le!=null&&Le.safe)){const De=Le.nodesChanged?GG(_.current,Ve.nodes,Le.changedNodeIds):_.current,dt=Le.edgesChanged?YG(S.current,Ve.edges):S.current,Pt=Le.displayPageChanged||!lo(z.current,ze),Bl=Le.nodesChanged||Le.edgesChanged||Pt;if(Bl&&(kt.current=!0),Le.nodesChanged){const yi=JG(ee.current,Ve.instances,Le.changedNodeIds);ee.current=yi,_.current=De,se(yi),g(De)}if(Le.edgesChanged&&(S.current=dt,x(dt)),Pt&&(z.current=ze,T(ze)),Bl&&Cu(De,dt,{instances:Le.nodesChanged?ee.current:Ve.instances}),Le.nodesChanged||Pt){const yi=new Set(ze.nodeIds);V(Ea=>{const Ia=Ea.filter(cp=>yi.has(cp));return Ia.length===Ea.length?Ea:Ia})}}else ee.current=Ve.instances,_.current=Ve.nodes,S.current=Ve.edges,z.current=ze,kt.current=!0,se(Ve.instances),g(Ve.nodes),x(Ve.edges),T(ze),V([]),Cu(Ve.nodes,Ve.edges,{instances:Ve.instances});const qt=Qp(le.workspaceSchedules||[]);_a(De=>lo(De,qt)?De:qt),me.current=String(le.revision||""),Me.current=Ne,at.current=!1;const st=le.collaboration||null;Wf(De=>lo(De,st)?De:st),V$(le.adminReview||null),kl(null),Ke&&(D(We),L.current=We,O.current=!0);const Ye=le.writable!==!1;return H$(Ye),ye(Ye?"Workspace ready":"Readonly workspace"),Us(Ye?"synced":"readonly"),Gs(Ye?"所有修改已同步":le.adminReview?`管理员只读查看:${le.adminReview.ownerUsername||le.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ue.current=!0,{skipped:!1}},[a,t.language,$n,Cu,x,g,u]),Rl=m.useCallback((w={})=>{if(!ue.current)return;const j=String(w.revision||""),C=w.type==="graph.committed",P=!!(Te.current||it.current||jt.current);if(oY({eventType:w.type,revision:j,currentRevision:me.current,targetRevision:Vt.current,refreshPending:P}))return;if(C&&j&&(Vt.current=j),at.current){jt.current=!1,ye("检测到其他成员的更新;保存时将自动合并");return}if(jt.current=!0,Te.current||it.current)return;const R=async()=>{if(Te.current=null,Ee()){jt.current=!0;return}if(at.current){jt.current=!1,ye("检测到其他成员的更新;保存时将自动合并");return}jt.current=!1,it.current=!0;try{await As({background:!0}),Vt.current=me.current}catch(q){Vt.current="",ye(String(q.message||q))}finally{it.current=!1,jt.current&&!at.current&&(Te.current=window.setTimeout(R,40))}};Te.current=window.setTimeout(R,40)},[As,Ee]),Au=m.useCallback(async(w=Jn)=>{const j=String(w||"").trim();jS(!0),Nl("");try{if(a.workflowDemo){const q=xY(j);if(!q)throw new Error("本地示例数据已失效,请返回迭代页重新载入示例");mu(q),gu(""),yu(null),_l(null);return}const C=Wr(a);C.set("tapdId",j),C.set("runtimeOnly","1");const P=await fetch(`/api/prd-workflow/snapshot?${C.toString()}`),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"读取 PRD Workflow 失败");mu(R.snapshot||null),gu(""),yu(null),_l(null);try{const q=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;j?window.localStorage.setItem(q,j):window.localStorage.removeItem(q)}catch{}}catch(C){Nl(String(C.message||C))}finally{jS(!1)}},[a,Jn]),Ml=m.useCallback(async(w=null,j={})=>{const C=w&&typeof w=="object"?w:dn==null?void 0:dn.nextAction,P=Cm(C);if(!P||Hg)return;const R=(j==null?void 0:j.confirm)===!0,q=String((j==null?void 0:j.expectedRevision)||(dn==null?void 0:dn.revision)||"");NS(!0),Nl(""),R||(gu(""),yu(null),_l(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:Jn,action:P,stage:fl(C),title:co(C,0),...qY(C),dryRun:!R,confirm:R,issueKey:C.issueKey||C.issue_key||"",expectedRevision:q,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&mu(J.snapshot),J.conflict&&_l({...J.conflict,action:C}),new Error(J.error||"执行 PRD Workflow action 失败");gu(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),mu(J.snapshot||dn),_l(null),yu(R?null:{action:C,output:J.output||null,expectedRevision:q,at:new Date().toISOString()})}catch(X){Nl(String(X.message||X))}finally{NS(!1)}},[a,Hg,dn,Jn]),gL=m.useCallback((w=null)=>Ml(w,{confirm:!1}),[Ml]),yL=m.useCallback(()=>{const w=(_s==null?void 0:_s.action)||(dn==null?void 0:dn.nextAction);return Ml(w,{confirm:!0,expectedRevision:(_s==null?void 0:_s.expectedRevision)||""})},[Ml,_s,dn]),wL=m.useCallback(()=>{const w=(wu==null?void 0:wu.action)||(dn==null?void 0:dn.nextAction);return _l(null),Ml(w,{confirm:!1})},[Ml,wu,dn]),xL=m.useCallback(async()=>{var q,X;const w=String(Vg||(dn==null?void 0:dn.rawOutput)||"").trim();if(!w||Kg)return;const j=(_s==null?void 0:_s.action)||(dn==null?void 0:dn.nextAction)||{},C=`Review: ${co(j,0)||(dn==null?void 0:dn.pointer)||Jn||"PRD Workflow"}`,P=/^[\[{]/.test(w),R=w.startsWith("#")?w:`# ${C}
247
-
248
- ${P?`\`\`\`json
249
- ${w}
250
- \`\`\``:w}`;_S(!0),Nl("");try{const J=await fetch("/api/workflow-artifacts/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,workflow:{namespace:"tapd",id:Jn},title:C,markdown:R,action:Cm(j),stage:fl(j),issueKey:j.issueKey||j.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");mu(Y.snapshot||dn);const le=((q=Y.review)==null?void 0:q.shortUrl)||((X=Y.review)==null?void 0:X.url)||"";le&&gu(he=>`${he||w}
251
-
252
- Review link: ${le}`)}catch(J){Nl(String(J.message||J))}finally{_S(!1)}},[a,Vg,_s,Kg,dn,Jn]),bL=m.useCallback(async(w,j)=>{const C={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:j,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},P=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),R=await P.json().catch(()=>({}));if(!P.ok||(R==null?void 0:R.ok)===!1)throw new Error((R==null?void 0:R.error)||"Publish failed");return await As(),ye(`Published node ${R.definitionId||R.id||C.packageId}`),R},[a,As]),Ca=m.useCallback((w=qs)=>{const j=Array.isArray(w)?w:[],P=[...j].reverse().find(R=>(R==null?void 0:R.status)==="running"||(R==null?void 0:R.status)==="stopping")||[...j].reverse().find(R=>R==null?void 0:R.id);return String((P==null?void 0:P.id)||"workspace")},[qs]),kL=m.useCallback(w=>{const j=String(w||"").trim();!j||j==="workspace"||Xn(C=>{const P=(Array.isArray(C)?C:[]).filter(R=>R.id!==j);return Cs(R=>R===j?Ca(P):R),P})},[Ca]);m.useCallback((w="")=>{Al(!0),El(null),Ns(null),Cs(w||Ca())},[Ca]);const ej=m.useCallback((w={})=>{El({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),Al(!1),Ns(null),sn("")},[]),sy=m.useCallback(async(w="")=>{const j=String(w||"").trim();if(!(!j||!je)){HS(j),ye(`Optimizing run: ${j}`);try{await on(_.current,S.current);const C=Yl(_.current,S.current,ee.current),P=gC(_.current,ee.current,j,Vi),R=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:j,graph:C,model:P})}),q=await R.json().catch(()=>({}));if(!R.ok||q.ok===!1)throw new Error(q.error||"优化失败");const X=q.graph||C,J=Yu(X,yt);ee.current=J.instances,se(J.instances),g(J.nodes),x(J.edges),_a(Qp(q.workspaceSchedules||[])),Cu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(q.optimized)?q.optimized.length:0;ye(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(C){ye(String(C.message||C))}finally{HS("")}}},[Vi,S,a,_,yt,Cu,on,x,g,je]),tj=m.useCallback(async(w="")=>{const j=String(w||"").trim(),C=vu.current||{},P=Object.entries(C).find(([Y,le])=>Y===j||String((le==null?void 0:le.runNodeId)||"")===j)||Object.entries(C)[0]||null,R=(P==null?void 0:P[0])||"",q=(P==null?void 0:P[1])||null,X=String((q==null?void 0:q.runNodeId)||j||"").trim();if((q==null?void 0:q.status)==="stopping")return;const J=new Set([X,...Array.isArray(q==null?void 0:q.plannedNodeIds)?q.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));R&&qi(Y=>{const le={...Y};return le[R]&&(le[R]={...le[R],status:"stopping"}),le}),ye(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Xn(Y=>Y.map(le=>(R?le.id===R:!X||le.runNodeId===X)&&le.status==="running"?{...le,status:"stopping"}:le));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:R,runNodeId:X})}),le=await Y.json().catch(()=>({}));if(!Y.ok||(le==null?void 0:le.stopped)!==!0)throw new Error(le.error||"Workspace run stop failed");const he=R?Su.current.get(R):null;he&&(he.abort(),Su.current.delete(R)),R&&qi(fe=>{const Ne={...fe};return delete Ne[R],Ne}),Pl(fe=>{const Ne=new Set(fe);for(const Ve of J)Ne.delete(Ve);return Ne}),Tl(fe=>{var Ve;const Ne={...fe};for(const ze of J)ze&&(!Ne[ze]||((Ve=Ne[ze])==null?void 0:Ve.status)==="running")&&(Ne[ze]={status:"stopped"});return Ne}),ye(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),Xn(fe=>fe.map(Ne=>(R?Ne.id===R:!X||Ne.runNodeId===X)?{...Ne,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(Ne.messages)?Ne.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:Ne))}catch(Y){R&&qi(he=>{const fe={...he};return fe[R]&&(fe[R]={...fe[R],status:"running"}),fe});const le=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ye(`停止失败:${le}`),Xn(he=>he.map(fe=>(R?fe.id===R:!X||fe.runNodeId===X)?{...fe,status:"running",messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${le}`,at:Date.now()}].slice(-160)}:fe))}},[a,qi]),Uf=m.useCallback(async()=>{if(a.flowId)try{const w=Wr(a),j=await fetch(`/api/workspace/run/status?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok||!C.running)return;const P=Array.isArray(C.runs)&&C.runs.length?C.runs:[{runId:`run-restored-${C.startedAt||Date.now()}`,runNodeId:C.runNodeId||"",startedAt:C.startedAt||Date.now(),plannedNodeIds:[]}],R={},q=[];for(const X of P){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 le=String((X==null?void 0:X.label)||"").trim()||jw(_.current,ee.current,J,"Workspace Run");R[Y]={id:Y,runNodeId:J,label:le,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&&q.push(J)}if(!Object.keys(R).length)return;qi(X=>({...X,...R})),Pl(X=>{const J=new Set(X);for(const Y of q)J.add(Y);return J}),Tl(X=>{const J={...X};for(const Y of q)J[Y]={status:"running"};return J}),ye(q.length?`Workspace run still running: ${q.join(", ")}`:"Workspace run still running"),Xn(X=>{const J=[...X];for(const[Y,le]of Object.entries(R)){if(J.some(Ne=>Ne.id===Y||["running","stopping"].includes(Ne.status)&&Ne.runNodeId===le.runNodeId))continue;const he=String(le.runNodeId||""),fe=String(le.label||"").trim()||jw(_.current,ee.current,he,"Workspace Run");J.push({id:Y,label:Nw(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:le.status,startedAt:le.startedAt||Date.now(),steps:he?[{id:he,label:Nw(fe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:le.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,_,qi]),nj=m.useCallback(async w=>{if(!je){ye("Readonly workspace");return}if(!w)return;if(Object.values(vu.current||{}).find(st=>String((st==null?void 0:st.runNodeId)||"")===String(w||""))){ye(`Workspace run already running: ${w}`);return}let C=_.current,P=S.current,R=ee.current;const q=Zv.current;if(q!=null&&q.id){const st=C.find(Oe=>Oe.id===q.id),Ye=wC({nodes:C,edges:P,instances:R,selectedNode:st,draft:q,allowRename:!1});if(Ye!=null&&Ye.error){xl(Ye.error),ye(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(C=Ye.nodes,P=Ye.edges,R=Ye.instances,ee.current=R,_.current=C,S.current=P,se(R),g(C),x(P),Ur(Ye.nextId||q.id))}const X=Yl(C,P,R),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=jw(C,R,w,"Workspace Run"),le=Nw(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(zt=>String(zt||"").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 zt=Array.isArray(Oe.conflictNodeIds)&&Oe.conflictNodeIds.length?`: ${Oe.conflictNodeIds.join(", ")}`:"";ye(`Run ${w} conflicts with running ${Oe.runNodeId||Oe.runId}${zt}`);return}}catch(st){ye(String(st.message||st));return}const fe=new Set(he),Ne=Object.values(vu.current||{}).find(st=>(Array.isArray(st==null?void 0:st.plannedNodeIds)?st.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(Ne){const st=(Array.isArray(Ne.plannedNodeIds)?Ne.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));ye(`Run ${w} conflicts with running ${Ne.runNodeId||"workspace run"}${st.length?`: ${st.join(", ")}`:""}`);return}const Ve=new AbortController;Su.current.set(J,Ve),ju.current.delete(J),qi(st=>({...st,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),Pl(st=>new Set([...st,w])),Tl(st=>({...st,[w]:{status:"running"}})),ye(`Running ${le}...`),Cs(J),Xn(st=>[...st.slice(-7),{id:J,label:le,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let ze=w;const Ke=new Map,We=()=>ju.current.has(J),Le=st=>{const Ye=new Set((st||[]).map(Oe=>String(Oe||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),Pl(Oe=>{const zt=new Set(Oe);for(const De of Ye)zt.delete(De);return zt})},qt=(st,Ye)=>{const Oe=new Set((st||[]).map(zt=>String(zt||"").trim()).filter(Boolean));Oe.size||Oe.add(String(w||"")),Tl(zt=>{var dt;const De={...zt};for(const Pt of Oe)Pt&&(!De[Pt]||((dt=De[Pt])==null?void 0:dt.status)==="running")&&(De[Pt]={status:Ye});return De})};try{await on(C,P);const st=gC(C,R,w,Vi),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:me.current,clientId:Dt.current,model:st,selectedSkills:Ks,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(),zt=new TextDecoder;let De="",dt=[],Pt=[];const Bl=(xe,nt)=>{var lt,It;const Je=b.find(Ht=>Ht.id===xe),pt=String(((lt=Je==null?void 0:Je.data)==null?void 0:lt.label)||xe||"").trim(),be=String(nt||((It=Je==null?void 0:Je.data)==null?void 0:It.definitionId)||"").trim();return be&&be!==pt?`${pt} (${be})`:pt},yi=(xe,nt,Je)=>{const pt=String(xe||"").trim();pt&&Xn(be=>be.map(lt=>{if(lt.id!==J)return lt;const Ht=[...Array.isArray(lt.steps)?lt.steps:[]],ht=Ht.findIndex(mn=>mn.id===pt),_t={id:pt,label:Bl(pt,nt),status:Je};ht>=0?Ht[ht]={...Ht[ht],..._t}:Ht.push(_t);const pn=Ht.map((mn,Eo)=>{const Yi=mn.status==="done"?"[done]":mn.status==="failed"?"[failed]":"[running]";return`${Eo+1}. ${Yi} ${mn.label}`}).join(`
253
- `),Zt=Array.isArray(lt.messages)?lt.messages:[],cn=Zt.findIndex(mn=>mn.kind==="run-summary"),Sn={role:"assistant",kind:"run-summary",text:pn||"准备运行...",at:Date.now()},Ut=[...Zt];return cn>=0?Ut[cn]=Sn:Ut.unshift(Sn),{...lt,steps:Ht,messages:Ut.slice(-160)}}))},Ea=(xe,nt)=>{var Yj,Jj,Xj,Qj,Zj,e0,t0,n0,r0,s0;const Je=String(xe||"").trim(),pt=String(nt||"").trim();if(!Je||!pt)return;const be=(Yj=ee.current)==null?void 0:Yj[Je];if(!ui(be==null?void 0:be.definitionId))return;const lt=fa(be==null?void 0:be.input,"displayType","markdown"),It=OM(lt),Ht=DM(Je),ht=yt.find(Fr=>Fr.id===It),_t=fC(ht==null?void 0:ht.inputs,It,pt),pn=fC(ht==null?void 0:ht.outputs,It,pt),Zt=String((be==null?void 0:be.label)||Je||"一键任务").trim(),cn={...ee.current||{},[Je]:{...be||{},output:hC(be==null?void 0:be.output)},[Ht]:{...((Jj=ee.current)==null?void 0:Jj[Ht])||{},definitionId:It,label:Zt,role:"normal",body:pt,input:_t,output:pn,sourceContextRunNodeId:Je,displayReloadKey:String(Date.now())}};ee.current=cn,se(cn);const Sn=_.current||[],Ut=Sn.find(Fr=>Fr.id===Je),mn=Sn.find(Fr=>Fr.id===Ht),Eo=Number(((Xj=Ut==null?void 0:Ut.measured)==null?void 0:Xj.width)||(Ut==null?void 0:Ut.width)||((Zj=(Qj=Ut==null?void 0:Ut.data)==null?void 0:Qj.nodeSize)==null?void 0:Zj.width)||520),Yi=(mn==null?void 0:mn.position)||{x:Number(((e0=Ut==null?void 0:Ut.position)==null?void 0:e0.x)||0)+Eo+120,y:Number(((t0=Ut==null?void 0:Ut.position)==null?void 0:t0.y)||0)},dr=((n0=mn==null?void 0:mn.data)==null?void 0:n0.displaySize)||((r0=mn==null?void 0:mn.data)==null?void 0:r0.nodeSize)||{width:_b,height:Cb},wi=Sb({id:Ht,type:Ec,position:Yi,width:Number(dr.width)||_b,height:Number(dr.height)||Cb,data:{label:Zt,definitionId:It,role:"normal",body:pt,inputs:_t,outputs:pn,sourceContextRunNodeId:Je,displayReloadKey:cn[Ht].displayReloadKey,nodeSize:dr,displaySize:dr}},cn,yt),Io=Sn.map(Fr=>{if(Fr.id===Je){const{width:dde,height:fde,measured:pde,...v2}=Fr,{nodeSize:hde,displaySize:mde,...hp}=Fr.data||{};return{...v2,data:{...hp,outputs:hC(hp==null?void 0:hp.outputs),contextRunResultNonce:Date.now()}}}return Fr.id===Ht?{...wi,selected:Fr.selected}:Fr});mn||Io.push(wi),_.current=Io,g(Io);const Po=S.current||[],pp=FM(It),xy=pC((be==null?void 0:be.output)||((s0=Ut==null?void 0:Ut.data)==null?void 0:s0.outputs),"output",["content","result"],["text"]),b2=pC(_t,"input",[pp,"content"],["text"]),k2={id:`we-${Je}-${Ht}`,source:Je,target:Ht,sourceHandle:xy,targetHandle:b2,markerEnd:{type:Ai.ArrowClosed}},Gj=[...Po.filter(Fr=>!(Fr.source===Je&&Fr.target===Ht)),k2];S.current=Gj,x(Gj),window.requestAnimationFrame(()=>{o(Je),o(Ht)})},Ia=(xe,nt=null)=>{const Je=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},pt=nt instanceof Set?nt:null;for(const[be,lt]of Object.entries(Je)){if(pt&&!pt.has(be)||!ui(lt==null?void 0:lt.definitionId))continue;const It=Ng({outputs:lt.output});It&&Ea(be,It)}},cp=xe=>{const nt=String(xe||"").trim();if(!nt)return;const Je=ze;ze=nt,Pl(pt=>{const be=new Set(pt);return Je&&Je!==nt&&Je!==w&&be.delete(Je),w&&be.add(w),be.add(nt),be}),Tl(pt=>{var be;return{...pt,...Je&&Je!==nt&&Je!==w&&((be=pt[Je])==null?void 0:be.status)==="running"?{[Je]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},Kj=xe=>{const nt=String(xe||"").trim();nt&&(Pl(Je=>{const pt=new Set(Je);return pt.delete(nt),pt}),Tl(Je=>({...Je,[nt]:{status:"success"}})))},qj=(xe,nt)=>{const Je=String(nt||"");if(!Je.trim())return;const pt=["assistant","thinking","result","error","prompt"].includes(xe)?xe:"assistant";Xn(be=>be.map(lt=>{if(lt.id!==J)return lt;let It=Array.isArray(lt.messages)?lt.messages:[];if(pt==="result"){const _t=[...It].reverse().find(pn=>pn.kind==="assistant");if(String((_t==null?void 0:_t.text)||"").trim()===Je.trim())return lt}if(pt==="assistant"){const _t=It.findIndex(pn=>pn.kind==="result"&&String(pn.text||"").trim()===Je.trim());_t>=0&&(It=It.filter((pn,Zt)=>Zt!==_t))}const Ht=[...It],ht=Ht[Ht.length-1];return ht&&ht.kind===pt&&!ht.error?Ht[Ht.length-1]={...ht,text:`${ht.text||""}${ht.text?`
254
- `:""}${Je}`}:Ht.push({role:"assistant",kind:pt,text:Je,...pt==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Ht.slice(-160)}}))},up=xe=>{const nt=String(xe||"");nt.trim()&&Xn(Je=>Je.map(pt=>{var Ht;if(pt.id!==J)return pt;const be=Array.isArray(pt.messages)?pt.messages:[],lt=be.findIndex(ht=>ht.kind==="thinking"),It=[...be];if(lt>=0){const ht=String(((Ht=It[lt])==null?void 0:Ht.text)||"");It[lt]={...It[lt],text:`${ht}${ht&&!ht.endsWith(`
255
- `),""}${nt}`,at:Date.now()}}else{const ht=It.findIndex(_t=>_t.kind==="activity");It.splice(ht>=0?ht+1:It.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...pt,messages:It.slice(-160)}}))},Ao=(xe,nt=null)=>{const Je=AY(xe);Je&&Xn(pt=>pt.map(be=>{if(be.id!==J)return be;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),It=Number(be.startedAt)||lt,Ht=Number(be.lastActivityAt)||It,ht=Math.max(0,lt-Ht),_t=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,lt-It),pn=Array.isArray(be.activities)?be.activities:[],Zt=pn[pn.length-1],Sn=(typeof Zt=="string"?Zt:String((Zt==null?void 0:Zt.text)||""))===Je?pn:[...pn,{text:Je,kind:IY(Je),stepMs:ht,totalMs:_t,at:lt}].slice(-30),Ut=Array.isArray(be.timingEntries)?be.timingEntries:[],mn=Array.isArray(be.messages)?be.messages:[],Eo=mn.findIndex(wi=>wi.kind==="activity"),Yi={role:"assistant",kind:"activity",text:Y_(Sn,Ut,It,lt),at:Date.now()},dr=[...mn];if(Eo>=0)dr[Eo]=Yi;else{const wi=dr.findIndex(Io=>Io.kind==="run-summary");dr.splice(wi>=0?wi+1:0,0,Yi)}return{...be,activities:Sn,lastActivityAt:lt,messages:dr.slice(-160)}}))},Uj=xe=>{const nt=String((xe==null?void 0:xe.source)||"runner"),Je=String((xe==null?void 0:xe.stream)||""),pt=String((xe==null?void 0:xe.eventType)||"event"),be=String((xe==null?void 0:xe.text)||"").trim();if(!be)return;const lt=`[${nt}${Je?`:${Je}`:""}] ${pt}
256
- ${be}`,It=lJ(xe);Xn(Ht=>Ht.map(ht=>{if(ht.id!==J)return ht;const pn=[...Array.isArray(ht.rawTrace)?ht.rawTrace:[],lt].slice(-80),Zt=Array.isArray(ht.timingEntries)?ht.timingEntries:[],cn=It?[...Zt,It].slice(-80):Zt,Sn=Array.isArray(ht.activities)?ht.activities:[],Ut=Number(ht.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),mn=Number(It==null?void 0:It.at)||Number(xe==null?void 0:xe.ts)||Date.now(),Eo=Array.isArray(ht.messages)?ht.messages:[],Yi={role:"assistant",kind:"raw",text:pn.join(`
257
-
258
- ---
259
-
260
- `),at:Date.now()},dr=[...Eo],wi=dr.findIndex(Po=>Po.kind==="activity");if(It){const Po={role:"assistant",kind:"activity",text:Y_(Sn,cn,Ut,mn),at:Date.now()};if(wi>=0)dr[wi]=Po;else{const pp=dr.findIndex(xy=>xy.kind==="run-summary");dr.splice(pp>=0?pp+1:0,0,Po)}}const Io=dr.findIndex(Po=>Po.kind==="raw");return Io>=0?dr[Io]=Yi:dr.push(Yi),{...ht,rawTrace:pn,timingEntries:cn,messages:dr.slice(-160)}}))},x2=xe=>{Xn(nt=>nt.map(Je=>Je.id===J?{...Je,status:xe,endedAt:Date.now()}:Je))},dp=xe=>{const nt=new Set,Je=String((xe==null?void 0:xe.nodeId)||"").trim();Je&&nt.add(Je);for(const pt of Array.isArray(xe==null?void 0:xe.displayNodeIds)?xe.displayNodeIds:[]){const be=String(pt||"").trim();be&&nt.add(be)}for(const pt of Array.isArray(xe==null?void 0:xe.touchedNodeIds)?xe.touchedNodeIds:[]){const be=String(pt||"").trim();be&&nt.add(be)}if(nt.size===0)for(const pt of Array.isArray(xe==null?void 0:xe.order)?xe.order:[]){const be=String(pt||"").trim();be&&nt.add(be)}return nt},fp=(xe,nt=null)=>{const Je=Yu(xe||X,yt),pt=new Map(Je.nodes.map(ht=>[ht.id,ht])),be=Je.instances||{},lt=nt instanceof Set?nt:null,It=(ht,_t)=>{const pn={...ht||_t};Array.isArray(_t==null?void 0:_t.output)&&(pn.output=_t.output);for(const Zt of["scriptRef","implementationRef","implementationMode"])(_t==null?void 0:_t[Zt])!=null&&String(_t[Zt]).trim()!==""&&(pn[Zt]=_t[Zt]);return pn},Ht=(ht,_t)=>{const pn={...ht||{}};Array.isArray(_t==null?void 0:_t.outputs)&&(pn.outputs=_t.outputs);for(const Zt of["scriptRef","implementationRef","implementationMode"])(_t==null?void 0:_t[Zt])!=null&&String(_t[Zt]).trim()!==""&&(pn[Zt]=_t[Zt]);return pn};g(ht=>{const _t=new Set(ht.map(cn=>cn.id)),Zt={...Yl(ht,S.current,ee.current).instances||{}};for(const[cn,Sn]of Object.entries(be)){if(lt&&!lt.has(cn)||!_t.has(cn))continue;const Ut=Zt[cn];pl((Sn==null?void 0:Sn.definitionId)||(Ut==null?void 0:Ut.definitionId))?Zt[cn]=Sn:Array.isArray(Sn==null?void 0:Sn.output)&&(Zt[cn]=It(Ut,Sn))}return ee.current=Zt,se(Zt),ht.map(cn=>{var Ut,mn;if(lt&&!lt.has(cn.id))return cn;const Sn=pt.get(cn.id);return Sn?pl(((Ut=Sn.data)==null?void 0:Ut.definitionId)||((mn=cn.data)==null?void 0:mn.definitionId))?{...cn,data:{...cn.data,...Sn.data}}:{...cn,data:Ht(cn.data,Sn.data)}:cn})})};for(;;){const{value:xe,done:nt}=await Oe.read();if(nt)break;De+=zt.decode(xe,{stream:!0});const Je=De.split(`
261
- `);De=Je.pop()||"";for(const pt of Je){if(!pt.trim())continue;const be=JSON.parse(pt);if(be.type==="error")throw new Error(be.error||"Workspace run failed");if(be.type==="stopped"){ju.current.add(J),dt=Array.isArray(be.order)?be.order:dt,Ao("运行停止",be);continue}if(be.type==="node-start"&&(ye(`Running ${be.nodeId}...`),cp(be.nodeId),yi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const lt=Ke.get(String(be.nodeId||"").trim());lt&&Ea(be.nodeId,lt),Kj(be.nodeId),yi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Ao(be.line||be.message||"",be),be.type==="paused"&&(Pt=Array.isArray(be.nodeIds)?be.nodeIds:[],Ao("运行暂停",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"?up(be.text||""):qj(be.kind,be.text||"")),be.type==="raw"){const lt=J_(be);lt&&up(lt),Uj(be)}if(be.type==="graph"&&be.graph){const lt=dp(be);fp(be.graph,lt),Ia(be.graph,lt)}if(be.type==="done"){if(be.revision&&(me.current=String(be.revision)),be.graph){Me.current=be.graph;const lt=dp(be);fp(be.graph,lt),Ia(be.graph,lt)}dt=Array.isArray(be.order)?be.order:[],Pt=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:Pt,Ao(Pt.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"&&(ju.current.add(J),Ao("运行停止",xe)),xe.type==="node-start"&&(ye(`Running ${xe.nodeId}...`),cp(xe.nodeId),yi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const nt=Ke.get(String(xe.nodeId||"").trim());nt&&Ea(xe.nodeId,nt),Kj(xe.nodeId),yi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Ao(xe.line||xe.message||"",xe),xe.type==="paused"&&(Pt=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Ao("运行暂停",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"?up(xe.text||""):qj(xe.kind,xe.text||"")),xe.type==="raw"){const nt=J_(xe);nt&&up(nt),Uj(xe)}if(xe.type==="graph"&&xe.graph){const nt=dp(xe);fp(xe.graph,nt),Ia(xe.graph,nt)}if(xe.type==="done"){if(xe.revision&&(me.current=String(xe.revision)),xe.graph){Me.current=xe.graph;const nt=dp(xe);fp(xe.graph,nt),Ia(xe.graph,nt)}dt=Array.isArray(xe.order)?xe.order:[],Pt=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:Pt,Ao(Pt.length?"运行暂停":"运行完成",xe)}}We()&&(Le(he),qt(he,"stopped"));const wy=We()?`Workspace run stopped: ${w}`:Pt.length?`Workspace run paused at ${Pt.join(", ")}`:`Workspace run done: ${dt.length?dt.join(" -> "):w}`;if(ye(wy),We()||qt(he,Pt.length?"paused":"success"),x2(We()?"stopped":Pt.length?"paused":"done"),!We()){try{await on(_.current,S.current),ye(wy)}catch(xe){ye(`${wy},但保存结果失败:${String(xe.message||xe)}`)}await $n()}}catch(st){if(We()||(st==null?void 0:st.name)==="AbortError"){Le(he),qt(he,"stopped"),ye(`Workspace run stopped: ${w}`),Xn(Ye=>Ye.map(Oe=>Oe.id===J?{...Oe,status:"stopped",endedAt:Date.now()}:Oe));return}Le(he),qt([w,ze].filter(Boolean),"failed"),ye(String(st.message||st)),Xn(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{Su.current.get(J)===Ve&&Su.current.delete(J),qi(st=>{const Ye={...st};return delete Ye[J],Ye}),ju.current.delete(J),Le(he)}},[Vi,k,a,$n,b,yt,Ur,on,Ks,x,g,qi,o,je]),Gf=m.useCallback(async()=>{try{const j=await(await fetch("/api/skills")).json().catch(()=>({})),C=Array.isArray(j.skills)?j.skills.map(P=>({key:String(P.key),name:String(P.name||P.id||P.key),description:P.description?String(P.description):"",sourceLabel:P.sourceLabel?String(P.sourceLabel):""})):[];tL(C),wS(!0)}catch{wS(!0)}},[]),Yf=m.useCallback(async()=>{try{const j=await(await fetch("/api/mcps")).json().catch(()=>({})),C=Array.isArray(j.servers)?j.servers.map(P=>({name:String((P==null?void 0:P.name)||""),type:String((P==null?void 0:P.type)||""),url:String((P==null?void 0:P.url)||""),command:String((P==null?void 0:P.command)||""),args:Array.isArray(P==null?void 0:P.args)?P.args.map(String):[],description:String((P==null?void 0:P.description)||"")})).filter(P=>P.name):[];kS(C)}catch{kS([])}},[]),Jf=m.useCallback(async()=>{try{const w=Wr(a),C=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),P=Array.isArray(C.workspaces)?C.workspaces.map(R=>({id:String((R==null?void 0:R.id)||""),label:String((R==null?void 0:R.label)||(R==null?void 0:R.name)||"知识库"),path:String((R==null?void 0:R.path)||""),kind:(R==null?void 0:R.kind)==="git"?"git":"local",repoUrl:String((R==null?void 0:R.repoUrl)||""),branch:String((R==null?void 0:R.branch)||""),mountPath:String((R==null?void 0:R.mountPath)||""),type:String((R==null?void 0:R.type)||""),builtin:(R==null?void 0:R.builtin)===!0,exists:(R==null?void 0:R.exists)!==!1})).filter(R=>R.path):[];SS(P)}catch{SS([])}},[a]),rj=m.useCallback(async()=>{nn.current=!1;try{const w=Wr(a),j=await fetch(`/api/workspace/conversations?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||`HTTP ${j.status}`);const P=K_(C.conversations||{});Cl(P.composer.messages),Xn(P.composer.runSessions),Cs(P.composer.activeSessionId||"workspace"),No(P.nodeChats)}catch{Cl([]),Xn([]),Cs("workspace"),No({})}finally{nn.current=!0}},[a]),sj=m.useCallback(async()=>{if(!je||a.archived)return;const w=K_({composer:{activeSessionId:Gr,messages:ja,runSessions:qs},nodeChats:Na});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async j=>{if(!j.ok){const C=await j.json().catch(()=>({}));throw new Error(C.error||`HTTP ${j.status}`)}})},[Gr,ja,qs,a,Na,je]);m.useEffect(()=>{let w=!1;return l?(Qg(null),Zg(!0),()=>{w=!0}):((async()=>{const C=new URL(window.location.href),P=String(C.searchParams.get("invite")||"").trim();if(P){ye("正在加入共享 Workspace...");const R=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:P})}),q=await R.json().catch(()=>({}));if(!R.ok)throw new Error(q.error||"加入共享 Workspace 失败");C.searchParams.delete("invite"),window.history.replaceState({},"",`${C.pathname}${C.search}${C.hash}`)}w||(await As(),w||await rj())})().catch(C=>{const P=String(C.message||C);ye(P),Us("error"),Gs(P)}),qf(),fetch("/api/model-lists").then(C=>C.json()).then(C=>Z$({cursor:Array.isArray(C.cursor)?C.cursor.map(String):[],opencode:Array.isArray(C.opencode)?C.opencode.map(String):[],claudeCode:Array.isArray(C.claudeCode)?C.claudeCode.map(String):[],codex:Array.isArray(C.codex)?C.codex.map(String):[]})).catch(()=>{}),Gf(),Yf(),Jf(),Uf(),fetch("/api/skill-collections").then(C=>C.json()).then(C=>{nL(Ya(C)),rL(!0)}).catch(()=>{}),fetch("/api/auth/me").then(C=>C.json()).then(C=>{Qg(C.user||null),Zg(!0)}).catch(()=>{Qg(null),Zg(!0)}),()=>{w=!0})},[l,As,rj,qf,Yf,Gf,Uf,Jf,Ki]),m.useEffect(()=>{if(US(""),!(!yS||!xS)){if(!Ki){hu([]);return}hu(pz(Ki,"workspace",Vs,jl)),US(Ki)}},[jl,xS,Vs,yS,Ki]),m.useEffect(()=>{if(!(qS!==Ki||!Ki))try{localStorage.setItem(Ki,JSON.stringify(Ks))}catch{}},[Ks,Ki,qS]),m.useEffect(()=>{ee.current=re},[re]),m.useEffect(()=>{_.current=b},[b]),m.useEffect(()=>{if(ae.current)return;const w=B.current,j=new Map,C=[];for(const P of b){const R=xM(P);j.set(P.id,R),w.get(P.id)!==R&&C.push(P.id)}B.current=j,C.length!==0&&Ur(C)},[b,Ur]),m.useEffect(()=>{S.current=k},[k]),m.useEffect(()=>{z.current=I},[I]),m.useEffect(()=>{L.current=E},[E]),m.useEffect(()=>{Zv.current=gt},[gt]),m.useEffect(()=>{Qv.current=br},[br]),m.useEffect(()=>{Z.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=C=>{C.key==="Escape"&&te(null)},j=C=>{var P,R;(R=(P=C.target)==null?void 0:P.closest)!=null&&R.call(P,".af-connect-node-menu")||te(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",j)}},[G]),m.useEffect(()=>{if(!ue.current||!je)return;if(ae.current){de.current&&window.clearTimeout(de.current);return}const w=Mt.current;if(Mt.current=null,(w==null?void 0:w.nodes)===b&&w.edges===k&&w.displayPage===I)return;if(kt.current){kt.current=!1;return}gi(),de.current&&window.clearTimeout(de.current);const j=tt.current?0:650;return tt.current=!1,de.current=window.setTimeout(()=>{on().catch(C=>ye(String(C.message||C)))},j),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,I,gi,on,je]),m.useEffect(()=>{if(nn.current&&!(!je||a.archived))return Kt.current&&window.clearTimeout(Kt.current),Kt.current=window.setTimeout(()=>{sj().catch(w=>ye(String(w.message||w)))},900),()=>{Kt.current&&window.clearTimeout(Kt.current)}},[Gr,ja,qs,a.archived,Na,sj,je]);const Eu=m.useMemo(()=>b.filter(w=>{var j;return((j=w==null?void 0:w.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"}).map(w=>{var j;return{id:w.id,config:Lv(((j=w.data)==null?void 0:j.body)||"")}}),[b]),vL=m.useMemo(()=>Eu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[Eu]);m.useEffect(()=>{if(!ue.current||f!=="workspace"||!a.flowId){_a({});return}if(!Eu.length){_a({});return}let w=!1;const j=async()=>{try{const P=Wr(a),R=await fetch(`/api/workspace/schedules?${P.toString()}`),q=await R.json().catch(()=>({}));if(!R.ok)throw new Error(q.error||"读取 Workspace 定时状态失败");w||_a(Qp(q.schedules||[]))}catch{w||_a(P=>{var q;const R={};for(const X of Eu)R[X.id]={...P[X.id]||{},lastStatus:((q=P[X.id])==null?void 0:q.lastStatus)||"unknown"};return R})}};j();const C=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(C)}},[a,Eu,vL,f]);const ij=m.useCallback((w,j)=>{if(!je){ye("Readonly workspace");return}const C=dC(j),P=Y=>Array.isArray(Y)?Y.map(le=>(le==null?void 0:le.name)!=="skillKeys"&&(le==null?void 0:le.name)!=="skillsContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:C,value:C}):[],R=b.map(Y=>{var le;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:P((le=Y.data)==null?void 0:le.inputs)}}}),q=ee.current||{},X=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...X,body:C,input:P(X.input)}};ee.current=J,g(R),se(J),Ns(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:P(Y.inputs)}),on(R,k).catch(Y=>ye(String(Y.message||Y)))},[k,b,on,g,je]),oj=m.useCallback((w,j)=>{if(!je){ye("Readonly workspace");return}const C=yX(j),P=Y=>Array.isArray(Y)?Y.map(le=>(le==null?void 0:le.name)!=="serverNames"&&(le==null?void 0:le.name)!=="mcpContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:C,value:C}):[],R=b.map(Y=>{var le;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:P((le=Y.data)==null?void 0:le.inputs)}}}),q=ee.current||{},X=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...X,body:C,input:P(X.input)}};ee.current=J,g(R),se(J),Ns(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:P(Y.inputs)}),on(R,k).catch(Y=>ye(String(Y.message||Y)))},[k,b,on,g,je]),aj=m.useCallback((w,j)=>{if(!je){ye("Readonly workspace");return}const C=(Array.isArray(j)?j:j?[j]:[]).filter(ze=>String((ze==null?void 0:ze.path)||"").trim()),P=C[0]||null,R=String((P==null?void 0:P.path)||"").trim(),q=C.length===1?String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim():C.length?`${C.length} 个知识库`:"",X=C.length?JSON.stringify(_g(C)):"",J=P?JSON.stringify({version:1,id:(P==null?void 0:P.id)||"",label:String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim(),kind:(P==null?void 0:P.kind)||"local",cwd:R,workspaceRoot:R,repoUrl:(P==null?void 0:P.repoUrl)||"",branch:(P==null?void 0:P.branch)||"",mountPath:(P==null?void 0:P.mountPath)||"",type:(P==null?void 0:P.type)||""}):"",Y=ze=>Array.isArray(ze)?ze.map(Ke=>(Ke==null?void 0:Ke.name)==="path"?{...Ke,default:R,value:R}:(Ke==null?void 0:Ke.name)==="label"?{...Ke,default:q,value:q}:(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):[],le=ze=>Array.isArray(ze)?ze.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:R,value:R,showOnNode:!1}:Ke):[],he=b.map(ze=>{var Ke,We,Le;return ze.id===w?{...ze,data:{...ze.data,label:((Ke=ze.data)==null?void 0:Ke.label)||"加载知识库",inputs:Y((We=ze.data)==null?void 0:We.inputs),outputs:le((Le=ze.data)==null?void 0:Le.outputs)}}:ze}),fe=ee.current||{},Ne=fe[w]&&typeof fe[w]=="object"?fe[w]:{},Ve={...fe,[w]:{...Ne,label:Ne.label||"加载知识库",input:Y(Ne.input),output:le(Ne.output)}};ee.current=Ve,g(he),se(Ve),Ns(ze=>(ze==null?void 0:ze.id)===w?{...ze,inputs:Y(ze.inputs),outputs:le(ze.outputs)}:ze),on(he,k).catch(ze=>ye(String(ze.message||ze)))},[k,b,on,g,je]),lj=m.useCallback((w,j)=>{if(!je){ye("Readonly workspace");return}const C=String(w||"");if(!C)return;const P=dC((j==null?void 0:j.skillKeys)||[]),R=Mf((j==null?void 0:j.displayType)||"markdown"),q=String((j==null?void 0:j.model)||"").trim(),X=(j==null?void 0:j.includeWorkspaceContext)===!1?"false":"true",J=j!=null&&j.workspaceContext&&typeof j.workspaceContext=="object"?JSON.stringify(j.workspaceContext):"",Y=j!=null&&j.knowledgeContext&&typeof j.knowledgeContext=="object"?JSON.stringify(j.knowledgeContext):"",le=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="skillKeys"?{...Le,default:P,value:P}:(Le==null?void 0:Le.name)==="displayType"?{...Le,default:R,value:R}:(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=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="displayType"?{...Le,default:R,value:R}:Le):[],fe=String((j==null?void 0:j.task)??""),Ne=b.map(We=>{var Le,qt;return We.id===C?{...We,data:{...We.data,body:fe,model:q,inputs:le((Le=We.data)==null?void 0:Le.inputs),outputs:he((qt=We.data)==null?void 0:qt.outputs)}}:We}),Ve=ee.current||{},ze=Ve[C]&&typeof Ve[C]=="object"?Ve[C]:{},Ke={...Ve,[C]:{...ze,body:fe,model:q,input:le(ze.input),output:he(ze.output)}};ee.current=Ke,g(Ne),se(Ke),Ns(We=>(We==null?void 0:We.id)===C?{...We,body:fe,model:q,inputs:le(We.inputs),outputs:he(We.outputs)}:We),on(Ne,k).catch(We=>ye(String(We.message||We)))},[k,b,on,g,je]),cj=m.useCallback((w,j)=>{if(!je){ye("Readonly workspace");return}const C=wJ(j),P=b.map(J=>J.id===w?{...J,data:{...J.data,body:C}}:J),R=ee.current||{},q=R[w]&&typeof R[w]=="object"?R[w]:{},X={...R,[w]:{...q,body:C}};ee.current=X,kt.current=!0,g(P),se(X),Ns(J=>(J==null?void 0:J.id)===w?{...J,body:C}:J),on(P,k).catch(J=>ye(String(J.message||J)))},[k,b,on,g,je]),uj=m.useCallback(w=>{const j=String(w||"").trim();j&&($S(C=>C===j?"":j),No(C=>({...C,[j]:C[j]||{sessionId:`nodechat_${Date.now()}_${j.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),dj=m.useCallback(()=>$S(""),[]),fj=m.useCallback((w,j)=>{const C=String(w||"").trim();C&&No(P=>({...P,[C]:{...P[C]||{sessionId:`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(j||""),error:""}}))},[]),Ys=m.useCallback((w,j,C="replace",P={})=>{var st,Ye;if(!je){ye("Readonly workspace");return}const R=String(w||"").trim();if(!R)return;const q=_.current.find(Oe=>Oe.id===R),X=Ln(q==null?void 0:q.data),J=ui((st=q==null?void 0:q.data)==null?void 0:st.definitionId),Y=Li(j),le=X==="html"?su(Y):X==="react"?jg(Y):String(Y||""),he=q?uo(q.data):"",fe=C==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
262
-
263
- ${le.trim()}`:le,Ne=X==="image"?"src":"content",Ve=P!=null&&P.reloadDisplay?Date.now():(Ye=q==null?void 0:q.data)==null?void 0:Ye.displayReloadKey,ze=Oe=>{let zt=!1;return(Array.isArray(Oe)?Oe:[]).map(dt=>{const Pt=String((dt==null?void 0:dt.name)||""),Bl=String((dt==null?void 0:dt.type)||"");return(J?Pt===Ne||Pt==="result"||Pt==="filePath":Pt===Ne||Pt==="filePath"||Bl==="text")?zt?{...dt,default:"",value:""}:(zt=!0,{...dt,default:fe,value:fe}):dt})},Ke=_.current.map(Oe=>{var zt,De;return Oe.id!==R?Oe:{...Oe,data:{...Oe.data,body:J?Oe.data.body:fe,...Ve?{displayReloadKey:Ve}:{},inputs:ze((zt=Oe.data)==null?void 0:zt.inputs),outputs:ze((De=Oe.data)==null?void 0:De.outputs)}}}),We=ee.current||{},Le=We[R]&&typeof We[R]=="object"?We[R]:{},qt={...We,[R]:{...Le,body:J?Le.body:fe,input:ze(Le.input),output:ze(Le.output)}};ee.current=qt,g(Ke),se(qt),Ns(Oe=>(Oe==null?void 0:Oe.id)===R?{...Oe,...J?{}:{body:fe}}:Oe),(P==null?void 0:P.logChat)!==!1&&No(Oe=>{var zt;return{...Oe,[R]:{...Oe[R]||{},candidateContent:"",messages:[...(zt=Oe[R])!=null&&zt.messages&&Array.isArray(Oe[R].messages)?Oe[R].messages:[],{role:"assistant",text:C==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),on(Ke,S.current).catch(Oe=>ye(String(Oe.message||Oe))),ye(String((P==null?void 0:P.statusMessage)||"")||(C==="append"?"已追加节点内容":"已替换节点内容"))},[on,g,je]),Xf=m.useCallback(async(w,j="")=>{if(!je)return ye("Readonly workspace"),"";if(!w)return"";try{const C=new FormData;C.set("file",w),C.set("dir",String(j||"")),a.flowId&&C.set("flowId",a.flowId),a.flowSource&&C.set("flowSource",a.flowSource),a.adminOwnerId&&C.set("adminOwnerId",a.adminOwnerId),a.archived&&C.set("archived","1");const P=await fetch("/api/workspace/upload",{method:"POST",body:C}),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"上传文件失败");const q=String(R.path||"").trim();if(!q)throw new Error("上传文件失败:未返回路径");return await $n(),Sl(X=>{const J=new Set(X);for(const Y of eh(q))J.delete(Y);return J}),ye(`已上传 ${q}`),q}catch(C){return ye(String(C.message||C)),""}},[a,$n,je]),Qf=m.useCallback(async w=>Nm(w)?Xf(w,"img"):(ye("请选择图片文件"),""),[Xf]),pj=m.useCallback((w="")=>{var j;if(!je){ye("Readonly workspace");return}hS.current=String(w||""),(j=pS.current)==null||j.click()},[je]),SL=m.useCallback(async w=>{const j=Array.from(w.target.files||[]);if(w.target.value="",!j.length)return;const C=hS.current||"";fS(!0);try{let P="";for(const R of j){const q=await Xf(R,C);q&&(P=q)}j.length>1&&ye(`已上传 ${j.length} 个文件${P?`,最后一个:${P}`:""}`)}catch(P){ye(String(P.message||P))}finally{fS(!1)}},[Xf]),hj=m.useCallback(async(w,j)=>{const C=String(w||"").trim();if(!C)return;const P=await Qf(j);P&&Ys(C,P,"replace",{logChat:!1,statusMessage:`已上传图片 ${P}`})},[Ys,Qf]),mj=m.useCallback(async(w,j=void 0)=>{var ze,Ke;if(!je){ye("Readonly workspace");return}const C=String(w||"").trim();if(!C)return;const P=Na[C]||{},R=String(j!==void 0?j:P.draft||"").trim();if(!R||P.running)return;const q=_.current.find(We=>We.id===C);if(!q)return;const X=Ln(q.data)||"markdown",J=uo(q.data);let Y=da(J,X),le=Li(J);if(Y)try{le=await hl(a,Y)}catch(We){ye(String(We.message||We))}else if(X!=="image"&&String(le||"").trim()){const We=Ka(X,le);if(We){ye(`${We} 未进入微调。`);return}try{const Le=await Mb(a,cC(C,q.data),le);await $n(),Ys(C,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),Y=Le,le=""}catch(Le){ye(String(Le.message||Le));return}}const he=$J(C,_.current,S.current),fe={role:"user",text:R,at:Date.now()},Ne=Array.isArray(P.messages)?P.messages:[],Ve=P.sessionId||`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`;No(We=>({...We,[C]:{...P,sessionId:Ve,messages:[...Ne,fe],draft:"",running:!0,error:""}}));try{const We=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:Ve,node:{id:C,label:((ze=q.data)==null?void 0:ze.label)||C,definitionId:((Ke=q.data)==null?void 0:Ke.definitionId)||""},nodeKind:X,currentContent:Y?"":le,sourceContext:he,targetFilePath:Y,messages:Ne,message:R,model:Vi})}),Le=await We.json().catch(()=>({}));if(!We.ok)throw new Error(Le.error||"节点微调失败");const qt=String(Le.candidateContent||Le.reply||"").trim(),st=!!Le.directFileEdit,Ye=String(Le.artifactPath||Y||"").trim();if(st&&Ye){const Oe=Ka(X,qt);if(Oe)throw new Error(`${Oe} 文件已由 agent 修改,请检查 ${Ye}。`);await $n(),Ys(C,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(qt){const Oe=Ka(X,qt);if(Oe)throw new Error(`${Oe} 已取消写入,避免覆盖当前展示文件。`);if(Y){const zt=await Mb(a,Y,qt);await $n(),Ys(C,zt,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${zt}`})}else Ys(C,qt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}No(Oe=>{var zt;return{...Oe,[C]:{...Oe[C]||{},sessionId:String(Le.sessionId||Ve),running:!1,candidateContent:"",messages:[...(zt=Oe[C])!=null&&zt.messages&&Array.isArray(Oe[C].messages)?Oe[C].messages:[...Ne,fe],{role:"assistant",text:qt||st?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(We){const Le=String(We.message||We);No(qt=>({...qt,[C]:{...qt[C]||{},running:!1,error:Le}})),ye(Le)}},[Vi,a,$n,Na,Ys,je]),gj=m.useCallback(async(w,j)=>{if(!je){ye("Readonly workspace");return}const C=Ln(j)||"markdown",P=uo(j),R=da(P,C);let q=Li(P);if(R)try{q=await hl(a,R)}catch(le){ye(String(le.message||le));return}if(!String(q||"").trim()){ye("展示节点没有可保存内容");return}const X=Ka(C,q);if(X){ye(`${X} 未保存文件。`);return}const J=cC(w,j),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const le=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:q})}),he=await le.json().catch(()=>({}));if(!le.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||Y,Ne=Wr(a);Ne.set("path",fe);const Ve=await fetch(`/api/workspace/file?${Ne.toString()}`);if(!Ve.ok){const ze=await Ve.json().catch(()=>({}));throw new Error(ze.error||`保存后读取失败:${fe}`)}await $n(),eS(ze=>lX(ze,fe,String(q||"").length)),Sl(ze=>{const Ke=new Set(ze);for(const We of eh(fe))Ke.delete(We);return Ke}),Ys(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ye(`已保存 ${fe}`)}catch(le){ye(String(le.message||le))}},[a,$n,Ys,je]),yj=m.useCallback(w=>{var R,q;const j=String(w||"").trim();if(!j||Wn)return;const C=_.current.find(X=>X.id===j);if(!C||!Ln(C==null?void 0:C.data)){ye("展示节点不可用");return}const P=String(((R=C.data)==null?void 0:R.label)||((q=C.data)==null?void 0:q.displayName)||j).trim()||"AgentFlow Display";Bt(Aw({title:P,layout:"single",nodeIds:[j],mode:"single-node",sourceNodeId:j})),ce(""),et(null),_r(!0)},[Wn]),Zf=m.useCallback((w,j)=>{const C=String(w||"");C&&Ns(P=>{if(!P||P.id!==C)return P;const R=typeof j=="function"?j(P):j;return!R||typeof R!="object"?P:{...P,...R}})},[]),wj=m.useCallback((w,j)=>{const C=String(w||"");!C||!je||(g(P=>P.map(R=>{var X;if(R.id!==C)return R;const q=Array.isArray((X=R.data)==null?void 0:X.outputs)&&R.data.outputs.length?R.data.outputs.map((J,Y)=>Y===0?{...J,default:j,value:j}:J):[{type:"file",name:"value",default:j,value:j}];return{...R,data:{...R.data,body:"",outputs:q}}})),Zf(C,P=>({body:"",outputs:Array.isArray(P==null?void 0:P.outputs)&&P.outputs.length?P.outputs.map((q,X)=>X===0?{...q,default:j,value:j}:q):[{type:"file",name:"value",default:j,value:j}]})),ye(`已选择文件 ${j}`))},[g,Zf,je]),xj=m.useCallback(w=>{zg({nodeId:String(w||""),query:""})},[]),iy=m.useCallback(()=>{zg({nodeId:"",query:""})},[]),jL=m.useCallback(w=>{const j=String((w==null?void 0:w.path)||"").trim();!j||!pu.nodeId||(wj(pu.nodeId,j),iy())},[iy,pu.nodeId,wj]),bj=m.useCallback(async(w,j)=>{if(!je)return;const C=XJ(w,j);if(C.length===0)return;const P=[];try{for(const R of C){const q=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:R})});if(q.status===404)continue;const X=await q.json().catch(()=>({}));if(!q.ok)throw new Error(X.error||"清理节点输出失败");P.push(X.path||R)}if(P.length===0)return;ye(`已清理 ${P.join(", ")}`),await $n(),Fg(R=>C.some(q=>R===q||R.startsWith(`${q}/`))?"":R)}catch(R){ye(String(R.message||R))}},[a,$n,je]),Iu=m.useMemo(()=>({modelLists:va,showBodyPreview:!0,flowParams:a,readOnly:!je,onRunWorkspaceNode:nj,onStopWorkspaceNode:tj,onOpenWorkspaceRunLogs:ej,onOptimizeWorkspaceRun:sy,onOptimizeWorkspaceSchedule:sy,runningRunNodeIds:GS,onChangeScheduledRunConfig:cj,onChangeContextRunConfig:lj,skills:Vs,skillCollections:jl,onChangeLoadSkillKeys:ij,onRefreshSkills:Gf,mcpServers:bS,onChangeLoadMcpNames:oj,onRefreshMcps:Yf,workspaceTargets:vS,onChangeLoadWorkspace:aj,onRefreshWorkspaces:Jf,onSaveDisplayNodeToFile:gj,onShareDisplayNode:yj,onOpenDisplayPreview:U,onRefreshNodeInternals:Ur,onEnsureWorkspaceNodeDisplaySize:AS,sharingDisplayNodeId:Wn,onUploadWorkspaceImage:Qf,onUploadImageToDisplayNode:hj,onOpenProvideFilePicker:xj,onStatus:ye,onSetDisplayNodeContent:Ys,onToggleNodeChat:uj,onCloseNodeChat:dj,onUpdateNodeChatDraft:fj,onSendNodeChat:mj,onSyncNodePropDraft:Zf,onCleanupWorkspaceNodeOutputs:bj}),[lj,oj,ij,aj,cj,bj,dj,AS,a,bS,va,xj,ej,sy,Yf,Ur,Gf,Jf,nj,GS,gj,mj,Ys,yj,Wn,jl,Vs,tj,Zf,uj,fj,hj,Qf,vS,je]),NL=m.useRef(new Map),cs=m.useMemo(()=>{const w=NL.current,j=new Set,C=b.map(P=>{var Y,le,he;const R={selected:P.selected===!0,isExecuting:WS.has(P.id),nodeStatus:((Y=ry[P.id])==null?void 0:Y.status)??null,nodeElapsed:((le=ry[P.id])==null?void 0:le.elapsed)??null,optimizingRun:BS===P.id,scheduledRunState:zS[P.id]||null,nodeChatActive:MS===P.id,nodeChat:Na[P.id]||null},q=w.get(P.id);if(q&&q.source===P&&q.commonData===Iu&&tC(q.runtime,R))return j.add(P.id),q.node;const X=!!(q&&((he=q.source)==null?void 0:he.data)===P.data&&q.commonData===Iu&&tC(q.runtime,R)),J={...P,data:X?q.node.data:{...P.data,...Iu,...R}};return w.set(P.id,{source:P,commonData:Iu,runtime:R,node:J}),j.add(P.id),J});for(const P of w.keys())j.has(P)||w.delete(P);return C},[MS,Iu,Na,b,BS,zS,WS,ry]),ut=f==="display",hn=f==="workflow",kj=m.useMemo(()=>ut?new Map(cs.map(w=>[w.id,w])):jJ,[cs,ut]),vj=m.useMemo(()=>js&&cs.find(w=>w.id===js)||null,[js,cs]),Sj=m.useRef(new Map),Pu=m.useMemo(()=>{if(!ut)return Sj.current.clear(),NJ;const w=new Set(M),j=Sj.current,C=new Set,P=I.nodeIds.map((R,q)=>{var Ve,ze,Ke,We;const X=kj.get(R);if(!X||!Ln(X.data))return null;const J=ec(X)||{width:520,height:320},Y=Qa(I.nodeSizes[R]||J,{display:!0})||J,le=I.nodePositions[R]||{x:180+q*36,y:120+q*28},he=w.has(R),fe=j.get(R);if(fe&&fe.source===X&&((Ve=fe.position)==null?void 0:Ve.x)===le.x&&((ze=fe.position)==null?void 0:ze.y)===le.y&&((Ke=fe.size)==null?void 0:Ke.width)===Y.width&&((We=fe.size)==null?void 0:We.height)===Y.height&&fe.selected===he)return C.add(R),fe.node;const Ne={...X,id:nC(R),position:le,selected:he,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:R,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return j.set(R,{source:X,position:le,size:Y,selected:he,node:Ne}),C.add(R),Ne}).filter(Boolean);for(const R of j.keys())C.has(R)||j.delete(R);return P},[I,kj,ut,M]),$l=m.useMemo(()=>cs.filter(w=>Ln(w==null?void 0:w.data)),[cs]);m.useEffect(()=>{if(!ut||!I.viewport)return;const w=I.viewport,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[I.viewport,ut,r]),m.useEffect(()=>{if(ut||hn||!E)return;const w=E,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[ut,hn,r,E]),m.useEffect(()=>{hn&&Au(Jn)},[hn]),m.useEffect(()=>{if(!hn||!Jn||a.workflowDemo)return;const w=Wr(a);w.set("tapdId",Jn);let j=null,C=null,P=!1;const R=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{P||document.hidden||j||(j=new EventSource(`/api/prd-workflow/events?${w.toString()}`),j.onmessage=()=>{Au(Jn)},j.onerror=()=>{R(),!P&&!document.hidden&&(C=window.setTimeout(q,5e3))})},X=()=>{if(document.hidden){R();return}Au(Jn),q()};return q(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),R()}},[a,hn,Au,Jn]),m.useEffect(()=>{if(!a.flowId||hn)return;const w=Wr(a);w.set("clientId",Dt.current);let j=null,C=null,P=!1;const R=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{P||document.hidden||j||(j=new EventSource(`/api/workspace/events?${w.toString()}`),j.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===Dt.current)){if(Y.type==="graph.committed"){Rl(Y);return}if(Y.type==="runtime.committed"){Rl(Y);return}if(String(Y.type||"").startsWith("file.")){$n();return}String(Y.type||"").startsWith("run.")&&Uf()}},j.onerror=()=>{R(),!P&&!document.hidden&&(C=window.setTimeout(q,5e3))})},X=()=>{if(document.hidden){R();return}Rl({type:"visibility.resume"}),q()};return q(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),R(),Te.current&&(window.clearTimeout(Te.current),Te.current=null),jt.current=!1}},[a,hn,$n,Uf,Rl]),m.useEffect(()=>{if(ae.current)return;const w=F.current,j=new Map,C=[];for(const P of[...cs,...Pu]){const R=SJ(P);j.set(P.id,R),w.get(P.id)!==R&&C.push(P.id)}F.current=j,C.length!==0&&Ur(C)},[Pu,cs,Ur]);const Yt=m.useMemo(()=>b.find(w=>w.id===br)||null,[b,br]),oy=m.useRef({id:"",draft:null}),_L=m.useMemo(()=>{const w=mC(Yt);return w?JSON.stringify(w):""},[Yt==null?void 0:Yt.data,Yt==null?void 0:Yt.id]);m.useEffect(()=>{if(!Yt){oy.current={id:"",draft:null},Ns(null),xl("");return}const w=mC(Yt),j=oy.current;oy.current={id:Yt.id,draft:w},Ns(C=>!C||C.id!==Yt.id||j.id!==Yt.id||!j.draft?w:kX(C,j.draft,w)),xl("")},[Yt==null?void 0:Yt.id,_L]);const ay=m.useCallback((w=!1)=>{if(!gt||!Yt)return!1;if(!je)return xl("Readonly workspace"),ye("Readonly workspace"),!1;xl("");const j=wC({nodes:b,edges:k,instances:ee.current,selectedNode:Yt,draft:gt,allowRename:w});return j!=null&&j.error?(xl(j.error),!1):(!(j!=null&&j.ok)||!j.changed||(ee.current=j.instances,se(j.instances),g(j.nodes),x(j.edges),j.nextId!==Yt.id&&sn(j.nextId),Ur(j.nextId)),!0)},[k,gt,b,Yt,x,g,Ur,je]);m.useEffect(()=>{if(!je||!gt||!Yt)return;const w=window.setTimeout(()=>{ay(!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)||[]),ay,Yt==null?void 0:Yt.id,je]);const jj=m.useRef({refs:new Map,nodeDataById:new Map}),ly=m.useMemo(()=>{const w=jj.current;let j=w.refs.size!==b.length;const C=new Map;for(const R of b)C.set(R.id,R.data),(!w.refs.has(R.id)||w.refs.get(R.id)!==R.data)&&(j=!0);if(!j)return w.nodeDataById;const P=new Map(b.map(R=>[R.id,R.data]));return jj.current={refs:C,nodeDataById:P},P},[b]),CL=m.useMemo(()=>k.map(w=>{var Y,le;const j=ly.get(w.source),C=ly.get(w.target),P=/^output-(\d+)$/.exec(w.sourceHandle||""),R=/^input-(\d+)$/.exec(w.targetHandle||""),q=j&&P?(Y=j.outputs)==null?void 0:Y[parseInt(P[1],10)]:null,X=C&&R?(le=C.inputs)==null?void 0:le[parseInt(R[1],10)]:null,J=q!=null&&q.type?Dn(q.type):X!=null&&X.type?Dn(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ai.ArrowClosed,color:J}}:w}),[ly,k]),ep=ut?Pu:cs,AL=ut?[]:CL,Nj=m.useRef(ep),Ll=m.useRef([]);ae.current||(Nj.current=ep);const EL=m.useMemo(()=>ut?Pu.map(w=>({...w,id:Zp(w.id)})):cs,[Pu,cs,ut]),cy=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=ut?nC(j):j;ut?V([j]):(g(R=>R.map(q=>({...q,selected:q.id===C}))),x(R=>R.map(q=>({...q,selected:!1}))),sn(C));const P=()=>{var le,he,fe;const R=r.getNode(C);if(!R)return;const q=(le=r.getInternalNode)==null?void 0:le.call(r,C),X=((he=q==null?void 0:q.measured)==null?void 0:he.width)??(q==null?void 0:q.width)??R.width??260,J=((fe=q==null?void 0:q.measured)==null?void 0:fe.height)??(q==null?void 0:q.height)??R.height??120,{zoom:Y}=r.getViewport();r.setCenter(R.position.x+X/2,R.position.y+J/2,{zoom:PJ(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(P))},[ut,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!ue.current||f!=="workspace"||cs.some(j=>j.id===w)&&(c.current="",kt.current=!0,cy(w))},[cs,cy,f]);const _j=m.useCallback(()=>{const w=r.getViewport(),j={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(ut){const C={...z.current,viewport:j};z.current=C,T(C),ye("已固定 Display 进入视角")}else{L.current=j,D(j);try{window.localStorage.setItem(u,JSON.stringify(j))}catch{}ye("已固定 Workspace 进入视角");return}on(_.current,S.current).catch(C=>ye(String(C.message||C)))},[ut,r,on,u]),uy=m.useMemo(()=>{const w=Ce.trim().toLowerCase(),j={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const C of yt)w&&![C.id,C.label,C.displayName,C.description].some(P=>String(P||"").toLowerCase().includes(w))||j[ad(C)].push(C);for(const C of Ql)j[C].sort((P,R)=>P.id.localeCompare(R.id));return j},[yt,Ce]),Tu=m.useMemo(()=>{const w=En.trim().toLowerCase();return yt.filter(j=>!w||[j.id,j.label,j.displayName,j.description].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>{const P=Ql.indexOf(ad(j)),R=Ql.indexOf(ad(C));return P!==R?P-R:ld(j).localeCompare(ld(C))}).slice(0,30)},[yt,En]),Ru=m.useMemo(()=>{const w=En.trim().toLowerCase();return vt.filter(j=>!w||[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>String(j.displayName||j.name||j.id).localeCompare(String(C.displayName||C.name||C.id))).slice(0,30)},[vt,En]);m.useEffect(()=>{cr(0)},[En,we,Ae]),m.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var j;return(j=PS.current)==null?void 0:j.focus()},0);return()=>window.clearTimeout(w)},[we]);const IL=m.useMemo(()=>{const w=Og.trim().toLowerCase();return w?Ov(bl).filter(j=>j.path.toLowerCase().includes(w)):bl},[Og,bl]),Aa=m.useMemo(()=>PM(bl,Dg),[bl,Dg]),Ui=(Aa==null?void 0:Aa.type)==="directory"?Aa.path:sX((Aa==null?void 0:Aa.path)||""),PL=m.useCallback(w=>{var j,C;(C=(j=w.target)==null?void 0:j.closest)!=null&&C.call(j,".af-work-file")||Fg("")},[]),TL=[...(va.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(va.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(va.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(va.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],dy=m.useMemo(()=>new Set(Ks),[Ks]),Ol=m.useMemo(()=>{const w=new Map(Vs.map(q=>[q.key,q])),j=new Set,C=new Set,P=jl.map(q=>{const X=ca(q,Vs).map(J=>w.get(J)).filter(Boolean);for(const J of X)j.add(J.key),C.add(String(J.name||J.id||J.key||"").trim());return{...q,skills:X}}).filter(q=>q.skills.length>0),R=Vs.filter(q=>{const X=String(q.name||q.id||q.key||"").trim();return!j.has(q.key)&&!C.has(X)});return{groups:P,ungrouped:R}},[jl,Vs]);m.useEffect(()=>{ES(w=>{let j=!1;const C=new Set(w);for(const P of Ol.groups)C.has(P.id)||(C.add(P.id),j=!0);return j?C:w})},[Ol.groups]);const or=m.useMemo(()=>{const w=b.filter(j=>j.selected);return w.length>0?w:br?b.filter(j=>j.id===br):[]},[b,br]),tp=m.useMemo(()=>or.map(w=>w.id),[or]),Cj=m.useCallback(()=>{if(ut)return;if(!je){ye("Readonly workspace");return}const w=(_.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Im(J));if(w.length<2){ye("选择至少两个节点后按 G 创建 Group");return}const j=w.reduce((J,Y)=>{var Ve,ze,Ke,We,Le,qt,st,Ye,Oe,zt,De,dt;const le=Number(((Ve=Y.position)==null?void 0:Ve.x)||0),he=Number(((ze=Y.position)==null?void 0:ze.y)||0),fe=Number(((Ke=Y.measured)==null?void 0:Ke.width)||Y.width||((Le=(We=Y.data)==null?void 0:We.nodeSize)==null?void 0:Le.width)||((st=(qt=Y.data)==null?void 0:qt.displaySize)==null?void 0:st.width)||oM),Ne=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||((zt=(Oe=Y.data)==null?void 0:Oe.nodeSize)==null?void 0:zt.height)||((dt=(De=Y.data)==null?void 0:De.displaySize)==null?void 0:dt.height)||jm);return{minX:Math.min(J.minX,le),minY:Math.min(J.minY,he),maxX:Math.max(J.maxX,le+fe),maxY:Math.max(J.maxY,he+Ne)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(j.minX)||!Number.isFinite(j.minY))return;const C=new Set((_.current||[]).map(J=>J.id));let P=1,R=`group_${P}`;for(;C.has(R);)P+=1,R=`group_${P}`;const q=Pb({width:j.maxX-j.minX+Jp*2,height:j.maxY-j.minY+Jp*2})||{width:ul,height:dl},X={id:R,type:Ec,position:{x:j.minX-Jp,y:j.minY-Jp},width:q.width,height:q.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Pm(P-1),title:Pm(P-1),color:"purple",nodeSize:q}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),sn(""),ye(`Created group for ${w.length} nodes`)},[ut,x,g,je]),Mu=m.useMemo(()=>b.filter(w=>Ln(w==null?void 0:w.data)),[b]),fy=m.useMemo(()=>or.filter(w=>Ln(w==null?void 0:w.data)).map(w=>w.id),[or]),RL=m.useMemo(()=>{const w=String((Dr==null?void 0:Dr.username)||(Dr==null?void 0:Dr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Dr]),py=m.useMemo(()=>new Set(tp),[tp]),np=m.useMemo(()=>k.filter(w=>py.has(w.source)&&py.has(w.target)),[k,py]),hy=m.useCallback(w=>{const j=w==="display"?"display":w==="workflow"?"workflow":"workspace";p(j),sn(""),V([]),te(null),$e(!1),vn(!1);const C=Wr(a);j==="display"&&C.set("view","display"),j==="workflow"&&(C.set("view","workflow"),Jn.trim()&&C.set("tapdId",Jn.trim()));const P=`/workspace${C.toString()?`?${C.toString()}`:""}`;window.history.pushState({},"",P)},[a,Jn]),Aj=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=_.current.find(P=>P.id===j);if(!C||!Ln(C.data)){ye("展示节点不可用");return}T(P=>{if(P.nodeIds.includes(j))return P;const R=P.nodeIds.length,q=ec(C);return{nodeIds:[...P.nodeIds,j],nodePositions:{...P.nodePositions,[j]:{x:180+R*36,y:120+R*28}},nodeSizes:{...P.nodeSizes,...q?{[j]:q}:{}}}}),V([j])},[]),Ej=m.useCallback(w=>{const j=String(w||"").trim();j&&(T(C=>{const P=C.nodeIds.filter(X=>X!==j),R={...C.nodePositions},q={...C.nodeSizes};return delete R[j],delete q[j],{nodeIds:P,nodePositions:R,nodeSizes:q}}),V(C=>C.filter(P=>P!==j)))},[]),Ij=m.useCallback(w=>{const j=String(w||"").trim();j&&(z.current.nodeIds.includes(j)?Ej(j):Aj(j))},[Aj,Ej]),rp=m.useMemo(()=>{const w=Vn.trim().toLowerCase();return w?$l.filter(j=>{var C,P;return[j.id,(C=j.data)==null?void 0:C.label,(P=j.data)==null?void 0:P.definitionId].filter(Boolean).some(R=>String(R).toLowerCase().includes(w))}):$l},[$l,Vn]),Pj=m.useMemo(()=>{const w=rp.length,j=w<=1?1:w<=4?2:3,C=Array.from({length:j},()=>({height:0,nodes:[]}));for(const P of rp){const R=ec(P)||{width:420,height:260},q=Math.max(1,Number(R.width)||420),X=Math.max(1,Number(R.height)||260),J=Math.min(26,Math.max(5.5,X/q*16))+3.2;let Y=C[0];for(const le of C)le.height<Y.height&&(Y=le);Y.nodes.push(P),Y.height+=J}return C.map(P=>P.nodes)},[rp]),ML=m.useCallback(w=>{var q;const j=I.nodeIds.includes(w.id),C=ec(w)||{width:420,height:260},P=Math.max(1,Math.round(Number(C.width)||420)),R=Math.max(1,Math.round(Number(C.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(j?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${P} / ${R}`},onClick:()=>Ij(w.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:j,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(qJ,{node:w})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((q=w.data)==null?void 0:q.label)||w.id}),i.jsxs("small",{children:[Ln(w.data)," · ",w.id]})]})]},w.id)},[I.nodeIds,Ij]),Tj=m.useMemo(()=>{const w=Ce.trim().toLowerCase();return w?vt.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(C=>String(C).toLowerCase().includes(w))):vt},[vt,Ce]),Rj=m.useCallback((w,j)=>{const C=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let P=`${C}_${Date.now().toString(36)}`,R=2;for(;j.has(P);)P=`${C}_${Date.now().toString(36)}_${R}`,R+=1;return j.add(P),P},[]),$u=m.useCallback((w,j)=>{var Oe,zt;if(!je){ye("Readonly workspace");return}const C=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},P=C.instances&&typeof C.instances=="object"?C.instances:{},R=Object.keys(P);if(R.length===0)return;const q=new Set(_.current.map(De=>De.id)),X={};for(const De of R)X[De]=Rj(De,q);const J=(Oe=C.ui)!=null&&Oe.nodePositions&&typeof C.ui.nodePositions=="object"?C.ui.nodePositions:{},Y=(zt=C.ui)!=null&&zt.nodeSizes&&typeof C.ui.nodeSizes=="object"?C.ui.nodeSizes:{},le=R.map(De=>{const dt=J[De];return{id:De,x:typeof(dt==null?void 0:dt.x)=="number"?dt.x:0,y:typeof(dt==null?void 0:dt.y)=="number"?dt.y:0}}),he=Math.min(...le.map(De=>De.x)),fe=Math.min(...le.map(De=>De.y));let Ne=j||{x:360+_.current.length*24,y:180+_.current.length*18};if(!j){const De=document.querySelector(".af-workspace-canvas .react-flow");if(De){const dt=De.getBoundingClientRect();Ne=r.screenToFlowPosition({x:dt.left+dt.width*.48,y:dt.top+dt.height*.32})}}const Ve={},ze={},Ke={};for(const De of le){const dt=X[De.id];Ve[dt]={...P[De.id]||{}},ze[dt]={x:Ne.x+(De.x-he),y:Ne.y+(De.y-fe)};const Pt=Y[De.id];typeof(Pt==null?void 0:Pt.width)=="number"&&typeof(Pt==null?void 0:Pt.height)=="number"&&(Ke[dt]={width:Pt.width,height:Pt.height})}const We=new Set(R),Le=(Array.isArray(C.edges)?C.edges:[]).filter(De=>We.has(De==null?void 0:De.source)&&We.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})),qt=Yu({instances:Ve,edges:Le,ui:{nodePositions:ze,nodeSizes:Ke}},yt),st=qt.nodes.map(De=>De.id),Ye=qt.nodes.map(De=>({...De,selected:!0}));ee.current={...ee.current,...qt.instances},se(ee.current),g(De=>[...De.map(dt=>({...dt,selected:!1})),...Ye]),x(De=>[...De.map(dt=>({...dt,selected:!1})),...qt.edges.map(dt=>({...dt,selected:!1}))]),sn(""),V([]),ye(`已添加流程片段:${w.displayName||w.id}(已选中 ${st.length} 个节点)`)},[Rj,yt,r,x,g,je]),$L=m.useCallback(()=>{var C,P;if(or.length<2){ln("请先在 workspace 画布上选择至少两个节点。"),Et("flows");return}const w=or[0],j=or.length===2?`${((C=w.data)==null?void 0:C.label)||w.id} 片段`:`${((P=w.data)==null?void 0:P.label)||w.id} 等 ${or.length} 个节点`;bn({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),rr(""),An(!0),Et("flows")},[or]),LL=m.useCallback(async()=>{var R,q;if(or.length<2)return;const w=en.name.trim();if(!w){rr("请填写片段名称。");return}const j={},C={};for(const X of or){j[X.id]={x:((R=X.position)==null?void 0:R.x)||0,y:((q=X.position)==null?void 0:q.y)||0};const J=ec(X);J&&(C[X.id]=J)}const P=np.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));fn(!0),rr("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:en.id,name:w,displayName:w,version:"1.0.0",description:en.description,snippet:{instances:Cv(or,ee.current),edges:P,ui:{nodePositions:j,nodeSizes:C}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");An(!1),ye(`流程片段已发布:${J.id||w}`),CS(`流程片段已发布:${J.id||w}`),await qf(),Et("flows")}catch(X){rr(String(X.message||X))}finally{fn(!1)}},[qf,en,np,or,CS]),Mj=m.useCallback(async()=>{var j;const w=uu.trim();if(w){nS(!0),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"添加协作成员失败");Wf(P.workspace||null),sS(""),ye(`已将 Workspace 分享给 ${((j=P.member)==null?void 0:j.username)||w}`)}catch(C){jo(String(C.message||C))}finally{nS(!1)}}},[a,uu]),OL=m.useCallback(()=>{jo(""),Rg(!0),fetch("/api/teams/me").then(w=>w.json().then(j=>({response:w,payload:j}))).then(({response:w,payload:j})=>{var R;if(!w.ok)throw new Error(j.error||"读取团队失败");const C=j.team||null;q$(C);const P=(R=Lt==null?void 0:Lt.teamShares)==null?void 0:R.find(q=>q.teamId===(C==null?void 0:C.id));aS((P==null?void 0:P.role)==="editor"?"editor":"viewer")}).catch(w=>jo(String(w.message||w)))},[Lt==null?void 0:Lt.teamShares]),my=m.useCallback(async(w=!1)=>{if(Hs!=null&&Hs.id){lS(!0),jo("");try{const j=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Hs.id,role:$g})}),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||(w?"取消团队分享失败":"分享到团队失败"));Wf(C.workspace||null),ye(w?`已取消对「${Hs.name}」的分享`:`已分享到「${Hs.name}」`)}catch(j){jo(String(j.message||j))}finally{lS(!1)}}},[a,Hs,$g]),DL=m.useCallback(async w=>{const j=String((w==null?void 0:w.userId)||"").trim();if(!(!j||j===(Lt==null?void 0:Lt.ownerId))){oS(j),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:j})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"取消成员分享失败");Wf(P.workspace||null),ye(`已取消对 ${(w==null?void 0:w.username)||j} 的分享`)}catch(C){jo(String(C.message||C))}finally{oS("")}}},[a,Lt==null?void 0:Lt.ownerId]),$j=m.useCallback(async()=>{const w=Yl(_.current,S.current,ee.current);w.ui={...w.ui||{},...L.current?{viewport:L.current}:{},displayPage:rC(z.current,_.current)};const j=new Blob([`${JSON.stringify(w,null,2)}
264
- `],{type:"application/json"}),C=URL.createObjectURL(j),P=document.createElement("a");P.href=C,P.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(C),await As(),kl(null),ka(!1),ye("已备份本地草稿并载入远端最新版本")},[S,a.flowId,As,_]),FL=m.useCallback(async()=>{const w=Array.isArray(Mn==null?void 0:Mn.conflictItems)?Mn.conflictItems:[];if(!w.length||!(Mn!=null&&Mn.mergeGraph)||!(Mn!=null&&Mn.currentGraph)){fu("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let j=Mn.mergeGraph;try{w.forEach((P,R)=>{const q=Lg[String(R)]||{mode:"local"};let X,J=!0;q.mode==="remote"?(X=P.current,J=P.hasCurrent!==!1):q.mode==="manual"?X=JSON.parse(String(q.manual||"")):(X=P.incoming,J=P.hasIncoming!==!1),j=EX(j,P.pathParts,X,J)})}catch(P){fu(`手动值不是有效 JSON:${String(P.message||P)}`);return}cS(!0),fu(""),Us("saving"),Gs("正在提交冲突解决结果");const C=Se.current.catch(()=>{}).then(async()=>{const P=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:j,baseRevision:Mn.currentRevision,baseGraph:Mn.currentGraph,clientId:Dt.current})}),R=await P.json().catch(()=>({}));if(!P.ok){if(P.status===409&&Array.isArray(R.conflictItems)){const q=R.conflictItems;kl({currentRevision:String(R.currentRevision||""),message:R.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(R.conflictPaths)?R.conflictPaths:[],conflictItems:q,mergeGraph:R.mergeGraph||null,currentGraph:R.currentGraph||null}),vl(Object.fromEntries(q.map((X,J)=>[String(J),{mode:"local",manual:Ju(X)}])))}throw new Error(R.error||"提交冲突解决结果失败")}await As(),kl(null),ka(!1),ye("冲突已解决并保存")});Se.current=C;try{await C}catch(P){fu(String(P.message||P)),Us("error"),Gs(String(P.message||P))}finally{cS(!1)}},[a,As,Mn,Lg]);m.useCallback(()=>{if(Mu.length===0){ye("当前 workspace 没有 display 节点");return}const w=fy.length>0?fy:Mu.map(C=>C.id),j=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";Bt(Aw({title:j,layout:"gallery",nodeIds:w,mode:"multi-node"})),ce(""),et(null),_r(!0)},[a.flowId,fy,Mu]);const zL=m.useCallback(w=>{Bt(j=>{const C=Array.isArray(j.nodeIds)?j.nodeIds:[];return C.includes(w)?{...j,nodeIds:C.filter(P=>P!==w)}:{...j,nodeIds:[...C,w]}})},[]),Js=m.useCallback(async()=>{Hi(!0),oe("");try{const w=await fetch("/api/display/shares"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取分享列表失败");xr(Array.isArray(j.shares)?j.shares:[])}catch(w){oe(String(w.message||w)),xr([])}finally{Hi(!1)}},[]),WL=m.useCallback(()=>{ir(!0),$t(""),Js()},[Js]),BL=m.useCallback(async()=>{var C,P;const w=rt.title.trim(),j=Array.isArray(rt.nodeIds)?rt.nodeIds:[];if(j.length===0){ce("请选择至少一个 display 节点。");return}Lr(!0),ce(""),et(null);try{await on(b,k);const R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:rt.layout,nodeIds:j,...iC(rt)})}),q=await R.json().catch(()=>({}));if(!R.ok||q.ok===!1)throw new Error(q.error||"发布展示页失败");const X=new URL(q.url||`/display/${((C=q.share)==null?void 0:C.id)||""}`,window.location.origin).href;et({...q,absoluteUrl:X}),ye((P=q.share)!=null&&P.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Qt&&Js()}catch(R){ce(String(R.message||R))}finally{Lr(!1)}},[rt,Qt,k,a,Js,b,on]),HL=m.useCallback(async()=>{var j,C;const w=Array.isArray(I.nodeIds)?I.nodeIds:[];if(w.length===0){ce("请先添加至少一个展示节点。"),ye("请先添加至少一个展示节点"),vn(!0);return}Lr(!0),ce("");try{await on(b,k);const P=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:P,layout:"canvas",nodeIds:w,...iC(rt)})}),q=await R.json().catch(()=>({}));if(!R.ok||q.ok===!1)throw new Error(q.error||"生成展示链接失败");const X=new URL(q.url||`/display/${((j=q.share)==null?void 0:j.id)||""}`,window.location.origin).href;et({...q,absoluteUrl:X}),wr(!0),ye((C=q.share)!=null&&C.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Qt&&Js()}catch(P){const R=String(P.message||P);ce(R),ye(R)}finally{Lr(!1)}},[I.nodeIds,rt,Qt,k,a,Js,b,on]),Lj=m.useCallback(async()=>{const w=ge==null?void 0:ge.absoluteUrl;if(!w)return;const j=await Rb(w);Xt(j?"copied":"failed"),window.setTimeout(()=>Xt(""),1600)},[ge==null?void 0:ge.absoluteUrl]),VL=m.useCallback(async w=>{const j=oC(w),C=await Rb(j);$t(C?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>$t(""),1600)},[]),KL=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.id)||"");if(C){Re(C),oe("");try{const P=j==="permanent"?{id:C,expiresMode:"permanent",permanent:!0}:{id:C,expiresMode:"days",expiresInDays:Number(j||30)},R=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),q=await R.json().catch(()=>({}));if(!R.ok||q.ok===!1)throw new Error(q.error||"更新分享有效期失败");await Js(),ye("分享有效期已更新")}catch(P){oe(String(P.message||P))}finally{Re("")}}},[Js]),qL=m.useCallback(async w=>{const j=String((w==null?void 0:w.id)||"");if(j){Re(j),oe("");try{const C=await fetch(`/api/display/share?id=${encodeURIComponent(j)}`,{method:"DELETE"}),P=await C.json().catch(()=>({}));if(!C.ok||P.ok===!1)throw new Error(P.error||"撤销分享失败");await Js(),ye("分享已撤销")}catch(C){oe(String(C.message||C))}finally{Re("")}}},[Js]),UL=m.useCallback(w=>{g(j=>j.map(C=>C.id===w?{...C,selected:!1}:C)),sn(j=>j===w?"":j)},[g]),Dl=m.useCallback(()=>{const w=Gg.current;if(!w)return;const j=w.getBoundingClientRect(),C=Math.min(420,Math.max(320,j.width+160)),P=12,R=Math.max(180,j.top-P*2),q=Math.min(560,R);uL({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-C-12,j.left)),top:Math.max(P,j.top-q-P),width:C,maxHeight:q,zIndex:1e4})},[]);m.useEffect(()=>{if(!Hf)return;Dl();const w=C=>{var R,q;const P=C.target;(R=Gg.current)!=null&&R.contains(P)||(q=IS.current)!=null&&q.contains(P)||Ug(!1)},j=C=>{C.key==="Escape"&&Ug(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",j),window.addEventListener("resize",Dl),window.addEventListener("scroll",Dl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",j),window.removeEventListener("resize",Dl),window.removeEventListener("scroll",Dl,!0)}},[Hf,Dl]);const sp=m.useCallback(w=>{const j=iM(w);if(j.active&&(ae.current=!0),j.finished&&(ae.current=!1,tt.current=!0),eY(w)&&gi(),f==="display"){T(R=>{var Y,le;let q=R.nodePositions,X=R.nodeSizes;for(const he of w||[]){const fe=Zp(he==null?void 0:he.id);if(!(!fe||!R.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const Ne=q[fe];if((Ne==null?void 0:Ne.x)===he.position.x&&(Ne==null?void 0:Ne.y)===he.position.y)continue;q===R.nodePositions&&(q={...R.nodePositions}),q[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((le=he.dimensions)!=null&&le.height)){const Ne=Qa({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(Ne){const Ve=X[fe];if((Ve==null?void 0:Ve.width)===Ne.width&&(Ve==null?void 0:Ve.height)===Ne.height)continue;X===R.nodeSizes&&(X={...R.nodeSizes}),X[fe]=Ne}}}}if(q===R.nodePositions&&X===R.nodeSizes)return R;const J={...R,nodePositions:q,nodeSizes:X};return z.current=J,J});const P=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");P.length>0&&V(R=>{const q=new Set(R);for(const J of P){const Y=Zp(J==null?void 0:J.id);Y&&(J.selected?q.add(Y):q.delete(Y))}const X=Array.from(q);return X.length===R.length&&X.every((J,Y)=>J===R[Y])?R:X});return}if(!je){const P=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");P.length>0&&g(R=>Nd(P,R));return}const C=(w||[]).filter(P=>{var R,q;return(P==null?void 0:P.type)==="dimensions"&&((R=P.dimensions)==null?void 0:R.width)&&((q=P.dimensions)==null?void 0:q.height)});g(P=>{const R=new Map;if(C.length>0){const J=new Map(P.map(Y=>[Y.id,Y]));for(const Y of C){const le=J.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=Im(le)?Pb(he):Qa(he,{display:!!Ln(le==null?void 0:le.data)});fe&&R.set(Y.id,fe)}}const q=Nd(w,P),X=R.size===0?q:q.map(J=>{const Y=R.get(J.id);if(!Y)return J;const le={...J.data,nodeSize:Y};return Ln(J.data)&&(le.displaySize=Y),{...J,width:Y.width,height:Y.height,data:le}});return j.mutated||(Mt.current={nodes:X,edges:S.current,displayPage:z.current}),_.current=X,X}),C.length>0&&Ur(C.map(P=>P.id))},[gi,Ur,g,f,je]),ip=m.useCallback((w=[],{finish:j=!1}={})=>{const C=j?sY([...K.current,...w]):Nb(w);j&&(K.current=[]),C.length>0&&sp(C)},[sp]),GL=m.useCallback(w=>{const{transient:j,committed:C,finishesInteraction:P}=rY(w);if(j.length>0){de.current&&(window.clearTimeout(de.current),de.current=null),ae.current||(ae.current=!0,Ll.current=Nj.current),K.current=Nb([...K.current,...j]);const R=Nd(j,Ll.current);Ll.current=R,s.getState().setNodes(R)}if(P){Ll.current=[],ip(C,{finish:!0});return}C.length>0&&sp(C)},[sp,ip,s]),Fl=m.useCallback(()=>{ke.current.size>0||qe.current||((ae.current||K.current.length>0)&&(ip([],{finish:!0}),Ll.current=[]),jt.current&&Rl({type:"interaction.finished"}))},[ip,Rl]),YL=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),_o=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask(Fl)},[Fl]),JL=m.useCallback(()=>{qe.current=!0},[]),XL=m.useCallback(()=>{qe.current=!1,window.queueMicrotask(Fl)},[Fl]);m.useEffect(()=>{const w=()=>{ke.current.clear(),qe.current=!1,Fl()},j=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",_o,!0),window.addEventListener("pointercancel",_o,!0),window.addEventListener("lostpointercapture",_o,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pointerup",_o,!0),window.removeEventListener("pointercancel",_o,!0),window.removeEventListener("lostpointercapture",_o,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",j),ke.current.clear(),qe.current=!1,K.current=[],Ll.current=[]}},[_o,Fl]);const QL=m.useCallback(w=>{if(f!=="display"){if(!je){const j=(w||[]).filter(C=>(C==null?void 0:C.type)==="select");j.length>0&&x(C=>{const P=mm(j,C);return S.current=P,P});return}(w||[]).some(j=>(j==null?void 0:j.type)!=="select")&&gi(),x(j=>{const C=mm(w,j);return S.current=C,C})}},[gi,x,f,je]),zl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const j=w.getBoundingClientRect();return r.screenToFlowPosition({x:j.left+j.width*.48,y:j.top+j.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),op=m.useCallback(()=>{var w,j,C;if(Yt){const P=Number(((w=Yt.measured)==null?void 0:w.width)||Yt.width||260);return{x:Number(((j=Yt.position)==null?void 0:j.x)||0)+P+140,y:Number(((C=Yt.position)==null?void 0:C.y)||0)}}return zl()},[zl,Yt]),Gi=m.useCallback((w,j={})=>{if(!je)return ye("Readonly workspace"),null;if(!w)return null;const C=Mv(w)||w.id,P=gM(w),R=wM(w),q=j.id||hJ(C,b),X=ud(w.inputs),J=ud(w.outputs),Y={definitionId:C,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:j.label||Em(w),role:"normal",body:j.body||"",...j.script||R?{script:j.script||R}:{},...j.scriptRef?{scriptRef:j.scriptRef}:{},...j.implementationRef?{implementationRef:j.implementationRef}:{},...j.implementationMode?{implementationMode:j.implementationMode}:{},input:j.inputs||X,output:j.outputs||J},le={id:q,type:Ec,position:j.position||zl(),data:{label:Y.label,definitionId:C,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:mM(C,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={...Sb(le,{...ee.current,[q]:Y},yt),selected:!0};return gi(),g(fe=>[...fe.map(Ne=>({...Ne,selected:!1})),he]),j.openProperties&&sn(q),q},[zl,gi,b,yt,g,je]),ZL=m.useCallback(w=>_w(w,_.current),[]),e2=m.useCallback(w=>{if(!je){ye("Readonly workspace");return}if(!_w(w,_.current)){ye("端口类型不匹配,已取消连线");return}te(null),gi(),g(j=>bw(j,w)),x(j=>{const C=j.filter(R=>!(R.target===w.target&&R.targetHandle===w.targetHandle)),P=Ch({...w,markerEnd:{type:Ai.ArrowClosed}},C);return S.current=P,P})},[gi,x,g,je]),t2=m.useCallback((w,j)=>{if(!je)return;const C=dJ(j,_.current);ne.current=C?{...C,preferExisting:!!(w!=null&&w.shiftKey)}:null,te(null)},[je]),n2=m.useCallback((w,j)=>{var We,Le,qt,st;if(!je)return;const C=ne.current;if(ne.current=null,!C||j!=null&&j.toNode)return;const P=fJ(yt,C),R=pJ(_.current,S.current,C);if(P.length===0&&R.length===0){ye(`没有匹配 ${C.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||C.preferExisting)?R.length>0?"existing":"create":P.length>0?"create":"existing",J=((Le=(We=w==null?void 0:w.changedTouches)==null?void 0:We[0])==null?void 0:Le.clientX)??(w==null?void 0:w.clientX),Y=((st=(qt=w==null?void 0:w.changedTouches)==null?void 0:qt[0])==null?void 0:st.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const le=document.querySelector(".af-workspace-canvas .react-flow");if(!le)return;const he=le.getBoundingClientRect(),fe=320,Ne=Math.max(P.length,R.length),Ve=Math.min(480,150+Ne*58),ze=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:ze,top:Ke,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:C,candidates:P,existingCandidates:R,mode:X,query:""})},[yt,r,je]),r2=m.useCallback(w=>{if(!je){ye("Readonly workspace"),te(null);return}const j=Z.current;if(!j||!(w!=null&&w.def))return;const C=Gi(w.def,{position:j.flowPosition});if(!C)return;const P=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:C,targetHandle:`input-${w.slotIndex}`}:{source:C,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};g(R=>bw(R,P)),x(R=>{const q=R.filter(J=>!(J.target===P.target&&J.targetHandle===P.targetHandle)),X=Ch({...P,markerEnd:{type:Ai.ArrowClosed}},q);return S.current=X,X}),te(null)},[Gi,x,je]),s2=m.useCallback(w=>{if(!je){ye("Readonly workspace"),te(null);return}const j=w==null?void 0:w.connection;if(!j||!_w(j,_.current)){ye("端口类型不匹配,已取消连线"),te(null);return}g(C=>bw(C,j)),x(C=>{const P=C.filter(q=>!(q.target===j.target&&q.targetHandle===j.targetHandle)),R=Ch({...j,markerEnd:{type:Ai.ArrowClosed}},P);return S.current=R,R}),te(null)},[x,g,je]),Oj=m.useCallback(w=>{w&&(Gi(w,{position:op()}),$e(!1),Ft(""))},[Gi,op]),Dj=m.useCallback(w=>{w&&($u(w,op()),$e(!1),Ft(""))},[$u,op]),i2=m.useCallback(w=>{var C,P,R;if(ut||hn)return;const j=w==null?void 0:w.target;q_(j)||(C=j==null?void 0:j.closest)!=null&&C.call(j,"button, a, [role='button'], .react-flow__handle")||(R=(P=N.current)==null?void 0:P.focus)==null||R.call(P,{preventScroll:!0})},[ut,hn]);m.useEffect(()=>{const w=j=>{var le;if(j.defaultPrevented)return;const C=ZU(j.target)||q_(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){j.preventDefault(),on().catch(he=>ye(String(he.message||he)));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),OS(he=>!he);return}if(ty)return;if(ey){(j.key==="Escape"||__(j))&&(j.preventDefault(),Kf(!1));return}const P=j.key.toLowerCase(),R=(j.metaKey||j.ctrlKey)&&P==="c",q=(j.metaKey||j.ctrlKey)&&P==="v",X=C&&R&&CY(j.target);if(C&&!X)return;const J=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&P==="z",Y=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&P==="z"||P==="y");if(J||Y){if(ut){j.preventDefault(),j.stopPropagation(),ye("展示页布局会自动保存");return}if(!je){j.preventDefault(),ye("Readonly workspace");return}j.preventDefault(),j.stopPropagation();const he=J?QS():ZS();ye(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(R){if(ut)return;const he=Qv.current,fe=(_.current||[]).some(Ve=>Ve==null?void 0:Ve.selected)?_.current:(_.current||[]).map(Ve=>he&&Ve.id===he?{...Ve,selected:!0}:Ve),Ne=vU(fe,S.current,ee.current);Ne&&(j.preventDefault(),j.stopPropagation(),W.current=Ne,EJ(Ne),X&&typeof((le=j.target)==null?void 0:le.blur)=="function"&&j.target.blur(),ye(`Copied ${Ne.nodes.length} node${Ne.nodes.length>1?"s":""}`));return}if(q){if(ut){j.preventDefault(),j.stopPropagation();return}if(!je){j.preventDefault(),ye("Readonly workspace");return}const he=W.current||IJ();he&&!W.current&&(W.current=he);const fe=SU(he,_.current,S.current,ee.current);fe&&(j.preventDefault(),j.stopPropagation(),ee.current=fe.instances,se(fe.instances),g(fe.nodes),x(fe.edges),ye(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(__(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Kf(!0);return}if(P==="g"&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Cj();return}if(j.key==="a"||j.key==="A"){if(j.metaKey||j.ctrlKey){j.preventDefault(),ut?V(z.current.nodeIds):(g(he=>he.map(fe=>({...fe,selected:!0}))),x(he=>he.map(fe=>({...fe,selected:!1}))));return}if(j.altKey)return;if(ut){j.preventDefault(),vn(!0);return}if(!je){j.preventDefault(),ye("Readonly workspace");return}j.preventDefault(),$e(!0);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),DS("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),DS("pan");return}(j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),_j())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[Cj,ut,ty,_j,ZS,on,ey,x,g,QS,je]);const o2=m.useCallback(w=>{Sl(j=>{const C=new Set(j);return C.has(w)?C.delete(w):C.add(w),C})},[]),a2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:j.path,name:j.name,type:j.type})),w.dataTransfer.setData("text/plain",j.path)},[]),l2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",j.id),w.dataTransfer.setData("text/plain",j.id)},[]),ap=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),P=C.split(".").pop(),R=["jsx","tsx","js"].includes(P)?"display_react_app":P==="html"?"display_html":P==="csv"||P==="tsv"||P==="json"&&/\b(table|data|rows|report)\b/i.test(C)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(P)?"display_image":"display_markdown",q=yt.find(fe=>fe.id===R);if(!q){ye("展示节点不可用");return}const X=R==="display_image";let J=String(w.path||"");if(!X){const fe=Wr(a);fe.set("path",w.path);const Ne=await fetch(`/api/workspace/file?${fe.toString()}`),Ve=await Ne.json();if(!Ne.ok)throw new Error(Ve.error||"读取文件失败");J=String(Ve.content||"")}const Y=R==="display_image"?"src":"content",le=ud(q.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),he=ud(q.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);Gi(q,{label:w.name||"Display",body:J,inputs:le,outputs:he,position:j}),ye(`已创建展示:${w.path}`)},[Gi,a,yt]),c2=m.useCallback(w=>{if(!je){ye("Readonly workspace");return}ap(w,zl()).catch(j=>ye(String(j.message||j)))},[ap,zl,je]),u2=m.useCallback(w=>{if(!je){w.preventDefault(),ye("Readonly workspace");return}const j=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(j){w.preventDefault();let X;try{X=JSON.parse(j)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});ap(X,J).catch(Y=>ye(String(Y.message||Y)));return}const C=w.dataTransfer.getData("application/agentflow-snippet");if(C){const X=vt.find(Y=>`${Y.id}@${Y.version}`===C);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});$u(X,J);return}const P=w.dataTransfer.getData("application/agentflow-node");if(!P)return;const R=yt.find(X=>X.id===P);if(!R)return;w.preventDefault();const q=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Gi(R,{position:q})},[ap,Gi,vt,$u,yt,r,je]),d2=m.useCallback(w=>{if(!je)return;const j=Array.from(w.dataTransfer.types||[]);!j.includes("application/x-agentflow-workspace-file")&&!j.includes("application/agentflow-node")&&!j.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=j.includes("application/agentflow-node")||j.includes("application/agentflow-snippet")?"move":"copy")},[je]),f2=m.useCallback(async(w="")=>{if(!je){ye("Readonly workspace");return}const j=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const P=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C,content:""})}),R=await P.json();if(!P.ok)throw new Error(R.error||"创建文件失败");await $n(),Sl(q=>{const X=new Set(q);for(const J of eh(R.path||C))X.delete(J);return X}),ye(`已创建 ${R.path}`)}catch(P){ye(String(P.message||P))}},[a,$n,je]),p2=m.useCallback(async(w="")=>{if(!je){ye("Readonly workspace");return}const j=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const P=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C})}),R=await P.json();if(!P.ok)throw new Error(R.error||"创建文件夹失败");await $n(),Sl(q=>{const X=new Set(q);for(const J of eh(R.path||C))X.delete(J);return R.path&&X.delete(R.path),X}),ye(`已创建 ${R.path}`)}catch(P){ye(String(P.message||P))}},[a,$n,je]),h2=m.useCallback(async w=>{if(!je){ye("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const j=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),C=await j.json();if(!j.ok)throw new Error(C.error||"删除失败");ye(`已删除 ${C.path}`),await $n()}catch(j){ye(String(j.message||j))}},[a,$n,je]),m2=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const j=ff(w.path,a,{download:!0});if(!j)return;const C=document.createElement("a");C.href=j,C.download=w.name||w.path.split("/").pop()||"download",C.rel="noopener",document.body.appendChild(C),C.click(),C.remove()},[a]),lp=m.useCallback(async()=>{if(!je){ye("Readonly workspace");return}const w=Sa.trim(),j=Gr,C=qs.find(X=>X.id===j)||null;if(!w||ls||(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="stopping")return;const P=C?Array.isArray(C.messages)?C.messages:[]:ja,R=Yl(b,k,ee.current);Yg(""),TS(!0),Al(!0),El(null);const q={role:"user",text:w,at:Date.now()};C?Xn(X=>X.map(J=>J.id===j?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],q].slice(-180)}:J)):(Cs("workspace"),Cl(X=>[...X,q]));try{await on(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:R,allowFlowYaml:!1,model:Vi,selectedSkills:Ks,selectedNodeIds:tp,messages:P})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const le={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};C?Xn(he=>he.map(fe=>fe.id===j?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],le].slice(-180)}:fe)):Cl(he=>[...he,le]),await As(),ye("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};C?Xn(le=>le.map(he=>he.id===j?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):Cl(le=>[...le,Y]),ye(J)}finally{TS(!1)}},[Gr,ja,Vi,qs,ls,Sa,k,a,As,b,on,tp,Ks,je]),ur=qs.find(w=>w.id===Gr)||null,gy=ur?Array.isArray(ur.messages)?ur.messages:[]:ja,Wl=ur&&(ur.status==="running"||ur.status==="stopping")||ls,g2=dX(gy,Wl),yy=fX(gy),Fj=ur?ur.status==="stopping"?`${ur.label} stopping`:ur.status==="running"?`${ur.label} running`:ur.status==="paused"?`${ur.label} paused`:ur.status==="failed"?`${ur.label} failed`:`${ur.label} done`:ls?"Workspace agent running":ja.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Gr!=="workspace"&&(qs.some(w=>w.id===Gr)||Cs(Ca()))},[Gr,qs,Ca]),m.useEffect(()=>{if(!xu)return;const w=window.requestAnimationFrame(()=>{var C,P;const j=RS.current;j&&(j.scrollTop=j.scrollHeight),(P=(C=Jg.current)==null?void 0:C.scrollIntoView)==null||P.call(C,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[gy.length,Gr,Fj,yy.length,xu]);const y2=String(a.flowId||"").trim()||"Workspace",Co=(rt==null?void 0:rt.mode)==="single-node",zj=Co&&Mu.find(w=>{var j;return w.id===rt.sourceNodeId||((j=rt.nodeIds)==null?void 0:j.includes(w.id))})||null,w2=Co&&zj?[zj]:Mu;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":a.returnTo||"/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} · ${tS}`:tS||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:y2}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",yY,"-STABLE"]})]}),zf?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",zf.ownerUsername||zf.ownerUserId]}):null,i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:f==="workspace"?"af-view-switch__active":"",onClick:()=>hy("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:f==="display"?"af-view-switch__active":"",onClick:()=>hy("display"),children:"Display"}),i.jsx("button",{type:"button",className:f==="workflow"?"af-view-switch__active":"",onClick:()=>hy("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${VS}`,title:`${JS} · ${KS}`,role:"status","aria-label":`${JS}:${KS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),Mn?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=Mn.conflictItems)!=null&&w.length?ka(!0):$j()},title:["先下载当前本地草稿,再载入远端最新版本",...Mn.conflictPaths||[]].join(`
265
- `),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,ut?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||Yn||!(ge!=null&&ge.absoluteUrl)&&I.nodeIds.length===0,onClick:()=>{Xt(""),wr(!0)},title:ge!=null&&ge.absoluteUrl?"查看展示链接":I.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Yn?"hourglass_empty":"ios_share"}),Yn?"生成中":ge!=null&&ge.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||$l.length===0,onClick:()=>vn(!0),title:$l.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:hn?!Jn:!je||!!(Lt!=null&&Lt.role&&Lt.role!=="owner"),onClick:()=>{hn?G$(w=>w+1):OL()},title:hn?Jn?"管理当前需求的成员权限和只读链接":"先读取一个 TAPD 需求":Lt!=null&&Lt.role&&Lt.role!=="owner"?"仅 Workspace 所有者可以管理项目协作":"管理项目的团队和成员协作",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作"]}),zf?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:WL,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:!YS,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:!YS&&!_u,onClick:()=>v(!0),"aria-label":_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:_u?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Kf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(xu?" af-composer-topbar-btn--active":"")+(ls?" af-composer-topbar-btn--running":""),disabled:!je||ut||hn,onClick:()=>{El(null),Al(w=>(w||Cs(Ca()),!w))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!je,onClick:()=>on().catch(w=>ye(String(w.message||w))),children:"Save"})]})]}),vs?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:vs}),i.jsx("button",{type:"button",onClick:()=>sr(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!ut&&!hn&&(xu||gt)?" af-workspace-body--drawer":"")+(!ut&&!hn&&ku?" af-workspace-body--sidebar-collapsed":"")+(ut?" af-workspace-body--display-mode":"")+(hn?" af-workspace-body--workflow-mode":""),children:[!ut&&!hn&&ku?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:()=>Vf(!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:()=>Vf(!1),"aria-label":"展开侧边栏",title:(Dr==null?void 0:Dr.username)||(Dr==null?void 0:Dr.userId)||"展开侧边栏",children:RL})]})}):null,!ut&&!hn?i.jsxs("aside",{ref:Wg,className:"af-workspace-sidebar"+(Q$?" af-workspace-sidebar--resizing":""),"aria-hidden":ku,style:{"--af-work-files-pane-height":`${Math.round(Bg)}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:()=>Vf(!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:!je,onClick:()=>f2(Ui),"aria-label":"新增文件",title:Ui?`在 ${Ui} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je,onClick:()=>p2(Ui),"aria-label":"新增文件夹",title:Ui?`在 ${Ui} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je||dS,onClick:()=>pj(Ui),"aria-label":"上传文件",title:Ui?`上传到 ${Ui}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:dS?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void $n(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:pS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:SL})]})]}),i.jsx("input",{className:"af-workspace-search",value:Og,onChange:w=>J$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:PL,children:i.jsx(MM,{items:IL,onOpen:c2,selectedPath:Dg,collapsedDirs:X$,onToggleDir:o2,onSelect:w=>Fg(w.path||""),onFileDragStart:a2,onDelete:h2,onDownload:m2})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:aL,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:Be==="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:Ce,onChange:w=>Ge(w.target.value),placeholder:Be==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Be==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":Be==="nodes",className:"af-palette-tab"+(Be==="nodes"?" af-palette-tab--active":""),onClick:()=>Et("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":Be==="flows",className:"af-palette-tab"+(Be==="flows"?" af-palette-tab--active":""),onClick:()=>Et("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:Be==="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:$L,disabled:or.length<2,title:or.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:["已选 ",or.length," 节点 / ",np.length," 连线"]})]})}),bt?i.jsx("p",{className:"af-err af-palette-list-err",children:bt}):null,He?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Tj.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:Tj.map(w=>{const j=`${w.id}@${w.version}`,C=w.displayName||w.name||w.id,P=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:R=>{R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("application/agentflow-snippet",j),R.dataTransfer.setData("text/plain",j)},onClick:()=>$u(w),title:P,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:C}),i.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),P?i.jsx("span",{className:"af-palette-card-desc",children:P}):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"]})]})]},j)})})]}):i.jsx("p",{className:"af-palette-empty",children:Ce.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Ql.map(w=>{var j;return(j=uy[w])!=null&&j.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:uy[w].map(C=>{const P=Z_(C.inputs,"input"),R=Z_(C.outputs,"output"),q=Ib(C),X=ld(C);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>l2(J,C),onClick:()=>Gi(C),title:q||C.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:X_(w)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:X}),X!==C.id?i.jsx("span",{className:"af-palette-card-id",children:C.id}):null]})]}),q?i.jsx("span",{className:"af-palette-card-desc",children:q}):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:[P.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[P.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:Q_("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Dn(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Xp(J,Y)})]},`in-${Y}`)),P.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",P.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:[R.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[R.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:Q_("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Xp(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Dn(J==null?void 0:J.type)}})]},`out-${Y}`)),R.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",R.hidden]}):null]})]})]})]},C.id)})})]},w):null}),yt.length>0&&Ce.trim()&&Ql.every(w=>{var j;return!((j=uy[w])!=null&&j.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,hn?i.jsx(AX,{flowParams:a,tapdId:Jn,setTapdId:sL,collaborationOpenRequest:U$,snapshot:dn,loading:iL,error:oL,actionRunning:Hg,actionOutput:Vg,pendingConfirm:_s,conflict:wu,reviewPublishing:Kg,onRefresh:()=>Au(Jn),onRunDryRun:gL,onConfirmAction:yL,onRetryConflict:wL,onPublishReview:xL}):i.jsxs("main",{ref:N,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{i2(w),YL(w)},onLostPointerCaptureCapture:_o,children:[i.jsx(VT,{className:"af-flow-canvas af-workspace-flow"+(ny==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ut?" af-workspace-flow--display-mode":""),nodes:ep,edges:AL,nodeTypes:rX,onNodesChange:GL,onEdgesChange:QL,onMoveStart:JL,onMoveEnd:XL,onConnect:ut?void 0:e2,onConnectStart:ut?void 0:t2,onConnectEnd:ut?void 0:n2,isValidConnection:ut?void 0:ZL,onNodeClick:(w,j)=>{var C;if(ut){V([Zp(j.id)]);return}if((C=j==null?void 0:j.data)!=null&&C.isWorkspaceGroup){sn("");return}if(w.detail>=3){Al(!1),g(P=>P.map(R=>({...R,selected:R.id===j.id}))),x(P=>P.map(R=>({...R,selected:!1}))),sn(j.id);return}br&&sn(j.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{ut?V([]):sn("")},onDrop:ut?void 0:u2,onDragOver:ut?void 0:d2,nodesDraggable:je,nodesConnectable:ut?!1:je,edgesReconnectable:ut?!1:je,onlyRenderVisibleElements:ep.length>=80,deleteKeyCode:ut?null:je?["Backspace","Delete"]:null,selectionOnDrag:ny==="select",panOnDrag:ny==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(qT,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ut&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),j=G.mode==="create"?"create":"existing",C=Array.isArray(G.candidates)?G.candidates:[],P=Array.isArray(G.existingCandidates)?G.existingCandidates:[],R=w?C.filter(Y=>{var le,he,fe;return[(le=Y.def)==null?void 0:le.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(Ne=>String(Ne).toLowerCase().includes(w))}):C,q=w?P.filter(Y=>{var le,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(le=Y.slot)==null?void 0:le.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):P,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:Dn((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:j==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:P.length===0,onClick:()=>te(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:P.length})]}),i.jsxs("button",{type:"button",className:j==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:C.length===0,onClick:()=>te(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:C.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(le=>le&&{...le,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[j==="create"?R.map(Y=>{var fe,Ne;const le=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),he=Xp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>r2(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:le}),le!==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:Dn((Ne=Y.slot)==null?void 0:Ne.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${Y.def.id}-${Y.slotIndex}`)}):q.map(Y=>{var fe;const le=Y.nodeLabel||Y.nodeId,he=Xp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>s2(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:le}),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:Dn((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}`)}),(j==="create"?R.length:q.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ut&&!hn&&!dL?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:()=>Xg(!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:or.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):or.map(w=>{var R,q;const j=String(((R=w.data)==null?void 0:R.label)??w.id),C=(q=w.data)!=null&&q.definitionId?String(w.data.definitionId):"",P=C&&C!==j?`${j} · ${w.id} · ${C}`:`${j} · ${w.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:P,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:C||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:j}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>UL(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:Sa,rows:2,onChange:w=>Yg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),lp())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!je})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Gg,type:"button",className:"af-composer-skills-button"+(Ks.length>0?" af-composer-skills-button--active":""),disabled:ls||!je,"aria-haspopup":"listbox","aria-expanded":Hf,onClick:()=>Ug(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Ks.length>0?`Skills ${Ks.length}`:"Skills"})]}),Hf&&!ls?pr.createPortal(i.jsx("div",{ref:IS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:cL,children:Vs.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Ol.groups.map(w=>{const j=ca(w,Vs),C=dz(w,dy,Vs),P=lL.has(w.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(P?" 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:C==="all",disabled:j.length===0,onChange:R=>{const q=R.target.checked;hu(X=>q?cz(X,j):uz(X,j))}}),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,C==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":P?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{ES(R=>{const q=new Set(R);return q.has(w.id)?q.delete(w.id):q.add(w.id),q})},children:[i.jsx("span",{children:w.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:P?"expand_more":"expand_less"})]})]}),P?null:i.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(R=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:dy.has(R.key),onChange:q=>{const X=q.target.checked;hu(J=>X?J.includes(R.key)?J:[...J,R.key]:J.filter(Y=>Y!==R.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:R.name}),R.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:R.description}):null]})]},`${w.id}:${R.key}`))})]},w.id)}),Ol.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:Ol.ungrouped.length})]}),Ol.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:dy.has(w.key),onChange:j=>{const C=j.target.checked;hu(P=>C?P.includes(w.key)?P:[...P,w.key]:P.filter(R=>R!==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:Vi,onChange:w=>eL(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),TL.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(Sa.trim()&&!ls?" af-composer-send--active":"")+(ls?" af-composer-send--stop":""),disabled:ls||!Sa.trim()||!je,"aria-label":ls?"Running":"Send",onClick:()=>void lp(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ls?"sync":"arrow_upward"})})]})]})]})}):!ut&&!hn?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Xg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!ut&&!hn&&xu?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:()=>Al(!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"+(Gr==="workspace"?" af-composer-session-tab--active":""),ref:Gr==="workspace"?Jg:null,onClick:()=>Cs("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),qs.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:Gr===w.id?Jg:null,className:"af-composer-session-tab"+(Gr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>Cs(w.id),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),Cs(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:j=>{j.preventDefault(),j.stopPropagation(),kL(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"+(Wl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Fj}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:RS,children:[i.jsx(uC,{messages:g2,running:Wl,showRunningIndicator:!ur}),yy.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",...Wl?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(uC,{messages:yy,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:Sa,rows:3,onChange:w=>Yg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),lp())},placeholder:ur?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!je||Wl}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!je||Wl||!Sa.trim(),onClick:()=>void lp(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!ut&&!hn&&gt&&Yt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(kG,{draft:gt,setDraft:Ns,definitionId:String(((Wj=Yt.data)==null?void 0:Wj.definitionId)||Yt.id),systemPromptReadonly:String(((Bj=Yt.data)==null?void 0:Bj.description)||""),modelLists:va,disabled:!je,onIdBlur:()=>ay(!0),onClose:()=>sn(""),onPublishToMarketplace:bL,error:W$,ioSlots:{inputs:Array.isArray(gt==null?void 0:gt.inputs)?gt.inputs:[],outputs:Array.isArray(gt==null?void 0:gt.outputs)?gt.outputs:[]}})}):null,!ut&&!hn&&bu?pr.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>El(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(oG,{flowParams:a,scheduleNodeId:bu.scheduleNodeId,runNodeId:bu.runNodeId,lastRunId:bu.lastRunId,label:bu.label,onClose:()=>El(null)})})}),document.body):null,i.jsx(nG,{open:ey,onClose:()=>Kf(!1)}),i.jsx(sG,{open:ty,onClose:()=>OS(!1),onJump:cy,nodes:EL}),i.jsx(vG,{open:d,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:Nu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(SG,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:Nu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:_u,onDeleted:async()=>{v(!1),n("/projects")}}),Y$&&Mn?pr.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"}),"解决 ",((Hj=Mn.conflictItems)==null?void 0:Hj.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ka(!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:()=>vl(Object.fromEntries((Mn.conflictItems||[]).map((w,j)=>[String(j),{mode:"local",manual:Ju(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>vl(Object.fromEntries((Mn.conflictItems||[]).map((w,j)=>[String(j),{mode:"remote",manual:Ju(w)}]))),children:"全部使用远端"})]})]}),(Mn.conflictItems||[]).map((w,j)=>{const C=Lg[String(j)]||{mode:"local",manual:Ju(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(([P,R])=>i.jsx("button",{type:"button",className:C.mode===P?"is-active":"",onClick:()=>vl(q=>({...q,[String(j)]:{...C,mode:P}})),children:R},P))}),i.jsxs("div",{className:"af-workspace-conflict-values",children:[i.jsxs("div",{className:C.mode==="local"?"is-selected":"",children:[i.jsx("span",{children:"我的修改"}),i.jsx("pre",{children:xC(w,"incoming")})]}),i.jsxs("div",{className:C.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:xC(w,"current")})]})]}),C.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:C.manual,onChange:P=>vl(R=>({...R,[String(j)]:{...C,manual:P.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${j}`)}),uS?i.jsx("div",{className:"af-flow-snippet-error",children:uS}):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:Bf,onClick:()=>void $j(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Bf,onClick:()=>ka(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Bf||!(Mn.conflictItems||[]).length,onClick:()=>void FL(),children:Bf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,Tn?pr.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:()=>An(!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:en.name,onChange:w=>{const j=w.target.value;bn(C=>({...C,name:j,id:C.id?C.id:j.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:en.id,onChange:w=>bn(j=>({...j,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:en.description,onChange:w=>bn(j=>({...j,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",or.length," 个节点和 ",np.length," 条内部连线。"]}),kn?i.jsx("div",{className:"af-flow-snippet-error",children:kn}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>An(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:nr||!en.name.trim(),onClick:()=>void LL(),children:nr?"发布中...":"发布"})]})]})}),document.body):null,vj?i.jsx(KJ,{node:vj,onClose:()=>U("")}):null,Nr?pr.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":Co?"新建分享":"发布展示页",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"}),Co?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>_r(!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=>Bt(j=>({...j,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),Co?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=>Bt(j=>({...j,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:sC(rt),onChange:w=>{const j=w.target.value;Bt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Cw.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":Co?"分享内容":"选择展示节点",children:[Co?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,w2.map(w=>{var C;const j=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:j,disabled:Co,onChange:()=>zL(w.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((C=w.data)==null?void 0:C.label)||w.id}),i.jsxs("small",{children:[Ln(w.data)," · ",w.id]})]})]},w.id)})]}),ge!=null&&ge.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:ge.absoluteUrl,onFocus:w=>w.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(ge.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void Lj(),children:ct==="copied"?"已复制":ct==="failed"?"复制失败":"复制"})]}):null,Or?i.jsx("div",{className:"af-flow-snippet-error",children:Or}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>_r(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Yn||!Array.isArray(rt.nodeIds)||rt.nodeIds.length===0,onClick:()=>void BL(),children:Yn?"生成中...":"生成链接"})]})]})}),document.body):null,Ar?pr.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:()=>{Xt(""),wr(!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:[ge!=null&&ge.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:ge.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(ge.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 Lj(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ct==="copied"?"check":"content_copy"}),ct==="copied"?"已复制":ct==="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:sC(rt),onChange:w=>{const j=w.target.value;Bt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Cw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),Or?i.jsx("div",{className:"af-flow-snippet-error",children:Or}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Xt(""),wr(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Yn||I.nodeIds.length===0,onClick:()=>void HL(),children:Yn?"生成中...":ge!=null&&ge.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,K$?pr.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:()=>Rg(!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:Hs?Hs.name:"尚未加入团队"})]}),Hs?i.jsxs("div",{className:"af-workspace-team-share__actions",children:[i.jsxs("select",{value:$g,onChange:w=>aS(w.target.value),"aria-label":"团队权限",children:[i.jsx("option",{value:"viewer",children:"只读"}),i.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(Vj=Lt==null?void 0:Lt.teamShares)!=null&&Vj.some(w=>w.teamId===Hs.id)?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!1),children:du?"处理中...":"更新权限"}),i.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!0),children:"取消分享"})]}):i.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!1),children:du?"分享中...":"分享到团队"})]}):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:uu,onChange:w=>sS(w.target.value),onKeyDown:w=>{w.key==="Enter"&&uu.trim()&&!Mg&&(w.preventDefault(),Mj())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:Mg||!uu.trim(),onClick:()=>void Mj(),children:Mg?"添加中...":"添加成员"})]}),rS?i.jsx("div",{className:"af-flow-snippet-error",children:rS}):null,i.jsx("div",{className:"af-workspace-member-list",children:((Lt==null?void 0:Lt.members)||[]).map(w=>{const j=w.userId===(Lt==null?void 0:Lt.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:j?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:w.username||w.userId}),i.jsx("small",{children:j?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),j?null:i.jsx("button",{type:"button",disabled:iS===w.userId,onClick:()=>void DL(w),children:iS===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:()=>Rg(!1),children:"完成"})})]})}),document.body):null,Qt?pr.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:()=>ir(!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:ot.length?`${ot.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Js(),disabled:Ws,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Bs?i.jsx("div",{className:"af-flow-snippet-error",children:Bs}):null,Ws?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!Ws&&ot.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:ot.map(w=>{const j=oC(w),C=ve===w.id,P=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:_J(w)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:j,onFocus:R=>R.target.select()}),i.jsx("select",{className:"af-display-share-select",value:P,disabled:C,onChange:R=>void KL(w,R.target.value),"aria-label":"修改分享有效期",children:Cw.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))}),i.jsxs("div",{className:"af-display-share-item__actions",children:[i.jsxs("button",{type:"button",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void VL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Nt===w.id?"check":"content_copy"}),Nt===w.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:C,onClick:()=>void qL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,rn?pr.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:()=>vn(!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:Vn,onChange:w=>Ss(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":Pj.length||1},children:rp.length>0?Pj.map((w,j)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(ML)},`display-picker-column-${j}`)):i.jsx("div",{className:"af-display-picker-empty",children:$l.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:()=>vn(!1),children:"完成"})})]})}),document.body):null,pu.nodeId?pr.createPortal(i.jsx(uX,{files:bl,query:pu.query,onQueryChange:w=>zg(j=>({...j,query:w})),onSelect:jL,onUpload:pj,onClose:iy}),document.body):null,!ut&&!hn&&we?pr.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":Ae==="nodes",className:"af-workspace-quick-add__tab"+(Ae==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ze("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":Ae==="flows",className:"af-workspace-quick-add__tab"+(Ae==="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:PS,value:En,onChange:w=>Ft(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),$e(!1);else if(w.key==="ArrowDown"){w.preventDefault();const j=Ae==="flows"?Ru.length:Tu.length;cr(C=>Math.min(Math.max(0,j-1),C+1))}else w.key==="ArrowUp"?(w.preventDefault(),cr(j=>Math.max(0,j-1))):w.key==="Tab"?(w.preventDefault(),Ze(j=>j==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),Ae==="flows"?Dj(Ru[Rn]||Ru[0]):Oj(Tu[Rn]||Tu[0]))},placeholder:Ae==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ae==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:Ae==="flows"?Ru.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:He?"正在加载流程片段...":bt||"没有匹配的流程片段"}):Ru.map((w,j)=>{const C=w.displayName||w.name||w.id,P=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,R=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,q=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(P||{}).length,X=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(R)?R.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===Rn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>cr(j),onClick:()=>Dj(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:C}),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||`${q} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):Tu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Tu.map((w,j)=>{const C=ad(w),P=ld(w),R=Ib(w);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===Rn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>cr(j),onClick:()=>Oj(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:X_(C)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:P}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),R?i.jsx("span",{className:"af-workspace-quick-add__desc",children:R}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:C})]},w.id)})})]})}),document.body):null]})]})}function KM(){return i.jsx(iv,{children:i.jsx(IX,{})})}function PX(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 TX(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 RX(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 qM(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=RX(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
270
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
271
- `).replace(/\s+$/g,""):f.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 Dv(e){let t=qM(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 MX(e){const t=Dv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function $X(e){const t=Dv(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 UM(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 LX(e,t,n={}){const r=String(e||"").trim();return r?UM(r,t,n):""}function OX({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 f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),h=p>d+1,y=h?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=h?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const f=requestAnimationFrame(a),p=n.current;if(!p||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const d=new ResizeObserver(a);d.observe(p);for(const h of Array.from(p.children))d.observe(h);return()=>{cancelAnimationFrame(f),d.disconnect()}},[t,a]);const l=m.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=m.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(f-h.top-p)/v},[s.height]),u=m.useCallback(f=>{if(!s.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=f.clientY>=d.top+h&&f.clientY<=d.top+h+y?f.clientY-d.top-h:y/2;l(c(f.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 Lb({node:e,shareId:t,style:n,bare:r=!1}){const s=PX(e),o=e.kind==="html"?Dv(s):e.kind==="react"?jg(s):qM(s),a=e.kind==="html"?MX(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:TX(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(OX,{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:$X(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:Av(o)}):null,e.kind==="image"?i.jsx("img",{src:UM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(vv,{content:o,resolveSrc:(c,u)=>LX(c,t,u)})}):null,e.kind==="chart"?i.jsx(jv,{content:o}):null,e.kind==="table"?i.jsx(Sv,{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 DX({data:e}){return i.jsx(Lb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const FX={publicDisplay:DX};function zX(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 GM(){var l,c,u,f;const{path:e}=os(),t=m.useMemo(()=>zX(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let p=!1;async function d(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");p||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){p||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return d(),()=>{p=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((d,h)=>{const y=d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"?d.position:{x:120+h*40,y:100+h*32},v=d.size&&typeof d.size.width=="number"&&typeof d.size.height=="number"?d.size:{width:520,height:320};return{id:d.id,type:"publicDisplay",position:y,data:{node:d,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 p=(v=n.share)==null?void 0:v.viewport;if(!p||typeof p!="object")return null;const d=Number(p.x),h=Number(p.y),y=Number(p.zoom);return!Number.isFinite(d)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:d,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(d=>i.jsx(Lb,{node:d,shareId:t,bare:!0},d.id))})});const p=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 ${p}`,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:(f=n.share)!=null&&f.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>i.jsx(Lb,{node:d,shareId:t},d.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(iv,{children:i.jsx(VT,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:FX,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(qT,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const St=e=>typeof e=="string",Xu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},bC=e=>e==null?"":""+e,WX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},BX=/###/g,kC=e=>e&&e.indexOf("###")>-1?e.replace(BX,"."):e,vC=e=>!e||St(e),Pd=(e,t,n)=>{const r=St(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(vC(e))return{};const o=kC(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return vC(e)?{}:{obj:e,k:kC(r[s])}},SC=(e,t,n)=>{const{obj:r,k:s}=Pd(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=Pd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Pd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},HX=(e,t,n,r)=>{const{obj:s,k:o}=Pd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},Mm=(e,t)=>{const{obj:n,k:r}=Pd(e,t);if(n)return n[r]},VX=(e,t,n)=>{const r=Mm(e,n);return r!==void 0?r:Mm(t,n)},YM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?St(e[r])||e[r]instanceof String||St(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):YM(e[r],t[r],n):e[r]=t[r]);return e},Jl=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var KX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const qX=e=>St(e)?e.replace(/[&<>"'\/]/g,t=>KX[t]):e;class UX{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 GX=[" ",",","?","!",";"],YX=new UX(20),JX=(e,t,n)=>{t=t||"",n=n||"";const r=GX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=YX.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},Ob=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},$m=e=>e&&e.replace("_","-"),XX={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 Lm{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||XX,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:(St(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Lm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Lm(this.logger,t)}}var Pi=new Lm;class Cg{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 jC extends Cg{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):St(r)&&o?l.push(...r.split(o)):l.push(r)));const c=Mm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!St(r)?c:Ob(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),SC(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)(St(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=Mm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?YM(c,r,o):c={...c,...r},SC(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 JM={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 NC={};class Om extends Cg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),WX(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Pi.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&&!JX(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:St(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:St(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,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(f){const _=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${_}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${_}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const p=this.resolve(t,n);let d=p&&p.res;const h=p&&p.usedKey||a,y=p&&p.exactUsedKey||a,v=Object.prototype.toString.apply(d),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!St(d)&&typeof d!="boolean"&&typeof d!="number";if(k&&d&&x&&b.indexOf(v)<0&&!(St(g)&&Array.isArray(d))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,d,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(p.res=_,p.usedParams=this.getUsedParamsDetails(n),p):_}if(o){const _=Array.isArray(d),S=_?[]:{},N=_?y:h;for(const I in d)if(Object.prototype.hasOwnProperty.call(d,I)){const T=`${N}${o}${I}`;S[I]=this.translate(T,{...n,joinArrays:!1,ns:l}),S[I]===T&&(S[I]=d[I])}d=S}}else if(k&&St(g)&&Array.isArray(d))d=d.join(g),d&&(d=this.extendTranslation(d,t,n,r));else{let _=!1,S=!1;const N=n.count!==void 0&&!St(n.count),I=Om.hasDefaultValue(n),T=N?this.pluralResolver.getSuffix(u,n.count,n):"",z=n.ordinal&&N?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",E=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),D=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${T}`]||n[`defaultValue${z}`]||n.defaultValue;!this.isValidLookup(d)&&I&&(_=!0,d=D),this.isValidLookup(d)||(S=!0,d=a);const O=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&S?void 0:d,M=I&&D!==d&&this.options.updateMissing;if(S||_||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?D:d),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 B=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&B&&B[0])for(let $=0;$<B.length;$++)V.push(B[$]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(n.lng||this.language):V.push(n.lng||this.language);const F=($,H,A)=>{const Q=I&&A!==d?A:O;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,H,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing($,c,H,Q,M,n),this.emit("missingKey",$,c,H,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?V.forEach($=>{const H=this.pluralResolver.getSuffixes($,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(A=>{F([$],a+A,n[`defaultValue${A}`]||D)})}):F(V,a,D))}d=this.extendTranslation(d,t,n,p,r),S&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${c}:${a}`),(S||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,_?d:void 0):d=this.options.parseMissingKeyHandler(d))}return s?(p.res=d,p.usedParams=this.getUsedParamsDetails(n),p):d}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=St(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(u){const d=t.match(this.interpolator.nestingRegexp);f=d&&d.length}let p=r.replace&&!St(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(p={...this.options.interpolation.defaultVariables,...p}),t=this.interpolator.interpolate(t,p,r.lng||this.language||s.usedLng,r),u){const d=t.match(this.interpolator.nestingRegexp),h=d&&d.length;f<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var d=arguments.length,h=new Array(d),y=0;y<d;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=St(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=JM.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 St(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),f=u.key;s=f;let p=u.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const d=n.count!==void 0&&!St(n.count),h=d&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(St(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(b=>{this.isValidLookup(r)||(l=b,!NC[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(NC[`${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=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,g,b,n);else{let _;d&&(_=this.pluralResolver.getSuffix(g,n.count,n));const S=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(k.push(f+_),n.ordinal&&_.indexOf(N)===0&&k.push(f+_.replace(N,this.options.pluralSeparator)),h&&k.push(f+S)),y){const I=`${f}${this.options.contextSeparator}${n.context}`;k.push(I),d&&(k.push(I+_),n.ordinal&&_.indexOf(N)===0&&k.push(I+_.replace(N,this.options.pluralSeparator)),h&&k.push(I+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&&!St(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 Iw=e=>e.charAt(0).toUpperCase()+e.slice(1);class _C{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Pi.create("languageUtils")}getScriptPartFromCode(t){if(t=$m(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=$m(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(St(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]=Iw(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]=Iw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Iw(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)),St(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 St(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))):St(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let QX=[{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}],ZX={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 eQ=["v1","v2","v3"],tQ=["v4"],CC={zero:0,one:1,two:2,few:3,many:4,other:5},nQ=()=>{const e={};return QX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:ZX[t.fc]}})}),e};class rQ{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Pi.create("pluralResolver"),(!this.options.compatibilityJSON||tQ.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=nQ(),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=$m(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)=>CC[s]-CC[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!eQ.includes(this.options.compatibilityJSON)}}const AC=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=VX(e,t,n);return!o&&s&&St(n)&&(o=Ob(e,n,r),o===void 0&&(o=Ob(t,n,r))),o},Pw=e=>e.replace(/\$/g,"$$$$");class sQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pi.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:f,unescapePrefix:p,nestingPrefix:d,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:qX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Jl(o):a||"{{",this.suffix=l?Jl(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=d?Jl(d):h||Jl("$t("),this.nestingSuffix=y?Jl(y):v||Jl(")"),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=AC(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(AC(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Pw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Pw(this.escape(h)):Pw(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 f=="function"){const b=f(t,o,s);a=St(b)?b:""}else if(s&&Object.prototype.hasOwnProperty.call(s,y))a="";else if(p){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!St(a)&&!this.useRawValueToEscape&&(a=bC(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),p?(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 f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${f}[ ]*{`));let d=`{${p[1]}`;c=p[0],d=this.interpolate(d,a);const h=d.match(/'/g),y=d.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(d=d.replace(/'/g,'"'));try{a=JSON.parse(d),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${f}${d}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!St(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 f=s[1].split(this.formatSeparator).map(p=>p.trim());s[1]=f.shift(),c=f,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!St(o))return o;St(o)||(o=bC(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((f,p)=>this.format(f,p,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const iQ=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,""),f=l.trim();n[f]||(n[f]=u),u==="false"&&(n[f]=!1),u==="true"&&(n[f]=!0),isNaN(u)||(n[f]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Xl=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($m(r),s),t[a]=l),l(n)}};class oQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pi.create("formatter"),this.options=t,this.formats={number:Xl((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Xl((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Xl((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Xl((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Xl((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()]=Xl(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:f}=iQ(c);if(this.formats[u]){let p=l;try{const d=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=d.locale||d.lng||s.locale||s.lng||r;p=this.formats[u](l,h,{...f,...s,...d})}catch(d){this.logger.warn(d)}return p}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const aQ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class lQ extends Cg{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=Pi.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 f=!0;n.forEach(p=>{const d=`${u}|${p}`;!r.reload&&this.store.hasResourceBundle(u,p)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?a[d]===void 0&&(a[d]=!0):(this.state[d]=1,f=!1,a[d]===void 0&&(a[d]=!0),o[d]===void 0&&(o[d]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(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=>{HX(c.loaded,[o],a),aQ(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const f=c.loaded[u];f.length&&f.forEach(p=>{l[u][p]===void 0&&(l[u][p]=!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,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(u&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(f=>l(null,f)).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();St(t)&&(t=this.languageUtils.toResolveHierarchy(t)),St(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 f;u.length===5?f=u(t,n,r,s,c):f=u(t,n,r,s),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const EC=()=>({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]),St(e[1])&&(t.defaultValue=e[1]),St(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}}),IC=e=>(St(e.ns)&&(e.ns=[e.ns]),St(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),St(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),th=()=>{},cQ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class mf extends Cg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=IC(t),this.services={},this.logger=Pi,this.modules={external:[]},cQ(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&&(St(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=EC();this.options={...s,...this.options,...IC(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=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?Pi.init(o(this.modules.logger),this.options):Pi.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=oQ);const p=new _C(this.options);this.store=new jC(this.options.resources,this.options);const d=this.services;d.logger=Pi,d.resourceStore=this.store,d.languageUtils=p,d.pluralResolver=new rQ(p,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(d.formatter=o(f),d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new sQ(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new lQ(o(this.modules.backend),d.resourceStore,d,this.options),d.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&&(d.languageDetector=o(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=o(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new Om(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=th),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const c=Xu(),u=()=>{const f=(p,d)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(d),r(p,d)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:th;const s=St(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=Xu();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=th),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"&&JM.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=Xu();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=St(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,f=>{a(f,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,f=new Array(u>2?u-2:0),p=2;p<u;p++)f[p-2]=arguments[p];c=s.options.overloadTranslationOptionHandler([a,l].concat(f))}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 d=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${d}${y}`):h=c.keyPrefix?`${c.keyPrefix}${d}${a}`:a,s.t(h,c)};return St(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=Xu();return this.options.ns?(St(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=Xu();St(t)&&(t=[t]);const s=this.options.preload||[],o=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=s.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new _C(EC());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 mf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:th;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new mf(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 jC(this.store.data,s),o.services.resourceStore=o.store),o.translator=new Om(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),f=1;f<c;f++)u[f-1]=arguments[f];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 jr=mf.createInstance();jr.createInstance=mf.createInstance;jr.createInstance;jr.dir;jr.init;jr.loadResources;jr.reloadResources;jr.use;jr.changeLanguage;jr.getFixedT;jr.t;jr.exists;jr.setDefaultNamespace;jr.hasLoadedNamespace;jr.loadNamespaces;jr.loadLanguages;function uQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gf(e){"@babel/helpers - typeof";return gf=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},gf(e)}function dQ(e,t){if(gf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(gf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function fQ(e){var t=dQ(e,"string");return gf(t)=="symbol"?t:t+""}function pQ(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,fQ(r.key),r)}}function hQ(e,t,n){return t&&pQ(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var XM=[],mQ=XM.forEach,gQ=XM.slice;function yQ(e){return mQ.call(gQ.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var PC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,wQ=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(!PC.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!PC.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},TC={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=wQ(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)}},xQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=TC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&TC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},bQ={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}},Qu=null,RC=function(){if(Qu!==null)return Qu;try{Qu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qu=!1}return Qu},kQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&RC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&RC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Zu=null,MC=function(){if(Zu!==null)return Zu;try{Zu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zu=!1}return Zu},vQ={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&MC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&MC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},SQ={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}},jQ={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}},NQ={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}},_Q={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]}},QM=!1;try{document.cookie,QM=!0}catch{}var ZM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];QM||ZM.splice(1,1);function CQ(){return{order:ZM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var e$=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};uQ(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return hQ(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=yQ(r,this.options||{},CQ()),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(xQ),this.addDetector(bQ),this.addDetector(kQ),this.addDetector(vQ),this.addDetector(SQ),this.addDetector(jQ),this.addDetector(NQ),this.addDetector(_Q)}},{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)}))}}])}();e$.type="languageDetector";const AQ={name:"AgentFlow",tagline:"AI Workflow Orchestration"},EQ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},IQ={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"},PQ={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},TQ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},RQ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},MQ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},$Q={app:AQ,nav:EQ,common:IQ,status:PQ,nodeTypes:TQ,engine:RQ,links:MQ},LQ="Flow Editor",OQ="Nodes",DQ="Edges",FQ="Properties",zQ={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"},WQ={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}}"},BQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},HQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},VQ={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"},KQ={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)"},qQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},UQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},GQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},YQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},JQ={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"},XQ={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"},QQ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},ZQ={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."},eZ={mainNav:"Main Navigation"},tZ={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'},nZ={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}}"},rZ={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"},sZ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},iZ={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}}"},oZ={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"},aZ={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"},lZ={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"},cZ={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"},uZ={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"},dZ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},fZ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},pZ={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"},hZ={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."},mZ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},gZ={save:"Save",cancel:"Cancel"},yZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},wZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},xZ={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"},bZ={title:LQ,nodes:OQ,edges:DQ,properties:FQ,node:zQ,nodeProps:WQ,actions:BQ,panel:HQ,palette:VQ,pipeline:KQ,status:qQ,roles:UQ,phases:GQ,types:YQ,runContext:JQ,shortcuts:XQ,jumpPalette:QQ,emptyCanvas:ZQ,sidebar:eZ,validation:tZ,composer:nZ,topbar:rZ,palette2:sZ,run:iZ,fileEdit:oZ,settings:aZ,schedule:lZ,history:cZ,nodePropsError:uZ,placeholder:dZ,time:fZ,userCheck:pZ,userAsk:hZ,toolPrint:mZ,provideEdit:gZ,runParams:yZ,runPreset:wZ,runConfig:xZ},kZ="Settings",vZ={engine:"Engine Settings",preferences:"Global Preferences"},SZ={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)."},jZ={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..."}},NZ={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."},_Z={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."},CZ={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."},AZ={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)"},EZ={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"},IZ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},PZ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},TZ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},RZ={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."},MZ={title:kZ,crumb:vZ,workspace:SZ,cursor:jZ,opencode:NZ,claudeCode:_Z,codex:CZ,env:AZ,allowlist:EZ,system:IZ,shortcuts:PZ,language:TZ,onboarding:RZ},$Z={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},LZ={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)"},OZ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},DZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},FZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},zZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},WZ={aiLabels:$Z,placeholders:LZ,actions:OZ,labels:DZ,tooltips:FZ,rightPanel:zZ},BZ="Projects",HZ="All",VZ="Archived",KZ="Nodes",qZ="My Nodes",UZ="My Flows",GZ="Skills",YZ="Active Projects",JZ="Archived Pipelines",XZ="Global Nodes",QZ="All Nodes",ZZ="My Nodes",eee="Manage node versions published to the current workspace marketplace, {{count}} total.",tee="Manage flow snippets published to the current workspace marketplace, {{count}} total.",nee="Global Skills",ree="Create New Project",see="New Pipeline",iee="SEARCH PIPELINES...",oee="SEARCH NODES...",aee="SEARCH FLOW SNIPPETS...",lee="SEARCH SKILLS...",cee="Refresh Resources",uee="Loading pipelines...",dee="Loading global resources...",fee="Filter result: {{count}} items (matching title, description, path and tags)",pee="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",hee="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",mee="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",gee="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",yee="Executable building blocks for pipeline runtime",wee="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.",xee="Published local node packages",bee="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",kee="Published flow snippets",vee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",See="Operating guides for Composer and agents",jee="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",Nee="No archived projects.",_ee="No active pipelines; archived items are in the Archived tab.",Cee="No global nodes available.",Aee="No marketplace nodes have been published.",Eee="No flow snippets have been published. Select multiple canvas nodes and publish them first.",Iee="No skills available.",Pee="No description.",Tee='No node matches "{{query}}".',Ree='No flow snippet matches "{{query}}".',Mee='No skill matches "{{query}}".',$ee="{{inputs}} in / {{outputs}} out",Lee="Flow Snippet",Oee="{{nodes}} nodes / {{edges}} edges",Dee="Skill",Fee="Node detail",zee="Flow snippet detail",Wee="Skill detail",Bee="Type",Hee="Source",Vee="Package",Kee="Version",qee="Path",Uee="Editable",Gee="Read only",Yee="Editable",Jee="Schema",Xee="Inputs",Qee="Outputs",Zee="Runtime",ete="Node Body",tte="Files",nte="Usage",rte="No runtime manifest.",ste="No node body or README.",ite="No previewable files.",ote="Select a file to preview.",ate="Binary file preview is not supported.",lte="Large file; showing the first 256KB only.",cte="No pipelines using this node were found.",ute="Node Management",dte="Delete Node Version",fte="Deleting...",pte="AgentFlow checks all flow references before deleting; installed or used versions are kept.",hte="Delete {{id}}@{{version}}? This cannot be undone.",mte="Deleted {{id}}@{{version}}.",gte="{{count}} flow(s) still use it.",yte="Flow Snippet Management",wte="Delete Flow Snippet",xte="Deleting...",bte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",kte="Delete {{id}}@{{version}}? This cannot be undone.",vte="Deleted {{id}}@{{version}}.",Ste="No slots",jte="Purpose",Nte="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",_te="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.",Cte="Scale",Ate="Flow Preview",Ete="Edges",Ite="Snippet JSON",Pte="{{count}} more edge(s)",Tte="No previewable nodes.",Rte="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Mte="SKILL.md Preview",$te="No preview content available.",Lte="Select a resource to inspect details.",Ote="Failed to load pipeline list.",Dte="No pipelines in current workspace.",Fte="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.",zte='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Wte="Recent Activity",Bte="No recent activity",Hte="No recent activity matching the keyword",Vte="Recent Run",Kte="Recent Open",qte={builtin:"Built-in",workspace:"Workspace",user:"User"},Ute={flow:"Flow",global:"Global",marketplace:"Marketplace"},Gte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Yte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Jte="Open to edit this pipeline in the node canvas.",Xte={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>"},Qte={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"},Zte={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"},ene={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"},tne={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"},nne={title:BZ,all:HZ,archived:VZ,nodes:KZ,myNodes:qZ,myFlows:UZ,skills:GZ,activeProjects:YZ,archivedPipelines:JZ,globalNodes:XZ,nodeScopeAll:QZ,nodeScopeMine:ZZ,myNodesHint:eee,myFlowsHint:tee,globalSkills:nee,createNew:ree,newPipeline:see,searchPipelines:iee,searchNodes:oee,searchFlows:aee,searchSkills:lee,refreshResources:cee,loadingPipelines:uee,loadingResources:dee,filterResult:fee,archivedHint:pee,activeHint:hee,nodesHint:mee,skillsHint:gee,nodesPurposeTitle:yee,nodesPurposeDesc:wee,myNodesPurposeTitle:xee,myNodesPurposeDesc:bee,myFlowsPurposeTitle:kee,myFlowsPurposeDesc:vee,skillsPurposeTitle:See,skillsPurposeDesc:jee,noArchived:Nee,noActive:_ee,noNodes:Cee,noMyNodes:Aee,noMyFlows:Eee,noSkills:Iee,noDescription:Pee,noNodeMatch:Tee,noFlowSnippetMatch:Ree,noSkillMatch:Mee,nodeSlots:$ee,flowSnippet:Lee,flowSnippetNodes:Oee,skill:Dee,nodeDetail:Fee,flowDetail:zee,skillDetail:Wee,detailType:Bee,detailSource:Hee,detailPackage:Vee,detailVersion:Kee,detailPath:qee,detailEditable:Uee,readOnly:Gee,editable:Yee,nodeSchema:Jee,nodeInputs:Xee,nodeOutputs:Qee,nodeRuntime:Zee,nodeBody:ete,nodeFiles:tte,nodeUsage:nte,noRuntimeManifest:rte,noNodeBody:ste,noNodeFiles:ite,selectNodeFile:ote,binaryFile:ate,fileTruncated:lte,noNodeUsage:cte,myNodeManagement:ute,deleteMyNode:dte,deletingMyNode:fte,deleteMyNodeHint:pte,deleteMyNodeConfirm:hte,deleteMyNodeSuccess:mte,deleteMyNodeUsedBy:gte,myFlowManagement:yte,deleteMyFlow:wte,deletingMyFlow:xte,deleteMyFlowHint:bte,deleteMyFlowConfirm:kte,deleteMyFlowSuccess:vte,noSlots:Ste,resourceMeaning:jte,nodesMeaning:Nte,myFlowsMeaning:_te,flowSnippetScale:Cte,flowSnippetPreview:Ate,flowSnippetEdges:Ete,flowSnippetJson:Ite,flowSnippetMoreEdges:Pte,noFlowSnippetPreview:Tte,skillsMeaning:Rte,skillPreview:Mte,skillPreviewEmpty:$te,selectResource:Lte,loadFailed:Ote,noPipelines:Dte,emptyHint:Fte,noMatch:zte,recentActivity:Wte,noRecentActivity:Bte,noMatchRecent:Hte,recentRun:Vte,recentOpen:Kte,sourceBadge:qte,resourceSource:Ute,resourceFilter:Gte,nodeDetailTabs:Yte,defaultCardDesc:Jte,hubCard:Xte,newPipelineModal:Qte,importModal:Zte,deleteModal:ene,archiveModal:tne},rne="Back",sne="Next",ine="Skip",one="Done",ane="Start Creating",lne={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.`},cne={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.`},une={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"},dne={back:rne,next:sne,skip:ine,done:one,startCreate:ane,projects:lne,flow:cne,newPipeline:une},fne={name:"AgentFlow",tagline:"AI 工作流编排"},pne={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},hne={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},mne={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},gne={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},yne={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},wne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},xne={app:fne,nav:pne,common:hne,status:mne,nodeTypes:gne,engine:yne,links:wne},bne="流程编辑器",kne="节点",vne="连线",Sne="属性",jne={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:"编辑内容"},Nne={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}}"},_ne={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},Cne={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},Ane={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Ene={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Ine={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Pne={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Tne={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Rne={node:"节点",text:"文本",file:"文件",bool:"布尔"},Mne={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:"等待"},$ne={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},Lne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},One={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Dne={mainNav:"主导航"},Fne={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},zne={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}}"},Wne={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},Bne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Hne={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}} 的分支"},Vne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Kne={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:"已复制"},qne={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:"定时配置已保存"},Une={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Gne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Yne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Jne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Xne={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Qne={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Zne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},ere={save:"保存",cancel:"取消"},tre={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},nre={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},rre={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},sre={title:bne,nodes:kne,edges:vne,properties:Sne,node:jne,nodeProps:Nne,actions:_ne,panel:Cne,palette:Ane,pipeline:Ene,status:Ine,roles:Pne,phases:Tne,types:Rne,runContext:Mne,shortcuts:$ne,jumpPalette:Lne,emptyCanvas:One,sidebar:Dne,validation:Fne,composer:zne,topbar:Wne,palette2:Bne,run:Hne,fileEdit:Vne,settings:Kne,schedule:qne,history:Une,nodePropsError:Gne,placeholder:Yne,time:Jne,userCheck:Xne,userAsk:Qne,toolPrint:Zne,provideEdit:ere,runParams:tre,runPreset:nre,runConfig:rre},ire="设置",ore={engine:"引擎设置",preferences:"全局首选项"},are={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},lre={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},cre={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},ure={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},dre={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},fre={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},pre={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:"添加"},hre={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},mre={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},gre={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},yre={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},wre={title:ire,crumb:ore,workspace:are,cursor:lre,opencode:cre,claudeCode:ure,codex:dre,env:fre,allowlist:pre,system:hre,shortcuts:mre,language:gre,onboarding:yre},xre={thinking:"思考",result:"结果",reply:"回复",error:"错误"},bre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},kre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},vre={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Sre={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},jre={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Nre={aiLabels:xre,placeholders:bre,actions:kre,labels:vre,tooltips:Sre,rightPanel:jre},_re="项目",Cre="全部",Are="已归档",Ere="Nodes",Ire="我的 Nodes",Pre="我的流程",Tre="Skills",Rre="活跃项目",Mre="已归档流水线",$re="全局 Nodes",Lre="全部 Nodes",Ore="我的 Nodes",Dre="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Fre="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",zre="全局 Skills",Wre="创建新项目",Bre="新建流水线",Hre="搜索流水线…",Vre="搜索 nodes…",Kre="搜索流程片段…",qre="搜索 skills…",Ure="刷新资源",Gre="加载流水线列表…",Yre="加载全局资源…",Jre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Xre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Qre="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Zre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",ese="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",tse="流程运行时的可执行积木",nse="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",rse="已发布的本地节点包",sse="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",ise="已发布的流程片段",ose="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",ase="Composer/Agent 的操作指南",lse="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",cse="暂无归档项目。",use="暂无未归档流水线;已归档项在 Archived 标签中查看。",dse="暂无可用全局 nodes。",fse="暂无已发布的 marketplace nodes。",pse="暂无已发布的流程片段。可在画布中选中多个节点后发布。",hse="暂无可用 skills。",mse="暂无描述。",gse="未找到与「{{query}}」匹配的 node。",yse="未找到与「{{query}}」匹配的流程片段。",wse="未找到与「{{query}}」匹配的 skill。",xse="{{inputs}} in / {{outputs}} out",bse="流程片段",kse="{{nodes}} 节点 / {{edges}} 连线",vse="Skill",Sse="Node 详情",jse="流程片段详情",Nse="Skill 详情",_se="类型",Cse="来源",Ase="包",Ese="版本",Ise="路径",Pse="可编辑",Tse="只读",Rse="可编辑",Mse="Schema",$se="输入",Lse="输出",Ose="Runtime",Dse="节点内容",Fse="Files",zse="Usage",Wse="暂无 runtime manifest。",Bse="暂无节点正文或 README。",Hse="暂无可预览文件。",Vse="请选择文件查看内容。",Kse="二进制文件暂不支持预览。",qse="文件较大,仅显示前 256KB。",Use="暂未发现使用此 node 的流水线。",Gse="节点管理",Yse="删除节点版本",Jse="删除中…",Xse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Qse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Zse="已删除 {{id}}@{{version}}。",eie="仍有 {{count}} 个 Flow 使用它。",tie="流程片段管理",nie="删除流程片段",rie="删除中…",sie="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",iie="确定删除 {{id}}@{{version}}?此操作不可撤销。",oie="已删除 {{id}}@{{version}}。",aie="无槽位",lie="作用",cie="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",uie="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",die="规模",fie="流程预览",pie="连线",hie="片段 JSON",mie="还有 {{count}} 条连线",gie="暂无可预览节点。",yie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",wie="SKILL.md 预览",xie="暂无可预览内容。",bie="请选择一个资源查看详情。",kie="未能加载流水线列表。",vie="当前工作区暂无流水线。",Sie="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",jie="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Nie="最近打开或最近运行",_ie="暂无打开或运行记录",Cie="暂无与关键词匹配的最近记录",Aie="最近运行",Eie="最近打开",Iie={builtin:"内置",workspace:"工作区",user:"用户"},Pie={flow:"Flow",global:"Global",marketplace:"Marketplace"},Tie={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Rie={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Mie="打开以在节点画布中编辑此流水线。",$ie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Lie={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:"关闭"},Oie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Die={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Fie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},zie={title:_re,all:Cre,archived:Are,nodes:Ere,myNodes:Ire,myFlows:Pre,skills:Tre,activeProjects:Rre,archivedPipelines:Mre,globalNodes:$re,nodeScopeAll:Lre,nodeScopeMine:Ore,myNodesHint:Dre,myFlowsHint:Fre,globalSkills:zre,createNew:Wre,newPipeline:Bre,searchPipelines:Hre,searchNodes:Vre,searchFlows:Kre,searchSkills:qre,refreshResources:Ure,loadingPipelines:Gre,loadingResources:Yre,filterResult:Jre,archivedHint:Xre,activeHint:Qre,nodesHint:Zre,skillsHint:ese,nodesPurposeTitle:tse,nodesPurposeDesc:nse,myNodesPurposeTitle:rse,myNodesPurposeDesc:sse,myFlowsPurposeTitle:ise,myFlowsPurposeDesc:ose,skillsPurposeTitle:ase,skillsPurposeDesc:lse,noArchived:cse,noActive:use,noNodes:dse,noMyNodes:fse,noMyFlows:pse,noSkills:hse,noDescription:mse,noNodeMatch:gse,noFlowSnippetMatch:yse,noSkillMatch:wse,nodeSlots:xse,flowSnippet:bse,flowSnippetNodes:kse,skill:vse,nodeDetail:Sse,flowDetail:jse,skillDetail:Nse,detailType:_se,detailSource:Cse,detailPackage:Ase,detailVersion:Ese,detailPath:Ise,detailEditable:Pse,readOnly:Tse,editable:Rse,nodeSchema:Mse,nodeInputs:$se,nodeOutputs:Lse,nodeRuntime:Ose,nodeBody:Dse,nodeFiles:Fse,nodeUsage:zse,noRuntimeManifest:Wse,noNodeBody:Bse,noNodeFiles:Hse,selectNodeFile:Vse,binaryFile:Kse,fileTruncated:qse,noNodeUsage:Use,myNodeManagement:Gse,deleteMyNode:Yse,deletingMyNode:Jse,deleteMyNodeHint:Xse,deleteMyNodeConfirm:Qse,deleteMyNodeSuccess:Zse,deleteMyNodeUsedBy:eie,myFlowManagement:tie,deleteMyFlow:nie,deletingMyFlow:rie,deleteMyFlowHint:sie,deleteMyFlowConfirm:iie,deleteMyFlowSuccess:oie,noSlots:aie,resourceMeaning:lie,nodesMeaning:cie,myFlowsMeaning:uie,flowSnippetScale:die,flowSnippetPreview:fie,flowSnippetEdges:pie,flowSnippetJson:hie,flowSnippetMoreEdges:mie,noFlowSnippetPreview:gie,skillsMeaning:yie,skillPreview:wie,skillPreviewEmpty:xie,selectResource:bie,loadFailed:kie,noPipelines:vie,emptyHint:Sie,noMatch:jie,recentActivity:Nie,noRecentActivity:_ie,noMatchRecent:Cie,recentRun:Aie,recentOpen:Eie,sourceBadge:Iie,resourceSource:Pie,resourceFilter:Tie,nodeDetailTabs:Rie,defaultCardDesc:Mie,hubCard:$ie,newPipelineModal:Lie,importModal:Oie,deleteModal:Die,archiveModal:Fie},Wie="返回",Bie="下一步",Hie="跳过",Vie="完成",Kie="开始创建",qie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
303
-
304
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
305
-
306
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Uie={intro:`现在进入流程编辑器。
307
-
308
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
309
-
310
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
311
-
312
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
313
-
314
- 左侧节点面板可以自由拖拽、删除和调整连接。`},Gie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Yie={back:Wie,next:Bie,skip:Hie,done:Vie,startCreate:Kie,projects:qie,flow:Uie,newPipeline:Gie},Jie={en:{common:$Q,flow:bZ,settings:MZ,composer:WZ,project:nne,onboarding:dne},zh:{common:xne,flow:sre,settings:wre,composer:Nre,project:zie,onboarding:Yie}};jr.use(e$).use(cF).init({resources:Jie,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 Xie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Qie(e){return jr.changeLanguage(e)}const Db="agentflow-settings-opencode-plan-v1",dd="CURSOR_API_KEYS",fd="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Tw=new Set([dd,fd,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),t$=["cursor","opencode","claudeCode","codex"];function n$(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function Fb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function Pa(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of t$)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(Fb).filter(Boolean))]:[];return n}function Xi(e){if(!e||typeof e!="object")return n$();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 Pc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Zie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Oa(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()||Pc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function $C(e){return Oa(e).map(({key:t,value:n})=>({key:t,value:n}))}function LC(){try{return localStorage.getItem(Db)??""}catch{return""}}function r$(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function eoe(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()||Pc(),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 OC(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||Pc(),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 toe(e){const t=String(e||"").trim();return t?t.length<=10?r$(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function noe(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 roe({authUser:e}){const{t,i18n:n}=qr(["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}),[f,p]=m.useState(n$()),[d,h]=m.useState(()=>Pa({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(!1),[N,I]=m.useState(!1),[T,z]=m.useState(""),[E,D]=m.useState([]),[L,O]=m.useState(""),[M,V]=m.useState(!1),[B,F]=m.useState(""),[$,H]=m.useState(""),[A,Q]=m.useState(!1),[K,W]=m.useState(()=>new Set),[ne,Z]=m.useState(""),[G,te]=m.useState(""),[re,se]=m.useState(!!(e!=null&&e.isAdmin)),[ee,ue]=m.useState(""),[de,me]=m.useState([]),[Me,Se]=m.useState([]),[_e,Fe]=m.useState(""),[at,mt]=m.useState(""),[Te,it]=m.useState(!1),[jt,Vt]=m.useState(!1),[kt,Mt]=m.useState(""),[ae,ke]=m.useState(""),[qe,tt]=m.useState(""),[Ee,Dt]=m.useState(null),[nn,Kt]=m.useState(!1),[yt,Cn]=m.useState(!1),[ie,Ce]=m.useState(""),Ge=m.useRef(null),Be=m.useRef(!1),Et=m.useRef(!1),vt=m.useRef(""),pe=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("")}},[]),He=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(Xi(ve.modelLists)),p(Xi(ve.allModelLists)),h(Pa(ve.hiddenModels));else{const Re=Xi(ve);u(Re),p(Re),h(Pa({}))}}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin]),wt=m.useCallback(async()=>{O("");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 Re=Oa(Array.isArray(ve.env)?ve.env:[],"user").map(rn=>({...rn,scope:"user"})),$t=[...e!=null&&e.isAdmin?Oa(Array.isArray(ve.globalEnv)?ve.globalEnv:[],"global").map(rn=>({...rn,scope:"global"})):[],...Re];vt.current=JSON.stringify($t),D($t)}catch(oe){D([]),O(String(oe.message||oe))}finally{Et.current=!0}},[e==null?void 0:e.isAdmin]),bt=m.useCallback(async()=>{if(e!=null&&e.isAdmin){it(!0),Mt("");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 Re=ve.allowlist&&typeof ve.allowlist=="object"?ve.allowlist:{};me(Array.isArray(Re.fileUsers)?Re.fileUsers.map(String):[]),Se(Array.isArray(Re.envUsers)?Re.envUsers.map(String):[]),Fe(typeof Re.path=="string"?Re.path:"")}catch(oe){Mt(String(oe.message||oe))}finally{it(!1)}}},[e==null?void 0:e.isAdmin]),ln=m.useCallback(async oe=>{if(e!=null&&e.isAdmin){Vt(!0),Mt("");try{const ve=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Re=await ve.json().catch(()=>({}));if(!ve.ok)throw new Error(typeof Re.error=="string"?Re.error:"HTTP "+ve.status);const Nt=Re.allowlist&&typeof Re.allowlist=="object"?Re.allowlist:{};me(Array.isArray(Nt.fileUsers)?Nt.fileUsers.map(String):[]),Se(Array.isArray(Nt.envUsers)?Nt.envUsers.map(String):[]),Fe(typeof Nt.path=="string"?Nt.path:"")}catch(ve){Mt(String(ve.message||ve))}finally{Vt(!1)}}},[e==null?void 0:e.isAdmin]),Tn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Kt(!0),Ce("");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 Re=ve.config&&typeof ve.config=="object"?ve.config:{};Dt(Re),ke(typeof Re.dataRoot=="string"?Re.dataRoot:""),tt(typeof Re.skillsRoot=="string"?Re.skillsRoot:"")}catch(oe){Ce(String(oe.message||oe))}finally{Kt(!1)}}},[e==null?void 0:e.isAdmin]),An=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Cn(!0),Ce("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ae.trim(),skillsRoot:qe.trim(),migrateLegacySkills:!0})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Re=ve.config&&typeof ve.config=="object"?ve.config:{};Dt(Re),ke(typeof Re.dataRoot=="string"?Re.dataRoot:""),tt(typeof Re.skillsRoot=="string"?Re.skillsRoot:"")}catch(oe){Ce(String(oe.message||oe))}finally{Cn(!1)}}},[e==null?void 0:e.isAdmin,ae,qe]),en=m.useCallback(async oe=>{const ve=Oa(oe),Re=ve.filter($t=>$t.scope!=="global"),Nt=ve.filter($t=>$t.scope==="global");V(!0),O("");try{const $t=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:$C(Re),...e!=null&&e.isAdmin?{globalEnv:$C(Nt)}:{}})}),rn=await $t.json().catch(()=>({}));if(!$t.ok)throw new Error(typeof rn.error=="string"?rn.error:"HTTP "+$t.status);const vn=Oa(Array.isArray(rn.env)?rn.env:[],"user").map(js=>({...js,scope:"user"})),Ss=[...e!=null&&e.isAdmin?Oa(Array.isArray(rn.globalEnv)?rn.globalEnv:[],"global").map(js=>({...js,scope:"global"})):[],...vn];vt.current=JSON.stringify(Ss),D(Ss)}catch($t){O(String($t.message||$t))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),bn=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:ee.trim()})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);u(Xi(ve.modelLists)),e!=null&&e.isAdmin?await He():p(Xi(ve.modelLists))}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin,He,ee]),nr=m.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const ve=Pa(oe);h(ve),v(!0),g("");try{const Re=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:ve})}),Nt=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(typeof Nt.error=="string"?Nt.error:"HTTP "+Re.status);u(Xi(Nt.modelLists)),p(Xi(Nt.allModelLists)),h(Pa(Nt.hiddenModels))}catch(Re){g(String(Re.message||Re)),He()}finally{v(!1)}},[e==null?void 0:e.isAdmin,He]),fn=m.useCallback((oe,ve,Re)=>{const Nt=t$.includes(oe)?oe:"cursor",$t=Fb(ve);if(!$t)return;const rn=Pa(d),vn=new Set(rn[Nt]);Re?vn.delete($t):vn.add($t),nr({...rn,[Nt]:Array.from(vn)})},[d,nr]);m.useEffect(()=>{wt(),e!=null&&e.isAdmin?(pe(),He(),bt(),Tn(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const ve=await oe.json(),Re=typeof ve.opencodeProvider=="string"?ve.opencodeProvider:"";ue(Re),Ge.current=Re;try{localStorage.setItem(Db,Re)}catch{}}else{const ve=LC();ue(ve),Ge.current=ve}}catch{const oe=LC();ue(oe),Ge.current=oe}finally{Be.current=!0}})()):(o(""),Be.current=!1)},[e==null?void 0:e.isAdmin,pe,He,Tn,bt,wt]),m.useEffect(()=>{if(!Et.current||JSON.stringify(Oa(E))===vt.current)return;const ve=setTimeout(()=>{en(E)},350);return()=>clearTimeout(ve)},[E,en]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!Be.current)return;const oe=ee.trim();if(oe===Ge.current)return;const ve=setTimeout(()=>{(async()=>{I(!0),z("");try{const Re=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),Nt=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(typeof Nt.error=="string"?Nt.error:"HTTP "+Re.status);Ge.current=oe;try{localStorage.setItem(Db,oe)}catch{}Nt.modelLists&&(u(Xi(Nt.modelLists)),e!=null&&e.isAdmin?He():p(Xi(Nt.modelLists)))}catch(Re){z(String(Re.message||Re))}finally{I(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,He,ee]);const kn=e!=null&&e.isAdmin?f:c,rr=kn.cursor.length>0,vs=kn.opencode.length>0,sr=kn.claudeCode.length>0,Gn=kn.codex.length>0,Nr=Pa(d),_r={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Yn=m.useCallback((oe,ve,Re)=>{const Nt=Array.isArray(ve)?ve:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Re,children:Nt.join(`
315
- `)});const $t=new Set(Nr[oe]||[]);return i.jsxs("div",{className:"af-set-model-visibility","aria-label":Re,children:[i.jsxs("div",{className:"af-set-model-visibility-head",children:[i.jsxs("span",{children:["展示 ",_r[oe]||0," / ",Nt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:Nt.map(rn=>{const vn=Fb(rn),Vn=!$t.has(vn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:Vn,disabled:y,onChange:Ss=>fn(oe,rn,Ss.target.checked)}),i.jsx("span",{children:rn})]},`${oe}-${rn}`)})})]})},[e==null?void 0:e.isAdmin,Nr,y,_r,fn]),Lr=de.length>0||Me.length>0,Or=e!=null&&e.isAdmin?E:E.filter(oe=>!Tw.has(String((oe==null?void 0:oe.key)||"").trim())),ce=e!=null&&e.isAdmin&&re?"global":"user",ge=m.useMemo(()=>E.find(oe=>oe.key===dd&&(oe.scope||"user")===ce)||null,[ce,E]),et=m.useMemo(()=>eoe((ge==null?void 0:ge.value)||""),[ge==null?void 0:ge.value]),rt=m.useMemo(()=>E.find(oe=>oe.key===fd&&(oe.scope||"user")===ce)||null,[ce,E]),Bt=rt!=null&&rt.value?String(rt.value):"30",Wn=m.useCallback((oe,ve,Re)=>{const Nt=String(oe||"").trim();if(!Nt)return;const $t=String(ve??"");D(rn=>{const vn=rn.find(Vn=>Vn.key===Nt&&(Vn.scope||"user")===Re);return $t?vn?rn.map(Vn=>Vn.id===vn.id?{...Vn,value:$t,scope:Re}:Vn):[{id:Pc(),key:Nt,value:$t,scope:Re},...rn]:rn.filter(Vn=>!(Vn.key===Nt&&(Vn.scope||"user")===Re))})},[]),Cr=m.useCallback(()=>{const oe=G.trim();if(!oe)return;const ve=[...et,{id:Pc(),name:ne.trim()||`Key ${et.length+1}`,key:oe,createdAt:new Date().toISOString()}];Wn(dd,OC(ve),ce),Z(""),te("")},[ne,et,ce,G,Wn]),Ar=m.useCallback(oe=>{const ve=et.filter(Re=>Re.id!==oe);Wn(dd,ve.length?OC(ve):"",ce)},[et,ce,Wn]),wr=m.useCallback(oe=>{const ve=String(oe||"").replace(/[^\d]/g,"");if(!ve){Wn(fd,"",ce);return}const Re=Math.min(1440,Math.max(1,Number(ve)||30));Wn(fd,String(Re),ce)},[ce,Wn]),ct=m.useCallback(()=>{var oe;s&&((oe=navigator.clipboard)==null||oe.writeText(s))},[s]),Xt=m.useCallback(()=>{const oe=B.trim(),ve=$;if(oe){if(!Zie(oe)){O(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Tw.has(oe)){O("该运行基础设施变量仅管理员可配置。");return}D(Re=>[{id:Pc(),key:oe,value:ve,scope:e!=null&&e.isAdmin&&A?"global":"user"},...Re]),F(""),H("")}},[e==null?void 0:e.isAdmin,A,B,$,t]),Qt=m.useCallback(oe=>{D(ve=>ve.filter(Re=>Re.id!==oe))},[]),ir=m.useCallback((oe,ve)=>{const Re=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Re&&Tw.has(Re)){O("该运行基础设施变量仅管理员可配置。");return}D(Nt=>Nt.map($t=>$t.id===oe?{...$t,...ve}:$t))},[e==null?void 0:e.isAdmin]),ot=m.useCallback(oe=>{W(ve=>{const Re=new Set(ve);return Re.has(oe)?Re.delete(oe):Re.add(oe),Re})},[]),xr=m.useCallback(()=>{const oe=at.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){Mt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Re=>String(Re||"").trim().toLowerCase())).has(oe.toLowerCase())){mt("");return}mt(""),ln([...de,oe])},[at,de,ln]),Ws=m.useCallback(oe=>{const ve=String(oe||"").trim().toLowerCase();ve&&ln(de.filter(Re=>String(Re||"").trim().toLowerCase()!==ve))},[de,ln]),Hi=m.useCallback(oe=>{const ve=oe.target.value;Qie(ve)},[]),Bs=oe=>{const ve=noe(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,L?i.jsx("p",{className:"af-err af-settings-api-hint",children:L}):null,ie?i.jsx("p",{className:"af-err af-settings-api-hint",children:ie}):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:ct,"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"+(rr?" af-set-badge--ok":" af-set-badge--muted"),children:t(rr?"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:rr?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(rr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:rr?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${kn.cursor.length}`:"")+" · "+Bs(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),rr?Yn("cursor",kn.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:()=>bn(),disabled:_,children:t(_?"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"+(et.length?" af-set-badge--ok":" af-set-badge--muted"),children:[et.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:re?"":"is-active",onClick:()=>se(!1),children:"个人"}),i.jsx("button",{type:"button",className:re?"is-active":"",onClick:()=>se(!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:Bt,onChange:oe=>wr(oe.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":ce==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:et.length?et.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:toe(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:()=>Ar(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:ne,onChange:oe=>Z(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:Cr,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",dd,";冷却时间保存到 ",fd,"。个人配置会覆盖全局配置。"]})]}),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"+(vs?" af-set-badge--ok":" af-set-badge--err"),children:t(vs?"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:ee,onChange:oe=>ue(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),N?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,T?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:T}):null]}),vs?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?` / ${kn.opencode.length}`:"")+" · "+Bs(c.opencodeFetchedAt)}),Yn("opencode",kn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>bn(),disabled:_,children:t(_?"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"+(sr?" af-set-badge--ok":" af-set-badge--err"),children:t(sr?"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:sr?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(sr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:sr?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${kn.claudeCode.length}`:"")+" · "+Bs(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),sr?Yn("claudeCode",kn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>bn(),disabled:_,children:t(_?"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"+(Gn?" af-set-badge--ok":" af-set-badge--err"),children:t(Gn?"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: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.codex.length})+(e!=null&&e.isAdmin?` / ${kn.codex.length}`:"")+" · "+Bs(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Gn?Yn("codex",kn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>bn(),disabled:_,children:t(_?"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:B,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:A?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:A?"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=>H(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:Xt,disabled:!B.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),Or.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=>ir(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:()=>ir(oe.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>ir(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=>ir(oe.id,{value:ve.target.value}),placeholder:r$(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>ot(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:()=>Qt(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"+(Ee!=null&&Ee.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:Ee!=null&&Ee.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Tn(),disabled:nn||yt,children:nn?"刷新中...":"刷新"})]}),ie?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ie}):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:ae,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(Ee!=null&&Ee.envLocked)||yt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void An(),"aria-label":"保存 AgentFlow Data Root",disabled:yt||!!(Ee!=null&&Ee.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:yt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(Ee==null?void 0:Ee.dataRoot)||ae||"-"}),Ee!=null&&Ee.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:Ee.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 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",Ee!=null&&Ee.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:qe,onChange:oe=>tt(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(Ee!=null&&Ee.skillsEnvLocked)||yt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void An(),"aria-label":"保存 AgentFlow Skills Root",disabled:yt||!!(Ee!=null&&Ee.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:yt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(Ee==null?void 0:Ee.skillsRoot)||qe||"-"}),Ee!=null&&Ee.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:Ee.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",Ee!=null&&Ee.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"+(Lr?" af-set-badge--ok":" af-set-badge--muted"),children:t(Lr?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void bt(),disabled:Te,children:t(Te?"settings:allowlist.refreshing":"common:common.refresh")})]}),kt?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:kt}):null,_e?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:_e})]}):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:jt?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:()=>Ws(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:jt,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:at,onChange:oe=>mt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&xr()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:xr,disabled:jt||!at.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:Hi,"aria-label":t("settings:language.description"),children:Xie.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 soe(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 ioe(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function ooe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function aoe({run:e,onClose:t}){const[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),f=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"),f()},[f]),m.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||f({quiet:!0})},5e3);return()=>window.clearInterval(v)},[f,e==null?void 0:e.status]);const p=Array.isArray(n==null?void 0:n.events)?n.events:[],d=m.useMemo(()=>p.filter(v=>(v==null?void 0:v.kind)==="thinking"),[p]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?d:p;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"," · ",ooe(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 f(),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:p.length})]}),i.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",i.jsx("span",{children:d.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:soe(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:ioe(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 zr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function nh(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Rw(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 loe(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Mw(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 coe(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function uoe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function doe({authUser:e}){const{navigate:t}=os(),[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[f,p]=m.useState(null),[d,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 E=await fetch("/api/admin/usage-dashboard"),D=await E.json().catch(()=>({}));if(!E.ok)throw new Error(typeof D.error=="string"?D.error:"HTTP "+E.status);r(D)}catch(E){r(null),l(String((E==null?void 0:E.message)||E))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=m.useCallback(async E=>{const D=String((E==null?void 0:E.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!D)){p({userId:D,username:String((E==null?void 0:E.username)||D)}),h([]),g(""),v(!0);try{const L=new URLSearchParams({userId:D}),O=await fetch(`/api/admin/user-workspaces?${L.toString()}`),M=await O.json().catch(()=>({}));if(!O.ok)throw new Error(M.error||"读取用户 Workspace 失败");p(M.owner||{userId:D,username:String((E==null?void 0:E.username)||D)}),h(Array.isArray(M.workspaces)?M.workspaces:[])}catch(L){g(String(L.message||L))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),_=m.useCallback(E=>{const D=String((E==null?void 0:E.ownerUserId)||(f==null?void 0:f.userId)||"").trim(),L=String((E==null?void 0:E.id)||"").trim();if(!D||!L)return;const O=new URLSearchParams({flowId:L,flowSource:"user",adminOwnerId:D});E!=null&&E.archived&&O.set("archived","1"),t(`/workspace?${O.toString()}`)},[t,f==null?void 0:f.userId]);m.useEffect(()=>{k()},[k]);const S=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],N=m.useMemo(()=>{const L={top:20,right:24,bottom:42,left:42},O=980-L.left-L.right,M=250-L.top-L.bottom,V=S.length>0?S:[],B=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=>L.left+(V.length<=1?O/2:K*O/(V.length-1)),H=K=>L.top+M-Math.max(0,Number(K||0))/B*M,A=K=>L.top+M-Math.max(0,Number(K||0))/F*M,Q=K=>V.map((W,ne)=>`${ne===0?"M":"L"} ${$(ne)} ${A(W[K])}`).join(" ");return{width:980,height:250,margin:L,innerHeight:M,rows:V,x:$,yRuns:H,yLine:A,lineUsers:Q("users"),linePipelines:Q("pipelines"),barWidth:Math.min(34,Math.max(12,O/Math.max(1,V.length)*.44))}},[S]),I=(n==null?void 0:n.usage)||{},T=(n==null?void 0:n.totals)||{},z=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:nh(I.activeUserRate)}),i.jsxs("em",{children:[zr(I.activeUsers)," / ",zr(T.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:nh(I.activePipelineRate)}),i.jsxs("em",{children:[zr(I.activePipelines)," / ",zr(T.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:zr(I.runs)}),i.jsxs("em",{children:[zr(I.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:nh(I.successRate)}),i.jsxs("em",{children:["失败率 ",nh(I.failureRate)," · avg ",Rw(I.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 ${N.width} ${N.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:N.margin.left,y1:N.margin.top+N.innerHeight,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight}),[.25,.5,.75,1].map(E=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:N.margin.left,y1:N.margin.top+N.innerHeight-N.innerHeight*E,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight-N.innerHeight*E},E)),N.rows.map((E,D)=>{const L=N.x(D),O=N.yRuns(E.runs),M=N.margin.top+N.innerHeight,V=Math.max(2,M-O);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:L-N.barWidth/2,y:M-V,width:N.barWidth,height:V,rx:"5",children:i.jsx("title",{children:`${E.date}: ${E.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:L,y:M+22,children:zr(E.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:L,y:M+42,children:loe(E.date)})]},E.date)}),N.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:N.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:N.linePipelines}),N.rows.map((E,D)=>{const L=N.x(D);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:L,cy:N.yLine(E.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:L,cy:N.yLine(E.pipelines),r:"3.5"})]},`${E.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:z.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):z.map(E=>i.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(E),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),u(E))},children:[i.jsxs("td",{children:[i.jsx("strong",{children:E.username||E.userId||"-"}),i.jsx("span",{children:E.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:E.flowId||"-"}),i.jsxs("span",{children:[E.runType==="workspace"?"Workspace Run":"Pipeline"," · ",E.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Mw(E.at)}),E.endedAt?i.jsxs("span",{children:["结束 ",Mw(E.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:uoe(E.status)})})}),i.jsx("td",{children:Rw(E.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:E.runId,children:coe(E.runId)}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${E.userId}:${E.flowSource}:${E.flowId}:${E.runId}:${E.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(E=>{var D,L,O,M,V,B,F,$,H,A,Q,K,W;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:E.username||E.userId}),i.jsxs("span",{children:[E.userId,E.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:zr((D=E.pipelines)==null?void 0:D.total)}),i.jsxs("span",{children:[zr((L=E.pipelines)==null?void 0:L.active)," active / ",zr((O=E.pipelines)==null?void 0:O.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:zr((M=E.runs)==null?void 0:M.total)}),i.jsxs("span",{children:["avg ",Rw((V=E.runs)==null?void 0:V.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",zr((B=E.runs)==null?void 0:B.success)]}),i.jsxs("em",{children:["失败 ",zr((F=E.runs)==null?void 0:F.failed)]}),i.jsxs("em",{children:["运行中 ",zr(($=E.runs)==null?void 0:$.running)]})]})}),i.jsx("td",{children:(H=E.runs)!=null&&H.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((A=E.runs)==null?void 0:A.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((Q=E.runs)==null?void 0:Q.lastRunStatus)||"unknown"," · ",Mw(E.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})}),i.jsx("td",{children:i.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((K=E.pipelines)!=null&&K.total)||y&&(f==null?void 0:f.userId)===E.userId,onClick:()=>void x(E),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(f==null?void 0:f.userId)===E.userId?"读取中":`查看 ${zr((W=E.pipelines)==null?void 0:W.total)}`]})})]},E.userId)})})]})})]}),f?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:[f.username||f.userId," 的 Workspace"]}),i.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),i.jsx("button",{type:"button",onClick:()=>{p(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..."}):d.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):d.map(E=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>_(E),children:[i.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:E.archived?"inventory_2":"account_tree"}),i.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[i.jsx("strong",{children:E.id}),i.jsx("small",{children:E.description||(E.archived?"已归档 Workspace":"用户 Workspace")})]}),i.jsx("span",{className:"af-admin-user-workspace-card__status",children:E.archived?"已归档":"只读打开"})]},`${E.id}:${E.archived?"archived":"active"}`))})]}):null,c?i.jsx(aoe,{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 foe({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,f]=m.useState(""),[p,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState(""),g=m.useCallback(async()=>{b("");try{const S=await fetch("/api/admin/teams"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"读取团队失败");const I=Array.isArray(N.teams)?N.teams:[];n(I),s(Array.isArray(N.users)?N.users:[]),a(T=>{var z;return T&&I.some(E=>E.id===T)?T:((z=I[0])==null?void 0:z.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,N)=>{y(!0),b("");try{const I=await fetch("/api/admin/teams",{method:S,headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"更新团队失败");return await g(),T}catch(I){return b(String(I.message||I)),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 _=r.filter(S=>{const N=p.trim().toLowerCase();return!N||`${S.username} ${S.userId}`.toLowerCase().includes(N)});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(N=>{var I;(I=N==null?void 0:N.team)!=null&&I.id&&a(N.team.id),N&&f("")})},children:[i.jsx("input",{value:u,onChange:S=>f(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(N=>({...N,name:S.target.value}))})]}),i.jsxs("label",{children:[i.jsx("span",{children:"状态"}),i.jsxs("select",{value:l.status,onChange:S=>c(N=>({...N,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(N=>({...N,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:p,onChange:S=>d(S.target.value),placeholder:"搜索用户"})]}),i.jsx("div",{className:"af-team-admin-members",children:_.map(S=>{var I;const N=l.members.includes(S.userId);return i.jsxs("label",{className:N?"is-selected":"",children:[i.jsx("input",{type:"checkbox",checked:N,onChange:T=>c(z=>({...z,members:T.target.checked?[...z.members,S.userId]:z.members.filter(E=>E!==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:((I=t.find(T=>T.id===S.teamId))==null?void 0:I.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 poe(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 hoe({authUser:e}){const{navigate:t}=os(),[n,r]=m.useState(""),[s,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[f,p]=m.useState(!1),[d,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"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"加载失败");h(Array.isArray(N.feedback)?N.feedback:[])}catch(S){g(String(S.message||S)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const _=async S=>{if(S.preventDefault(),!a){l(!0),u("");try{const N=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),I=await N.json().catch(()=>({}));if(!N.ok)throw new Error(I.error||"提交失败");p(!0),r(""),o("")}catch(N){u(String(N.message||N))}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:d.length>0?d.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:poe(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"}),"返回"]})]}),f?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:_,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 s$(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function DC(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:s$(),key:r,value:String(s??""),private:n.has(r)}))}function FC(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 Th(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:DC(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:DC(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 $w(){return Th({name:"",raw:{command:""}})}function moe(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=FC(e.envRows),s=FC(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 zC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function WC(e){return e?e.ok?"ok":"error":"unknown"}function zb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function goe(e,t){return e&&e.label||t}async function Lw(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 Fv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function i$({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:Fv(t)}}}},null,2)}function o$({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(Fv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
318
- `)}function yoe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=i$({baseUrl:n,token:t}),s=o$({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: ${Fv(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 woe({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--${zb(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:goe(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 BC({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:s$(),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 xoe(){var Z;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState($w),[a,l]=m.useState(""),[c,u]=m.useState(!1),[f,p]=m.useState(!1),[d,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[N,I]=m.useState(""),[T,z]=m.useState(""),E=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),D=E&&y[E.name]||null,L=m.useMemo(()=>i$({baseUrl:_,token:N}),[_,N]),O=m.useMemo(()=>o$({baseUrl:_,token:N}),[_,N]),M=m.useMemo(()=>yoe({baseUrl:_,token:N}),[_,N]),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 re=Array.isArray(te.servers)?te.servers:[];t(String(te.path||"")),r(re),a&&re.some(se=>se.name===a)&&o(Th(re.find(se=>se.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{V()},[V]);const B=()=>{l(""),o($w()),x(""),g("")},F=G=>{l(G.name),o(Th(G)),x(""),g("")},$=m.useCallback(async()=>{if(!M)return;const G=await Lw(M);z(G?"prompt":"copy-failed"),window.setTimeout(()=>z(""),1200)},[M]),H=m.useCallback(async()=>{const G=await Lw(L);z(G?"cursor":"copy-failed"),window.setTimeout(()=>z(""),1200)},[L]),A=m.useCallback(async()=>{const G=await Lw(O);z(G?"codex":"copy-failed"),window.setTimeout(()=>z(""),1200)},[O]),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);I(String(te.token||"")),z("token"),window.setTimeout(()=>z(""),1200)}catch(G){z(""),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}:{})}),re=await te.json().catch(()=>({}));if(!te.ok)throw new Error(re.error||"检测 MCP 失败");const se=Array.isArray(re.results)?re.results:[];v(ee=>{const ue={...ee};for(const de of se)de!=null&&de.name&&(ue[de.name]=de);return ue}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(te){g(String(te.message||te))}finally{h(!1)}},W=async()=>{p(!0),g(""),x("");try{const G=moe(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)}),re=await te.json().catch(()=>({}));if(!te.ok)throw new Error(re.error||"保存 MCP 失败");const se=Array.isArray(re.servers)?re.servers:[];r(se),t(String(re.path||e)),l(G.nextName),o(Th(se.find(ee=>ee.name===G.nextName)||null)),v(ee=>{const ue={...ee};return s.originalName&&s.originalName!==G.nextName&&delete ue[s.originalName],delete ue[G.nextName],ue}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{p(!1)}},ne=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){p(!0),g(""),x("");try{const te=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),re=await te.json().catch(()=>({}));if(!te.ok)throw new Error(re.error||"删除 MCP 失败");r(Array.isArray(re.servers)?re.servers:[]),l(""),o($w()),v(se=>{const ee={...se};return delete ee[G.name],ee}),x("已删除。")}catch(te){g(String(te.message||te))}finally{p(!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||f,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(),disabled:d||c||f||n.length===0,children:d?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:f,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:_,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:N,onChange:G=>I(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:T==="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:H,children:T==="cursor"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:L})]}),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:A,children:T==="codex"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:O})]})]}),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"}),T==="prompt"?"已复制 Prompt":T==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),T==="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:B,disabled:f,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:B,disabled:f,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var te,re,se,ee;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--${WC(y[G.name])}`,children:zC(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${zb((re=(te=G.backends)==null?void 0:te.cursor)==null?void 0:re.status)}`,children:"Cursor"}),i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${zb((ee=(se=G.backends)==null?void 0:se.codex)==null?void 0:ee.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:E?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),E?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(E.name),disabled:d||f,children:d?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>ne(E),disabled:f,children:"删除"})]}):null]}),b?i.jsx("p",{className:"af-mcp-error",children:b}):null,k?i.jsx("p",{className:"af-mcp-status",children:k}):null,E?i.jsx(woe,{server:E}):null,D?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${WC(D)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:zC(D)}),i.jsxs("span",{children:[D.elapsedMs||0,"ms"]})]}),D.error?i.jsx("p",{children:D.error}):null,(Z=D.tools)!=null&&Z.length?i.jsx("div",{className:"af-mcp-tools-list",children:D.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(BC,{title:"Headers",rows:s.headerRows,onChange:G=>o(te=>({...te,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(BC,{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:B,disabled:f,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:W,disabled:f,children:f?"保存中...":"保存 MCP"})]})]})]})]})})]})}function boe(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 HC(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function VC(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 koe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function voe(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 Soe(){const{navigate:e}=os(),[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 d=await fetch("/api/schedules"),h=await d.json().catch(()=>({}));if(!d.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(d){a(String(d.message||d)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const f=m.useCallback(async d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`;c(h),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:d.kind,flowId:d.flowId,flowSource:d.flowSource||"user",scheduleNodeId:d.scheduleNodeId||"",enabled:!d.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]),p=m.useMemo(()=>{const d=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:d,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:p.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"启用中"}),i.jsx("strong",{children:p.enabled})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("strong",{children:p.workspace})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Pipeline"}),i.jsx("strong",{children:p.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(d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`,y=l===h,v=boe(d);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:d.label||d.flowId||"-"}),i.jsx("span",{className:`af-schedule-badge af-schedule-badge--${d.kind||"pipeline"}`,children:koe(d)}),i.jsx("span",{className:`af-schedule-state ${d.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:voe(d)})]}),i.jsxs("div",{className:"af-schedule-card__meta",children:[i.jsx("span",{children:d.flowId||"-"}),i.jsx("span",{children:d.flowSource||"user"}),d.scheduleNodeId?i.jsx("span",{children:d.scheduleNodeId}):null]}),i.jsxs("div",{className:"af-schedule-card__grid",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Cron"}),i.jsx("strong",{children:d.cron||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"时区"}),i.jsx("strong",{children:d.timezone||"Asia/Shanghai"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"下次执行"}),i.jsx("strong",{children:VC(d.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:VC(d.lastTriggeredAt)})]})]}),d.lastError?i.jsx("p",{className:"af-schedule-card__error",children:d.lastError}):null]}),i.jsxs("div",{className:"af-schedule-card__actions",children:[v?i.jsxs("button",{type:"button",className:"af-schedule-open",title:HC(d),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),HC(d)]}):null,i.jsxs("button",{type:"button",className:d.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":d.enabled,title:d.enabled?"点击停用":"点击启用",onClick:()=>void f(d),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":d.enabled?"toggle_on":"toggle_off"}),d.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const KC={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 qC(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 joe(e){var c,u,f,p,d,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((f=(u=t.ui)==null?void 0:u.card)==null?void 0:f.actions)?t.ui.card.actions:[],l=(p=e==null?void 0:e.test)!=null&&p.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(_=>[`input.${_.name||"-"}`,`${_.type||"text"}${_.required?" · required":""}${_.default?` · default: ${_.default}`:""}`]),...s.map(_=>[`output.${_.name||"-"}`,_.type||"text"]),...o.map(_=>[`config.${_.key||"-"}`,_.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((d=t.runtime)==null?void 0:d.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((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(_=>[`action.${_.id||_.label||"-"}`,_.variant||_.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([_,S])=>[`sample.${_}`,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 Noe(){var O,M,V,B,F,$,H;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(""),[f,p]=m.useState(!1),[d,h]=m.useState(""),y=e||KC,v=m.useMemo(()=>joe(y),[y]),b=m.useMemo(()=>v.find(A=>A.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((O=y==null?void 0:y.test)==null?void 0:O.inputs)||{},_=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],S=((B=(V=g.ui)==null?void 0:V.card)==null?void 0:B.icon)||"event_repeat",N=(($=(F=g.ui)==null?void 0:F.card)==null?void 0:$.variant)||"default",I=k.enabled===!0,T=m.useCallback(async()=>{var A;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 W=Array.isArray(K.drafts)?K.drafts[0]:null;if(!(W!=null&&W.id)){t(null),h("");return}const ne=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(W.id)}`),Z=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(Z.error||"读取节点草稿失败");t(Z.draft||null),h(String(((A=Z.draft)==null?void 0:A.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{T()},[T]);const z=m.useCallback(async(A={})=>{var Q;p(!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",...A})}),W=await K.json().catch(()=>({}));if(!K.ok||W.ok===!1)throw new Error(W.error||"保存节点草稿失败");t(W.draft||e),h(String(((Q=W.draft||e)==null?void 0:Q.promptDraft)||""))}catch(K){u(String(K.message||K))}finally{p(!1)}},[e]),E=()=>{o(!0),window.setTimeout(()=>o(!1),900)},D=A=>{const Q={...k,enabled:A};t(K=>({...K||KC,config:Q})),z({config:{enabled:A}})},L=()=>{z({promptDraft:d,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 T(),disabled:a,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),i.jsxs("button",{type:"button",onClick:E,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((A,Q)=>i.jsx("div",{className:A.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:A.text||""},`${A.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:d,onChange:A=>h(A.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:L,disabled:f,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"sync":"send"}),f?"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?N==="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:qC(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:I,onChange:A=>D(A.target.checked)}),i.jsx("span",{children:I?"定时开启":"定时关闭"})]}),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:A=>z({config:{scheduleType:A.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:A=>z({config:{hour:A.target.value}}),children:[i.jsx("option",{children:"09"}),i.jsx("option",{children:"10"})]}),i.jsxs("select",{value:k.minute||"00",onChange:A=>z({config:{minute:A.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:I?"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:qC(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:((H=g.runtime)==null?void 0:H.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:E,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..."]:_.length?_:["No test run yet."]).map((A,Q)=>i.jsx("span",{children:A},`${A}-${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(A=>i.jsxs("button",{type:"button",className:A.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(A.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:A.icon}),A.label]},A.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([A,Q])=>i.jsxs("div",{className:"af-node-studio-internal-row",children:[i.jsx("span",{children:A}),i.jsx("strong",{children:Q})]},A))}),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 _oe(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Coe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Rh(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 Aoe(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 Ow(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function rh(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 Eoe(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Rh(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 Qi(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 Ioe({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function UC({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(Ioe,{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 Poe(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[f,p]=m.useState(""),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState(Ow),[k,x]=m.useState(""),[_,S]=m.useState([]),[N,I]=m.useState(""),T=m.useMemo(()=>y.findIndex((K,W)=>Qi(K,W)===N),[y,N]),E=!!m.useMemo(()=>d.find((K,W)=>Qi(K,W)===N)||null,[d,N]),D=m.useMemo(()=>{const K=String(b.credentialRef||"").trim();return K?_.some(W=>String((W==null?void 0:W.key)||"").trim()===K&&String((W==null?void 0:W.value)??"")!==""):!1},[b.credentialRef,_]),L=m.useCallback(async()=>{t(!0),l("");try{const[K,W]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),ne=await K.json().catch(()=>({})),Z=await W.json().catch(()=>({}));if(!W.ok)throw new Error(typeof Z.error=="string"?Z.error:"ENV HTTP "+W.status);if(!K.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+K.status);const G=Array.isArray(ne.workspaces)?ne.workspaces:[],te=Array.isArray(ne.customWorkspaces)?ne.customWorkspaces:[];p(String(ne.path||"")),h(G.filter(re=>re==null?void 0:re.builtin)),v(te),S(Array.isArray(Z.env)?Z.env.map(re=>({key:String((re==null?void 0:re.key)||""),value:String((re==null?void 0:re.value)??"")})):[])}catch(K){l(String(K.message||K))}finally{t(!1)}},[]);m.useEffect(()=>{L()},[L]);const O=m.useCallback(async(K,W="")=>{r(!0),l(""),u("");try{const ne=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:K})}),Z=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(typeof Z.error=="string"?Z.error:"HTTP "+ne.status);const G=Array.isArray(Z.customWorkspaces)?Z.customWorkspaces:K;v(G),h((Array.isArray(Z.workspaces)?Z.workspaces:[]).filter(te=>te==null?void 0:te.builtin)),p(String(Z.path||f)),W&&I(W),u("已保存")}catch(ne){l(String(ne.message||ne))}finally{r(!1)}},[f]),M=m.useCallback(()=>{I(""),g(Ow()),x(""),u(""),l("")},[]),V=m.useCallback((K,W)=>{I(Qi(K,W)),g(rh(K)),x(""),u("")},[]),B=m.useCallback((K,W)=>{I(Qi(K,W)),g(rh(K)),x(""),u("")},[]),F=m.useCallback(async(K,W)=>{const ne=String(K||"").trim(),Z=String(W??"");if(!ne||!Z)return;const G=_.filter(se=>String((se==null?void 0:se.key)||"").trim()!==ne);G.push({key:ne,value:Z});const te=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),re=await te.json().catch(()=>({}));if(!te.ok)throw new Error(typeof re.error=="string"?re.error:"ENV HTTP "+te.status);S(Array.isArray(re.env)?re.env.map(se=>({key:String((se==null?void 0:se.key)||""),value:String((se==null?void 0:se.value)??"")})):G)},[_]),$=m.useCallback(()=>{const K=Eoe({...b,id:b.id||_oe()}),W=k.trim();if(K.kind==="git"&&W&&!K.credentialRef&&(K.credentialRef=Aoe(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&&!Coe(K.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const ne=T>=0?y.map((Z,G)=>G===T?K:Z):[K,...y];g(rh(K)),(async()=>{r(!0);try{W&&await F(K.credentialRef,W),x(""),await O(ne,Qi(K))}catch(Z){l(String(Z.message||Z)),r(!1)}})()},[y,b,O,F,T,k]),H=m.useCallback(()=>{if(T<0)return;const K=y.filter((W,ne)=>ne!==T);g(Ow()),I(""),O(K)},[y,O,T]),A=m.useCallback(async()=>{if(!E){if(T<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})}),W=await K.json().catch(()=>({}));if(!K.ok)throw new Error(typeof W.error=="string"?W.error:"HTTP "+K.status);const ne=Array.isArray(W.customWorkspaces)?W.customWorkspaces:y;v(ne),h((Array.isArray(W.workspaces)?W.workspaces:[]).filter(te=>te==null?void 0:te.builtin));const Z=ne.find(te=>String((te==null?void 0:te.id)||"")===String(b.id||""));Z&&g(rh(Z));const G=String(W.commit||"").trim();u(W.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(K){l(String(K.message||K))}finally{o(!1)}}},[y,b,E,T]),Q=m.useCallback(K=>{g(W=>({...W,...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:L,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 的资源配置保持一致。"}),f?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",f]}):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:d.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,W)=>i.jsx(UC,{item:K,selected:Qi(K,W)===N,onClick:()=>V(K,W)},Qi(K,W))):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:"内置知识库"})}),d.map((K,W)=>i.jsx(UC,{item:K,selected:Qi(K,W)===N,onClick:()=>B(K,W),readOnly:!0},Qi(K,W)))]}),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:E?"查看内置知识库":T>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:E?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:E,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:E,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:E,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:E,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:E,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:E,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:E,onChange:K=>{const W=K.target.value,ne=Rh(b.repoUrl),Z=String(b.mountPath||"").trim();Q({repoUrl:W,...!Z||Z===ne?{mountPath:Rh(W)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:b.branch,disabled:E,onChange:K=>Q({branch:K.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:b.mountPath,disabled:E,onChange:K=>Q({mountPath:K.target.value}),placeholder:Rh(b.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:b.credentialRef,disabled:E,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:E,onChange:K=>x(K.target.value),placeholder:D?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 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:E,onChange:K=>Q({description:K.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!E&&T>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:H,disabled:n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):i.jsx("span",{}),i.jsxs("div",{children:[b.kind==="git"&&T>=0?i.jsxs("button",{type:"button",onClick:A,disabled:E||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:E||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const a$="agentflow.workflows.scopeView",qa=8,GC=24;function Toe(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(a$)==="team"?"team":"personal"}catch{return"personal"}}function Roe(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 Moe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"}):"日期待定"}function $oe(e){return Object.values((e==null?void 0:e.dimensions)||{}).flatMap(t=>Array.isArray(t)?t:[t]).map(t=>String(t||"").trim()).filter(Boolean).join(" · ")}function Loe(e){const t=Number((e==null?void 0:e.workflowCount)||0),n=Number((e==null?void 0:e.completedCount)||0);if(t>0&&n>=t)return{key:"completed",label:"已完成"};const r=Date.parse(String((e==null?void 0:e.date)||""));return Number.isFinite(r)&&r<Date.now()?{key:"overdue",label:"已到期"}:{key:"planned",label:"计划中"}}function Ta(e){const t=new Date;return t.setHours(12,0,0,0),t.setDate(t.getDate()+e),t.toISOString().slice(0,10)}function Ooe(e){const t=Array.isArray(e)?e.length:0;if(t<=qa)return{start:0,end:t};const n=Date.now();let r=e.findIndex(o=>{const a=Date.parse(String((o==null?void 0:o.date)||""));return Number.isFinite(a)&&a>=n});r<0&&(r=t-1);const s=Math.max(0,Math.min(r-3,t-qa));return{start:s,end:Math.min(t,s+qa)}}function Doe(){const e=[{key:"prd-flow:version:android-5.62.0",kind:"version",id:"android-5.62.0",title:"Likee Android 5.62.0",date:Ta(-12),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:android-5.63.0",kind:"version",id:"android-5.63.0",title:"Likee Android 5.63.0",date:Ta(6),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:ios-5.63.0",kind:"version",id:"ios-5.63.0",title:"Likee iOS 5.63.0",date:Ta(10),source:"prd-flow",dimensions:{platform:"iOS"}},{key:"prd-flow:milestone:august-gray",kind:"milestone",id:"august-gray",title:"8 月灰度窗口",date:Ta(18),source:"prd-flow",dimensions:{channel:"灰度"}},...Array.from({length:12},(s,o)=>({key:`prd-flow:version:android-5.${50+o}.0`,kind:"version",id:`android-5.${50+o}.0`,title:`Likee Android 5.${50+o}.0`,date:Ta(-180+o*14),source:"prd-flow",dimensions:{platform:"Android"}})),...Array.from({length:8},(s,o)=>({key:`prd-flow:version:android-5.${64+o}.0`,kind:"version",id:`android-5.${64+o}.0`,title:`Likee Android 5.${64+o}.0`,date:Ta(32+o*14),source:"prd-flow",dimensions:{platform:"Android"}}))],t=Object.fromEntries(e.map(s=>[s.key,s])),n=[{id:"demo-1",tapdId:"1020124",title:"Likee Android AI Runtime Hook Skill 搭建",pointer:"继续实现 Android Action 与通用 Hook 多层注入平台",phase:"IMPLEMENTATION_IN_PROGRESS",state:"active",role:"owner",ownerUsername:"wangfang",issueCount:2,platforms:["android"],actionCount:5,completedActionCount:4,latestAction:{title:"Android 实现协议已确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"]],demo:!0},{id:"demo-2",tapdId:"1013667",title:"激励视频增收方案",pointer:"检查并选择 TAPD 未解决 Bug",phase:"BUG_SELECTION_READY",state:"blocked",role:"viewer",ownerUsername:"surujija",issueCount:18,platforms:["android","ios"],actionCount:33,completedActionCount:32,latestAction:{title:"等待版本风险确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"],t["prd-flow:version:ios-5.63.0"]],demo:!0},{id:"demo-3",tapdId:"1133202860001018940",title:"Likee Android 5.62.0",pointer:"发版上下文已同步",phase:"RELEASED",state:"completed",role:"reporter",ownerUsername:"chenjunlun",issueCount:1,platforms:["ios"],actionCount:1,completedActionCount:1,latestAction:{title:"版本发布完成",at:Ta(-12)},timeline:[t["prd-flow:version:android-5.62.0"]],demo:!0},{id:"demo-4",tapdId:"1015046",title:"Remote Config 拉取频控",pointer:"双端方案进入提测准备",phase:"SUBMIT_TEST",state:"active",role:"owner",ownerUsername:"alice",issueCount:4,platforms:["android","ios"],actionCount:8,completedActionCount:6,latestAction:{title:"测试用例已归档",at:new Date().toISOString()},timeline:[t["prd-flow:version:ios-5.63.0"],t["prd-flow:milestone:august-gray"]],demo:!0},{id:"demo-5",tapdId:"1027788",title:"直播间礼物动效治理",pointer:"等待确认目标版本",phase:"PLANNING",state:"active",role:"editor",ownerUsername:"bob",issueCount:3,platforms:["all"],actionCount:4,completedActionCount:1,latestAction:{title:"技术方案评审中",at:new Date().toISOString()},timeline:[],demo:!0},...e.slice(4).map((s,o)=>({id:`demo-timeline-${o+1}`,tapdId:`DEMO-${String(o+1).padStart(3,"0")}`,title:`${s.title} 版本事项`,pointer:o<12?"历史版本事项已归档":"等待进入版本排期",phase:o<12?"RELEASED":"PLANNING",state:o<12?"completed":"active",role:o%3===0?"owner":"reporter",ownerUsername:o%3===0?"wangfang":"demo-user",issueCount:o%4+1,platforms:["android"],actionCount:4,completedActionCount:o<12?4:1,latestAction:{title:o<12?"版本归档完成":"版本排期已同步",at:s.date},timeline:[s],demo:!0}))],r=e.map(s=>{const o=n.filter(a=>a.timeline.some(l=>l.key===s.key));return{...s,workflowCount:o.length,completedCount:o.filter(a=>a.state==="completed").length,blockedCount:o.filter(a=>a.state==="blocked").length,workflowIds:o.map(a=>a.id)}}).sort((s,o)=>Date.parse(s.date)-Date.parse(o.date));return{workflows:n,timeline:r,unassignedCount:1}}function Foe(e){return e==="owner"?"我创建的":e==="reporter"||e==="editor"?"可上报":e==="viewer"?"只读协作":"可访问"}function l$(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function c$(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function zoe(e){const t=new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||""),returnTo:"/workflows"});return e!=null&&e.demo&&t.set("workflowDemo","1"),`/workspace?${t.toString()}`}function Woe(e){var u,f,p;const t=String((e==null?void 0:e.tapdId)||"DEMO"),n=c$(((u=e==null?void 0:e.platforms)==null?void 0:u[0])||"all")||"双端",r=((f=e==null?void 0:e.timeline)==null?void 0:f[0])||{},s=[["方案已确认","需求范围和实现方案已完成确认。"],["研发任务已创建","Issue 与研发分支信息已经同步。"],["实现进度已更新","实现状态和当前风险已归档。"],["测试状态已更新","自测、提测状态已经同步。"],["版本归属已确认","版本排期和发布上下文已经确认。"]],o=Math.min(5,Math.max(1,Number((e==null?void 0:e.actionCount)||1))),a=Number((e==null?void 0:e.actionCount)||0)>0?Number((e==null?void 0:e.completedActionCount)||0)/Number(e.actionCount):0,l=Math.round(o*a),c=s.slice(0,o).map(([d,h],y)=>({id:`demo-action-${y+1}`,actionId:`demo-action-${y+1}`,stageKey:["plan","issue","implementation","test","release"][y],title:d,detail:h,status:y<l?"done":y===l?"current":"pending",issueKey:`demo-${t.toLowerCase()}`,platform:n,updatedAt:new Date(Date.now()-(o-y)*45*60*1e3).toISOString()}));return{revision:`demo-${t}`,phase:(e==null?void 0:e.phase)||"PLANNING",pointer:(e==null?void 0:e.pointer)||((p=e==null?void 0:e.latestAction)==null?void 0:p.title)||"本地 Workflow 示例",actions:c,issues:Array.from({length:Math.min(4,Math.max(1,Number((e==null?void 0:e.issueCount)||1)))},(d,h)=>({key:`demo-${t.toLowerCase()}-${h+1}`,title:h===0?(e==null?void 0:e.title)||"示例研发事项":`子任务 ${h+1}`,platform:n,status:(e==null?void 0:e.state)==="completed"?"done":h===0?"in_progress":"pending",epicKey:"示例需求"})),globalState:{title:(e==null?void 0:e.title)||`TAPD ${t}`,status:{label:l$(e==null?void 0:e.state)},workflow:{namespace:"tapd",id:t},sections:{version:{title:"版本归属",fields:{version:{label:"版本",type:"text",value:r.title||"待归属"},date:{label:"版本日期",type:"text",value:r.date||"待确认"},platform:{label:"平台",type:"chips",value:[n]}}},progress:{title:"研发进度",fields:{actions:{label:"Action",type:"text",value:`${(e==null?void 0:e.completedActionCount)||0}/${(e==null?void 0:e.actionCount)||0}`},issues:{label:"Issues",type:"text",value:String((e==null?void 0:e.issueCount)||0)},owner:{label:"Owner",type:"user",value:(e==null?void 0:e.ownerUsername)||"demo-user"}}}}},runtimeEvents:c.map(d=>({...d,type:"demo-runtime-event"})),demo:!0}}function Boe(e,t){if(t!=null&&t.demo)try{window.sessionStorage.setItem(`agentflow.workflow.demo:${t.tapdId}`,JSON.stringify(Woe(t)))}catch{}e(zoe(t))}function Hoe(){const{navigate:e}=os(),[t,n]=m.useState([]),[r,s]=m.useState([]),[o,a]=m.useState(0),[l,c]=m.useState("all"),[u,f]=m.useState(Toe),[p,d]=m.useState(null),[h,y]=m.useState(!1),[v,b]=m.useState(""),[g,k]=m.useState(""),[x,_]=m.useState("all"),[S,N]=m.useState("all"),[I,T]=m.useState(!1),[z,E]=m.useState({start:0,end:0}),D=m.useRef(null),L=m.useRef(null),O=m.useRef(!1),M=m.useRef(0),V=m.useRef(0),B=m.useCallback(async()=>{T(!1),y(!0),b("");try{const Z=await fetch(`/api/prd-workflows?view=${encodeURIComponent(u)}`),G=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(G.error||"读取迭代列表失败");const te=Array.isArray(G.workflows)?G.workflows:[],re=Array.isArray(G.timeline)?G.timeline:[];n(te),s(re),a(Number(G.unassignedCount||0)),c(se=>se==="all"||se==="unassigned"&&Number(G.unassignedCount||0)>0||re.some(ee=>ee.key===se)?se:"all"),d(G.team||null)}catch(Z){b(String(Z.message||Z)),n([]),s([]),a(0),c("all"),d(null)}finally{y(!1)}},[u]),F=m.useCallback(()=>{const Z=Doe();n(Z.workflows),s(Z.timeline),a(Z.unassignedCount),c("all"),k(""),_("all"),N("all"),b(""),T(!0)},[]);m.useEffect(()=>{B()},[B]),m.useEffect(()=>{try{localStorage.setItem(a$,u)}catch{}},[u]),m.useEffect(()=>{E(Ooe(r))},[r]),m.useLayoutEffect(()=>{const Z=L.current,G=D.current;if(G){if(Z){L.current=null;const te=Array.from(G.children).find(re=>re.dataset.timelineKey===Z.key);te&&(G.scrollLeft=Z.scrollLeft+te.offsetLeft-Z.offsetLeft)}window.clearTimeout(M.current),M.current=window.setTimeout(()=>{O.current=!1},80)}},[z]),m.useEffect(()=>()=>{window.clearTimeout(M.current),window.cancelAnimationFrame(V.current)},[]);const $=m.useMemo(()=>r.slice(z.start,z.end),[r,z]),H=z.start>0,A=z.end<r.length,Q=m.useCallback(()=>{if(!H||O.current)return;O.current=!0;const Z=D.current,G=Z==null?void 0:Z.querySelector("[data-timeline-key]");L.current=G?{key:G.dataset.timelineKey,offsetLeft:G.offsetLeft,scrollLeft:Z.scrollLeft}:null,E(te=>({start:Math.max(0,te.start-qa),end:Math.min(te.end,Math.max(0,te.start-qa)+GC)}))},[H]),K=m.useCallback(()=>{if(!A||O.current)return;O.current=!0;const Z=D.current,G=Z==null?void 0:Z.querySelectorAll("[data-timeline-key]"),te=G==null?void 0:G[G.length-1];L.current=te?{key:te.dataset.timelineKey,offsetLeft:te.offsetLeft,scrollLeft:Z.scrollLeft}:null,E(re=>({start:Math.max(re.start,Math.min(r.length,re.end+qa)-GC),end:Math.min(r.length,re.end+qa)}))},[A,r.length]),W=m.useCallback(Z=>{const G=Z.currentTarget;V.current||(V.current=window.requestAnimationFrame(()=>{V.current=0,!O.current&&(G.scrollLeft<=32?Q():G.scrollLeft+G.clientWidth>=G.scrollWidth-32&&K())}))},[Q,K]),ne=m.useMemo(()=>{const Z=g.trim().toLowerCase();return t.filter(G=>{var te;return l==="unassigned"&&(G.timeline||[]).length>0||l!=="all"&&l!=="unassigned"&&!(G.timeline||[]).some(re=>re.key===l)||x==="owned"&&G.role!=="owner"||x==="collaborating"&&G.role==="owner"||S!=="all"&&G.state!==S?!1:Z?[G.tapdId,G.title,G.pointer,G.phase,G.ownerUsername,(te=G.latestAction)==null?void 0:te.title,...(G.timeline||[]).flatMap(re=>[re.title,re.kind,re.date,...Object.values(re.dimensions||{})])].some(re=>String(re||"").toLowerCase().includes(Z)):!0})},[g,x,S,l,t]);return i.jsx("div",{className:"af-settings-page af-workflows-page",children: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:u==="team"?`汇总${p!=null&&p.name?`「${p.name}」`:"当前团队"}的需求 Workflow,按负责人追踪进度与风险。`:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]}),i.jsxs("div",{className:"af-workflows-hero-actions",children:[i.jsxs("button",{type:"button",className:"af-workflows-guide-link",onClick:()=>e("/workflow-report"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"integration_instructions"}),"接入说明"]}),i.jsxs("div",{className:"af-scope-switch","aria-label":"迭代视图",children:[i.jsx("button",{type:"button",className:u==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人迭代"}),i.jsx("button",{type:"button",className:u==="team"?"is-active":"",onClick:()=>f("team"),children:"团队迭代"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void B(),disabled:h,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:h?"hourglass_empty":"refresh"}),"刷新"]})]})]}),r.length>0||o>0?i.jsxs("section",{className:"af-workflows-timeline","aria-label":"迭代时间线",children:[i.jsxs("div",{className:"af-workflows-timeline__heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"迭代时间线"}),i.jsx("strong",{children:"按排期归属汇总"}),I?i.jsx("em",{children:"本地示例"}):null]}),i.jsxs("div",{className:"af-workflows-timeline__actions",children:[l!=="all"?i.jsx("button",{type:"button",onClick:()=>c("all"),children:"查看全部"}):null,I?i.jsx("button",{type:"button",onClick:()=>void B(),children:"退出示例"}):null]})]}),i.jsxs("div",{className:"af-workflows-timeline__rail",ref:D,onScroll:W,children:[$.map(Z=>{const G=$oe(Z),te=Loe(Z);return i.jsxs("button",{type:"button","data-timeline-key":Z.key,className:`is-${te.key}${l===Z.key?" is-active":""}`,"aria-pressed":l===Z.key,onClick:()=>c(re=>re===Z.key?"all":Z.key),children:[i.jsxs("span",{className:"af-workflows-timeline__date",children:[Moe(Z.date),i.jsx("em",{children:te.label})]}),i.jsx("strong",{children:Z.title||Z.id}),i.jsx("small",{children:[G,`${Z.workflowCount||0} 项`,Z.completedCount?`${Z.completedCount} 项已完成`:"",Z.blockedCount?`${Z.blockedCount} 项需关注`:""].filter(Boolean).join(" · ")})]},Z.key)}),o>0&&!A?i.jsxs("button",{type:"button",className:`af-workflows-timeline__unassigned${l==="unassigned"?" is-active":""}`,"aria-pressed":l==="unassigned",onClick:()=>c(Z=>Z==="unassigned"?"all":"unassigned"),children:[i.jsx("span",{className:"af-workflows-timeline__date",children:"未排期"}),i.jsx("strong",{children:"未归属"}),i.jsxs("small",{children:[o," 项 Workflow"]})]}):null]})]}):null,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:g,onChange:Z=>k(Z.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),i.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([Z,G])=>i.jsx("button",{type:"button",className:x===Z?"is-active":"","aria-pressed":x===Z,onClick:()=>_(Z),children:G},Z))}),i.jsxs("select",{value:S,onChange:Z=>N(Z.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:"需关注"})]})]}),v?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,h?i.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!h&&!v&&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:u==="team"&&!p?"尚未加入团队":"暂无迭代"}),i.jsx("p",{children:u==="team"&&!p?"请联系超级管理员完成团队划分。":"当 prd-flow 上报 Workflow 后,它会出现在这里。"}),i.jsxs("button",{type:"button",className:"af-workflows-demo-button",onClick:F,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"science"}),"载入本地示例时间线"]})]}):null,!h&&t.length>0&&ne.length===0?i.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,i.jsx("div",{className:"af-workflows-list",children:ne.map(Z=>{var te,re;const G=Z.actionCount>0?Math.round(Z.completedActionCount/Z.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 ",Z.tapdId]}),i.jsx("span",{className:`af-workflow-state af-workflow-state--${Z.state||"active"}`,children:l$(Z.state)}),i.jsx("span",{className:"af-workflow-role",children:Foe(Z.role)}),Z.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:Z.title||Z.pointer||`需求 ${Z.tapdId}`}),i.jsxs("div",{className:"af-workflow-card__meta",children:[i.jsx("span",{children:Z.phase||"未识别阶段"}),i.jsxs("span",{children:[Z.issueCount||0," Issues"]}),(Z.platforms||[]).map(se=>i.jsx("span",{children:c$(se)},se)),(Z.timeline||[]).map(se=>i.jsx("span",{children:se.title||se.id},se.key)),i.jsxs("span",{children:["Owner · ",Z.ownerUsername||Z.ownerId||"-"]}),u==="team"&&Z.teamName?i.jsxs("span",{children:["团队 · ",Z.teamName]}):null]})]}),i.jsxs("div",{className:"af-workflow-card__progress",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Action 进度"}),i.jsxs("strong",{children:[Z.completedActionCount||0,"/",Z.actionCount||0]})]}),i.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${G}%`,children:i.jsx("span",{style:{width:`${G}%`}})}),i.jsxs("small",{children:[G,"%"]})]}),i.jsxs("div",{className:"af-workflow-card__latest",children:[i.jsx("span",{children:"最新动态"}),i.jsx("strong",{children:((te=Z.latestAction)==null?void 0:te.title)||"暂无 Action 记录"}),i.jsx("small",{children:Roe(((re=Z.latestAction)==null?void 0:re.at)||Z.updatedAt)})]}),i.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>Boe(e,Z),children:[Z.demo?"查看示例":"打开 Workflow",i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Z.demo?"science":"arrow_forward"})]})]},Z.id||Z.tapdId)})})]})})})}const Voe=`skillhub install agentflow-cli --global --agent codex
321
- skillhub install agentflow-workflow-report --global --agent codex
322
-
323
- export AGENTFLOW_BASE_URL=http://ai.mengma.bigo.inner
324
- export AGENTFLOW_TOKEN=<your-token>
325
-
326
- # 本地联调
327
- # export AGENTFLOW_BASE_URL=http://127.0.0.1:8765`,Koe=`{
328
- "schemaVersion": 1,
329
- "workflow": { "namespace": "tapd", "id": "1020124" },
330
- "source": "my-adapter",
331
- "action": {
332
- "key": "requirement-imported",
333
- "title": "需求已同步",
334
- "status": "done",
335
- "occurredAt": "2026-08-05T08:00:00.000Z"
336
- },
337
- "expectedVersions": {
338
- "action:my-adapter:requirement-imported": "absent"
339
- },
340
- "idempotencyKey": "requirement-imported:1020124:v1"
341
- }`,qoe=`# 1. 读取;记录本次要修改 key 的 snapshot.resourceVersions
342
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
343
- --workflow tapd:1020124 --runtime-only
344
-
345
- # 2. 将右侧 JSON 保存为 workflow-report.json 后上报
346
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-report \\
347
- --workflow tapd:1020124 \\
348
- --file workflow-report.json
349
-
350
- # 3. 再读一次,确认 action 和对应 resourceVersions 已更新
351
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
352
- --workflow tapd:1020124 --runtime-only`,Uoe=`GET /api/workflows/state?workflow=tapd%3A1020124&runtimeOnly=1
353
- Authorization: Bearer <AGENTFLOW_TOKEN>`,Goe=`{
354
- "ok": true,
355
- "workflow": {
356
- "namespace": "tapd",
357
- "id": "1020124",
358
- "key": "tapd:1020124"
359
- },
360
- "snapshot": {
361
- "runtimeRevision": "runtime:<current-revision>",
362
- "resourceVersions": {
363
- "action:my-adapter:requirement-imported": "rv:<resource-version>"
364
- },
365
- "globalState": {},
366
- "actions": [],
367
- "artifacts": [],
368
- "projections": { "timeline": [] },
369
- "extensions": {}
370
- }
371
- }`,Yoe=`{
372
- "workflow": { "namespace": "tapd", "id": "1020124" },
373
- "authority": {
374
- "type": "tapd",
375
- "owner": { "username": "alice" },
376
- "participants": ["alice", "bob", "carol"],
377
- "observedAt": "2026-08-05T08:00:00.000Z",
378
- "revision": "tapd-story-modified-at-or-content-digest"
379
- }
380
- }`,Joe=`{
381
- "schemaVersion": 1,
382
- "workflow": { "namespace": "tapd", "id": "1020124" },
383
- "source": "prd-flow",
384
- "globalState": {
385
- "mode": "merge",
386
- "patch": {
387
- "tapdCurrentVersion": {
388
- "id": "1133202860001000338",
389
- "name": "Likee Android 5.63.0",
390
- "date": "2026-08-31",
391
- "platform": "android"
392
- }
393
- }
394
- },
395
- "projections": {
396
- "timeline": [
397
- {
398
- "kind": "version",
399
- "id": "android:1133202860001000338",
400
- "key": "prd-flow:version:android:1133202860001000338",
401
- "title": "Likee Android 5.63.0",
402
- "date": "2026-08-31",
403
- "source": "prd-flow",
404
- "dimensions": { "platform": "android" }
405
- }
406
- ]
407
- },
408
- "expectedVersions": {
409
- "global:tapdCurrentVersion.id": "rv:<version-from-get-or-absent>",
410
- "global:tapdCurrentVersion.name": "rv:<version-from-get-or-absent>",
411
- "global:tapdCurrentVersion.date": "rv:<version-from-get-or-absent>",
412
- "global:tapdCurrentVersion.platform": "rv:<version-from-get-or-absent>",
413
- "projection:prd-flow:version:android:1133202860001000338": "absent"
414
- },
415
- "idempotencyKey": "timeline:1020124:android-version-1133202860001000338:v1"
416
- }`,Xoe=`{
417
- "schemaVersion": 1,
418
- "workflow": { "namespace": "tapd", "id": "1020124" },
419
- "source": "prd-flow",
420
- "action": {
421
- "key": "implementation:runtime-hook:android",
422
- "title": "Android 实现完成",
423
- "detail": "MR !957 已合并",
424
- "status": "done",
425
- "group": "implementation",
426
- "platform": "android",
427
- "issueKey": "runtime-hook",
428
- "occurredAt": "2026-08-05T08:25:00.000Z"
429
- },
430
- "artifacts": [{
431
- "key": "implementation-mr:runtime-hook:android",
432
- "type": "gitlab-mr",
433
- "title": "实现 MR !957",
434
- "url": "https://git.example.test/merge_requests/957",
435
- "scope": "action",
436
- "status": "ready"
437
- }],
438
- "expectedVersions": {
439
- "action:prd-flow:implementation:runtime-hook:android": "absent",
440
- "artifact:prd-flow:implementation-mr:runtime-hook:android": "absent"
441
- },
442
- "idempotencyKey": "implementation-finished:android:runtime-hook:v1"
443
- }`,Qoe=`{
444
- "schemaVersion": 1,
445
- "workflow": { "namespace": "tapd", "id": "1020124" },
446
- "source": "prd-flow",
447
- "extensions": {
448
- "prd-flow": {
449
- "aiDocs": [{
450
- "key": "tech-design",
451
- "title": "技术方案",
452
- "url": "https://ai-doc.example.test/docs/123"
453
- }],
454
- "issues": [{
455
- "key": "runtime-hook",
456
- "title": "Runtime Hook",
457
- "platform": "android",
458
- "status": "implementing"
459
- }]
460
- }
461
- },
462
- "expectedVersions": {
463
- "extension:prd-flow:aiDocs": "rv:<version-from-get-or-absent>",
464
- "extension:prd-flow:issues": "rv:<version-from-get-or-absent>"
465
- },
466
- "idempotencyKey": "prd-panels:1020124:<semantic-digest>"
467
- }`,Zoe=`{
468
- "workflow": { "namespace": "tapd", "id": "1020124" },
469
- "source": "my-adapter",
470
- "globalState": {
471
- "mode": "merge",
472
- "patch": {
473
- "title": "Remote Config 拉取频控",
474
- "url": "https://tapd.example.test/1020124",
475
- "status": "实现中",
476
- "sections": {
477
- "ownership": {
478
- "title": "归属信息",
479
- "fields": {
480
- "owner": {
481
- "label": "负责人",
482
- "type": "user",
483
- "value": { "username": "alice" }
484
- },
485
- "platforms": {
486
- "label": "平台",
487
- "type": "chips",
488
- "value": ["Android", "iOS"]
489
- },
490
- "branch": {
491
- "label": "需求分支",
492
- "type": "text",
493
- "value": "story/1020124"
494
- },
495
- "risks": {
496
- "label": "当前风险",
497
- "type": "list",
498
- "value": ["等待服务端字段确认", "灰度策略待补充"]
499
- },
500
- "design": {
501
- "label": "技术方案",
502
- "type": "link",
503
- "value": "打开方案文档",
504
- "url": "https://docs.example.test/1020124"
505
- }
506
- }
507
- }
508
- }
509
- }
510
- }
511
- }`,eae=`POST /api/workflow-artifacts/publish
512
- Authorization: Bearer <AGENTFLOW_TOKEN>
513
- Content-Type: application/json
514
-
515
- {
516
- "workflow": { "namespace": "tapd", "id": "1020124" },
517
- "source": "prd-flow",
518
- "title": "Issue1 · Android 方案草稿",
519
- "markdown": "# 方案内容\\n...",
520
- "stage": "issue-plan:runtime-hook",
521
- "issueKey": "runtime-hook",
522
- "platform": "android",
523
- "artifactKey": "plan:runtime-hook:android",
524
- "artifactLabel": "方案预览",
525
- "durability": "temporary",
526
- "ttlDays": 7,
527
- "expectedVersions": {
528
- "artifact:prd-flow:plan:runtime-hook:android": "absent"
529
- },
530
- "idempotencyKey": "review:plan:runtime-hook:android:<content-digest>"
531
- }`,YC=`请使用 $agentflow-workflow-report 接入一个生产方,并完整阅读 references/protocol.md。
532
-
533
- 运行态数据只有三个正式接口,TAPD 人员权限另有一个控制面接口:
534
- 0. POST /api/workflows/access/sync:把 TAPD Owner 和参与人同步为 Workflow 派生权限;它不写业务状态。
535
- 1. GET /api/workflows/state:读取当前状态和 snapshot.resourceVersions。
536
- 2. POST /api/workflows/report:写全局信息、Action、普通产物、迭代投影或自定义区域。
537
- 3. POST /api/workflow-artifacts/publish:把本地 Markdown 内容发布成预览 URL。
538
-
539
- 先输出接入映射表:
540
- - 稳定 Workflow 身份是什么;当前服务支持 tapd:<short-id>。
541
- - 哪些事实进入 observation.state / globalState。
542
- - 哪些关键业务节点进入 action;每个稳定 action.key 是什么。
543
- - 哪些外部链接进入 artifacts;哪些本地 Markdown 需要先 publish。
544
- - 哪些版本/Sprint/里程碑进入 projections.timeline。
545
- - 普通自定义信息是否可用 globalState.sections 的 text/user/chips/list/link 渲染器表达。
546
- - 只有通用渲染器不够时,才设计 extensions namespace/schema/前端渲染器。
547
-
548
- 实现 access sync → read → merge → report → verify:
549
- - TAPD Owner 映射为 Workflow Owner;TAPD 参与人默认 Viewer;Owner 可在 AgentFlow 中显式授予 Reporter。
550
- - owner/reporter 才能写;viewer、团队成员、分享链接、管理员代看只读。
551
- - globalState 只 patch 自己拥有的路径;对象递归合并,数组/标量替换。
552
- - source 使用真实业务 Adapter 的稳定小写名称;agentflow-cli 只是传输工具。
553
- - 同一 source + action.key 更新同一阶段,不为刷新或重试创建新 key。
554
- - timeline 只提交当前 source 的完整切片;服务端原子保留其他生产方条目。
555
- - globalState.sections 是当前通用自定义卡片能力;优先使用现有 field type。
556
- - extensions 只写自己的 namespace;当前仅 prd-flow 注册了 AI Docs / Issues 专用 renderer,保存其他 namespace 不会自动出现 UI。
557
- - 为本次触及的每个业务 key 携带 expectedVersions 与稳定 idempotencyKey;任一 key 冲突时整次请求不落库,刷新冲突 key 后只重试一次。
558
- - 不输出 Token,不新增生产方专用写接口,不使用 /api/prd-workflow/* 兼容接口。
559
-
560
- 最后验证 Workflow 全局区域、Action 时间轴、产物链接、个人/团队迭代和自定义区域。`,tae=[{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 权限",detail:"把 TAPD Owner 和参与人投影为 Workflow 派生权限;不传业务状态。",permission:"首次为 TAPD Owner;后续为当前 Owner / 管理员",effect:"更新 Owner 与 TAPD Viewer,保留显式授权"},{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",detail:"取得服务端物化快照与每个业务 key 的 resourceVersions;安全写入的第一步。",permission:"可访问该 Workflow 的用户可读",effect:"只读,不修改任何状态"},{method:"POST",path:"/api/workflows/report",title:"统一上报",detail:"写入全局信息、Action、普通产物、迭代归属和自定义区域。",permission:"owner / reporter",effect:"按区域执行替换、合并或更新"},{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",detail:"上传 Markdown 内容,生成可供浏览器查看的规范 URL 与短链。",permission:"owner / reporter",effect:"保存预览副本与辅助 Artifact,不推进阶段"}],nae=[["workflow","string","二选一","规范 Workflow key,例如 tapd:1020124"],["namespace + id","string","二选一","拆分传入身份;当前 namespace 仅支持 tapd"],["runtimeOnly","0 | 1","否","1 只读已保存运行态,不主动刷新上游"],["flowId / flowSource","string","否","关联 AgentFlow 项目上下文;flowSource 默认 user"],["workspaceId","string","否","关联项目的工作区上下文"],["workflowShare","string","否","只读分享 token,不能用于写接口"]],rae=[["workflow","object","规范身份 {namespace,id,key}"],["snapshot.resourceVersions","object","业务 key 到并发版本的映射;新接入按本次触及 key 取值"],["snapshot.runtimeRevision","string","整份运行态版本;页面缓存与旧客户端兼容使用"],["snapshot.globalState","object","服务端合并后的全局区域"],["snapshot.actions","array","已物化的 Action 时间轴"],["snapshot.artifacts","array","已物化的全局产物"],["snapshot.projections.timeline","array","当前完整迭代归属"],["snapshot.extensions","object","所有已保存的 namespace 数据"]],sae=[["schemaVersion","number","否","当前固定为 1"],["workflow","object | string","是","{namespace,id} 或规范 key"],["source","string","是","真实业务 Adapter 的稳定小写名称;agentflow-cli 仅负责传输"],["expectedVersions","object","生产建议","本次触及的每个 resource key 及读取时版本;新建 key 使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","业务操作稳定身份,不使用时间戳或随机 UUID"],["observation","object","条件","同一 clientId 的完整生产方观察"],["globalState","object","条件","全局事实的 merge patch 与 remove"],["action","object","条件","一个关键业务阶段;key 必填"],["artifacts","array","条件","Action 证据或全局证据"],["projections","object","条件","当前 source 的完整 timeline 迭代归属切片"],["extensions","object","条件","按生产方 namespace 组织的自定义区域"]],iae=[["workflow","object | string","是","规范 Workflow 身份;当前仅 tapd:<short-id>"],["authority.type","string","是","当前固定为 tapd;表示权限事实来源,不是 report source"],["authority.owner","string | object","是","TAPD 需求 Owner 的 AgentFlow username/userId;必须已登录或注册"],["authority.participants","array","否","TAPD 参与人用户名;匹配到账号后自动获得 Viewer"],["authority.observedAt","ISO date","建议","读取 TAPD 人员快照的时间;旧于已保存快照时返回 409"],["authority.revision","string","建议","TAPD modified 值或人员内容摘要,供审计和排查"]],oae=[["key","string","是","稳定阶段身份;同 key 更新同一阶段"],["title / detail","string","否","时间轴卡片标题与摘要"],["status","enum","否","pending/running/done/error/conflict/skipped/cancelled/observed"],["group / scope","string","否","阶段分组与业务范围"],["platform / issueKey","string","否","平台和自定义 Issue 维度"],["tags","string[]","否","额外筛选标签"],["occurredAt","ISO date","否","业务发生时间,不是 HTTP 重试时间"]],aae=[["schema","string","否","生产方观察 schema,建议带版本,例如 my-adapter/v1"],["clientId","string","建议","稳定客户端身份;决定哪份完整观察被替换"],["observedAt","ISO date","建议","本次事实采集时间"],["scope","string","否","观察范围,默认 client"],["state","object","是","该 clientId 的完整当前观察,不是 patch"]],lae=[["mode","merge","是","当前只支持 merge"],["patch","object","条件","对象递归合并;数组、标量整体替换;null 删除字段"],["remove","string[]","条件","显式删除点路径,例如 sections.progress.fields.owner"]],cae=[["sections.<key>.title","string","建议","分区标题;key=progress 使用紧凑网格"],["fields.<key>.label","string","建议","字段显示名"],["fields.<key>.type","enum","否","text / user / chips / list / link;未知值回退 text"],["fields.<key>.value","any","是","展示值;空值不渲染"],["fields.<key>.url","string","link 条件","link 类型的跳转地址"]],uae=[["timeline","array","是","替换当前 source 的完整切片;省略 projections 才表示不修改"],["timeline[].kind","string","是","version / sprint / milestone 或生产方自定义类型"],["timeline[].id","string","是","业务对象稳定 ID;改名或改期不改变"],["timeline[].key","string","建议","建议 source:kind:id,避免不同生产方碰撞"],["timeline[].title / date","string","否","卡片标题和 YYYY-MM-DD 排期"],["timeline[].source","string","建议","条目所有者,用于 read-merge 时识别自有条目"],["timeline[].dimensions","object","否","平台、发布列车等不透明筛选维度"]],dae=[["extensions.<namespace>","object","是","生产方自有、带版本约定的结构化 JSON"],["namespace","string","是","小写稳定标识;建议与 report.source 相同"],["对象字段","object","否","递归合并;null 删除"],["数组 / 标量","any","否","整体替换,不做元素级 merge"],["renderer","前端注册","展示条件","未知 namespace 只保存,不自动出现面板"]],fae=[["key","string","建议","稳定证据身份;不要依赖标题去重"],["type","string","否","gitlab-mr/build/test-report/document 等"],["title","string","否","页面展示标题"],["url / path","string","至少一个","外部地址或可识别路径"],["scope","action | global","否","有 Action 时默认 action"],["status","string","否","生产方定义的证据状态"]],pae=[["workflow","object | string","是","目标 Workflow"],["source","string","是","真实生产方身份;agentflow-cli 只是传输工具"],["title","string","是","Review 页面标题"],["markdown","string","是","Markdown 实际内容,不是本地文件路径"],["stage / stageKey","string","建议","关联的稳定 Action 阶段"],["issueKey / platform","string","否","Issue 与平台维度"],["artifactKey","string","是","预览 Artifact 的稳定槽位"],["artifactLabel","string","否","页面按钮文案"],["durability","enum","否","temporary 或 durable"],["ttlDays","number","临时建议","临时预览有效期,通常 7 天"],["expectedVersions","object","生产建议","目标 artifact:source:key 的当前版本;新建使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","包含内容摘要;同 source + key 重放返回同一预览"]],JC=[["api","快速开始"],["model","区域模型"],["renderers","渲染效果"],["reference","参数参考"],["scenarios","关键场景"],["safety","权限与覆盖"],["design","设计思想"],["ai","AI 引导"]],hae=[{icon:"dashboard",name:"全局区域",question:"这个需求现在是什么?",fields:"observation.state · globalState · projections.timeline",detail:"标题、状态、负责人、平台、版本事实和迭代归属。事实留在 globalState,迭代列表只读取可重建的 projection。"},{icon:"timeline",name:"Action 时间轴",question:"关键阶段发生了什么?",fields:"action · artifacts",detail:"方案确认、实现、提测、发布等业务节点及其 MR、构建、测试或文档证据。Action 不是刷新日志。"},{icon:"extension",name:"自定义展示",question:"生产方还需要展示什么?",fields:"globalState.sections · extensions[namespace]",detail:"普通键值、标签、列表和链接优先使用通用 sections;只有需要树形结构或专用交互时才使用 extensions 并开发 renderer。"}],mae=[["observation.state","同一 clientId 完整替换","省略不改","只替换自己的完整观察"],["globalState","对象递归合并;数组/标量替换","null 或 remove 删除","只 patch 自己拥有的路径"],["action","同 source + action.key 更新同一阶段","无通用物理删除","取消/跳过使用业务状态表达"],["artifacts","同 source + 稳定 key 更新/归并","无通用物理删除","不要改 key 来伪造删除"],["projections.timeline","当前 source 的完整切片替换","[] 只清空当前 source","其他生产方条目由服务端原子保留"],["extensions","仅 extensions[source] 内对象递归合并;数组/标量替换","null 删除自有字段","不能写别人的 namespace"]],gae=[["TAPD Owner","可读","可写","Workflow Owner;可管理成员和分享"],["显式 Reporter","可读","可写","Owner 主动授权;不能管理成员"],["TAPD 参与人","可读","只读","由 TAPD 派生;移出 TAPD 后自动收回"],["显式 Viewer","可读","只读","Owner 主动授权;不依赖 TAPD"],["同团队成员","可读","只读","自动获得 team viewer"],["分享链接","可读","只读","不能用于上报"],["超级管理员代看","可读","只读","不会以管理员身份覆盖数据"]];async function yae(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",document.body.appendChild(r),r.select();const s=document.execCommand("copy");return r.remove(),s}catch{return!1}}function Do({number:e,title:t,detail:n}){return i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:e}),i.jsxs("div",{children:[i.jsx("h2",{children:t}),i.jsx("p",{children:n})]})]})}function Ps({title:e,value:t,copyKey:n,copied:r,onCopy:s,wrap:o=!1}){const a=r===`failed:${n}`;return i.jsxs("div",{className:`af-wr-code-panel${o?" is-wrap":""}`,children:[i.jsxs("div",{className:"af-wr-code-panel__head",children:[i.jsx("span",{children:e}),i.jsxs("button",{type:"button",onClick:()=>void s(n,t),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r===n?"check":"content_copy"}),r===n?"已复制":"复制"]})]}),i.jsx("pre",{children:t}),a?i.jsx("p",{className:"af-wr-copy-error",children:"浏览器禁止访问剪贴板,请手动选择代码块内容。"}):null]})}function Yr({columns:e=["参数","类型","必填","含义"],rows:t,label:n}){return i.jsxs("div",{className:`af-wr-table is-${e.length}-columns`,role:"table","aria-label":n,children:[i.jsx("div",{className:"af-wr-table__row is-head",role:"row",children:e.map(r=>i.jsx("span",{role:"columnheader",children:r},r))}),t.map(r=>i.jsx("div",{className:"af-wr-table__row",role:"row",children:r.map((s,o)=>i.jsx("span",{role:"cell","data-label":e[o],children:s},`${r[0]}-${o}`))},r[0]))]})}function sh({method:e,path:t,title:n,permission:r,effect:s}){return i.jsxs("div",{className:"af-wr-endpoint__head",children:[i.jsxs("div",{className:"af-wr-endpoint__identity",children:[i.jsx("span",{className:`is-${e.toLowerCase()}`,children:e}),i.jsx("code",{children:t}),i.jsx("h3",{children:n})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"权限"}),i.jsx("dd",{children:r})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"副作用"}),i.jsx("dd",{children:s})]})]})]})}function wae(){return i.jsxs("article",{className:"af-prd-workflow-card af-prd-overall af-wr-render-preview",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"需求概览"}),i.jsx("span",{className:"af-prd-overall__status",children:"实现中"})]}),i.jsx("div",{className:"af-prd-overall__requirement",children:i.jsx("strong",{children:"Remote Config 拉取频控"})}),i.jsx("div",{className:"af-prd-overall__platforms",children:i.jsxs("section",{className:"af-prd-overall-platform",children:[i.jsx("div",{className:"af-prd-overall-platform__head",children:i.jsx("strong",{children:"归属信息"})}),i.jsxs("div",{className:"af-prd-overall-platform__fields",children:[i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--user",children:[i.jsx("small",{children:"负责人 · user"}),i.jsx("div",{children:i.jsx("span",{children:"alice"})})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--chips",children:[i.jsx("small",{children:"平台 · chips"}),i.jsxs("div",{children:[i.jsx("span",{children:"Android"}),i.jsx("span",{children:"iOS"})]})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--text",children:[i.jsx("small",{children:"需求分支 · text"}),i.jsx("div",{children:i.jsx("span",{children:"story/1020124"})})]}),i.jsxs("div",{className:"af-prd-overall-platform__rules",children:[i.jsx("small",{children:"当前风险 · list"}),i.jsxs("ul",{children:[i.jsx("li",{children:"等待服务端字段确认"}),i.jsx("li",{children:"灰度策略待补充"})]})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[i.jsx("small",{children:"技术方案 · link"}),i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"打开方案文档"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]})]})]})})]})}function xae(){return i.jsxs("div",{className:"af-prd-workflow-action af-prd-workflow-action--done af-wr-render-preview",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:[i.jsx("time",{children:"16:25:40"}),i.jsx("strong",{children:"Android 实现完成"})]}),i.jsx("p",{children:"MR !957 已合并"}),i.jsxs("div",{className:"af-prd-workflow-action__meta",children:[i.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--issue",children:[i.jsx("b",{children:"Issue"}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"runtime-hook"})]}),i.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--platform",children:[i.jsx("b",{children:"平台"}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"Android"})]})]})]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:"完成"})]}),i.jsx("div",{className:"af-prd-workflow-action__links",children:i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"实现 MR !957"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]})]})}function bae(){return i.jsxs("article",{className:"af-prd-workflow-card af-wr-render-preview",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:"2"})]}),i.jsxs("div",{className:"af-prd-workflow-list",children:[i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"测试报告 #128"}),i.jsx("small",{children:"test-report"})]}),i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"Jenkins Build #8451"}),i.jsx("small",{children:"build"})]})]})]})}function kae(){return i.jsxs("section",{className:"af-workflows-timeline af-wr-render-preview",children:[i.jsx("div",{className:"af-workflows-timeline__heading",children:i.jsxs("div",{children:[i.jsx("span",{children:"迭代时间线"}),i.jsx("strong",{children:"按排期归属汇总"})]})}),i.jsx("div",{className:"af-workflows-timeline__rail",children:i.jsxs("button",{type:"button",className:"is-active",children:[i.jsxs("span",{className:"af-workflows-timeline__date",children:["2026/08/31",i.jsx("em",{children:"计划中"})]}),i.jsx("strong",{children:"Likee Android 5.63.0"}),i.jsx("small",{children:"Android · 3 项 · 1 项需关注"})]})})]})}function vae(){return i.jsxs("div",{className:"af-wr-extension-preview",children:[i.jsxs("section",{children:[i.jsxs("div",{children:[i.jsx("span",{children:"AI DOCS"}),i.jsx("strong",{children:"2"})]}),i.jsx("p",{children:"技术方案"}),i.jsx("p",{children:"测试与灰度说明"})]}),i.jsxs("section",{children:[i.jsxs("div",{children:[i.jsx("span",{children:"ISSUES"}),i.jsx("strong",{children:"2 / 3"})]}),i.jsxs("p",{children:[i.jsx("i",{className:"is-done"})," Runtime Hook · Android"]}),i.jsxs("p",{children:[i.jsx("i",{})," iOS 容器适配"]})]})]})}function Sae(){const{navigate:e}=os(),[t,n]=m.useState(""),[r,s]=m.useState("api"),o=m.useCallback(async(a,l)=>{n(await yae(l)?a:`failed:${a}`)},[]);return m.useEffect(()=>{const a=JC.map(([c])=>document.getElementById(c)).filter(Boolean);if(!a.length||typeof IntersectionObserver>"u")return;const l=new IntersectionObserver(c=>{var f,p;const u=c.filter(d=>d.isIntersecting).sort((d,h)=>d.boundingClientRect.top-h.boundingClientRect.top);(p=(f=u[0])==null?void 0:f.target)!=null&&p.id&&s(u[0].target.id)},{rootMargin:"-18% 0px -68% 0px",threshold:[0,.1]});return a.forEach(c=>l.observe(c)),()=>l.disconnect()},[]),i.jsx("div",{className:"af-wr-page",children:i.jsxs("div",{className:"af-wr-inner",children:[i.jsxs("section",{className:"af-wr-hero",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-wr-kicker",children:"WORKFLOW REPORT · API REFERENCE"}),i.jsx("h1",{children:"Workflow 接入文档"}),i.jsx("p",{children:"用 3 个运行态数据接口和 1 个权限控制面接口,把生产流程的人员权限、全局信息、Action 时间轴、产物链接、迭代归属和自定义面板接入 AgentFlow。数据协议面向任意 Adapter;当前服务端的 Workflow 身份与权限适配器只支持 TAPD,prd-flow 仅作为 TAPD 研发场景的参考实现。"}),i.jsxs("div",{className:"af-wr-hero__boundary",children:[i.jsx("strong",{children:"当前边界"}),i.jsx("span",{children:"可接入任意事实来源"}),i.jsx("i",{children:"·"}),i.jsx("span",{children:"Workflow key 目前必须是 tapd:<short-id>"})]})]}),i.jsxs("div",{className:"af-wr-hero__actions",children:[i.jsxs("button",{type:"button",className:"is-primary",onClick:()=>void o("ai",YC),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:t==="ai"?"check":"smart_toy"}),t==="ai"?"已复制 AI 引导":"复制 AI 接入引导"]}),i.jsx("button",{type:"button",onClick:()=>e("/workflows"),children:"打开 Workflow Dashboard"})]})]}),i.jsx("nav",{className:"af-wr-toc","aria-label":"接入文档目录",children:JC.map(([a,l])=>i.jsx("a",{className:r===a?"is-active":"",href:`#${a}`,children:l},a))}),i.jsxs("section",{className:"af-wr-section",id:"api",children:[i.jsx(Do,{number:"01",title:"5 分钟跑通一次上报",detail:"运行态数据接口只有三个,人员权限由独立控制面接口同步。先准备登录 Token 和稳定 source,再执行 access sync → read → merge → report → verify;旧 /api/prd-workflow/* 仅为兼容入口。"}),i.jsx("div",{className:"af-wr-endpoint-grid",children:tae.map(a=>i.jsxs("article",{children:[i.jsxs("div",{children:[i.jsx("span",{className:`is-${a.method.toLowerCase()}`,children:a.method}),i.jsx("code",{children:a.path})]}),i.jsx("h3",{children:a.title}),i.jsx("p",{children:a.detail}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"权限"}),i.jsx("dd",{children:a.permission})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"副作用"}),i.jsx("dd",{children:a.effect})]})]})]},a.path))}),i.jsxs("div",{className:"af-wr-quickstart",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"开始前准备"}),i.jsxs("p",{children:["在 AgentFlow 的 MCP 页面点击“使用当前登录 Token”,仅在本机设置 ",i.jsx("code",{children:"AGENTFLOW_TOKEN"}),"。当前 Workflow 身份必须使用 ",i.jsx("code",{children:"tapd:<short-id>"}),";",i.jsx("code",{children:"source"})," 填业务 Adapter 名,不能填传输工具名。"]})]}),i.jsx(Ps,{title:"安装与认证",value:Voe,copyKey:"install",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-code-grid af-wr-quickstart-run",children:[i.jsx(Ps,{title:"可直接执行的三步命令",value:qoe,copyKey:"quickstart",copied:t,onCopy:o}),i.jsx(Ps,{title:"workflow-report.json 最小请求",value:Koe,copyKey:"quickstart-report",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-success-check",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("p",{children:[i.jsx("strong",{children:"成功标准:"}),"POST 返回 ",i.jsx("code",{children:"ok: true"})," 和实际 ",i.jsx("code",{children:"resourceKeys"}),",再次 GET 能看到 ",i.jsx("code",{children:"requirement-imported"}),",且对应 ",i.jsx("code",{children:"snapshot.resourceVersions"})," 已从 ",i.jsx("code",{children:"absent"})," 变为新版本。"]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"model",children:[i.jsx(Do,{number:"02",title:"先决定数据进入哪个区域",detail:"页面区域和协议字段一一对应。不要把所有内容都塞进一个 snapshot,也不要从 Action 标题反推结构化数据。"}),i.jsx("div",{className:"af-wr-region-grid",children:hae.map(a=>i.jsxs("article",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a.icon}),i.jsxs("div",{children:[i.jsx("small",{children:a.question}),i.jsx("h3",{children:a.name}),i.jsx("code",{children:a.fields}),i.jsx("p",{children:a.detail})]})]},a.name))}),i.jsxs("div",{className:"af-wr-model-note",children:[i.jsx("strong",{children:"核心原则"}),i.jsx("span",{children:"globalState.sections 解决通用自定义展示"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"Action 表达关键业务节点"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"projection 只做聚合索引"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"extension 承载专用结构"})]})]}),i.jsxs("section",{className:"af-wr-section",id:"renderers",children:[i.jsx(Do,{number:"03",title:"当前可直接使用的通用渲染器",detail:"这些 schema 已经由 AgentFlow 页面识别,接入方只需上报数据,不需要开发前端。下面的预览使用与 Workflow 详情页相同的样式类。"}),i.jsxs("div",{className:"af-wr-renderer-notice",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"info"}),i.jsxs("p",{children:[i.jsx("strong",{children:"普通自定义信息不要放进 extensions。"}),"负责人、平台、分支、风险列表、文档链接等,直接使用 ",i.jsx("code",{children:"globalState.sections"}),"。只有通用组件无法表达的树形结构、复杂交互或专用业务面板,才需要 ",i.jsx("code",{children:"extensions"})," 和前端 renderer。"]})]}),i.jsxs("div",{className:"af-wr-renderer-feature",children:[i.jsxs("div",{className:"af-wr-renderer-feature__copy",children:[i.jsx("span",{children:"GENERIC · GLOBAL STATE"}),i.jsx("h3",{children:"概览分区 / 字段渲染器"}),i.jsxs("p",{children:["每个 section 生成一张分区卡片;字段按 ",i.jsx("code",{children:"type"})," 选择固定样式。section key 为 ",i.jsx("code",{children:"progress"})," 时使用紧凑响应式网格,其余分区纵向排列。"]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"text"}),i.jsx("dd",{children:"普通文本,无胶囊背景"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"user"}),i.jsx("dd",{children:"负责人文本,使用强调色"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"chips"}),i.jsx("dd",{children:"一个或多个标签胶囊"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"list"}),i.jsx("dd",{children:"纵向项目符号列表"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"link"}),i.jsx("dd",{children:"可点击文本与外链图标"})]})]})]}),i.jsx(wae,{})]}),i.jsx(Ps,{title:"globalState.sections 上报示例",value:Zoe,copyKey:"generic-section",copied:t,onCopy:o}),i.jsxs("div",{className:"af-wr-renderer-grid",children:[i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"Action 时间轴"}),i.jsx("code",{children:"action + artifacts[scope=action]"}),i.jsx("p",{children:"按日期分组,展示状态点、时间、标题、详情、Issue/平台标签和阶段产物按钮。"})]}),i.jsx(xae,{})]}),i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"关联产物列表"}),i.jsx("code",{children:"artifacts[scope=global]"}),i.jsx("p",{children:"用于构建、测试报告、外部文档等全局链接;显示标题、类型与跳转状态。"})]}),i.jsx(bae,{})]}),i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"迭代时间线"}),i.jsx("code",{children:"projections.timeline"}),i.jsx("p",{children:"根据 kind/id/title/date/dimensions 聚合个人与团队迭代,支持横向时间线和筛选。"})]}),i.jsx(kae,{})]})]}),i.jsxs("div",{className:"af-wr-extension-registry",children:[i.jsxs("div",{children:[i.jsx("span",{children:"REGISTERED EXTENSION"}),i.jsx("h3",{children:i.jsx("code",{children:'extensions["prd-flow"]'})}),i.jsx("p",{children:"当前唯一已注册的专用 extension renderer。支持 AI Docs 链接列表和带父子层级、平台、MR 状态及关联链接的 Issues 树。"}),i.jsx(vae,{})]}),i.jsxs("div",{children:[i.jsx("strong",{children:"其他 namespace 当前如何显示?"}),i.jsx("p",{children:"数据会被保存并参与 revision,但不会自动出现面板。若现有 sections / Action / Artifact / timeline 足够,应优先使用通用组件;确实需要新布局时,再提交扩展 schema、空态/错误态、响应式样式和 renderer 实现。"})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"reference",children:[i.jsx(Do,{number:"04",title:"接口与参数参考",detail:"以下字段来自当前服务端真实校验与合并逻辑;可以按区域只提交本次需要更新的部分。"}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(sh,{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 派生权限",permission:"首次:TAPD Owner;后续:当前 Owner / 管理员",effect:"只改权限控制面,不写运行态"}),i.jsxs("p",{className:"af-wr-endpoint__intro",children:["Adapter 读取 TAPD Story 后,先把 Owner 与参与人同步到 AgentFlow。Owner 必须已注册 AgentFlow;未匹配的参与人会在 ",i.jsx("code",{children:"unresolvedParticipants"})," 中返回,注册后下次同步即可获得 Viewer。"]}),i.jsx(Yr,{rows:iae,label:"Workflow access sync 参数"}),i.jsx(Ps,{title:"权限同步请求",value:Yoe,copyKey:"access-sync",copied:t,onCopy:o}),i.jsxs("div",{className:"af-wr-callout",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"security"}),i.jsxs("p",{children:[i.jsx("strong",{children:"派生权限与显式授权分开保存。"}),"TAPD 参与人只自动获得 Viewer;Owner 可在 Workflow 分享弹窗把某人提升为 Reporter。后续 TAPD 同步会替换派生参与人,但不会覆盖显式授权。"]})]})]}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(sh,{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",permission:"owner / reporter / viewer / team viewer / share viewer",effect:"无"}),i.jsxs("p",{className:"af-wr-endpoint__intro",children:["写入前读取当前快照,从 ",i.jsx("code",{children:"snapshot.resourceVersions"})," 保存本次将触及的业务 key 版本;不存在的 key 使用 ",i.jsx("code",{children:"absent"}),"。客户端提交的完整状态叫 ",i.jsx("code",{children:"observation.state"}),";只有服务端返回的数据才叫 ",i.jsx("code",{children:"snapshot"}),"。"]}),i.jsx(Yr,{rows:nae,label:"Workflow state query 参数"}),i.jsx("h4",{children:"成功响应"}),i.jsx(Yr,{columns:["字段","类型","含义"],rows:rae,label:"Workflow state 成功响应"}),i.jsxs("div",{className:"af-wr-code-grid",children:[i.jsx(Ps,{title:"请求",value:Uoe,copyKey:"read-request",copied:t,onCopy:o}),i.jsx(Ps,{title:"关键响应字段",value:Goe,copyKey:"read-response",copied:t,onCopy:o})]})]}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(sh,{method:"POST",path:"/api/workflows/report",title:"统一上报 Workflow",permission:"owner / reporter",effect:"修改运行态并返回新 snapshot"}),i.jsx("p",{className:"af-wr-endpoint__intro",children:"至少提交 observation、globalState、action、artifacts、projections、extensions 之一。一次请求可以组合多个区域:每个业务 key 独立校验版本,任一冲突则整次请求原子失败,不会只写入一半。"}),i.jsx("h4",{children:"Envelope"}),i.jsx(Yr,{rows:sae,label:"Workflow Report 顶层参数"}),i.jsxs("div",{className:"af-wr-subreference",children:[i.jsxs("div",{children:[i.jsx("h4",{children:"action"}),i.jsx("p",{children:"业务阶段,不是运行日志。"}),i.jsx(Yr,{rows:oae,label:"Action 参数"})]}),i.jsxs("div",{children:[i.jsx("h4",{children:"artifacts"}),i.jsx("p",{children:"已有 HTTP URL 的证据直接上报。"}),i.jsx(Yr,{rows:fae,label:"Artifact 参数"})]})]}),i.jsxs("div",{className:"af-wr-schema-reference",children:[i.jsxs("article",{children:[i.jsx("h4",{children:"observation"}),i.jsx("p",{children:"同一 clientId 的完整生产方观察。"}),i.jsx(Yr,{rows:aae,label:"Observation 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"globalState"}),i.jsx("p",{children:"可独立更新的全局事实和通用分区。"}),i.jsx(Yr,{rows:lae,label:"Global State 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"globalState.sections"}),i.jsx("p",{children:"无需前端开发的通用字段渲染器。"}),i.jsx(Yr,{rows:cae,label:"Global State Section 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"projections.timeline"}),i.jsx("p",{children:"个人/团队 Dashboard 使用的可重建索引。"}),i.jsx(Yr,{rows:uae,label:"Timeline Projection 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"extensions"}),i.jsx("p",{children:"只有专用 renderer 才能显示的 namespace 数据。"}),i.jsx(Yr,{rows:dae,label:"Workflow Extensions 参数"})]})]}),i.jsxs("p",{className:"af-wr-table-note",children:[i.jsx("strong",{children:"生产方隔离:"}),"Action、Artifact、Projection、Observation 和 Extension 都使用带 ",i.jsx("code",{children:"source"})," 的资源 key;不同 source 可以复用相同业务 key。",i.jsx("code",{children:"globalState"})," 按叶子路径分 key 并记录首次写入者,不能覆盖其他 source 的路径;timeline 只替换当前 source 的切片。"]})]}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(sh,{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",permission:"owner / reporter",effect:"保存预览副本和辅助 Artifact;不推进 Action"}),i.jsx("p",{className:"af-wr-endpoint__intro",children:"客户端读取本地 Markdown,再发送实际内容。服务端不能访问调用方本地路径;外部系统已有 URL 时直接使用 Report artifacts,无需发布副本。"}),i.jsx(Yr,{rows:pae,label:"Artifact Publish 参数"}),i.jsxs("div",{className:"af-wr-publish-layout",children:[i.jsxs("div",{className:"af-wr-result-list",children:[i.jsx("h4",{children:"返回什么"}),i.jsxs("p",{children:[i.jsx("code",{children:"artifact"}),":页面可识别的标准产物"]}),i.jsxs("p",{children:[i.jsx("code",{children:"review.url"}),":规范预览地址"]}),i.jsxs("p",{children:[i.jsx("code",{children:"review.shortUrl"}),":通常为 ",i.jsx("code",{children:"/r/<code>"})," 的分享短链"]}),i.jsxs("p",{children:[i.jsx("code",{children:"snapshot"}),":发布后的最新 Workflow 状态"]}),i.jsx("strong",{children:"不会确认方案、修改原文件、提交 ai-doc、创建 Issue 或推进阶段。"})]}),i.jsx(Ps,{title:"发布请求",value:eae,copyKey:"publish",copied:t,onCopy:o})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"scenarios",children:[i.jsx(Do,{number:"05",title:"三个关键接入场景",detail:"以 prd-flow 为例说明接口组合;它是 TAPD 研发流程的一种实现,不是协议依赖。"}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 A"}),i.jsx("h3",{children:"更新迭代:绑定或切换版本"}),i.jsxs("ol",{children:[i.jsx("li",{children:"Adapter 从业务系统得到稳定 version ID、标题、日期、平台;prd-flow 的来源恰好是 TAPD。"}),i.jsx("li",{children:"GET 当前 snapshot,取版本事实叶子路径及自有 projection 的 resourceVersions。"}),i.jsx("li",{children:"版本事实写入 globalState;归属索引写入 kind=version projection。"}),i.jsx("li",{children:"只提交当前 source 的完整投影切片;其他 source 的 Sprint/版本由服务端保留。"})]}),i.jsxs("p",{children:[i.jsx("strong",{children:"改名/改期:"}),"保持 ID 和 key 不变。",i.jsx("strong",{children:"取消归属:"}),"移除自有条目后上报剩余自有切片;发送空数组只清空当前 source。"]})]}),i.jsx(Ps,{title:"版本事实 + 当前生产方迭代投影",value:Joe,copyKey:"version",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 B"}),i.jsx("h3",{children:"上报 Action 和产物链接"}),i.jsxs("ol",{children:[i.jsx("li",{children:"先完成真实业务动作,例如创建并合并 MR。"}),i.jsx("li",{children:"用稳定 action.key 报告阶段,用 artifact.key 报告证据。"}),i.jsx("li",{children:"同一阶段刷新继续使用相同 key;occurredAt 使用业务时间。"}),i.jsx("li",{children:"本地 Markdown 先 publish,已有 HTTP URL 直接作为 Artifact。"})]}),i.jsx("p",{children:"AgentFlow 只记录和展示结果,不替接入方操作 TAPD、GitLab 或 Jenkins。"})]}),i.jsx(Ps,{title:"实现完成 + MR",value:Xoe,copyKey:"action",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 C"}),i.jsx("h3",{children:"上报自定义文档区 / Issue 区"}),i.jsxs("ol",{children:[i.jsx("li",{children:"定义生产方 namespace 和版本化 schema。"}),i.jsx("li",{children:"把结构化数组写入 extensions[namespace]。"}),i.jsx("li",{children:"数组上报完整新值,对象字段可以递归合并。"}),i.jsx("li",{children:"实现并注册专用渲染器,页面才会出现对应区域。"})]}),i.jsx("p",{children:"prd-flow 已有 AI Docs / Issues 渲染;其他生产方不能仅通过改字段名复用它。"})]}),i.jsx(Ps,{title:"prd-flow 专用扩展示例",value:Qoe,copyKey:"extension",copied:t,onCopy:o})]})]}),i.jsxs("section",{className:"af-wr-section",id:"safety",children:[i.jsx(Do,{number:"06",title:"权限、覆盖和冲突",detail:"接入前必须明确谁能写、每个区域怎么更新,以及冲突发生时是否可能误删其他生产方的数据。"}),i.jsxs("div",{className:"af-wr-safety-grid",children:[i.jsxs("div",{children:[i.jsx("h3",{children:"权限矩阵"}),i.jsx(Yr,{columns:["身份","读取","上报","说明"],rows:gae,label:"Workflow 权限矩阵"}),i.jsx("p",{className:"af-wr-table-note",children:"完成 TAPD 权限同步后,Owner 和参与人以 TAPD 为准;参与人默认只读。尚未同步过的历史 Workflow 保留原 Owner,直到当前 Owner 或管理员执行首次同步。"})]}),i.jsxs("div",{children:[i.jsx("h3",{children:"覆盖矩阵"}),i.jsx(Yr,{columns:["区域","重复上报","删除/清空","接入方责任"],rows:mae,label:"Workflow 覆盖矩阵"})]})]}),i.jsxs("div",{className:"af-wr-conflict-flow",children:[i.jsx("span",{children:"GET snapshot.resourceVersions"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"计算触及的 resource keys"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"POST + expectedVersions + idempotencyKey"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"409 时只刷新冲突 key / 重算 / 重试一次"})]}),i.jsxs("div",{className:"af-wr-errors",children:[i.jsxs("div",{children:[i.jsx("code",{children:"400"}),i.jsx("p",{children:"字段或 schema 错误;按协议修正"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"401"}),i.jsx("p",{children:"缺少认证;停止并配置 Token"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"403"}),i.jsx("p",{children:"只读或无权限;由 Owner 授权 Reporter"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"409"}),i.jsx("p",{children:"资源 key 冲突、路径属于其他 source,或权限快照过旧"})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"design",children:[i.jsx(Do,{number:"07",title:"设计思想与运行关系",detail:"业务解释留在 Adapter,传输和存储保持通用;这样新生产方不需要复制 prd-flow 的 TAPD 私有模型。"}),i.jsxs("div",{className:"af-wr-runtime",children:[i.jsxs("article",{children:[i.jsx("small",{children:"事实来源"}),i.jsx("strong",{children:"TAPD / GitLab / Jenkins / 其他系统"}),i.jsx("p",{children:"提供原始业务事实。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{className:"is-focus",children:[i.jsx("small",{children:"你需要实现"}),i.jsx("strong",{children:"业务 Adapter"}),i.jsx("p",{children:"先同步上游人员权限,再解释阶段、定义稳定 key、生成 Report。prd-flow 是一个现有 Adapter。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{children:[i.jsx("small",{children:"通用传输"}),i.jsx("strong",{children:"Workflow Report Client / agentflow-cli"}),i.jsx("p",{children:"负责地址、Token、JSON 和 HTTP,不理解业务。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{children:[i.jsx("small",{children:"接收与展示"}),i.jsx("strong",{children:"AgentFlow 服务与页面"}),i.jsx("p",{children:"鉴权、合并、存储并渲染三类区域。"})]})]}),i.jsxs("div",{className:"af-wr-design-rules",children:[i.jsxs("article",{children:[i.jsx("strong",{children:"事实与投影分离"}),i.jsx("p",{children:"版本完整信息属于 globalState;个人/团队迭代只读取 projection。投影可以重建,不成为第二份真相。"})]}),i.jsxs("article",{children:[i.jsx("strong",{children:"业务节点与技术日志分离"}),i.jsx("p",{children:"Action 只表达可理解的阶段。轮询、重试、刷新留在接入方日志,不污染时间轴。"})]}),i.jsxs("article",{children:[i.jsx("strong",{children:"通用存储与专用渲染分离"}),i.jsx("p",{children:"extensions 可以保存任意生产方结构,但专用面板必须显式注册 schema 和 renderer。"})]})]})]}),i.jsxs("section",{className:"af-wr-section af-wr-ai",id:"ai",children:[i.jsx(Do,{number:"08",title:"给 AI 的接入引导",detail:"复制后交给 AI,它会先输出事实到页面区域的映射,再按真实协议实现。"}),i.jsx(Ps,{title:"$agentflow-workflow-report",value:YC,copyKey:"ai-bottom",copied:t,onCopy:o,wrap:!0})]})]})})}const jae=[{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"}],Nae=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],_ae=[{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"}],Cae=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function ih({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 Aae(){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(ih,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(ih,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(ih,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(ih,{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 Mh({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 Eae(){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(Mh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:_ae.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 u$(){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(Aae,{}),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(Mh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:jae.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(Mh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:Nae.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(Eae,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(Mh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Cae.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 d$(e){return t=>typeof t===e}var Iae=d$("function"),Pae=e=>e===null,XC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",QC=e=>!Tae(e)&&!Pae(e)&&(Iae(e)||typeof e=="object"),Tae=d$("undefined");function Rae(e,t,n){return zae(n,e,t)?!0:(Wae(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Mae(e,t,n):e instanceof Map&&t instanceof Map?Oae(e,t,n):e instanceof Set&&t instanceof Set?Fae(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?$ae(e,t):XC(e)&&XC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Lae(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Dae(e,t,n))}function $f(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!QC(e)||!t||!QC(t)?!1:Rae(e,t,n)}function Mae(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!$f(e[s],t[s],n))return!1;return!0}function $ae(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 Lae(e,t,n){return e.message===t.message&&e.name===t.name&&$f(e.cause,t.cause,n)}function Oae(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(!$f(r[1],t.get(r[0]),n))return!1;return!0}function Dae(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)&&!$f(e[o],t[o],n))return!1}return!0}function Fae(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 zae(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Wae(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function zv(e,t){return $f(e,t,new WeakMap)}function Dw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Bae(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Hae(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Vae(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Kae(e,t){const n=Vae();m.useEffect(()=>{if(!n)return e()},t)}function f$(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function qae(e,t){const n=m.useRef(t);return zv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Uae(e){m.useEffect(()=>{e()},[])}function Gae(e=0){const[t,n]=m.useState({height:Dw()?window.innerHeight:0,width:Dw()?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(!Dw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Hae(window,"resize",o),()=>{Bae(window,"resize",o)}},[]),t}var Yae=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Jae=["bigint","boolean","null","number","string","symbol","undefined"];function Lf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Xae(t))return t}function mi(e){return t=>Lf(t)===e}function Xae(e){return Yae.includes(e)}function iu(e){return t=>typeof t===e}function Qae(e){return Jae.includes(e)}var Zae=["innerHTML","ownerDocument","style","attributes","nodeValue"],Of=e=>Array.isArray(e),ele=e=>Lf(e)==="AsyncGeneratorFunction",tle=mi("AsyncFunction"),nle=iu("bigint"),rle=e=>e===!0||e===!1,sle=mi("Date"),ile=mi("Error"),pa=iu("function"),ole=mi("GeneratorFunction"),ale=e=>typeof e=="number"&&Number.isInteger(e),Wb=mi("Map"),p$=e=>Number.isNaN(e),Wv=e=>e===null,h$=mi("Function"),lle=mi("Promise"),cle=mi("RegExp"),Bb=mi("Set"),Df=iu("string"),ule=iu("symbol"),Bv=iu("undefined"),dle=mi("WeakMap"),fle=mi("WeakSet"),Hv=e=>Wv(e)||Bv(e),m$=e=>!Bv(e),ple=e=>iu("number")(e)&&!p$(e),hle=e=>Df(e)&&e.trim().length>0,mle=e=>{if(!Df(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},Ag=e=>!Hv(e)&&(pa(e)||typeof e=="object"),g$=e=>{if(Lf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},gle=e=>Wv(e)||Qae(typeof e),yle=e=>Lf(e)==="URL",y$=e=>!Hv(e)&&pa(e[Symbol.iterator]),wle=e=>y$(e)&&pa(e.next)&&pa(e.throw),xle=e=>pa(e)&&/^class\s/.test(e.toString()),ble=(e,t)=>!Of(e)||!pa(t)?!1:e.every(n=>t(n)),kle=e=>Ag(e)&&!g$(e)&&e.nodeType===1&&Df(e.nodeName)&&Zae.every(t=>t in e),vle=e=>Df(e)&&e.length===0||Of(e)&&e.length===0||Ag(e)&&!Wb(e)&&!Bb(e)&&Object.keys(e).length===0||Bb(e)&&e.size===0||Wb(e)&&e.size===0,Sle=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,jle=(e,t)=>Of(e)?e.indexOf(t)>-1:!1,Nle=(e,t,n)=>{if(!Ag(e)||!t)return!1;const r=e[t];return pa(n)?n(r):m$(r)};function At(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(Of(e))return"Array";if(h$(e))return"Function";const t=Lf(e);return t||"Object"}At.array=Of;At.arrayOf=ble;At.asyncGeneratorFunction=ele;At.asyncFunction=tle;At.bigint=nle;At.boolean=rle;At.class=xle;At.date=sle;At.defined=m$;At.domElement=kle;At.empty=vle;At.error=ile;At.function=pa;At.generator=wle;At.generatorFunction=ole;At.instanceOf=Sle;At.integer=ale;At.iterable=y$;At.map=Wb;At.nan=p$;At.null=Wv;At.nullOrUndefined=Hv;At.nonEmptyString=hle;At.number=ple;At.numericString=mle;At.object=Ag;At.oneOf=jle;At.plainFunction=h$;At.plainObject=g$;At.primitive=gle;At.promise=lle;At.propertyOf=Nle;At.regexp=cle;At.set=Bb;At.string=Df;At.symbol=ule;At.undefined=Bv;At.url=yle;At.weakMap=dle;At.weakSet=fle;var Rr=At;/* v8 ignore next -- @preserve */var _le=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Cle=function(e,t){return e+yf(t)},yf=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(Cle,""):_le(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?yf(e.props.children):""};yf.default=yf;var Ale=yf;const Fw=ma(Ale);var w$={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 N=0;const I=S.length,T=new Array(I);for(N;N<I;++N)T[N]=g(S[N]);return T}function l(S){const N={};if(d&&Object.getPrototypeOf(S)!==t)return d(S);const I=p(S);let T,z,E;for(T=0,z=I.length;T<z;++T)o(E=I[T])&&(N[E]=g(S[E]));return N}function c(S,N){const I=S.length,T=N.length;let z=0;const E=new Array(I+T);for(z;z<I;++z)E[z]=g(S[z]);for(z=0;z<T;++z)E[z+I]=g(N[z]);return E}const u=Object.prototype.propertyIsEnumerable;function f(S){const N=Object.keys(S),I=Object.getOwnPropertySymbols(S);for(let T=0,z=I.length;T<z;++T)u.call(S,I[T])&&N.push(I[T]);return N}const p=s!=null&&s.symbols?f:Object.keys,d=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),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:p,isMergeableObject:h}):c;function g(S){return h(S)?Array.isArray(S)?a(S):l(S):S}function k(S,N){const I={},T=p(S),z=p(N);let E,D,L;for(E=0,D=T.length;E<D;++E)o(L=T[E])&&z.indexOf(L)===-1&&(I[L]=g(S[L]));for(E=0,D=z.length;E<D;++E)if(o(L=z[E]))if(L in S)T.indexOf(L)!==-1&&(d&&h(N[L])&&Object.getPrototypeOf(N[L])!==t?I[L]=d(N[L]):I[L]=x(S[L],N[L]));else{if(y&&typeof N[L]>"u")continue;I[L]=g(N[L])}return I}function x(S,N){if(y&&typeof N>"u")return g(S);const I=Array.isArray(N),T=Array.isArray(S);return v(N)?N:h(S)?I&&T?b(S,N):I!==T?g(N):k(S,N):g(N)}function _(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let S;for(let N=0,I=arguments.length;N<I;++N)S=x(S,arguments[N]);return S}return s!=null&&s.all?_:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(w$);var Ele=w$.exports;const Ile=ma(Ele);var Ple=new Error("Element already at target scroll position"),Tle=new Error("Scroll cancelled"),Rle=Math.min,ZC=Date.now,Mle={left:eA("scrollLeft"),top:eA("scrollTop")};function eA(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=Lle);var a=ZC(),l=n[e],c=s.ease||$le,u=isNaN(s.duration)?350:+s.duration,f=!1;return l===r?o(Ple,n[e]):requestAnimationFrame(d),p;function p(){f=!0}function d(h){if(f)return o(Tle,n[e]);var y=ZC(),v=Rle(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(d):requestAnimationFrame(function(){o(null,n[e])})}}}function $le(e){return .5*(1-Math.cos(Math.PI*e))}function Lle(){}const Ole=ma(Mle);var x$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(Td,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})})(x$);var Dle=x$.exports;const b$=ma(Dle),Fle=["top","right","bottom","left"],tA=["start","end"],nA=Fle.reduce((e,t)=>e.concat(t,t+"-"+tA[0],t+"-"+tA[1]),[]),Yc=Math.min,Za=Math.max,Dm=Math.round,oh=Math.floor,Oi=e=>({x:e,y:e}),zle={left:"right",right:"left",bottom:"top",top:"bottom"};function Hb(e,t,n){return Za(e,Yc(t,n))}function ou(e,t){return typeof e=="function"?e(t):e}function xo(e){return e.split("-")[0]}function Di(e){return e.split("-")[1]}function k$(e){return e==="x"?"y":"x"}function Vv(e){return e==="y"?"height":"width"}function Jo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Kv(e){return k$(Jo(e))}function v$(e,t,n){n===void 0&&(n=!1);const r=Di(e),s=Kv(e),o=Vv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=zm(a)),[a,zm(a)]}function Wle(e){const t=zm(e);return[Fm(e),t,Fm(t)]}function Fm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rA=["left","right"],sA=["right","left"],Ble=["top","bottom"],Hle=["bottom","top"];function Vle(e,t,n){switch(e){case"top":case"bottom":return n?t?sA:rA:t?rA:sA;case"left":case"right":return t?Ble:Hle;default:return[]}}function Kle(e,t,n,r){const s=Di(e);let o=Vle(xo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(Fm)))),o}function zm(e){const t=xo(e);return zle[t]+e.slice(t.length)}function qle(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?qle(e):{top:e,right:e,bottom:e,left:e}}function Wm(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 iA(e,t,n){let{reference:r,floating:s}=e;const o=Jo(t),a=Kv(t),l=Vv(a),c=xo(t),u=o==="y",f=r.x+r.width/2-s.width/2,p=r.y+r.height/2-s.height/2,d=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:f,y:r.y-s.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:p};break;case"left":h={x:r.x-s.width,y:p};break;default:h={x:r.x,y:r.y}}switch(Di(t)){case"start":h[a]-=d*(n&&u?-1:1);break;case"end":h[a]+=d*(n&&u?-1:1);break}return h}async function Ule(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:f="viewport",elementContext:p="floating",altBoundary:d=!1,padding:h=0}=ou(t,e),y=S$(h),b=l[d?p==="floating"?"reference":"floating":p],g=Wm(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:f,strategy:c})),k=p==="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)),_=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=Wm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-S.top+y.top)/_.y,bottom:(S.bottom-g.bottom+y.bottom)/_.y,left:(g.left-S.left+y.left)/_.x,right:(S.right-g.right+y.right)/_.x}}const Gle=50,Yle=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Ule},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:p}=iA(u,r,c),d=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:_,data:S,reset:N}=await k({x:f,y:p,initialPlacement:r,placement:d,strategy:s,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});f=x??f,p=_??p,y[g]={...y[g],...S},N&&h<Gle&&(h++,typeof N=="object"&&(N.placement&&(d=N.placement),N.rects&&(u=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):N.rects),{x:f,y:p}=iA(u,d,c)),v=-1)}return{x:f,y:p,placement:d,strategy:s,middlewareData:y}},Jle=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:f=0}=ou(e,t)||{};if(u==null)return{};const p=S$(f),d={x:n,y:r},h=Kv(s),y=Vv(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",_=o.reference[y]+o.reference[h]-d[h]-o.floating[y],S=d[h]-o.reference[h],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[x]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=l.floating[x]||o.floating[y]);const T=_/2-S/2,z=I/2-v[y]/2-1,E=Yc(p[g],z),D=Yc(p[k],z),L=E,O=I-v[y]-D,M=I/2-v[y]/2+T,V=Hb(L,M,O),B=!c.arrow&&Di(s)!=null&&M!==V&&o.reference[y]/2-(M<L?E:D)-v[y]/2<0,F=B?M<L?M-L:M-O:0;return{[h]:d[h]+F,data:{[h]:V,centerOffset:M-V-F,...B&&{alignmentOffset:F}},reset:B}}});function Xle(e,t,n){return(e?[...n.filter(s=>Di(s)===e),...n.filter(s=>Di(s)!==e)]:n.filter(s=>xo(s)===s)).filter(s=>e?Di(s)===e||(t?Fm(s)!==s:!1):!0)}const Qle=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:f=!1,alignment:p,allowedPlacements:d=nA,autoAlignment:h=!0,...y}=ou(e,t),v=p!==void 0||d===nA?Xle(p||null,h,d):d,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=v$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const _=[b[xo(k)],b[x[0]],b[x[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:_}],N=v[g+1];if(N)return{data:{index:g+1,overflows:S},reset:{placement:N}};const I=S.map(E=>{const D=Di(E.placement);return[E.placement,D&&f?E.overflows.slice(0,2).reduce((L,O)=>L+O,0):E.overflows[0],E.overflows]}).sort((E,D)=>E[1]-D[1]),z=((s=I.filter(E=>E[2].slice(0,Di(E[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||I[0][0];return z!==l?{data:{index:g+1,overflows:S},reset:{placement:z}}:{}}}},Zle=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:f=!0,crossAxis:p=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=ou(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=xo(s),k=Jo(l),x=xo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=d||(x||!v?[zm(l)]:Wle(l)),N=y!=="none";!d&&N&&S.push(...Kle(l,v,y,_));const I=[l,...S],T=await c.detectOverflow(t,b),z=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&z.push(T[g]),p){const M=v$(s,a,_);z.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:s,overflows:z}],!z.every(M=>M<=0)){var D,L;const M=(((D=o.flip)==null?void 0:D.index)||0)+1,V=I[M];if(V&&(!(p==="alignment"?k!==Jo(V):!1)||E.every($=>Jo($.placement)===k?$.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:V}};let B=(L=E.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:L.placement;if(!B)switch(h){case"bestFit":{var O;const F=(O=E.filter($=>{if(N){const H=Jo($.placement);return H===k||H==="y"}return!0}).map($=>[$.placement,$.overflows.filter(H=>H>0).reduce((H,A)=>H+A,0)]).sort(($,H)=>$[1]-H[1])[0])==null?void 0:O[0];F&&(B=F);break}case"initialPlacement":B=l;break}if(s!==B)return{reset:{placement:B}}}return{}}}},ece=new Set(["left","top"]);async function tce(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=xo(n),l=Di(n),c=Jo(n)==="y",u=ece.has(a)?-1:1,f=o&&c?-1:1,p=ou(t,e);let{mainAxis:d,crossAxis:h,alignmentAxis:y}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*f,y:d*u}:{x:d*u,y:h*f}}const nce=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 tce(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}}}}},rce=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}=ou(e,t),f={x:n,y:r},p=await o.detectOverflow(t,u),d=Jo(xo(s)),h=k$(d);let y=f[h],v=f[d];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+p[g],_=y-p[k];y=Hb(x,y,_)}if(l){const g=d==="y"?"top":"left",k=d==="y"?"bottom":"right",x=v+p[g],_=v-p[k];v=Hb(x,v,_)}const b=c.fn({...t,[h]:y,[d]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[d]:l}}}}}};function Eg(){return typeof window<"u"}function au(e){return j$(e)?(e.nodeName||"").toLowerCase():"#document"}function ys(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bi(e){var t;return(t=(j$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function j$(e){return Eg()?e instanceof Node||e instanceof ys(e).Node:!1}function fi(e){return Eg()?e instanceof Element||e instanceof ys(e).Element:!1}function So(e){return Eg()?e instanceof HTMLElement||e instanceof ys(e).HTMLElement:!1}function oA(e){return!Eg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ys(e).ShadowRoot}function Ff(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=pi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function sce(e){return/^(table|td|th)$/.test(au(e))}function Ig(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const ice=/transform|translate|scale|rotate|perspective|filter/,oce=/paint|layout|strict|content/,Ra=e=>!!e&&e!=="none";let zw;function qv(e){const t=fi(e)?pi(e):e;return Ra(t.transform)||Ra(t.translate)||Ra(t.scale)||Ra(t.rotate)||Ra(t.perspective)||!Uv()&&(Ra(t.backdropFilter)||Ra(t.filter))||ice.test(t.willChange||"")||oce.test(t.contain||"")}function ace(e){let t=ha(e);for(;So(t)&&!Jc(t);){if(qv(t))return t;if(Ig(t))return null;t=ha(t)}return null}function Uv(){return zw==null&&(zw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),zw}function Jc(e){return/^(html|body|#document)$/.test(au(e))}function pi(e){return ys(e).getComputedStyle(e)}function Pg(e){return fi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ha(e){if(au(e)==="html")return e;const t=e.assignedSlot||e.parentNode||oA(e)&&e.host||Bi(e);return oA(t)?t.host:t}function N$(e){const t=ha(e);return Jc(t)?e.ownerDocument?e.ownerDocument.body:e.body:So(t)&&Ff(t)?t:N$(t)}function wf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=N$(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ys(s);if(o){const l=Vb(a);return t.concat(a,a.visualViewport||[],Ff(s)?s:[],l&&n?wf(l):[])}else return t.concat(s,wf(s,[],n))}function Vb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _$(e){const t=pi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=So(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Dm(n)!==o||Dm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Gv(e){return fi(e)?e:e.contextElement}function Tc(e){const t=Gv(e);if(!So(t))return Oi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=_$(t);let a=(o?Dm(n.width):n.width)/r,l=(o?Dm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const lce=Oi(0);function C$(e){const t=ys(e);return!Uv()||!t.visualViewport?lce:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cce(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ys(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Gv(e);let a=Oi(1);t&&(r?fi(r)&&(a=Tc(r)):a=Tc(e));const l=cce(o,n,r)?C$(o):Oi(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,f=s.width/a.x,p=s.height/a.y;if(o){const d=ys(o),h=r&&fi(r)?ys(r):r;let y=d,v=Vb(y);for(;v&&r&&h!==y;){const b=Tc(v),g=v.getBoundingClientRect(),k=pi(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,_=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,f*=b.x,p*=b.y,c+=x,u+=_,y=ys(v),v=Vb(y)}}return Wm({width:f,height:p,x:c,y:u})}function Tg(e,t){const n=Pg(e).scrollLeft;return t?t.left+n:ml(Bi(e)).left+n}function A$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Tg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function uce(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Bi(r),l=t?Ig(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Oi(1);const f=Oi(0),p=So(r);if((p||!p&&!o)&&((au(r)!=="body"||Ff(a))&&(c=Pg(r)),p)){const h=ml(r);u=Tc(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const d=a&&!p&&!o?A$(a,c):Oi(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+f.x+d.x,y:n.y*u.y-c.scrollTop*u.y+f.y+d.y}}function dce(e){return Array.from(e.getClientRects())}function fce(e){const t=Bi(e),n=Pg(e),r=e.ownerDocument.body,s=Za(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Za(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Tg(e);const l=-n.scrollTop;return pi(r).direction==="rtl"&&(a+=Za(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const aA=25;function pce(e,t){const n=ys(e),r=Bi(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const f=Uv();(!f||f&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Tg(r);if(u<=0){const f=r.ownerDocument,p=f.body,d=getComputedStyle(p),h=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,y=Math.abs(r.clientWidth-p.clientWidth-h);y<=aA&&(o-=y)}else u<=aA&&(o+=u);return{width:o,height:a,x:l,y:c}}function hce(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=So(e)?Tc(e):Oi(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 lA(e,t,n){let r;if(t==="viewport")r=pce(e,n);else if(t==="document")r=fce(Bi(e));else if(fi(t))r=hce(t,n);else{const s=C$(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Wm(r)}function E$(e,t){const n=ha(e);return n===t||!fi(n)||Jc(n)?!1:pi(n).position==="fixed"||E$(n,t)}function mce(e,t){const n=t.get(e);if(n)return n;let r=wf(e,[],!1).filter(l=>fi(l)&&au(l)!=="body"),s=null;const o=pi(e).position==="fixed";let a=o?ha(e):e;for(;fi(a)&&!Jc(a);){const l=pi(a),c=qv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Ff(a)&&!c&&E$(e,a))?r=r.filter(f=>f!==a):s=l,a=ha(a)}return t.set(e,r),r}function gce(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Ig(t)?[]:mce(t,this._c):[].concat(n),r],l=lA(t,a[0],s);let c=l.top,u=l.right,f=l.bottom,p=l.left;for(let d=1;d<a.length;d++){const h=lA(t,a[d],s);c=Za(h.top,c),u=Yc(h.right,u),f=Yc(h.bottom,f),p=Za(h.left,p)}return{width:u-p,height:f-c,x:p,y:c}}function yce(e){const{width:t,height:n}=_$(e);return{width:t,height:n}}function wce(e,t,n){const r=So(t),s=Bi(t),o=n==="fixed",a=ml(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Oi(0);function u(){c.x=Tg(s)}if(r||!r&&!o)if((au(t)!=="body"||Ff(s))&&(l=Pg(t)),r){const h=ml(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();o&&!r&&s&&u();const f=s&&!r&&!o?A$(s,l):Oi(0),p=a.left+l.scrollLeft-c.x-f.x,d=a.top+l.scrollTop-c.y-f.y;return{x:p,y:d,width:a.width,height:a.height}}function Ww(e){return pi(e).position==="static"}function cA(e,t){if(!So(e)||pi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bi(e)===n&&(n=n.ownerDocument.body),n}function I$(e,t){const n=ys(e);if(Ig(e))return n;if(!So(e)){let s=ha(e);for(;s&&!Jc(s);){if(fi(s)&&!Ww(s))return s;s=ha(s)}return n}let r=cA(e,t);for(;r&&sce(r)&&Ww(r);)r=cA(r,t);return r&&Jc(r)&&Ww(r)&&!qv(r)?n:r||ace(e)||n}const xce=async function(e){const t=this.getOffsetParent||I$,n=this.getDimensions,r=await n(e.floating);return{reference:wce(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function bce(e){return pi(e).direction==="rtl"}const kce={convertOffsetParentRelativeRectToViewportRelativeRect:uce,getDocumentElement:Bi,getClippingRect:gce,getOffsetParent:I$,getElementRects:xce,getClientRects:dce,getDimensions:yce,getScale:Tc,isElement:fi,isRTL:bce};function P$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vce(e,t){let n=null,r;const s=Bi(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:f,top:p,width:d,height:h}=u;if(l||t(),!d||!h)return;const y=oh(p),v=oh(s.clientWidth-(f+d)),b=oh(s.clientHeight-(p+h)),g=oh(f),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Za(0,Yc(1,c))||1};let _=!0;function S(N){const I=N[0].intersectionRatio;if(I!==c){if(!_)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!P$(u,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(S,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),o}function uA(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=Gv(e),f=s||o?[...u?wf(u):[],...t?wf(t):[]]:[];f.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const p=u&&l?vce(u,n):null;let d=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?ml(e):null;c&&b();function b(){const g=ml(e);v&&!P$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;f.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),p==null||p(),(g=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const Sce=nce,jce=Qle,Nce=rce,_ce=Zle,dA=Jle,Cce=(e,t,n)=>{const r=new Map,s={platform:kce,...n},o={...s.platform,_c:r};return Yle(e,t,{...s,platform:o})};var Ace=typeof document<"u",Ece=function(){},$h=Ace?m.useLayoutEffect:Ece;function Bm(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(!Bm(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)&&!Bm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function T$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fA(e,t){const n=T$(e);return Math.round(t*n)/n}function Bw(e){const t=m.useRef(e);return $h(()=>{t.current=e}),t}function pA(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,[f,p]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);Bm(d,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback($=>{$!==N.current&&(N.current=$,v($))},[]),x=m.useCallback($=>{$!==I.current&&(I.current=$,g($))},[]),_=o||y,S=a||b,N=m.useRef(null),I=m.useRef(null),T=m.useRef(f),z=c!=null,E=Bw(c),D=Bw(s),L=Bw(u),O=m.useCallback(()=>{if(!N.current||!I.current)return;const $={placement:t,strategy:n,middleware:d};D.current&&($.platform=D.current),Cce(N.current,I.current,$).then(H=>{const A={...H,isPositioned:L.current!==!1};M.current&&!Bm(T.current,A)&&(T.current=A,pr.flushSync(()=>{p(A)}))})},[d,t,n,D,L]);$h(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);$h(()=>(M.current=!0,()=>{M.current=!1}),[]),$h(()=>{if(_&&(N.current=_),S&&(I.current=S),_&&S){if(E.current)return E.current(_,S,O);O()}},[_,S,O,E,z]);const V=m.useMemo(()=>({reference:N,floating:I,setReference:k,setFloating:x}),[k,x]),B=m.useMemo(()=>({reference:_,floating:S}),[_,S]),F=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!B.floating)return $;const H=fA(B.floating,f.x),A=fA(B.floating,f.y);return l?{...$,transform:"translate("+H+"px, "+A+"px)",...T$(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,l,B.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:O,refs:V,elements:B,floatingStyles:F}),[f,O,V,B,F])}const Ice=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?dA({element:r.current,padding:s}).fn(n):{}:r?dA({element:r,padding:s}).fn(n):{}}}},hA=(e,t)=>{const n=Sce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pce=(e,t)=>{const n=Nce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tce=(e,t)=>{const n=_ce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rce=(e,t)=>{const n=jce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mce=(e,t)=>{const n=Ice(e);return{name:n.name,fn:n.fn,options:[e,t]}},$ce={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},Lce={beaconOptions:{offset:-18}},R$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Oce={isFixed:!1,locale:R$,placement:"bottom"},Dce={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Wt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},fr={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Xe={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Ni={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Tt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Fce="react-joyride-portal";function zce(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function wc(...e){return Ile({all:!0,isMergeableObject:t=>!(!Rr.plainObject(t)||m.isValidElement(t))})(...e)}function M$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function to(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=Fw(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&&M$(e.type)==="function")try{o=to(e.type({}),t)}catch{o=Fw(n)}else o=Fw(n);return o}function gr(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 Wce(e,t){const n=zce(t);return{...e,...n}}function xf(){}function Bce(e){return Object.keys(e)}function Hm(e,...t){if(!Rr.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 mA(e,...t){if(!Rr.plainObject(e))throw new TypeError("Expected an object");if(!t.length)return e;const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&t.includes(r)&&(n[r]=e[r]);return n}function Kb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(M$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Rr.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):Kb(o,t,n))});if(Rr.function(e.type)&&!Object.values(e.props).length)try{return Kb(e.type({}),t,n)}catch{return e}return e}function gA(e){return Bce(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Yv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function yA(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 Jv(e){return e?e.getBoundingClientRect():null}function Hce(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 Ls(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 Vce(e,t,n){const r=Jv(e),s=lu(e),o=s?!s.isSameNode(ts()):!1,a=n??cu(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(ts())||(c+=ts().scrollTop)),Math.floor(c-t)}function lu(e,t){if(!e)return ts();const n=b$(e);if(n){if(n.isSameNode(ts()))return t?document:ts();if(!(n.scrollHeight>n.offsetHeight))return ts()}return n}function Kce(e){const t=e.getBoundingClientRect(),n=ts(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function qce(e,t){if(!e)return 0;const n=b$(e)??ts(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Jv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&($$(e)||Uce(e))){const f=e.getBoundingClientRect(),p=f.top-((s==null?void 0:s.top)??0),d=p+f.height,h=n.clientHeight,y=h*.2;p>=y&&d<=h-y?c=o:c=p+o}const u=Math.floor(c-t-r);return u<0?0:u}function Uce(e){return e.offsetParent!==document.body}function $$(e){if(!e)return!1;const t=lu(e);return t?!t.isSameNode(ts()):!1}function cu(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?cu(e.parentNode,t):!1}function ah(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 wA(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Xe.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?lu(s):ts(),l=a?!a.isSameNode(ts()):!1;return(r.isFixed||cu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function ts(){return document.scrollingElement??document.documentElement}function xA(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=Ole.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function Gce(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 L$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},lh={...L$,borderRadius:4,padding:8};function Yce(e,t){const{styles:n}=e,r=wc(n??{},t.styles??{});let{width:s}=t;Yv()&&(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 wc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...L$,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(${Gce(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:{...lh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...lh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...lh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...lh,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 Jce=["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 Xv(e,t){if(!t)return null;const n=wc(Oce,mA(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=wc($ce,e.options??{},mA(t,...Jce)),s=Yce(e,{...n,...r}),o=wc(Lce,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:wc(R$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Xce(r.spotlightPadding),styles:s}}function Xce(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 Qce(e,t,n){const{action:r}=t,s=n&&[Wt.PREV,Wt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function O$(e,t=!1){return Rr.plainObject(e)?e.target?!0:(gr(t,"tour","target is missing from the step"),!1):(gr(t,"tour","step must be an object"),!1)}function D$(e,t=!1){return Rr.array(e)?e.every(n=>O$(n,t)):(gr(t,"tour","steps must be an array"),!1)}var Zce=class{constructor(e){Bn(this,"beaconPosition",null);Bn(this,"debug");Bn(this,"eventListeners",new Map);Bn(this,"listeners",new Set);Bn(this,"props");Bn(this,"snapshot");Bn(this,"state");Bn(this,"steps");Bn(this,"tooltipPosition",null);Bn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Bn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Bn(this,"getServerSnapshot",()=>this.snapshot);Bn(this,"getSnapshot",()=>this.snapshot);Bn(this,"getEventState",()=>Hm(this.snapshot,"positioned"));Bn(this,"getState",()=>Hm(this.snapshot,"positioned"));Bn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&gr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Xe.BEACON_BEFORE||this.state.lifecycle===Xe.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});Bn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Bn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Bn(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)}});Bn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Bn(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,!zv(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=Rr.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,Rr.number(t)&&gr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Rr.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&gr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Wt.INIT,controlled:s,index:o,lifecycle:Xe.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Tt.READY:Tt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Tt.WAITING&&e.size>0?{...e,status:Tt.RUNNING}:e}getStep(e){return Xv(this.props,this.steps[e??this.state.index])}};function eue(e){return new Zce(e)}function bA(e,t){return Math.min(Math.max(e,0),t)}function tue(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===Tt.RUNNING&&e.current.updateState({action:Wt.CLOSE,index:g+1,origin:b,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){gr(r.current,"tour","go() is not supported in controlled mode");return}x===Tt.RUNNING&&e.current.updateState({action:Wt.GO,index:b,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:Tt.FINISHED,waiting:!1})},info:()=>Hm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===Tt.RUNNING&&e.current.updateState({action:Wt.NEXT,index:bA(g+1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===Tt.RUNNING&&e.current.updateState({action:Wt.UPDATE,lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===Tt.RUNNING&&e.current.updateState({action:Wt.PREV,index:bA(g-1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){gr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Wt.RESET,index:0,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:b?Tt.RUNNING:Tt.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===Tt.RUNNING&&e.current.updateState({action:Wt.SKIP,lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:Tt.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:Wt.START,index:Rr.number(b)?b:g,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:k?Tt.RUNNING:Tt.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[Tt.FINISHED,Tt.SKIPPED].includes(k)||e.current.updateState({action:Wt.STOP,index:g+(b?1:0),lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:Tt.PAUSED,waiting:!1})}}},[e])}const nue=new Set(["origin","positioned"]);function rue(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return gr(!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]&&!nue.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||gr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function sue(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 Wo(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 iue(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:u,index:f,lifecycle:p,positioned:d,scrolling:h,size:y,status:v}=a,b=f$(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),_=m.useRef(s),S=m.useRef(l),N=m.useRef(b),I=m.useRef(n),T=m.useRef(null),z=m.useRef(null),E=m.useRef(null);k.current=o,x.current=a,_.current=s,S.current=l,N.current=b,I.current=n;const D=()=>{T.current&&(clearInterval(T.current),T.current=null),z.current=null,E.current&&(E.current.cancel(),E.current=null)};m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:L}=Wo(x.current,_.current);(L("action",[Wt.NEXT,Wt.PREV,Wt.SKIP,Wt.CLOSE])||g.current===Wt.CLOSE&&u===Wt.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!_.current)return()=>{D()};const{hasChanged:L}=Wo(x.current,_.current),O=S.current;if(L("index")&&D(),v!==Tt.RUNNING||!O||p!==Xe.INIT)return()=>{D()};const{hasChangedTo:M}=Wo(x.current,_.current);M("status",Tt.RUNNING)&&[Tt.IDLE,Tt.READY,Tt.PAUSED].includes(_.current.status)&&r(fr.TOUR_START,O),c.current.cleanupPositionData();const{debug:V}=k.current;if(O.before&&!E.current){gr(V,`step:${f}`,"before()",O),E.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(fr.STEP_BEFORE_HOOK,O,{action:g.current??x.current.action});const B=()=>{E.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Xe.READY})},F=new AbortController,$=O.beforeTimeout;E.current={cancel:()=>F.abort()};const H=$?setTimeout(()=>{F.signal.aborted||(gr(V,`step:${f}`,"before()","timed out",`${$}ms`),F.abort(),t(O,"before_hook"),r(fr.ERROR,O,{error:new Error("Step before hook timed out")}),B())},$):null;O.before({...c.current.getState(),action:g.current??c.current.getState().action,step:O}).then(()=>{F.signal.aborted||(H&&clearTimeout(H),B())}).catch(A=>{F.signal.aborted||(H&&clearTimeout(H),t(O,"before_hook"),r(fr.ERROR,O,{error:A instanceof Error?A:new Error(String(A))}),B())})}else if(!E.current){T.current&&z.current!==O.target&&D();const B=Ls(O.target);if(B&&ah(B))D(),c.current.updateState({action:g.current??Wt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(O.targetWaitTimeout===0)c.current.updateState({action:g.current??Wt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(!T.current){const{targetWaitTimeout:F}=O,$=Date.now();z.current=O.target,gr(V,`step:${f}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),T.current=setInterval(()=>{const H=Ls(O.target),A=Date.now()-$,Q=A>=F;(H&&ah(H)||Q)&&(gr(V,`step:${f}`,"polling",H&&ah(H)?"found":"timed out",`${A}ms`),D(),c.current.updateState({action:g.current??Wt.UPDATE,lifecycle:Xe.READY,waiting:!1}))},100)}}return()=>{D()}},[t,r,f,p,v,c]),m.useEffect(()=>{if(!_.current)return;const{hasChanged:L,hasChangedTo:O,previous:M}=Wo(x.current,_.current),V=S.current;if(!V)return;const B=Ls(V.target),F=!!B;if(F&&ah(B)){if(O("lifecycle",Xe.READY)&&M.lifecycle===Xe.INIT&&r(fr.STEP_BEFORE,V,{action:g.current??x.current.action}),O("lifecycle",Xe.READY)){const $=x.current,H=Qce(V,$,k.current.continuous)?Xe.TOOLTIP:Xe.BEACON,A=Ls(V.scrollTarget??V.spotlightTarget??V.target),Q=wA({isFirstStep:$.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:V,target:A,targetLifecycle:H}),K=H===Xe.TOOLTIP?Xe.TOOLTIP_BEFORE:Xe.BEACON_BEFORE;gr(k.current.debug,`step:${f}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:Wt.UPDATE,lifecycle:K,scrolling:Q})}}else if(x.current.status===Tt.RUNNING&&p!==Xe.INIT&&p!==Xe.COMPLETE&&L("lifecycle")){gr(k.current.debug,`step:${f}`,F?"Target not visible":"Target not mounted",V),t(V,"target_not_found"),r(fr.TARGET_NOT_FOUND,V);const $=x.current;$.controlled||c.current.updateState({action:Wt.UPDATE,index:$.index+($.action===Wt.PREV?-1:1),lifecycle:Xe.INIT})}},[t,r,f,p,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:L,previous:O}=Wo(x.current,_.current),M=S.current,V=N.current;if(M&&L("lifecycle",Xe.TOOLTIP_BEFORE)&&O.lifecycle===Xe.BEACON){const $=Ls(M.scrollTarget??M.spotlightTarget??M.target);if(wA({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:$,targetLifecycle:Xe.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const B=p===Xe.BEACON_BEFORE||p===Xe.TOOLTIP_BEFORE;if(M&&B&&!h){const $=p===Xe.TOOLTIP_BEFORE?Xe.TOOLTIP:Xe.BEACON;c.current.updateState({action:Wt.UPDATE,lifecycle:$})}M&&L("lifecycle",Xe.BEACON)&&r(fr.BEACON,M),M&&L("lifecycle",Xe.TOOLTIP)&&r(fr.TOOLTIP,M);const F=x.current;if((F.status===Tt.RUNNING||F.controlled&&F.status===Tt.PAUSED&&M)&&V&&L("lifecycle",Xe.COMPLETE)&&O.lifecycle===Xe.TOOLTIP&&(r(fr.STEP_AFTER,V,{action:g.current??Wt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle}),V.after)){r(fr.STEP_AFTER_HOOK,V,{action:g.current??Wt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle});try{V.after({...c.current.getState(),action:g.current??Wt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle,step:V})}catch{}}},[r,p,d,h,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:L,previous:O}=Wo(x.current,_.current),M=S.current,V=N.current;y&&!M&&p===Xe.INIT&&c.current.updateState({action:Wt.UPDATE,lifecycle:Xe.COMPLETE,status:Tt.FINISHED}),!x.current.controlled&&v===Tt.RUNNING&&L("lifecycle",Xe.COMPLETE)&&f<y&&c.current.updateState({action:Wt.UPDATE,lifecycle:Xe.INIT}),L("lifecycle",Xe.COMPLETE)&&f>=y&&c.current.updateState({action:Wt.UPDATE,lifecycle:Xe.COMPLETE,status:Tt.FINISHED});const B=M??V??Xv(k.current,k.current.steps[f-1]);if(B&&L("status",[Tt.FINISHED,Tt.SKIPPED])){let F;M?F=f:V?F=O.index??f:F=f-1,r(fr.TOUR_END,B,{index:F}),x.current.controlled||I.current.reset(),g.current=null}M&&L("action",Wt.STOP)&&(g.current=null,r(fr.TOUR_STATUS,M)),M&&L("action",Wt.RESET)&&(r(fr.TOUR_STATUS,M),g.current=null)},[u,r,f,p,y,v,c])}function oue({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,f=m.useRef(void 0),p=m.useRef(r),d=m.useRef(e);p.current=r,d.current=e,m.useEffect(()=>{const h=f.current;if(f.current=n,!h||n===h)return;const{hasChanged:y}=Wo(n,h);if(zv(h.steps,u)||(D$(u,o)?s.current.setSteps(u):(gr(o,"tour","Steps are not valid",u),t(fr.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?s.current.getState().size&&d.current.start(c??a):d.current.stop();else if(Rr.number(c)&&y("stepIndex")){const v=Rr.number(h.stepIndex)&&h.stepIndex<c?Wt.NEXT:Wt.PREV;[Tt.FINISHED,Tt.SKIPPED].includes(p.current.status)||s.current.updateState({action:v,index:c,lifecycle:Xe.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,s])}function aue(e,t){var l,c,u,f;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Xe.BEACON_BEFORE&&(n!=null&&n.placement)){const p=lue(n);["bottom"].includes(n.placement)||(a+=Math.floor(p-s))}else if(r===Xe.TOOLTIP_BEFORE){const{placement:p}=o;if(p==="top"){const d=((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-=d+y}else if(p==="left"||p==="right"){const d=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((f=Ls(o.target))==null?void 0:f.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+h/2-d/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function lue(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 cue({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:f}=r,p=m.useRef(null),d=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(s);d.current=r,h.current=t,y.current=n,v.current=s,m.useEffect(()=>()=>{var b;(b=p.current)==null||b.call(p)},[]),m.useEffect(()=>{var S;if(!h.current||!v.current)return;const{hasChangedTo:b}=Wo(d.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,_=l===Xe.BEACON_BEFORE||l===Xe.TOOLTIP_BEFORE;if(f===Tt.RUNNING&&_&&u&&b("positioned",!0)){const N=Ls(g.scrollTarget??g.spotlightTarget??g.target),I=o.current.getPositionData("beacon"),T=lu(N),z=T?!T.isSameNode(ts()):!1;(S=p.current)==null||S.call(p),(async()=>{if(z&&!cu(T)){const F=ts(),$=Kce(T),H={initial:F.scrollTop,target:$,element:F,duration:x};e(fr.SCROLL_START,g,{scroll:H});const{cancel:A,promise:Q}=xA($,{element:F,duration:x});p.current=A,await Q,e(fr.SCROLL_END,g,{scroll:H})}const D=Math.floor(qce(N,g.scrollOffset))||0,L=z?D:aue(D,{beaconPosition:I,lifecycle:l,scrollOffset:g.scrollOffset,step:g});gr(k,`step:${a}`,"scroll",z?"custom":"document",`${D} → ${L}`);const O=T,M={initial:O.scrollTop,target:L,element:O,duration:x};e(fr.SCROLL_START,g,{scroll:M});const{cancel:V,promise:B}=xA(L,{element:O,duration:x});p.current=V,await B,e(fr.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,f,o])}function uue(e){const t=qae(()=>Wce(Dce,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(eue(t)),u=pT.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[f,p]=m.useState([]),d=m.useCallback((S,N)=>{p(I=>[...I,{reason:N,step:S}])},[]),h=m.useCallback(()=>{p([])},[]);rue(c,n);const y=tue(c,n,h),v=sue(s,y,c),{index:b,size:g,status:k}=u,x=f$(u),_=m.useMemo(()=>Xv(t,l[b]),[b,t,l]);return Uae(()=>{o&&g&&D$(l,n)&&y.start(a??r)}),Kae(()=>{o&&g&&k===Tt.IDLE&&c.current.updateState({status:Tt.READY})},[o,g,k]),oue({controls:y,emitEvent:v,props:t,state:u,store:c}),iue({addFailure:d,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),cue({emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),{controls:y,failures:f,mergedProps:t,state:u,step:_,store:c}}function due(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Rr.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=Fce,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const fue={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function pue({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return xf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
561
- @keyframes joyride-loader-spin {
562
- to { transform: rotate(360deg); }
563
- }
564
- `)),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=ft.createElement(c,{step:t})}else l=ft.createElement("div",{style:{...fue,height:s,width:o,borderTopColor:t.primaryColor}});return ft.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const hue={height:0,isFixed:!1,left:0,top:0,width:0};function ed(e,t){const n=Ls(e);if(!n)return hue;const r=Jv(n),s=cu(n),o=Vce(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 mue(e,t,n){const[r,s]=m.useState(()=>ed(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(p=>{const d=ed(e,t);return p.top===d.top&&p.left===d.left&&p.width===d.width&&p.height===d.height&&p.isFixed===d.isFixed?p:d})},100)},[e,t]);m.useEffect(()=>{let p=null;const d=y=>{a.current=lu(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(ed(e,t))},h=Ls(e);return h?d(h):(p=new MutationObserver(()=>{const y=Ls(e);y&&(p==null||p.disconnect(),p=null,d(y))}),p.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;p==null||p.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(ed(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=ed(e,t)),f}function gue(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function kA(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 yue=[Xe.BEACON_BEFORE,Xe.BEACON];function wue(e){var B,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:f,spotlightRadius:p,spotlightTarget:d,styles:h,target:y,waiting:v}=e,b=Gae(),g=mue(d??y,f,u||v),k=m.useRef(null),x=(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE)&&l!=="center",[_,S]=m.useState(!1),N=c?(B=k.current)==null?void 0:B.offsetParent:null,I=(N==null?void 0:N.clientWidth)??b.width,T=(N==null?void 0:N.clientHeight)??Hce()??b.height,z=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",E=m.useMemo(()=>{const{backgroundColor:$,mixBlendMode:H,...A}=h.overlay;return{height:T,pointerEvents:"none",...A}},[T,h.overlay]),D=x&&!u&&!v;m.useEffect(()=>{D?requestAnimationFrame(()=>S(!0)):S(!1)},[D]);const L=n&&yue.includes(s),O=!n&&s!==Xe.TOOLTIP;if(r||!v&&(L||O))return null;let M="";if(D)if(c&&N){const $=Ls(d??y);if($){const H=yA($),A=yA(N);M=kA(H.left-A.left-f.left,H.top-A.top-f.top,$.offsetWidth+f.left+f.right,$.offsetHeight+f.top+f.bottom,p)}}else M=kA(g.left,g.top,g.width,g.height,p);const V=gue(I,T,M);return ft.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:E},ft.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:T,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:I}},ft.createElement("path",{d:V,fill:z,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&ft.createElement("path",{d:M,fill:z,style:{opacity:_?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&ft.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function F$(e){const{children:t,element:n}=e;return n?pr.createPortal(t,n):null}const xue='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function bue(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return xf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(xue)],{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 oo(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 kue(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...oo(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...oo(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...oo(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...oo(e,t,n)};default:return null}}function vue(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...oo(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...oo(e,r,n)};case"left":return{right:-n,top:t.y??0,...oo(e,r,n)};case"right":return{left:-n,top:t.y??0,...oo(e,r,n)};default:return{}}}function Sue({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!oo(r,n,o))return null;c=ft.createElement("span",{style:{flexShrink:0}},ft.createElement(l,{base:n,placement:r,size:o}))}else{const u=kue(r,n,o);if(!u)return null;c=ft.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},ft.createElement("polygon",{fill:"currentColor",points:u.points}))}return ft.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...vue(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function jue(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:f,styles:p}=e,d=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return xf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
565
- @keyframes joyride-beacon-inner {
566
- 20% {
567
- opacity: 0.9;
568
- }
569
-
570
- 90% {
571
- opacity: 0.7;
572
- }
573
- }
574
-
575
- @keyframes joyride-beacon-outer {
576
- 0% {
577
- transform: scale(1);
578
- }
579
-
580
- 45% {
581
- opacity: 0.7;
582
- transform: scale(0.75);
583
- }
584
-
585
- 100% {
586
- opacity: 0.9;
587
- transform: scale(1);
588
- }
589
- }
590
- `)),document.head.appendChild(b);const g=setTimeout(()=>{Rr.domElement(d.current)&&c&&d.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=to(o.open);let v;if(t){const b=t;v=ft.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:f})}else v=ft.createElement("span",{style:p.beacon},ft.createElement("span",{style:p.beaconOuter}),ft.createElement("span",{style:p.beaconInner}));return ft.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:p.beaconWrapper,title:y,type:"button"},v)}function Nue({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return ft.createElement("button",{style:o,type:"button",...t},ft.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"},ft.createElement("g",null,ft.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 _ue(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:f,styles:p,title:d}=l,h={};u.includes("primary")&&(h.primary=ft.createElement("button",{"data-testid":"button-primary",style:p.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=ft.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:p.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=ft.createElement("button",{"data-testid":"button-back",style:p.buttonBack,type:"button",...t})),h.close=u.includes("close")&&ft.createElement(Nue,{"data-testid":"button-close",styles:p.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":to(f),"aria-describedby":"joyride-tooltip-content"};return ft.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:p.tooltip,...c,...y},ft.createElement("div",{style:p.tooltipContainer},d&&ft.createElement("h4",{id:"joyride-tooltip-title",style:p.tooltipTitle},d),ft.createElement("div",{id:"joyride-tooltip-content",style:p.tooltipContent},f)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&ft.createElement("div",{style:p.tooltipFooter},ft.createElement("div",{style:p.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Cue(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Ni.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ni.BUTTON_CLOSE):n.close(Ni.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Ni.BUTTON_PRIMARY);return}n.next(Ni.BUTTON_PRIMARY)},f=g=>{g.preventDefault(),n.skip(Ni.BUTTON_SKIP)},p=()=>{const{back:g,close:k,last:x,next:_,nextWithProgress:S,skip:N}=a.locale,I=to(g),T=to(k),z=to(x),E=to(_),D=to(N);let L=k,O=T;if(t){if(L=_,O=E,a.showProgress&&!s){const M=to(S,{step:r+1,steps:o});L=Kb(S,r+1,o),O=M}s&&(L=x,O=z)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":T,children:k,"data-action":"close",onClick:c,role:"button",title:T},primaryProps:{"aria-label":O,children:L,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":D,children:N,"data-action":"skip",onClick:f,role:"button",title:D},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=ft.createElement(g,{...p(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=ft.createElement(_ue,{...p(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Aue(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Eue(e,t,n){var r,s;return e?[Rce()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Tce({crossAxis:!1,fallbackPlacements:Aue(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Iue(e){var H,A,Q,K,W;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:f,size:p,step:d,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=d.placement==="center",x=d.placement==="auto",_=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(()=>$$(h)?lu(h):void 0,[h]),N=m.useMemo(()=>cu(h),[h]),I=m.useMemo(()=>S?{boundary:S,rootBoundary:"viewport"}:{},[S]),T=k||x?"bottom":d.placement,z=k?"fixed":((H=d.floatingOptions)==null?void 0:H.strategy)??(d.isFixed||N?"fixed":"absolute"),E=m.useMemo(()=>{var ne,Z,G,te;return k?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[hA(({placement:re})=>{var ue;let se="right";re.startsWith("top")?se="top":re.startsWith("bottom")?se="bottom":re.startsWith("left")&&(se="left");const ee=d.spotlightTarget?0:d.spotlightPadding[se];return d.offset+ee+((ue=d.floatingOptions)!=null&&ue.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(ne=d.floatingOptions)==null?void 0:ne.hideArrow]),...Eue(x,d,T),Pce({padding:10,...I,...(Z=d.floatingOptions)==null?void 0:Z.shiftOptions}),...(G=d.floatingOptions)!=null&&G.hideArrow?[]:[Mce({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((te=d.floatingOptions)==null?void 0:te.middleware)??[]]},[k,d,x,T,I]),D=pA({...k?{elements:{reference:_}}:{},placement:T,strategy:z,middleware:E}),L=pA({strategy:z,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:m.useMemo(()=>{var ne,Z;return[hA(((Z=(ne=d.floatingOptions)==null?void 0:ne.beaconOptions)==null?void 0:Z.offset)??-18)]},[(Q=(A=d.floatingOptions)==null?void 0:A.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:uA});g.current=D.middlewareData,b.current=L.middlewareData,m.useEffect(()=>{var G;const{floating:ne,reference:Z}=D.elements;if(!(!Z||!ne||s!==Xe.TOOLTIP))return uA(Z,ne,D.update,(G=d.floatingOptions)==null?void 0:G.autoUpdate)},[s,D.update,(K=d.floatingOptions)==null?void 0:K.autoUpdate,d.target,D.elements]),m.useEffect(()=>{!k&&h&&D.refs.setReference(h),h&&L.refs.setReference(h)},[L.refs,k,h,D.refs]),m.useEffect(()=>{D.isPositioned&&c("tooltip",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:g.current})},[c,D.isPositioned,D.placement,D.x,D.y]),m.useEffect(()=>{L.isPositioned&&c("beacon",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:b.current})},[c,L.isPositioned,L.placement,L.x,L.y]);const O=d.zIndex+100,M=m.useCallback(ne=>{ne.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),V=m.useCallback(ne=>{ne&&(D.refs.setFloating(ne),u(ne))},[D.refs,u]),{arrow:B,floater:F}=d.styles;let $=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const ne=gA({...F,...D.floatingStyles,zIndex:O,opacity:a&&D.isPositioned?1:0,...!a&&{transition:"none"}});$=ft.createElement("div",{ref:V,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:ne},ft.createElement(Cue,{continuous:t,controls:n,index:r,isLastStep:r+1===p,size:p,step:d}),!k&&!((W=d.floatingOptions)!=null&&W.hideArrow)&&ft.createElement(Sue,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:D.placement,position:D.middlewareData.arrow,size:d.arrowSize,styles:B}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&($=ft.createElement("div",{ref:L.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:gA({...L.floatingStyles,zIndex:O})},ft.createElement(jue,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===p,locale:d.locale,nonce:o,onInteract:M,shouldFocus:f,size:p,step:d,styles:d.styles})));return ft.createElement(F$,{element:l},$)}function Pue(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:f,updateState:p}=e,[d,h]=m.useState(null);bue(f.disableFocusTrap?null:d,"[data-action=primary]");const y=Ls(f.target),v=s===Xe.TOOLTIP;return!O$(f)||!Rr.domElement(y)?null:ft.createElement(Iue,{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:f,target:y,updateState:p})}function Tue({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,f=due(c),{index:p,lifecycle:d,status:h}=n,y=h===Tt.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=N=>{!r||d!==Xe.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ni.KEYBOARD):e.close(Ni.KEYBOARD))};return document.body.addEventListener("keydown",S,{passive:!0}),()=>{document.body.removeEventListener("keydown",S)}},[e,y,d,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ni.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ni.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const _=n.action===Wt.START&&!r.skipBeacon&&r.placement!=="center";return ft.createElement(ft.Fragment,null,d!==Xe.INIT&&ft.createElement(Pue,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:f,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(p!==0||u),step:r,updateState:s.current.updateState}),ft.createElement(F$,{element:f},ft.createElement(ft.Fragment,null,v&&ft.createElement(pue,{nonce:l,step:r}),!_&&ft.createElement(wue,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Rue(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=uue(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Hm(s,"positioned"),[s]),step:o,Tour:Yv()?ft.createElement(Tue,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function Mue(e){const{Tour:t}=Rue(e);return t}function $ue(e){return Yv()?ft.createElement(Mue,e):null}function Lue(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 Oue(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Due(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const ch="af:onboarding";function Fue({page:e,hasNodes:t=!1}){const{t:n}=qr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Lue(n):t?Oue(n):Due(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(ch),f=u?JSON.parse(u):{};if(f.completed||f[e]){s(!1),a([]);return}localStorage.setItem(ch,JSON.stringify({...f,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=f=>{var y;const p=f.target.closest("button");if(!p||!p.closest(".react-joyride__tooltip"))return;const h=(y=p.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(ch)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(ch,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($ue,{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 zue="agentflow:recent-runs:v1",Wue="agentflow:recent-runs:poller",Bue=3e3,Hue=8e3,Vue=2e3,vA=5e3,Kue=16e3,SA=[1e4,3e4,6e4];function que(e){return SA[Math.min(Math.max(e-1,0),SA.length-1)]}function Uue(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Gue(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function Yue(){const{navigate:e,path:t}=os(),[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:""}),f=m.useRef(()=>{});m.useEffect(()=>{let _=!1,S=!1,N=!1,I=null,T=0,z=0,E=0,D=0,L=null,O=0,M=0;const V=Uue(),B=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(zue):null,$=Se=>{try{F==null||F.postMessage({...Se,tabId:V,sentAt:Date.now()})}catch{}},H=()=>{const Se=Date.now()-Kue;for(const[_e,Fe]of B)Fe<Se&&B.delete(_e);l(1+B.size)},A=(Se="presence")=>{$({type:Se,visible:!document.hidden})},Q=Se=>{if(!_&&(Array.isArray(Se.runs)&&r(Se.runs),Se.syncHealth&&typeof Se.syncHealth=="object")){const _e=Se.syncHealth;O=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},K=Se=>{Q(Se),$({type:"state",...Se})},W=()=>{T&&(window.clearTimeout(T),T=0)},ne=Se=>{W(),!(_||!S||document.hidden)&&(T=window.setTimeout(()=>{T=0,Z()},Math.max(0,Se)))},Z=async()=>{if(_||!S||document.hidden||L)return;const Se=new AbortController;L=Se;let _e=!1;const Fe=window.setTimeout(()=>{_e=!0,Se.abort()},Hue);try{const at=await fetch("/api/pipeline-recent-runs",{signal:Se.signal});if(!at.ok)throw new Error(`HTTP ${at.status}`);const mt=await at.json();if(_||!S||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(mt.runs)?mt.runs:[];K({runs:Te.filter(it=>it&&it.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),ne(Bue)}catch(at){const mt=Se.signal.aborted&&!_e;if(_||!S||document.hidden||mt)return;O+=1,K({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((at==null?void 0:at.message)||at)}`}}),ne(que(O))}finally{window.clearTimeout(Fe),L===Se&&(L=null)}},G=()=>{W(),L&&(L.abort(),L=null)},te=()=>{if(G(),I){const Se=I;I=null,Se()}S=!1},re=(Se=Vue)=>{z&&window.clearTimeout(z),!(_||document.hidden||S||N)&&(z=window.setTimeout(()=>{z=0,ee()},Se))},se=()=>{_||document.hidden||S||(S=!0,ne(0))},ee=async()=>{var Se;if(!(_||document.hidden||S||N)){if(!((Se=navigator.locks)!=null&&Se.request)){se();return}N=!0;try{await navigator.locks.request(Wue,{mode:"exclusive",ifAvailable:!0},async _e=>{if(N=!1,!_e||_||document.hidden){re();return}S=!0,ne(0),await new Promise(Fe=>{I=Fe}),I=null,S=!1})}catch{N=!1}finally{re()}}},ue=()=>{if(!_){if(S){O=0,ne(0);return}$({type:"retry"}),re(0)}};f.current=ue,F&&(F.onmessage=Se=>{const _e=Se.data;if(!(!_e||_e.tabId===V)){if(_e.type==="hello"||_e.type==="presence"){B.set(_e.tabId,Date.now()),H(),_e.type==="hello"&&A();return}if(_e.type==="bye"){B.delete(_e.tabId),H(),re(0);return}if(_e.type==="state"){B.set(_e.tabId,Date.now()),H(),Q(_e);return}_e.type==="retry"&&S&&(O=0,ne(0))}});const de=()=>{A(),document.hidden?te():re(0)},me=()=>{A("bye"),te()},Me=()=>{A("hello"),re(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",me),window.addEventListener("pageshow",Me),A("hello"),E=window.setInterval(A,vA),D=window.setInterval(H,vA),re(0),()=>{_=!0,f.current=()=>{},A("bye"),te(),z&&window.clearTimeout(z),E&&window.clearInterval(E),D&&window.clearInterval(D),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",Me),F==null||F.close()}},[]);const p=_=>{const S=new URLSearchParams({flowId:_.flowId,flowSource:_.flowSource||"workspace"});e(`/flow?${S.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,h=(d==null?void 0:d.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){p(n[0]);return}o(_=>!_)};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:["最近成功:",Gue(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:_=>{_.stopPropagation(),f.current()},children:"立即重试"})]}),n.map(_=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(_.flowId===h?" af-run-indicator__item--current":""),onClick:()=>p(_),title:`${_.flowId} · ${_.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:_.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:_.runId.slice(0,12)})]},`${_.flowId}:${_.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 Hw="0.1.137",Jue=6e4,Xue=30*6e4;function Xc(e){return String(e||"").trim().replace(/^v/i,"")}function Que(e,t){const n=Xc(e),r=Xc(t);return!!(n&&r&&n!==r)}function Zue(e,t){return`agentflow.app-version.snooze:${Xc(e)}:${Xc(t)}`}function ede(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function tde(){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 f=Xc(u.version);if(!Que(Hw,f)){t(null);return}const p=Zue(Hw,f);if(ede(p)>Date.now())return;t({clientVersion:Xc(Hw),serverVersion:f,startedAt:String(u.startedAt||""),snoozeKey:p})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Jue);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()+Xue))}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 z$(e){return e==="/likee-context"||e==="/likee_context"}function nde(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function rde(){const{navigate:e}=os();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 sde 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 ide({authUser:e}){const{path:t}=os();return t==="/projects"||t==="/"?i.jsx(Kl,{authUser:e}):t==="/nodes"?i.jsx(Kl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Kl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Kl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Kl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Poe,{authUser:e}):t==="/workflows"?i.jsx(Hoe,{}):t==="/workflow-report"?i.jsx(Sae,{}):t==="/mcps"?i.jsx(xoe,{}):t==="/schedules"?i.jsx(Soe,{}):t==="/node-studio"?i.jsx(Noe,{}):t==="/flow"?i.jsx(rde,{}):t==="/workspace"?i.jsx(KM,{}):t.startsWith("/display")?i.jsx(GM,{}):t==="/settings"?i.jsx(roe,{authUser:e}):t==="/admin/usage"?i.jsx(doe,{authUser:e}):t==="/admin/teams"?i.jsx(foe,{authUser:e}):t==="/feedback"?i.jsx(hoe,{authUser:e}):z$(t)?i.jsx(u$,{}):i.jsx(Kl,{})}function ode({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,f]=m.useState(""),p=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}),f(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),f(String(h.message||h))}};m.useEffect(()=>{p()},[]);const d=async h=>{h.preventDefault(),c(!0),f("");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){f(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:d,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 ade({authUser:e,onLogout:t}){const{path:n}=os(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(Fue,{page:r?"flow":"projects"}):null,r?null:i.jsx(gF,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(ide,{authUser:e})}),i.jsx(Yue,{})]})}function lde(){return i.jsx(sde,{children:i.jsxs(XD,{children:[i.jsx(cde,{}),i.jsx(tde,{})]})})}function cde(){const{path:e}=os();return e.startsWith("/display")?i.jsx(GM,{}):z$(e)?i.jsx(u$,{}):nde(e)?i.jsx(KM,{}):i.jsx(ode,{children:({user:t,onLogout:n})=>i.jsx(ade,{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 jA=document.querySelector('link[rel="icon"]');jA&&(jA.href=zI);Vw.createRoot(document.getElementById("root")).render(i.jsx(ft.StrictMode,{children:i.jsx(lde,{})}));