@fieldwangai/agentflow 0.1.110 → 0.1.113
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.
- package/bin/lib/ui-server.mjs +63 -5
- package/builtin/web-ui/dist/assets/index-B86D6SK3.js +348 -0
- package/builtin/web-ui/dist/assets/{index-TQK269PM.css → index-Brqy4uhJ.css} +1 -1
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/builtin/web-ui/dist/assets/index-C3aw8qTz.js +0 -348
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
var OL=Object.defineProperty;var DL=(e,t,n)=>t in e?OL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Dn=(e,t,n)=>DL(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 hd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q_={exports:{}},_m={},Z_={exports:{}},Rt={};/**
|
|
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 tf=Symbol.for("react.element"),FL=Symbol.for("react.portal"),zL=Symbol.for("react.fragment"),BL=Symbol.for("react.strict_mode"),HL=Symbol.for("react.profiler"),WL=Symbol.for("react.provider"),VL=Symbol.for("react.context"),KL=Symbol.for("react.forward_ref"),qL=Symbol.for("react.suspense"),UL=Symbol.for("react.memo"),YL=Symbol.for("react.lazy"),O0=Symbol.iterator;function GL(e){return e===null||typeof e!="object"?null:(e=O0&&e[O0]||e["@@iterator"],typeof e=="function"?e:null)}var eE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tE=Object.assign,nE={};function Lc(e,t,n){this.props=e,this.context=t,this.refs=nE,this.updater=n||eE}Lc.prototype.isReactComponent={};Lc.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")};Lc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rE(){}rE.prototype=Lc.prototype;function Cb(e,t,n){this.props=e,this.context=t,this.refs=nE,this.updater=n||eE}var _b=Cb.prototype=new rE;_b.constructor=Cb;tE(_b,Lc.prototype);_b.isPureReactComponent=!0;var D0=Array.isArray,sE=Object.prototype.hasOwnProperty,Eb={current:null},iE={key:!0,ref:!0,__self:!0,__source:!0};function oE(e,t,n){var r,s={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)sE.call(t,r)&&!iE.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var 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:tf,type:e,key:o,ref:a,props:s,_owner:Eb.current}}function JL(e,t){return{$$typeof:tf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ab(e){return typeof e=="object"&&e!==null&&e.$$typeof===tf}function XL(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var F0=/\/+/g;function ey(e,t){return typeof e=="object"&&e!==null&&e.key!=null?XL(""+e.key):t.toString(36)}function Up(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 tf:case FL:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+ey(a,0):r,D0(s)?(n="",e!=null&&(n=e.replace(F0,"$&/")+"/"),Up(s,t,n,"",function(u){return u})):s!=null&&(Ab(s)&&(s=JL(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(F0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",D0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+ey(o,l);a+=Up(o,t,n,c,s)}else if(c=GL(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+ey(o,l++),a+=Up(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 Zf(e,t,n){if(e==null)return e;var r=[],s=0;return Up(e,r,"","",function(o){return t.call(n,o,s++)}),r}function QL(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 Or={current:null},Yp={transition:null},ZL={ReactCurrentDispatcher:Or,ReactCurrentBatchConfig:Yp,ReactCurrentOwner:Eb};function aE(){throw Error("act(...) is not supported in production builds of React.")}Rt.Children={map:Zf,forEach:function(e,t,n){Zf(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Zf(e,function(){t++}),t},toArray:function(e){return Zf(e,function(t){return t})||[]},only:function(e){if(!Ab(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Rt.Component=Lc;Rt.Fragment=zL;Rt.Profiler=HL;Rt.PureComponent=Cb;Rt.StrictMode=BL;Rt.Suspense=qL;Rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ZL;Rt.act=aE;Rt.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=tE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Eb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)sE.call(t,c)&&!iE.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:tf,type:e.type,key:s,ref:o,props:r,_owner:a}};Rt.createContext=function(e){return e={$$typeof:VL,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:WL,_context:e},e.Consumer=e};Rt.createElement=oE;Rt.createFactory=function(e){var t=oE.bind(null,e);return t.type=e,t};Rt.createRef=function(){return{current:null}};Rt.forwardRef=function(e){return{$$typeof:KL,render:e}};Rt.isValidElement=Ab;Rt.lazy=function(e){return{$$typeof:YL,_payload:{_status:-1,_result:e},_init:QL}};Rt.memo=function(e,t){return{$$typeof:UL,type:e,compare:t===void 0?null:t}};Rt.startTransition=function(e){var t=Yp.transition;Yp.transition={};try{e()}finally{Yp.transition=t}};Rt.unstable_act=aE;Rt.useCallback=function(e,t){return Or.current.useCallback(e,t)};Rt.useContext=function(e){return Or.current.useContext(e)};Rt.useDebugValue=function(){};Rt.useDeferredValue=function(e){return Or.current.useDeferredValue(e)};Rt.useEffect=function(e,t){return Or.current.useEffect(e,t)};Rt.useId=function(){return Or.current.useId()};Rt.useImperativeHandle=function(e,t,n){return Or.current.useImperativeHandle(e,t,n)};Rt.useInsertionEffect=function(e,t){return Or.current.useInsertionEffect(e,t)};Rt.useLayoutEffect=function(e,t){return Or.current.useLayoutEffect(e,t)};Rt.useMemo=function(e,t){return Or.current.useMemo(e,t)};Rt.useReducer=function(e,t,n){return Or.current.useReducer(e,t,n)};Rt.useRef=function(e){return Or.current.useRef(e)};Rt.useState=function(e){return Or.current.useState(e)};Rt.useSyncExternalStore=function(e,t,n){return Or.current.useSyncExternalStore(e,t,n)};Rt.useTransition=function(){return Or.current.useTransition()};Rt.version="18.3.1";Z_.exports=Rt;var m=Z_.exports;const ft=sa(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 e2=m,t2=Symbol.for("react.element"),n2=Symbol.for("react.fragment"),r2=Object.prototype.hasOwnProperty,s2=e2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i2={key:!0,ref:!0,__self:!0,__source:!0};function lE(e,t,n){var r,s={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)r2.call(t,r)&&!i2.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:t2,type:e,key:o,ref:a,props:s,_owner:s2.current}}_m.Fragment=n2;_m.jsx=lE;_m.jsxs=lE;Q_.exports=_m;var i=Q_.exports,Nw={},cE={exports:{}},hs={},uE={exports:{}},dE={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(T,W){var E=T.length;T.push(W);e:for(;0<E;){var Q=E-1>>>1,V=T[Q];if(0<s(V,W))T[Q]=W,T[E]=V,E=Q;else break e}}function n(T){return T.length===0?null:T[0]}function r(T){if(T.length===0)return null;var W=T[0],E=T.pop();if(E!==W){T[0]=E;e:for(var Q=0,V=T.length,B=V>>>1;Q<B;){var se=2*(Q+1)-1,ue=T[se],G=se+1,ee=T[G];if(0>s(ue,E))G<V&&0>s(ee,ue)?(T[Q]=ee,T[G]=E,Q=G):(T[Q]=ue,T[se]=E,Q=se);else if(G<V&&0>s(ee,E))T[Q]=ee,T[G]=E,Q=G;else break e}}return W}function s(T,W){var E=T.sortIndex-W.sortIndex;return E!==0?E:T.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],d=1,f=null,p=3,h=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(T){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=T)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function N(T){if(v=!1,x(T),!y)if(n(c)!==null)y=!0,H(j);else{var W=n(u);W!==null&&L(N,W.startTime-T)}}function j(T,W){y=!1,v&&(v=!1,g(I),I=-1),h=!0;var E=p;try{for(x(W),f=n(c);f!==null&&(!(f.expirationTime>W)||T&&!D());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=f.priorityLevel;var V=Q(f.expirationTime<=W);W=e.unstable_now(),typeof V=="function"?f.callback=V:f===n(c)&&r(c),x(W)}else r(c);f=n(c)}if(f!==null)var B=!0;else{var se=n(u);se!==null&&L(N,se.startTime-W),B=!1}return B}finally{f=null,p=E,h=!1}}var C=!1,P=null,I=-1,F=5,$=-1;function D(){return!(e.unstable_now()-$<F)}function z(){if(P!==null){var T=e.unstable_now();$=T;var W=!0;try{W=P(!0,T)}finally{W?O():(C=!1,P=null)}}else C=!1}var O;if(typeof k=="function")O=function(){k(z)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,K=M.port2;M.port1.onmessage=z,O=function(){K.postMessage(null)}}else O=function(){b(z,0)};function H(T){P=T,C||(C=!0,O())}function L(T,W){I=b(function(){T(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,H(j))},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(T){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var E=p;p=W;try{return T()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(T,W){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var E=p;p=T;try{return W()}finally{p=E}},e.unstable_scheduleCallback=function(T,W,E){var Q=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Q+E:Q):E=Q,T){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=E+V,T={id:d++,callback:W,priorityLevel:T,startTime:E,expirationTime:V,sortIndex:-1},E>Q?(T.sortIndex=E,t(u,T),n(c)===null&&T===n(u)&&(v?(g(I),I=-1):v=!0,L(N,E-Q))):(T.sortIndex=V,t(c,T),y||h||(y=!0,H(j))),T},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(T){var W=p;return function(){var E=p;p=W;try{return T.apply(this,arguments)}finally{p=E}}}})(dE);uE.exports=dE;var o2=uE.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var a2=m,fs=o2;function Ae(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var fE=new Set,md={};function sl(e,t){yc(e,t),yc(e+"Capture",t)}function yc(e,t){for(md[e]=t,e=0;e<t.length;e++)fE.add(t[e])}var ro=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jw=Object.prototype.hasOwnProperty,l2=/^[: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]*$/,z0={},B0={};function c2(e){return jw.call(B0,e)?!0:jw.call(z0,e)?!1:l2.test(e)?B0[e]=!0:(z0[e]=!0,!1)}function u2(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 d2(e,t,n,r){if(t===null||typeof t>"u"||u2(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 Dr(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 yr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){yr[e]=new Dr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];yr[t]=new Dr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){yr[e]=new Dr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){yr[e]=new Dr(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){yr[e]=new Dr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){yr[e]=new Dr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){yr[e]=new Dr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){yr[e]=new Dr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){yr[e]=new Dr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Pb=/[\-:]([a-z])/g;function Ib(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(Pb,Ib);yr[t]=new Dr(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(Pb,Ib);yr[t]=new Dr(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(Pb,Ib);yr[t]=new Dr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){yr[e]=new Dr(e,1,!1,e.toLowerCase(),null,!1,!1)});yr.xlinkHref=new Dr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){yr[e]=new Dr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Rb(e,t,n,r){var s=yr.hasOwnProperty(t)?yr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(d2(t,n,s,r)&&(n=null),r||s===null?c2(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 uo=a2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ep=Symbol.for("react.element"),zl=Symbol.for("react.portal"),Bl=Symbol.for("react.fragment"),Tb=Symbol.for("react.strict_mode"),Cw=Symbol.for("react.profiler"),pE=Symbol.for("react.provider"),hE=Symbol.for("react.context"),Mb=Symbol.for("react.forward_ref"),_w=Symbol.for("react.suspense"),Ew=Symbol.for("react.suspense_list"),$b=Symbol.for("react.memo"),Ao=Symbol.for("react.lazy"),mE=Symbol.for("react.offscreen"),H0=Symbol.iterator;function wu(e){return e===null||typeof e!="object"?null:(e=H0&&e[H0]||e["@@iterator"],typeof e=="function"?e:null)}var $n=Object.assign,ty;function Ou(e){if(ty===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ty=t&&t[1]||""}return`
|
|
34
|
+
`+ty+e}var ny=!1;function ry(e,t){if(!e||ny)return"";ny=!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{ny=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ou(e):""}function f2(e){switch(e.tag){case 5:return Ou(e.type);case 16:return Ou("Lazy");case 13:return Ou("Suspense");case 19:return Ou("SuspenseList");case 0:case 2:case 15:return e=ry(e.type,!1),e;case 11:return e=ry(e.type.render,!1),e;case 1:return e=ry(e.type,!0),e;default:return""}}function Aw(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 Bl:return"Fragment";case zl:return"Portal";case Cw:return"Profiler";case Tb:return"StrictMode";case _w:return"Suspense";case Ew:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case hE:return(e.displayName||"Context")+".Consumer";case pE:return(e._context.displayName||"Context")+".Provider";case Mb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $b:return t=e.displayName||null,t!==null?t:Aw(e.type)||"Memo";case Ao:t=e._payload,e=e._init;try{return Aw(e(t))}catch{}}return null}function p2(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 Aw(t);case 8:return t===Tb?"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 Jo(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function h2(e){var t=gE(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function tp(e){e._valueTracker||(e._valueTracker=h2(e))}function yE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function xh(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 Pw(e,t){var n=t.checked;return $n({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function W0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Jo(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 wE(e,t){t=t.checked,t!=null&&Rb(e,"checked",t,!1)}function Iw(e,t){wE(e,t);var n=Jo(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")?Rw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Rw(e,t.type,Jo(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function V0(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 Rw(e,t,n){(t!=="number"||xh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Du=Array.isArray;function rc(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=""+Jo(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 Tw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ae(91));return $n({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function K0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ae(92));if(Du(n)){if(1<n.length)throw Error(Ae(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Jo(n)}}function xE(e,t){var n=Jo(t.value),r=Jo(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 q0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function bE(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Mw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?bE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var np,kE=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(np=np||document.createElement("div"),np.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=np.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Gu={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},m2=["Webkit","ms","Moz","O"];Object.keys(Gu).forEach(function(e){m2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Gu[t]=Gu[e]})});function vE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Gu.hasOwnProperty(e)&&Gu[e]?(""+t).trim():t+"px"}function SE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=vE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var g2=$n({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 $w(e,t){if(t){if(g2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ae(62))}}function Lw(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 Ow=null;function Lb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dw=null,sc=null,ic=null;function U0(e){if(e=sf(e)){if(typeof Dw!="function")throw Error(Ae(280));var t=e.stateNode;t&&(t=Rm(t),Dw(e.stateNode,e.type,t))}}function NE(e){sc?ic?ic.push(e):ic=[e]:sc=e}function jE(){if(sc){var e=sc,t=ic;if(ic=sc=null,U0(e),t)for(e=0;e<t.length;e++)U0(t[e])}}function CE(e,t){return e(t)}function _E(){}var sy=!1;function EE(e,t,n){if(sy)return e(t,n);sy=!0;try{return CE(e,t,n)}finally{sy=!1,(sc!==null||ic!==null)&&(_E(),jE())}}function yd(e,t){var n=e.stateNode;if(n===null)return null;var r=Rm(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Ae(231,t,typeof n));return n}var Fw=!1;if(ro)try{var xu={};Object.defineProperty(xu,"passive",{get:function(){Fw=!0}}),window.addEventListener("test",xu,xu),window.removeEventListener("test",xu,xu)}catch{Fw=!1}function y2(e,t,n,r,s,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var Ju=!1,bh=null,kh=!1,zw=null,w2={onError:function(e){Ju=!0,bh=e}};function x2(e,t,n,r,s,o,a,l,c){Ju=!1,bh=null,y2.apply(w2,arguments)}function b2(e,t,n,r,s,o,a,l,c){if(x2.apply(this,arguments),Ju){if(Ju){var u=bh;Ju=!1,bh=null}else throw Error(Ae(198));kh||(kh=!0,zw=u)}}function il(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 AE(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 Y0(e){if(il(e)!==e)throw Error(Ae(188))}function k2(e){var t=e.alternate;if(!t){if(t=il(e),t===null)throw Error(Ae(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return Y0(s),e;if(o===r)return Y0(s),t;o=o.sibling}throw Error(Ae(188))}if(n.return!==r.return)n=s,r=o;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=o;break}if(l===r){a=!0,r=s,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=s;break}if(l===r){a=!0,r=o,n=s;break}l=l.sibling}if(!a)throw Error(Ae(189))}}if(n.alternate!==r)throw Error(Ae(190))}if(n.tag!==3)throw Error(Ae(188));return n.stateNode.current===n?e:t}function PE(e){return e=k2(e),e!==null?IE(e):null}function IE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=IE(e);if(t!==null)return t;e=e.sibling}return null}var RE=fs.unstable_scheduleCallback,G0=fs.unstable_cancelCallback,v2=fs.unstable_shouldYield,S2=fs.unstable_requestPaint,Wn=fs.unstable_now,N2=fs.unstable_getCurrentPriorityLevel,Ob=fs.unstable_ImmediatePriority,TE=fs.unstable_UserBlockingPriority,vh=fs.unstable_NormalPriority,j2=fs.unstable_LowPriority,ME=fs.unstable_IdlePriority,Em=null,Ni=null;function C2(e){if(Ni&&typeof Ni.onCommitFiberRoot=="function")try{Ni.onCommitFiberRoot(Em,e,void 0,(e.current.flags&128)===128)}catch{}}var Qs=Math.clz32?Math.clz32:A2,_2=Math.log,E2=Math.LN2;function A2(e){return e>>>=0,e===0?32:31-(_2(e)/E2|0)|0}var rp=64,sp=4194304;function Fu(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 Sh(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=Fu(l):(o&=a,o!==0&&(r=Fu(o)))}else a=n&~s,a!==0?r=Fu(a):o!==0&&(r=Fu(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-Qs(t),s=1<<n,r|=e[n],t&=~s;return r}function P2(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 I2(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-Qs(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=P2(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Bw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function $E(){var e=rp;return rp<<=1,!(rp&4194240)&&(rp=64),e}function iy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function nf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Qs(t),e[t]=n}function R2(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-Qs(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Db(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Qs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var sn=0;function LE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var OE,Fb,DE,FE,zE,Hw=!1,ip=[],zo=null,Bo=null,Ho=null,wd=new Map,xd=new Map,Ro=[],T2="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 J0(e,t){switch(e){case"focusin":case"focusout":zo=null;break;case"dragenter":case"dragleave":Bo=null;break;case"mouseover":case"mouseout":Ho=null;break;case"pointerover":case"pointerout":wd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":xd.delete(t.pointerId)}}function bu(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&&Fb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function M2(e,t,n,r,s){switch(t){case"focusin":return zo=bu(zo,e,t,n,r,s),!0;case"dragenter":return Bo=bu(Bo,e,t,n,r,s),!0;case"mouseover":return Ho=bu(Ho,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return wd.set(o,bu(wd.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,xd.set(o,bu(xd.get(o)||null,e,t,n,r,s)),!0}return!1}function BE(e){var t=Aa(e.target);if(t!==null){var n=il(t);if(n!==null){if(t=n.tag,t===13){if(t=AE(n),t!==null){e.blockedOn=t,zE(e.priority,function(){DE(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Gp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ww(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ow=r,n.target.dispatchEvent(r),Ow=null}else return t=sf(n),t!==null&&Fb(t),e.blockedOn=n,!1;t.shift()}return!0}function X0(e,t,n){Gp(e)&&n.delete(t)}function $2(){Hw=!1,zo!==null&&Gp(zo)&&(zo=null),Bo!==null&&Gp(Bo)&&(Bo=null),Ho!==null&&Gp(Ho)&&(Ho=null),wd.forEach(X0),xd.forEach(X0)}function ku(e,t){e.blockedOn===t&&(e.blockedOn=null,Hw||(Hw=!0,fs.unstable_scheduleCallback(fs.unstable_NormalPriority,$2)))}function bd(e){function t(s){return ku(s,e)}if(0<ip.length){ku(ip[0],e);for(var n=1;n<ip.length;n++){var r=ip[n];r.blockedOn===e&&(r.blockedOn=null)}}for(zo!==null&&ku(zo,e),Bo!==null&&ku(Bo,e),Ho!==null&&ku(Ho,e),wd.forEach(t),xd.forEach(t),n=0;n<Ro.length;n++)r=Ro[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ro.length&&(n=Ro[0],n.blockedOn===null);)BE(n),n.blockedOn===null&&Ro.shift()}var oc=uo.ReactCurrentBatchConfig,Nh=!0;function L2(e,t,n,r){var s=sn,o=oc.transition;oc.transition=null;try{sn=1,zb(e,t,n,r)}finally{sn=s,oc.transition=o}}function O2(e,t,n,r){var s=sn,o=oc.transition;oc.transition=null;try{sn=4,zb(e,t,n,r)}finally{sn=s,oc.transition=o}}function zb(e,t,n,r){if(Nh){var s=Ww(e,t,n,r);if(s===null)my(e,t,r,jh,n),J0(e,r);else if(M2(s,e,t,n,r))r.stopPropagation();else if(J0(e,r),t&4&&-1<T2.indexOf(e)){for(;s!==null;){var o=sf(s);if(o!==null&&OE(o),o=Ww(e,t,n,r),o===null&&my(e,t,r,jh,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else my(e,t,r,null,n)}}var jh=null;function Ww(e,t,n,r){if(jh=null,e=Lb(r),e=Aa(e),e!==null)if(t=il(e),t===null)e=null;else if(n=t.tag,n===13){if(e=AE(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 jh=e,null}function HE(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(N2()){case Ob:return 1;case TE:return 4;case vh:case j2:return 16;case ME:return 536870912;default:return 16}default:return 16}}var Lo=null,Bb=null,Jp=null;function WE(){if(Jp)return Jp;var e,t=Bb,n=t.length,r,s="value"in Lo?Lo.value:Lo.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 Jp=s.slice(e,1<r?1-r:void 0)}function Xp(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 op(){return!0}function Q0(){return!1}function ms(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)?op:Q0,this.isPropagationStopped=Q0,this}return $n(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=op)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=op)},persist:function(){},isPersistent:op}),t}var Oc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hb=ms(Oc),rf=$n({},Oc,{view:0,detail:0}),D2=ms(rf),oy,ay,vu,Am=$n({},rf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Wb,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!==vu&&(vu&&e.type==="mousemove"?(oy=e.screenX-vu.screenX,ay=e.screenY-vu.screenY):ay=oy=0,vu=e),oy)},movementY:function(e){return"movementY"in e?e.movementY:ay}}),Z0=ms(Am),F2=$n({},Am,{dataTransfer:0}),z2=ms(F2),B2=$n({},rf,{relatedTarget:0}),ly=ms(B2),H2=$n({},Oc,{animationName:0,elapsedTime:0,pseudoElement:0}),W2=ms(H2),V2=$n({},Oc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),K2=ms(V2),q2=$n({},Oc,{data:0}),eN=ms(q2),U2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Y2={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"},G2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function J2(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=G2[e])?!!t[e]:!1}function Wb(){return J2}var X2=$n({},rf,{key:function(e){if(e.key){var t=U2[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Xp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Y2[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Wb,charCode:function(e){return e.type==="keypress"?Xp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Xp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Q2=ms(X2),Z2=$n({},Am,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tN=ms(Z2),eO=$n({},rf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Wb}),tO=ms(eO),nO=$n({},Oc,{propertyName:0,elapsedTime:0,pseudoElement:0}),rO=ms(nO),sO=$n({},Am,{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}),iO=ms(sO),oO=[9,13,27,32],Vb=ro&&"CompositionEvent"in window,Xu=null;ro&&"documentMode"in document&&(Xu=document.documentMode);var aO=ro&&"TextEvent"in window&&!Xu,VE=ro&&(!Vb||Xu&&8<Xu&&11>=Xu),nN=" ",rN=!1;function KE(e,t){switch(e){case"keyup":return oO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Hl=!1;function lO(e,t){switch(e){case"compositionend":return qE(t);case"keypress":return t.which!==32?null:(rN=!0,nN);case"textInput":return e=t.data,e===nN&&rN?null:e;default:return null}}function cO(e,t){if(Hl)return e==="compositionend"||!Vb&&KE(e,t)?(e=WE(),Jp=Bb=Lo=null,Hl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return VE&&t.locale!=="ko"?null:t.data;default:return null}}var uO={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 sN(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!uO[e.type]:t==="textarea"}function UE(e,t,n,r){NE(r),t=Ch(t,"onChange"),0<t.length&&(n=new Hb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Qu=null,kd=null;function dO(e){sA(e,0)}function Pm(e){var t=Kl(e);if(yE(t))return e}function fO(e,t){if(e==="change")return t}var YE=!1;if(ro){var cy;if(ro){var uy="oninput"in document;if(!uy){var iN=document.createElement("div");iN.setAttribute("oninput","return;"),uy=typeof iN.oninput=="function"}cy=uy}else cy=!1;YE=cy&&(!document.documentMode||9<document.documentMode)}function oN(){Qu&&(Qu.detachEvent("onpropertychange",GE),kd=Qu=null)}function GE(e){if(e.propertyName==="value"&&Pm(kd)){var t=[];UE(t,kd,e,Lb(e)),EE(dO,t)}}function pO(e,t,n){e==="focusin"?(oN(),Qu=t,kd=n,Qu.attachEvent("onpropertychange",GE)):e==="focusout"&&oN()}function hO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Pm(kd)}function mO(e,t){if(e==="click")return Pm(t)}function gO(e,t){if(e==="input"||e==="change")return Pm(t)}function yO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ti=typeof Object.is=="function"?Object.is:yO;function vd(e,t){if(ti(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(!jw.call(t,s)||!ti(e[s],t[s]))return!1}return!0}function aN(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function lN(e,t){var n=aN(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=aN(n)}}function JE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?JE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function XE(){for(var e=window,t=xh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=xh(e.document)}return t}function Kb(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function wO(e){var t=XE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&JE(n.ownerDocument.documentElement,n)){if(r!==null&&Kb(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=lN(n,o);var a=lN(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 xO=ro&&"documentMode"in document&&11>=document.documentMode,Wl=null,Vw=null,Zu=null,Kw=!1;function cN(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kw||Wl==null||Wl!==xh(r)||(r=Wl,"selectionStart"in r&&Kb(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}),Zu&&vd(Zu,r)||(Zu=r,r=Ch(Vw,"onSelect"),0<r.length&&(t=new Hb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Wl)))}function ap(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Vl={animationend:ap("Animation","AnimationEnd"),animationiteration:ap("Animation","AnimationIteration"),animationstart:ap("Animation","AnimationStart"),transitionend:ap("Transition","TransitionEnd")},dy={},QE={};ro&&(QE=document.createElement("div").style,"AnimationEvent"in window||(delete Vl.animationend.animation,delete Vl.animationiteration.animation,delete Vl.animationstart.animation),"TransitionEvent"in window||delete Vl.transitionend.transition);function Im(e){if(dy[e])return dy[e];if(!Vl[e])return e;var t=Vl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in QE)return dy[e]=t[n];return e}var ZE=Im("animationend"),eA=Im("animationiteration"),tA=Im("animationstart"),nA=Im("transitionend"),rA=new Map,uN="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 ia(e,t){rA.set(e,t),sl(t,[e])}for(var fy=0;fy<uN.length;fy++){var py=uN[fy],bO=py.toLowerCase(),kO=py[0].toUpperCase()+py.slice(1);ia(bO,"on"+kO)}ia(ZE,"onAnimationEnd");ia(eA,"onAnimationIteration");ia(tA,"onAnimationStart");ia("dblclick","onDoubleClick");ia("focusin","onFocus");ia("focusout","onBlur");ia(nA,"onTransitionEnd");yc("onMouseEnter",["mouseout","mouseover"]);yc("onMouseLeave",["mouseout","mouseover"]);yc("onPointerEnter",["pointerout","pointerover"]);yc("onPointerLeave",["pointerout","pointerover"]);sl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));sl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));sl("onBeforeInput",["compositionend","keypress","textInput","paste"]);sl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));sl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));sl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zu="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(" "),vO=new Set("cancel close invalid load scroll toggle".split(" ").concat(zu));function dN(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,b2(r,t,void 0,e),e.currentTarget=null}function sA(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;dN(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;dN(s,l,u),o=c}}}if(kh)throw e=zw,kh=!1,zw=null,e}function bn(e,t){var n=t[Jw];n===void 0&&(n=t[Jw]=new Set);var r=e+"__bubble";n.has(r)||(iA(t,e,2,!1),n.add(r))}function hy(e,t,n){var r=0;t&&(r|=4),iA(n,e,r,t)}var lp="_reactListening"+Math.random().toString(36).slice(2);function Sd(e){if(!e[lp]){e[lp]=!0,fE.forEach(function(n){n!=="selectionchange"&&(vO.has(n)||hy(n,!1,e),hy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[lp]||(t[lp]=!0,hy("selectionchange",!1,t))}}function iA(e,t,n,r){switch(HE(t)){case 1:var s=L2;break;case 4:s=O2;break;default:s=zb}n=s.bind(null,t,n,e),s=void 0,!Fw||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function my(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=Aa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}EE(function(){var u=o,d=Lb(n),f=[];e:{var p=rA.get(e);if(p!==void 0){var h=Hb,y=e;switch(e){case"keypress":if(Xp(n)===0)break e;case"keydown":case"keyup":h=Q2;break;case"focusin":y="focus",h=ly;break;case"focusout":y="blur",h=ly;break;case"beforeblur":case"afterblur":h=ly;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=Z0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=z2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=tO;break;case ZE:case eA:case tA:h=W2;break;case nA:h=rO;break;case"scroll":h=D2;break;case"wheel":h=iO;break;case"copy":case"cut":case"paste":h=K2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=tN}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var k=u,x;k!==null;){x=k;var N=x.stateNode;if(x.tag===5&&N!==null&&(x=N,g!==null&&(N=yd(k,g),N!=null&&v.push(Nd(k,N,x)))),b)break;k=k.return}0<v.length&&(p=new h(p,y,null,n,d),f.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==Ow&&(y=n.relatedTarget||n.fromElement)&&(Aa(y)||y[so]))break e;if((h||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?Aa(y):null,y!==null&&(b=il(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=Z0,N="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=tN,N="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?p:Kl(h),x=y==null?p:Kl(y),p=new v(N,k+"leave",h,n,d),p.target=b,p.relatedTarget=x,N=null,Aa(d)===u&&(v=new v(g,k+"enter",y,n,d),v.target=x,v.relatedTarget=b,N=v),b=N,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=El(x))k++;for(x=0,N=g;N;N=El(N))x++;for(;0<k-x;)v=El(v),k--;for(;0<x-k;)g=El(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=El(v),g=El(g)}v=null}else v=null;h!==null&&fN(f,p,h,v,!1),y!==null&&b!==null&&fN(f,b,y,v,!0)}}e:{if(p=u?Kl(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var j=fO;else if(sN(p))if(YE)j=gO;else{j=hO;var C=pO}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(j=mO);if(j&&(j=j(e,u))){UE(f,j,n,d);break e}C&&C(e,p,u),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Rw(p,"number",p.value)}switch(C=u?Kl(u):window,e){case"focusin":(sN(C)||C.contentEditable==="true")&&(Wl=C,Vw=u,Zu=null);break;case"focusout":Zu=Vw=Wl=null;break;case"mousedown":Kw=!0;break;case"contextmenu":case"mouseup":case"dragend":Kw=!1,cN(f,n,d);break;case"selectionchange":if(xO)break;case"keydown":case"keyup":cN(f,n,d)}var P;if(Vb)e:{switch(e){case"compositionstart":var I="onCompositionStart";break e;case"compositionend":I="onCompositionEnd";break e;case"compositionupdate":I="onCompositionUpdate";break e}I=void 0}else Hl?KE(e,n)&&(I="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(I="onCompositionStart");I&&(VE&&n.locale!=="ko"&&(Hl||I!=="onCompositionStart"?I==="onCompositionEnd"&&Hl&&(P=WE()):(Lo=d,Bb="value"in Lo?Lo.value:Lo.textContent,Hl=!0)),C=Ch(u,I),0<C.length&&(I=new eN(I,e,null,n,d),f.push({event:I,listeners:C}),P?I.data=P:(P=qE(n),P!==null&&(I.data=P)))),(P=aO?lO(e,n):cO(e,n))&&(u=Ch(u,"onBeforeInput"),0<u.length&&(d=new eN("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=P))}sA(f,t)})}function Nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ch(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=yd(e,n),o!=null&&r.unshift(Nd(e,o,s)),o=yd(e,t),o!=null&&r.push(Nd(e,o,s))),e=e.return}return r}function El(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function fN(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=yd(n,o),c!=null&&a.unshift(Nd(n,c,l))):s||(c=yd(n,o),c!=null&&a.push(Nd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var SO=/\r\n?/g,NO=/\u0000|\uFFFD/g;function pN(e){return(typeof e=="string"?e:""+e).replace(SO,`
|
|
38
|
+
`).replace(NO,"")}function cp(e,t,n){if(t=pN(t),pN(e)!==t&&n)throw Error(Ae(425))}function _h(){}var qw=null,Uw=null;function Yw(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 Gw=typeof setTimeout=="function"?setTimeout:void 0,jO=typeof clearTimeout=="function"?clearTimeout:void 0,hN=typeof Promise=="function"?Promise:void 0,CO=typeof queueMicrotask=="function"?queueMicrotask:typeof hN<"u"?function(e){return hN.resolve(null).then(e).catch(_O)}:Gw;function _O(e){setTimeout(function(){throw e})}function gy(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),bd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);bd(t)}function Wo(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 mN(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 Dc=Math.random().toString(36).slice(2),wi="__reactFiber$"+Dc,jd="__reactProps$"+Dc,so="__reactContainer$"+Dc,Jw="__reactEvents$"+Dc,EO="__reactListeners$"+Dc,AO="__reactHandles$"+Dc;function Aa(e){var t=e[wi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[so]||n[wi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mN(e);e!==null;){if(n=e[wi])return n;e=mN(e)}return t}e=n,n=e.parentNode}return null}function sf(e){return e=e[wi]||e[so],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Kl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ae(33))}function Rm(e){return e[jd]||null}var Xw=[],ql=-1;function oa(e){return{current:e}}function vn(e){0>ql||(e.current=Xw[ql],Xw[ql]=null,ql--)}function hn(e,t){ql++,Xw[ql]=e.current,e.current=t}var Xo={},_r=oa(Xo),Jr=oa(!1),Ha=Xo;function wc(e,t){var n=e.type.contextTypes;if(!n)return Xo;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 Xr(e){return e=e.childContextTypes,e!=null}function Eh(){vn(Jr),vn(_r)}function gN(e,t,n){if(_r.current!==Xo)throw Error(Ae(168));hn(_r,t),hn(Jr,n)}function oA(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(Ae(108,p2(e)||"Unknown",s));return $n({},n,r)}function Ah(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Xo,Ha=_r.current,hn(_r,e),hn(Jr,Jr.current),!0}function yN(e,t,n){var r=e.stateNode;if(!r)throw Error(Ae(169));n?(e=oA(e,t,Ha),r.__reactInternalMemoizedMergedChildContext=e,vn(Jr),vn(_r),hn(_r,e)):vn(Jr),hn(Jr,n)}var qi=null,Tm=!1,yy=!1;function aA(e){qi===null?qi=[e]:qi.push(e)}function PO(e){Tm=!0,aA(e)}function aa(){if(!yy&&qi!==null){yy=!0;var e=0,t=sn;try{var n=qi;for(sn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}qi=null,Tm=!1}catch(s){throw qi!==null&&(qi=qi.slice(e+1)),RE(Ob,aa),s}finally{sn=t,yy=!1}}return null}var Ul=[],Yl=0,Ph=null,Ih=0,js=[],Cs=0,Wa=null,Yi=1,Gi="";function va(e,t){Ul[Yl++]=Ih,Ul[Yl++]=Ph,Ph=e,Ih=t}function lA(e,t,n){js[Cs++]=Yi,js[Cs++]=Gi,js[Cs++]=Wa,Wa=e;var r=Yi;e=Gi;var s=32-Qs(r)-1;r&=~(1<<s),n+=1;var o=32-Qs(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Yi=1<<32-Qs(t)+s|n<<s|r,Gi=o+e}else Yi=1<<o|n<<s|r,Gi=e}function qb(e){e.return!==null&&(va(e,1),lA(e,1,0))}function Ub(e){for(;e===Ph;)Ph=Ul[--Yl],Ul[Yl]=null,Ih=Ul[--Yl],Ul[Yl]=null;for(;e===Wa;)Wa=js[--Cs],js[Cs]=null,Gi=js[--Cs],js[Cs]=null,Yi=js[--Cs],js[Cs]=null}var us=null,ls=null,Cn=!1,Us=null;function cA(e,t){var n=As(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 wN(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,us=e,ls=Wo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,us=e,ls=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Wa!==null?{id:Yi,overflow:Gi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=As(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,us=e,ls=null,!0):!1;default:return!1}}function Qw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Zw(e){if(Cn){var t=ls;if(t){var n=t;if(!wN(e,t)){if(Qw(e))throw Error(Ae(418));t=Wo(n.nextSibling);var r=us;t&&wN(e,t)?cA(r,n):(e.flags=e.flags&-4097|2,Cn=!1,us=e)}}else{if(Qw(e))throw Error(Ae(418));e.flags=e.flags&-4097|2,Cn=!1,us=e}}}function xN(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;us=e}function up(e){if(e!==us)return!1;if(!Cn)return xN(e),Cn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Yw(e.type,e.memoizedProps)),t&&(t=ls)){if(Qw(e))throw uA(),Error(Ae(418));for(;t;)cA(e,t),t=Wo(t.nextSibling)}if(xN(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ae(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ls=Wo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ls=null}}else ls=us?Wo(e.stateNode.nextSibling):null;return!0}function uA(){for(var e=ls;e;)e=Wo(e.nextSibling)}function xc(){ls=us=null,Cn=!1}function Yb(e){Us===null?Us=[e]:Us.push(e)}var IO=uo.ReactCurrentBatchConfig;function Su(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ae(309));var r=n.stateNode}if(!r)throw Error(Ae(147,e));var s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=s.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Ae(284));if(!n._owner)throw Error(Ae(290,e))}return e}function dp(e,t){throw e=Object.prototype.toString.call(t),Error(Ae(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function bN(e){var t=e._init;return t(e._payload)}function dA(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=Uo(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,N){return k===null||k.tag!==6?(k=Ny(x,g.mode,N),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,N){var j=x.type;return j===Bl?d(g,k,x.props.children,N,x.key):k!==null&&(k.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ao&&bN(j)===k.type)?(N=s(k,x.props),N.ref=Su(g,k,x),N.return=g,N):(N=sh(x.type,x.key,x.props,null,g.mode,N),N.ref=Su(g,k,x),N.return=g,N)}function u(g,k,x,N){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=jy(x,g.mode,N),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function d(g,k,x,N,j){return k===null||k.tag!==7?(k=La(x,g.mode,N,j),k.return=g,k):(k=s(k,x),k.return=g,k)}function f(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Ny(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case ep:return x=sh(k.type,k.key,k.props,null,g.mode,x),x.ref=Su(g,null,k),x.return=g,x;case zl:return k=jy(k,g.mode,x),k.return=g,k;case Ao:var N=k._init;return f(g,N(k._payload),x)}if(Du(k)||wu(k))return k=La(k,g.mode,x,null),k.return=g,k;dp(g,k)}return null}function p(g,k,x,N){var j=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return j!==null?null:l(g,k,""+x,N);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case ep:return x.key===j?c(g,k,x,N):null;case zl:return x.key===j?u(g,k,x,N):null;case Ao:return j=x._init,p(g,k,j(x._payload),N)}if(Du(x)||wu(x))return j!==null?null:d(g,k,x,N,null);dp(g,x)}return null}function h(g,k,x,N,j){if(typeof N=="string"&&N!==""||typeof N=="number")return g=g.get(x)||null,l(k,g,""+N,j);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case ep:return g=g.get(N.key===null?x:N.key)||null,c(k,g,N,j);case zl:return g=g.get(N.key===null?x:N.key)||null,u(k,g,N,j);case Ao:var C=N._init;return h(g,k,x,C(N._payload),j)}if(Du(N)||wu(N))return g=g.get(x)||null,d(k,g,N,j,null);dp(k,N)}return null}function y(g,k,x,N){for(var j=null,C=null,P=k,I=k=0,F=null;P!==null&&I<x.length;I++){P.index>I?(F=P,P=null):F=P.sibling;var $=p(g,P,x[I],N);if($===null){P===null&&(P=F);break}e&&P&&$.alternate===null&&t(g,P),k=o($,k,I),C===null?j=$:C.sibling=$,C=$,P=F}if(I===x.length)return n(g,P),Cn&&va(g,I),j;if(P===null){for(;I<x.length;I++)P=f(g,x[I],N),P!==null&&(k=o(P,k,I),C===null?j=P:C.sibling=P,C=P);return Cn&&va(g,I),j}for(P=r(g,P);I<x.length;I++)F=h(P,g,I,x[I],N),F!==null&&(e&&F.alternate!==null&&P.delete(F.key===null?I:F.key),k=o(F,k,I),C===null?j=F:C.sibling=F,C=F);return e&&P.forEach(function(D){return t(g,D)}),Cn&&va(g,I),j}function v(g,k,x,N){var j=wu(x);if(typeof j!="function")throw Error(Ae(150));if(x=j.call(x),x==null)throw Error(Ae(151));for(var C=j=null,P=k,I=k=0,F=null,$=x.next();P!==null&&!$.done;I++,$=x.next()){P.index>I?(F=P,P=null):F=P.sibling;var D=p(g,P,$.value,N);if(D===null){P===null&&(P=F);break}e&&P&&D.alternate===null&&t(g,P),k=o(D,k,I),C===null?j=D:C.sibling=D,C=D,P=F}if($.done)return n(g,P),Cn&&va(g,I),j;if(P===null){for(;!$.done;I++,$=x.next())$=f(g,$.value,N),$!==null&&(k=o($,k,I),C===null?j=$:C.sibling=$,C=$);return Cn&&va(g,I),j}for(P=r(g,P);!$.done;I++,$=x.next())$=h(P,g,I,$.value,N),$!==null&&(e&&$.alternate!==null&&P.delete($.key===null?I:$.key),k=o($,k,I),C===null?j=$:C.sibling=$,C=$);return e&&P.forEach(function(z){return t(g,z)}),Cn&&va(g,I),j}function b(g,k,x,N){if(typeof x=="object"&&x!==null&&x.type===Bl&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ep:e:{for(var j=x.key,C=k;C!==null;){if(C.key===j){if(j=x.type,j===Bl){if(C.tag===7){n(g,C.sibling),k=s(C,x.props.children),k.return=g,g=k;break e}}else if(C.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ao&&bN(j)===C.type){n(g,C.sibling),k=s(C,x.props),k.ref=Su(g,C,x),k.return=g,g=k;break e}n(g,C);break}else t(g,C);C=C.sibling}x.type===Bl?(k=La(x.props.children,g.mode,N,x.key),k.return=g,g=k):(N=sh(x.type,x.key,x.props,null,g.mode,N),N.ref=Su(g,k,x),N.return=g,g=N)}return a(g);case zl:e:{for(C=x.key;k!==null;){if(k.key===C)if(k.tag===4&&k.stateNode.containerInfo===x.containerInfo&&k.stateNode.implementation===x.implementation){n(g,k.sibling),k=s(k,x.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=jy(x,g.mode,N),k.return=g,g=k}return a(g);case Ao:return C=x._init,b(g,k,C(x._payload),N)}if(Du(x))return y(g,k,x,N);if(wu(x))return v(g,k,x,N);dp(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=Ny(x,g.mode,N),k.return=g,g=k),a(g)):n(g,k)}return b}var bc=dA(!0),fA=dA(!1),Rh=oa(null),Th=null,Gl=null,Gb=null;function Jb(){Gb=Gl=Th=null}function Xb(e){var t=Rh.current;vn(Rh),e._currentValue=t}function ex(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 ac(e,t){Th=e,Gb=Gl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ur=!0),e.firstContext=null)}function Is(e){var t=e._currentValue;if(Gb!==e)if(e={context:e,memoizedValue:t,next:null},Gl===null){if(Th===null)throw Error(Ae(308));Gl=e,Th.dependencies={lanes:0,firstContext:e}}else Gl=Gl.next=e;return t}var Pa=null;function Qb(e){Pa===null?Pa=[e]:Pa.push(e)}function pA(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Qb(t)):(n.next=s.next,s.next=n),t.interleaved=n,io(e,r)}function io(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 Po=!1;function Zb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function hA(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 Zi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Vo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Kt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,io(e,n)}return s=r.interleaved,s===null?(t.next=t,Qb(r)):(t.next=s.next,s.next=t),r.interleaved=t,io(e,n)}function Qp(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,Db(e,n)}}function kN(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 Mh(e,t,n,r){var s=e.updateQueue;Po=!1;var o=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==a&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(o!==null){var f=s.baseState;a=0,d=u=c=null,l=o;do{var p=l.lane,h=l.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(p=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(h,f,p);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,p=typeof y=="function"?y.call(h,f,p):y,p==null)break e;f=$n({},f,p);break e;case 2:Po=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=h,c=f):d=d.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);Ka|=a,e.lanes=a,e.memoizedState=f}}function vN(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(Ae(191,s));s.call(r)}}}var of={},ji=oa(of),Cd=oa(of),_d=oa(of);function Ia(e){if(e===of)throw Error(Ae(174));return e}function ek(e,t){switch(hn(_d,t),hn(Cd,e),hn(ji,of),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Mw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Mw(t,e)}vn(ji),hn(ji,t)}function kc(){vn(ji),vn(Cd),vn(_d)}function mA(e){Ia(_d.current);var t=Ia(ji.current),n=Mw(t,e.type);t!==n&&(hn(Cd,e),hn(ji,n))}function tk(e){Cd.current===e&&(vn(ji),vn(Cd))}var Rn=oa(0);function $h(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 wy=[];function nk(){for(var e=0;e<wy.length;e++)wy[e]._workInProgressVersionPrimary=null;wy.length=0}var Zp=uo.ReactCurrentDispatcher,xy=uo.ReactCurrentBatchConfig,Va=0,Mn=null,tr=null,ur=null,Lh=!1,ed=!1,Ed=0,RO=0;function vr(){throw Error(Ae(321))}function rk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ti(e[n],t[n]))return!1;return!0}function sk(e,t,n,r,s,o){if(Va=o,Mn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Zp.current=e===null||e.memoizedState===null?LO:OO,e=n(r,s),ed){o=0;do{if(ed=!1,Ed=0,25<=o)throw Error(Ae(301));o+=1,ur=tr=null,t.updateQueue=null,Zp.current=DO,e=n(r,s)}while(ed)}if(Zp.current=Oh,t=tr!==null&&tr.next!==null,Va=0,ur=tr=Mn=null,Lh=!1,t)throw Error(Ae(300));return e}function ik(){var e=Ed!==0;return Ed=0,e}function hi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ur===null?Mn.memoizedState=ur=e:ur=ur.next=e,ur}function Rs(){if(tr===null){var e=Mn.alternate;e=e!==null?e.memoizedState:null}else e=tr.next;var t=ur===null?Mn.memoizedState:ur.next;if(t!==null)ur=t,tr=e;else{if(e===null)throw Error(Ae(310));tr=e,e={memoizedState:tr.memoizedState,baseState:tr.baseState,baseQueue:tr.baseQueue,queue:tr.queue,next:null},ur===null?Mn.memoizedState=ur=e:ur=ur.next=e}return ur}function Ad(e,t){return typeof t=="function"?t(e):t}function by(e){var t=Rs(),n=t.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=e;var r=tr,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=a=null,c=null,u=o;do{var d=u.lane;if((Va&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Mn.lanes|=d,Ka|=d}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,ti(r,t.memoizedState)||(Ur=!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,Mn.lanes|=o,Ka|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function ky(e){var t=Rs(),n=t.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do o=e(o,a.action),a=a.next;while(a!==s);ti(o,t.memoizedState)||(Ur=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function gA(){}function yA(e,t){var n=Mn,r=Rs(),s=t(),o=!ti(r.memoizedState,s);if(o&&(r.memoizedState=s,Ur=!0),r=r.queue,ok(bA.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||ur!==null&&ur.memoizedState.tag&1){if(n.flags|=2048,Pd(9,xA.bind(null,n,r,s,t),void 0,null),pr===null)throw Error(Ae(349));Va&30||wA(n,t,s)}return s}function wA(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Mn.updateQueue,t===null?(t={lastEffect:null,stores:null},Mn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function xA(e,t,n,r){t.value=n,t.getSnapshot=r,kA(t)&&vA(e)}function bA(e,t,n){return n(function(){kA(t)&&vA(e)})}function kA(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ti(e,n)}catch{return!0}}function vA(e){var t=io(e,1);t!==null&&Zs(t,e,1,-1)}function SN(e){var t=hi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ad,lastRenderedState:e},t.queue=e,e=e.dispatch=$O.bind(null,Mn,e),[t.memoizedState,e]}function Pd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Mn.updateQueue,t===null?(t={lastEffect:null,stores:null},Mn.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 SA(){return Rs().memoizedState}function eh(e,t,n,r){var s=hi();Mn.flags|=e,s.memoizedState=Pd(1|t,n,void 0,r===void 0?null:r)}function Mm(e,t,n,r){var s=Rs();r=r===void 0?null:r;var o=void 0;if(tr!==null){var a=tr.memoizedState;if(o=a.destroy,r!==null&&rk(r,a.deps)){s.memoizedState=Pd(t,n,o,r);return}}Mn.flags|=e,s.memoizedState=Pd(1|t,n,o,r)}function NN(e,t){return eh(8390656,8,e,t)}function ok(e,t){return Mm(2048,8,e,t)}function NA(e,t){return Mm(4,2,e,t)}function jA(e,t){return Mm(4,4,e,t)}function CA(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 _A(e,t,n){return n=n!=null?n.concat([e]):null,Mm(4,4,CA.bind(null,t,e),n)}function ak(){}function EA(e,t){var n=Rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&rk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function AA(e,t){var n=Rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&rk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function PA(e,t,n){return Va&21?(ti(n,t)||(n=$E(),Mn.lanes|=n,Ka|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ur=!0),e.memoizedState=n)}function TO(e,t){var n=sn;sn=n!==0&&4>n?n:4,e(!0);var r=xy.transition;xy.transition={};try{e(!1),t()}finally{sn=n,xy.transition=r}}function IA(){return Rs().memoizedState}function MO(e,t,n){var r=qo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},RA(e))TA(t,n);else if(n=pA(e,t,n,r),n!==null){var s=Lr();Zs(n,e,r,s),MA(n,t,r)}}function $O(e,t,n){var r=qo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(RA(e))TA(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,ti(l,a)){var c=t.interleaved;c===null?(s.next=s,Qb(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=pA(e,t,s,r),n!==null&&(s=Lr(),Zs(n,e,r,s),MA(n,t,r))}}function RA(e){var t=e.alternate;return e===Mn||t!==null&&t===Mn}function TA(e,t){ed=Lh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function MA(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Db(e,n)}}var Oh={readContext:Is,useCallback:vr,useContext:vr,useEffect:vr,useImperativeHandle:vr,useInsertionEffect:vr,useLayoutEffect:vr,useMemo:vr,useReducer:vr,useRef:vr,useState:vr,useDebugValue:vr,useDeferredValue:vr,useTransition:vr,useMutableSource:vr,useSyncExternalStore:vr,useId:vr,unstable_isNewReconciler:!1},LO={readContext:Is,useCallback:function(e,t){return hi().memoizedState=[e,t===void 0?null:t],e},useContext:Is,useEffect:NN,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,eh(4194308,4,CA.bind(null,t,e),n)},useLayoutEffect:function(e,t){return eh(4194308,4,e,t)},useInsertionEffect:function(e,t){return eh(4,2,e,t)},useMemo:function(e,t){var n=hi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=hi();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=MO.bind(null,Mn,e),[r.memoizedState,e]},useRef:function(e){var t=hi();return e={current:e},t.memoizedState=e},useState:SN,useDebugValue:ak,useDeferredValue:function(e){return hi().memoizedState=e},useTransition:function(){var e=SN(!1),t=e[0];return e=TO.bind(null,e[1]),hi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Mn,s=hi();if(Cn){if(n===void 0)throw Error(Ae(407));n=n()}else{if(n=t(),pr===null)throw Error(Ae(349));Va&30||wA(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,NN(bA.bind(null,r,o,e),[e]),r.flags|=2048,Pd(9,xA.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=hi(),t=pr.identifierPrefix;if(Cn){var n=Gi,r=Yi;n=(r&~(1<<32-Qs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ed++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=RO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},OO={readContext:Is,useCallback:EA,useContext:Is,useEffect:ok,useImperativeHandle:_A,useInsertionEffect:NA,useLayoutEffect:jA,useMemo:AA,useReducer:by,useRef:SA,useState:function(){return by(Ad)},useDebugValue:ak,useDeferredValue:function(e){var t=Rs();return PA(t,tr.memoizedState,e)},useTransition:function(){var e=by(Ad)[0],t=Rs().memoizedState;return[e,t]},useMutableSource:gA,useSyncExternalStore:yA,useId:IA,unstable_isNewReconciler:!1},DO={readContext:Is,useCallback:EA,useContext:Is,useEffect:ok,useImperativeHandle:_A,useInsertionEffect:NA,useLayoutEffect:jA,useMemo:AA,useReducer:ky,useRef:SA,useState:function(){return ky(Ad)},useDebugValue:ak,useDeferredValue:function(e){var t=Rs();return tr===null?t.memoizedState=e:PA(t,tr.memoizedState,e)},useTransition:function(){var e=ky(Ad)[0],t=Rs().memoizedState;return[e,t]},useMutableSource:gA,useSyncExternalStore:yA,useId:IA,unstable_isNewReconciler:!1};function Vs(e,t){if(e&&e.defaultProps){t=$n({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function tx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:$n({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var $m={isMounted:function(e){return(e=e._reactInternals)?il(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Lr(),s=qo(e),o=Zi(r,s);o.payload=t,n!=null&&(o.callback=n),t=Vo(e,o,s),t!==null&&(Zs(t,e,s,r),Qp(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Lr(),s=qo(e),o=Zi(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Vo(e,o,s),t!==null&&(Zs(t,e,s,r),Qp(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Lr(),r=qo(e),s=Zi(n,r);s.tag=2,t!=null&&(s.callback=t),t=Vo(e,s,r),t!==null&&(Zs(t,e,r,n),Qp(t,e,r))}};function jN(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?!vd(n,r)||!vd(s,o):!0}function $A(e,t,n){var r=!1,s=Xo,o=t.contextType;return typeof o=="object"&&o!==null?o=Is(o):(s=Xr(t)?Ha:_r.current,r=t.contextTypes,o=(r=r!=null)?wc(e,s):Xo),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=$m,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function CN(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&&$m.enqueueReplaceState(t,t.state,null)}function nx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Zb(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Is(o):(o=Xr(t)?Ha:_r.current,s.context=wc(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(tx(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&&$m.enqueueReplaceState(s,s.state,null),Mh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function vc(e,t){try{var n="",r=t;do n+=f2(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 vy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function rx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var FO=typeof WeakMap=="function"?WeakMap:Map;function LA(e,t,n){n=Zi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Fh||(Fh=!0,px=r),rx(e,t)},n}function OA(e,t,n){n=Zi(-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(){rx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){rx(e,t),typeof r!="function"&&(Ko===null?Ko=new Set([this]):Ko.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function _N(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new FO;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=ZO.bind(null,e,t,n),t.then(e,e))}function EN(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 AN(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=Zi(-1,1),t.tag=2,Vo(n,t,1))),n.lanes|=1),e)}var zO=uo.ReactCurrentOwner,Ur=!1;function Mr(e,t,n,r){t.child=e===null?fA(t,null,n,r):bc(t,e.child,n,r)}function PN(e,t,n,r,s){n=n.render;var o=t.ref;return ac(t,s),r=sk(e,t,n,r,o,s),n=ik(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(Cn&&n&&qb(t),t.flags|=1,Mr(e,t,r,s),t.child)}function IN(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!mk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,DA(e,t,o,r,s)):(e=sh(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:vd,n(a,r)&&e.ref===t.ref)return oo(e,t,s)}return t.flags|=1,e=Uo(o,r),e.ref=t.ref,e.return=t,t.child=e}function DA(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(vd(o,r)&&e.ref===t.ref)if(Ur=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Ur=!0);else return t.lanes=e.lanes,oo(e,t,s)}return sx(e,t,n,r,s)}function FA(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},hn(Xl,is),is|=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,hn(Xl,is),is|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,hn(Xl,is),is|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,hn(Xl,is),is|=r;return Mr(e,t,s,n),t.child}function zA(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function sx(e,t,n,r,s){var o=Xr(n)?Ha:_r.current;return o=wc(t,o),ac(t,s),n=sk(e,t,n,r,o,s),r=ik(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(Cn&&r&&qb(t),t.flags|=1,Mr(e,t,n,s),t.child)}function RN(e,t,n,r,s){if(Xr(n)){var o=!0;Ah(t)}else o=!1;if(ac(t,s),t.stateNode===null)th(e,t),$A(t,n,r),nx(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=Is(u):(u=Xr(n)?Ha:_r.current,u=wc(t,u));var d=n.getDerivedStateFromProps,f=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&CN(t,a,r,u),Po=!1;var p=t.memoizedState;a.state=p,Mh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Jr.current||Po?(typeof d=="function"&&(tx(t,n,d,r),c=t.memoizedState),(l=Po||jN(t,n,l,r,p,c,u))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,hA(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Vs(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Is(c):(c=Xr(n)?Ha:_r.current,c=wc(t,c));var h=n.getDerivedStateFromProps;(d=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&CN(t,a,r,c),Po=!1,p=t.memoizedState,a.state=p,Mh(t,r,a,s);var y=t.memoizedState;l!==f||p!==y||Jr.current||Po?(typeof h=="function"&&(tx(t,n,h,r),y=t.memoizedState),(u=Po||jN(t,n,u,r,p,y,c)||!1)?(d||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return ix(e,t,n,r,o,s)}function ix(e,t,n,r,s,o){zA(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&yN(t,n,!1),oo(e,t,o);r=t.stateNode,zO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=bc(t,e.child,null,o),t.child=bc(t,null,l,o)):Mr(e,t,l,o),t.memoizedState=r.state,s&&yN(t,n,!0),t.child}function BA(e){var t=e.stateNode;t.pendingContext?gN(e,t.pendingContext,t.pendingContext!==t.context):t.context&&gN(e,t.context,!1),ek(e,t.containerInfo)}function TN(e,t,n,r,s){return xc(),Yb(s),t.flags|=256,Mr(e,t,n,r),t.child}var ox={dehydrated:null,treeContext:null,retryLane:0};function ax(e){return{baseLanes:e,cachePool:null,transitions:null}}function HA(e,t,n){var r=t.pendingProps,s=Rn.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),hn(Rn,s&1),e===null)return Zw(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=Dm(a,r,0,null),e=La(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=ax(n),t.memoizedState=ox,e):lk(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return BO(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=Uo(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=Uo(l,o):(o=La(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?ax(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=ox,r}return o=e.child,e=o.sibling,r=Uo(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 lk(e,t){return t=Dm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function fp(e,t,n,r){return r!==null&&Yb(r),bc(t,e.child,null,n),e=lk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function BO(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=vy(Error(Ae(422))),fp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Dm({mode:"visible",children:r.children},s,0,null),o=La(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&bc(t,e.child,null,a),t.child.memoizedState=ax(a),t.memoizedState=ox,o);if(!(t.mode&1))return fp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ae(419)),r=vy(o,r,void 0),fp(e,t,a,r)}if(l=(a&e.childLanes)!==0,Ur||l){if(r=pr,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,io(e,s),Zs(r,e,s,-1))}return hk(),r=vy(Error(Ae(421))),fp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=eD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ls=Wo(s.nextSibling),us=t,Cn=!0,Us=null,e!==null&&(js[Cs++]=Yi,js[Cs++]=Gi,js[Cs++]=Wa,Yi=e.id,Gi=e.overflow,Wa=t),t=lk(t,r.children),t.flags|=4096,t)}function MN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ex(e.return,t,n)}function Sy(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 WA(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Mr(e,t,r.children,n),r=Rn.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&&MN(e,n,t);else if(e.tag===19)MN(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(hn(Rn,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&&$h(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Sy(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&&$h(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Sy(t,!0,n,null,o);break;case"together":Sy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function th(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function oo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ka|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ae(153));if(t.child!==null){for(e=t.child,n=Uo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Uo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function HO(e,t,n){switch(t.tag){case 3:BA(t),xc();break;case 5:mA(t);break;case 1:Xr(t.type)&&Ah(t);break;case 4:ek(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;hn(Rh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(hn(Rn,Rn.current&1),t.flags|=128,null):n&t.child.childLanes?HA(e,t,n):(hn(Rn,Rn.current&1),e=oo(e,t,n),e!==null?e.sibling:null);hn(Rn,Rn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return WA(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),hn(Rn,Rn.current),r)break;return null;case 22:case 23:return t.lanes=0,FA(e,t,n)}return oo(e,t,n)}var VA,lx,KA,qA;VA=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}};lx=function(){};KA=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Ia(ji.current);var o=null;switch(n){case"input":s=Pw(e,s),r=Pw(e,r),o=[];break;case"select":s=$n({},s,{value:void 0}),r=$n({},r,{value:void 0}),o=[];break;case"textarea":s=Tw(e,s),r=Tw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=_h)}$w(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"&&(md.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"&&(md.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&bn("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)}};qA=function(e,t,n,r){n!==r&&(t.flags|=4)};function Nu(e,t){if(!Cn)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 Sr(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 WO(e,t,n){var r=t.pendingProps;switch(Ub(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sr(t),null;case 1:return Xr(t.type)&&Eh(),Sr(t),null;case 3:return r=t.stateNode,kc(),vn(Jr),vn(_r),nk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(up(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Us!==null&&(gx(Us),Us=null))),lx(e,t),Sr(t),null;case 5:tk(t);var s=Ia(_d.current);if(n=t.type,e!==null&&t.stateNode!=null)KA(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ae(166));return Sr(t),null}if(e=Ia(ji.current),up(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[wi]=t,r[jd]=o,e=(t.mode&1)!==0,n){case"dialog":bn("cancel",r),bn("close",r);break;case"iframe":case"object":case"embed":bn("load",r);break;case"video":case"audio":for(s=0;s<zu.length;s++)bn(zu[s],r);break;case"source":bn("error",r);break;case"img":case"image":case"link":bn("error",r),bn("load",r);break;case"details":bn("toggle",r);break;case"input":W0(r,o),bn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},bn("invalid",r);break;case"textarea":K0(r,o),bn("invalid",r)}$w(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&&cp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&cp(r.textContent,l,e),s=["children",""+l]):md.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&bn("scroll",r)}switch(n){case"input":tp(r),V0(r,o,!0);break;case"textarea":tp(r),q0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=_h)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=bE(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[wi]=t,e[jd]=r,VA(e,t,!1,!1),t.stateNode=e;e:{switch(a=Lw(n,r),n){case"dialog":bn("cancel",e),bn("close",e),s=r;break;case"iframe":case"object":case"embed":bn("load",e),s=r;break;case"video":case"audio":for(s=0;s<zu.length;s++)bn(zu[s],e);s=r;break;case"source":bn("error",e),s=r;break;case"img":case"image":case"link":bn("error",e),bn("load",e),s=r;break;case"details":bn("toggle",e),s=r;break;case"input":W0(e,r),s=Pw(e,r),bn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=$n({},r,{value:void 0}),bn("invalid",e);break;case"textarea":K0(e,r),s=Tw(e,r),bn("invalid",e);break;default:s=r}$w(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?SE(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&kE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&gd(e,c):typeof c=="number"&&gd(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(md.hasOwnProperty(o)?c!=null&&o==="onScroll"&&bn("scroll",e):c!=null&&Rb(e,o,c,a))}switch(n){case"input":tp(e),V0(e,r,!1);break;case"textarea":tp(e),q0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Jo(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?rc(e,!!r.multiple,o,!1):r.defaultValue!=null&&rc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=_h)}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 Sr(t),null;case 6:if(e&&t.stateNode!=null)qA(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ae(166));if(n=Ia(_d.current),Ia(ji.current),up(t)){if(r=t.stateNode,n=t.memoizedProps,r[wi]=t,(o=r.nodeValue!==n)&&(e=us,e!==null))switch(e.tag){case 3:cp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&cp(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[wi]=t,t.stateNode=r}return Sr(t),null;case 13:if(vn(Rn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Cn&&ls!==null&&t.mode&1&&!(t.flags&128))uA(),xc(),t.flags|=98560,o=!1;else if(o=up(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ae(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ae(317));o[wi]=t}else xc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Sr(t),o=!1}else Us!==null&&(gx(Us),Us=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||Rn.current&1?nr===0&&(nr=3):hk())),t.updateQueue!==null&&(t.flags|=4),Sr(t),null);case 4:return kc(),lx(e,t),e===null&&Sd(t.stateNode.containerInfo),Sr(t),null;case 10:return Xb(t.type._context),Sr(t),null;case 17:return Xr(t.type)&&Eh(),Sr(t),null;case 19:if(vn(Rn),o=t.memoizedState,o===null)return Sr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Nu(o,!1);else{if(nr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=$h(e),a!==null){for(t.flags|=128,Nu(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 hn(Rn,Rn.current&1|2),t.child}e=e.sibling}o.tail!==null&&Wn()>Sc&&(t.flags|=128,r=!0,Nu(o,!1),t.lanes=4194304)}else{if(!r)if(e=$h(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Cn)return Sr(t),null}else 2*Wn()-o.renderingStartTime>Sc&&n!==1073741824&&(t.flags|=128,r=!0,Nu(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=Wn(),t.sibling=null,n=Rn.current,hn(Rn,r?n&1|2:n&1),t):(Sr(t),null);case 22:case 23:return pk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?is&1073741824&&(Sr(t),t.subtreeFlags&6&&(t.flags|=8192)):Sr(t),null;case 24:return null;case 25:return null}throw Error(Ae(156,t.tag))}function VO(e,t){switch(Ub(t),t.tag){case 1:return Xr(t.type)&&Eh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return kc(),vn(Jr),vn(_r),nk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return tk(t),null;case 13:if(vn(Rn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ae(340));xc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return vn(Rn),null;case 4:return kc(),null;case 10:return Xb(t.type._context),null;case 22:case 23:return pk(),null;case 24:return null;default:return null}}var pp=!1,Nr=!1,KO=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Jl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Fn(e,t,r)}else n.current=null}function cx(e,t,n){try{n()}catch(r){Fn(e,t,r)}}var $N=!1;function qO(e,t){if(qw=Nh,e=XE(),Kb(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,u=0,d=0,f=e,p=null;t:for(;;){for(var h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)p=f,f=h;for(;;){if(f===e)break t;if(p===n&&++u===s&&(l=a),p===o&&++d===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Uw={focusedElem:e,selectionRange:n},Nh=!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:Vs(t.type,v),b);g.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ae(163))}}catch(N){Fn(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,Qe=e;break}Qe=t.return}return y=$N,$N=!1,y}function td(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&&cx(t,n,o)}s=s.next}while(s!==r)}}function Lm(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 ux(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 UA(e){var t=e.alternate;t!==null&&(e.alternate=null,UA(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[jd],delete t[Jw],delete t[EO],delete t[AO])),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 YA(e){return e.tag===5||e.tag===3||e.tag===4}function LN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||YA(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 dx(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=_h));else if(r!==4&&(e=e.child,e!==null))for(dx(e,t,n),e=e.sibling;e!==null;)dx(e,t,n),e=e.sibling}function fx(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(fx(e,t,n),e=e.sibling;e!==null;)fx(e,t,n),e=e.sibling}var mr=null,Ks=!1;function So(e,t,n){for(n=n.child;n!==null;)GA(e,t,n),n=n.sibling}function GA(e,t,n){if(Ni&&typeof Ni.onCommitFiberUnmount=="function")try{Ni.onCommitFiberUnmount(Em,n)}catch{}switch(n.tag){case 5:Nr||Jl(n,t);case 6:var r=mr,s=Ks;mr=null,So(e,t,n),mr=r,Ks=s,mr!==null&&(Ks?(e=mr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):mr.removeChild(n.stateNode));break;case 18:mr!==null&&(Ks?(e=mr,n=n.stateNode,e.nodeType===8?gy(e.parentNode,n):e.nodeType===1&&gy(e,n),bd(e)):gy(mr,n.stateNode));break;case 4:r=mr,s=Ks,mr=n.stateNode.containerInfo,Ks=!0,So(e,t,n),mr=r,Ks=s;break;case 0:case 11:case 14:case 15:if(!Nr&&(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)&&cx(n,t,a),s=s.next}while(s!==r)}So(e,t,n);break;case 1:if(!Nr&&(Jl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Fn(n,t,l)}So(e,t,n);break;case 21:So(e,t,n);break;case 22:n.mode&1?(Nr=(r=Nr)||n.memoizedState!==null,So(e,t,n),Nr=r):So(e,t,n);break;default:So(e,t,n)}}function ON(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new KO),t.forEach(function(r){var s=tD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Bs(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:mr=l.stateNode,Ks=!1;break e;case 3:mr=l.stateNode.containerInfo,Ks=!0;break e;case 4:mr=l.stateNode.containerInfo,Ks=!0;break e}l=l.return}if(mr===null)throw Error(Ae(160));GA(o,a,s),mr=null,Ks=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Fn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)JA(t,e),t=t.sibling}function JA(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Bs(t,e),di(e),r&4){try{td(3,e,e.return),Lm(3,e)}catch(v){Fn(e,e.return,v)}try{td(5,e,e.return)}catch(v){Fn(e,e.return,v)}}break;case 1:Bs(t,e),di(e),r&512&&n!==null&&Jl(n,n.return);break;case 5:if(Bs(t,e),di(e),r&512&&n!==null&&Jl(n,n.return),e.flags&32){var s=e.stateNode;try{gd(s,"")}catch(v){Fn(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&&wE(s,o),Lw(l,a);var u=Lw(l,o);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?SE(s,f):d==="dangerouslySetInnerHTML"?kE(s,f):d==="children"?gd(s,f):Rb(s,d,f,u)}switch(l){case"input":Iw(s,o);break;case"textarea":xE(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?rc(s,!!o.multiple,h,!1):p!==!!o.multiple&&(o.defaultValue!=null?rc(s,!!o.multiple,o.defaultValue,!0):rc(s,!!o.multiple,o.multiple?[]:"",!1))}s[jd]=o}catch(v){Fn(e,e.return,v)}}break;case 6:if(Bs(t,e),di(e),r&4){if(e.stateNode===null)throw Error(Ae(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){Fn(e,e.return,v)}}break;case 3:if(Bs(t,e),di(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{bd(t.containerInfo)}catch(v){Fn(e,e.return,v)}break;case 4:Bs(t,e),di(e);break;case 13:Bs(t,e),di(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(dk=Wn())),r&4&&ON(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Nr=(u=Nr)||d,Bs(t,e),Nr=u):Bs(t,e),di(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(Qe=e,d=e.child;d!==null;){for(f=Qe=d;Qe!==null;){switch(p=Qe,h=p.child,p.tag){case 0:case 11:case 14:case 15:td(4,p,p.return);break;case 1:Jl(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Fn(r,n,v)}}break;case 5:Jl(p,p.return);break;case 22:if(p.memoizedState!==null){FN(f);continue}}h!==null?(h.return=p,Qe=h):FN(f)}d=d.sibling}e:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{s=f.stateNode,u?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=vE("display",a))}catch(v){Fn(e,e.return,v)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){Fn(e,e.return,v)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Bs(t,e),di(e),r&4&&ON(e);break;case 21:break;default:Bs(t,e),di(e)}}function di(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(YA(n)){var r=n;break e}n=n.return}throw Error(Ae(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(gd(s,""),r.flags&=-33);var o=LN(e);fx(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=LN(e);dx(e,l,a);break;default:throw Error(Ae(161))}}catch(c){Fn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function UO(e,t,n){Qe=e,XA(e)}function XA(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||pp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Nr;l=pp;var u=Nr;if(pp=a,(Nr=c)&&!u)for(Qe=s;Qe!==null;)a=Qe,c=a.child,a.tag===22&&a.memoizedState!==null?zN(s):c!==null?(c.return=a,Qe=c):zN(s);for(;o!==null;)Qe=o,XA(o),o=o.sibling;Qe=s,pp=l,Nr=u}DN(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Qe=o):DN(e)}}function DN(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:Nr||Lm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Nr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Vs(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&vN(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}vN(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&bd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ae(163))}Nr||t.flags&512&&ux(t)}catch(p){Fn(t,t.return,p)}}if(t===e){Qe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Qe=n;break}Qe=t.return}}function FN(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 zN(e){for(;Qe!==null;){var t=Qe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Lm(4,t)}catch(c){Fn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Fn(t,s,c)}}var o=t.return;try{ux(t)}catch(c){Fn(t,o,c)}break;case 5:var a=t.return;try{ux(t)}catch(c){Fn(t,a,c)}}}catch(c){Fn(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 YO=Math.ceil,Dh=uo.ReactCurrentDispatcher,ck=uo.ReactCurrentOwner,Ps=uo.ReactCurrentBatchConfig,Kt=0,pr=null,Yn=null,gr=0,is=0,Xl=oa(0),nr=0,Id=null,Ka=0,Om=0,uk=0,nd=null,Kr=null,dk=0,Sc=1/0,Ki=null,Fh=!1,px=null,Ko=null,hp=!1,Oo=null,zh=0,rd=0,hx=null,nh=-1,rh=0;function Lr(){return Kt&6?Wn():nh!==-1?nh:nh=Wn()}function qo(e){return e.mode&1?Kt&2&&gr!==0?gr&-gr:IO.transition!==null?(rh===0&&(rh=$E()),rh):(e=sn,e!==0||(e=window.event,e=e===void 0?16:HE(e.type)),e):1}function Zs(e,t,n,r){if(50<rd)throw rd=0,hx=null,Error(Ae(185));nf(e,n,r),(!(Kt&2)||e!==pr)&&(e===pr&&(!(Kt&2)&&(Om|=n),nr===4&&To(e,gr)),Qr(e,r),n===1&&Kt===0&&!(t.mode&1)&&(Sc=Wn()+500,Tm&&aa()))}function Qr(e,t){var n=e.callbackNode;I2(e,t);var r=Sh(e,e===pr?gr:0);if(r===0)n!==null&&G0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&G0(n),t===1)e.tag===0?PO(BN.bind(null,e)):aA(BN.bind(null,e)),CO(function(){!(Kt&6)&&aa()}),n=null;else{switch(LE(r)){case 1:n=Ob;break;case 4:n=TE;break;case 16:n=vh;break;case 536870912:n=ME;break;default:n=vh}n=iP(n,QA.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function QA(e,t){if(nh=-1,rh=0,Kt&6)throw Error(Ae(327));var n=e.callbackNode;if(lc()&&e.callbackNode!==n)return null;var r=Sh(e,e===pr?gr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Bh(e,r);else{t=r;var s=Kt;Kt|=2;var o=eP();(pr!==e||gr!==t)&&(Ki=null,Sc=Wn()+500,$a(e,t));do try{XO();break}catch(l){ZA(e,l)}while(!0);Jb(),Dh.current=o,Kt=s,Yn!==null?t=0:(pr=null,gr=0,t=nr)}if(t!==0){if(t===2&&(s=Bw(e),s!==0&&(r=s,t=mx(e,s))),t===1)throw n=Id,$a(e,0),To(e,r),Qr(e,Wn()),n;if(t===6)To(e,r);else{if(s=e.current.alternate,!(r&30)&&!GO(s)&&(t=Bh(e,r),t===2&&(o=Bw(e),o!==0&&(r=o,t=mx(e,o))),t===1))throw n=Id,$a(e,0),To(e,r),Qr(e,Wn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ae(345));case 2:Sa(e,Kr,Ki);break;case 3:if(To(e,r),(r&130023424)===r&&(t=dk+500-Wn(),10<t)){if(Sh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Lr(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Gw(Sa.bind(null,e,Kr,Ki),t);break}Sa(e,Kr,Ki);break;case 4:if(To(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Qs(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Wn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*YO(r/1960))-r,10<r){e.timeoutHandle=Gw(Sa.bind(null,e,Kr,Ki),r);break}Sa(e,Kr,Ki);break;case 5:Sa(e,Kr,Ki);break;default:throw Error(Ae(329))}}}return Qr(e,Wn()),e.callbackNode===n?QA.bind(null,e):null}function mx(e,t){var n=nd;return e.current.memoizedState.isDehydrated&&($a(e,t).flags|=256),e=Bh(e,t),e!==2&&(t=Kr,Kr=n,t!==null&&gx(t)),e}function gx(e){Kr===null?Kr=e:Kr.push.apply(Kr,e)}function GO(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(!ti(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 To(e,t){for(t&=~uk,t&=~Om,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Qs(t),r=1<<n;e[n]=-1,t&=~r}}function BN(e){if(Kt&6)throw Error(Ae(327));lc();var t=Sh(e,0);if(!(t&1))return Qr(e,Wn()),null;var n=Bh(e,t);if(e.tag!==0&&n===2){var r=Bw(e);r!==0&&(t=r,n=mx(e,r))}if(n===1)throw n=Id,$a(e,0),To(e,t),Qr(e,Wn()),n;if(n===6)throw Error(Ae(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Sa(e,Kr,Ki),Qr(e,Wn()),null}function fk(e,t){var n=Kt;Kt|=1;try{return e(t)}finally{Kt=n,Kt===0&&(Sc=Wn()+500,Tm&&aa())}}function qa(e){Oo!==null&&Oo.tag===0&&!(Kt&6)&&lc();var t=Kt;Kt|=1;var n=Ps.transition,r=sn;try{if(Ps.transition=null,sn=1,e)return e()}finally{sn=r,Ps.transition=n,Kt=t,!(Kt&6)&&aa()}}function pk(){is=Xl.current,vn(Xl)}function $a(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,jO(n)),Yn!==null)for(n=Yn.return;n!==null;){var r=n;switch(Ub(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Eh();break;case 3:kc(),vn(Jr),vn(_r),nk();break;case 5:tk(r);break;case 4:kc();break;case 13:vn(Rn);break;case 19:vn(Rn);break;case 10:Xb(r.type._context);break;case 22:case 23:pk()}n=n.return}if(pr=e,Yn=e=Uo(e.current,null),gr=is=t,nr=0,Id=null,uk=Om=Ka=0,Kr=nd=null,Pa!==null){for(t=0;t<Pa.length;t++)if(n=Pa[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}Pa=null}return e}function ZA(e,t){do{var n=Yn;try{if(Jb(),Zp.current=Oh,Lh){for(var r=Mn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Lh=!1}if(Va=0,ur=tr=Mn=null,ed=!1,Ed=0,ck.current=null,n===null||n.return===null){nr=1,Id=t,Yn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=gr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var h=EN(a);if(h!==null){h.flags&=-257,AN(h,a,l,o,t),h.mode&1&&_N(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)){_N(o,u,t),hk();break e}c=Error(Ae(426))}}else if(Cn&&l.mode&1){var b=EN(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),AN(b,a,l,o,t),Yb(vc(c,l));break e}}o=c=vc(c,l),nr!==4&&(nr=2),nd===null?nd=[o]:nd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=LA(o,c,t);kN(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"&&(Ko===null||!Ko.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var N=OA(o,l,t);kN(o,N);break e}}o=o.return}while(o!==null)}nP(n)}catch(j){t=j,Yn===n&&n!==null&&(Yn=n=n.return);continue}break}while(!0)}function eP(){var e=Dh.current;return Dh.current=Oh,e===null?Oh:e}function hk(){(nr===0||nr===3||nr===2)&&(nr=4),pr===null||!(Ka&268435455)&&!(Om&268435455)||To(pr,gr)}function Bh(e,t){var n=Kt;Kt|=2;var r=eP();(pr!==e||gr!==t)&&(Ki=null,$a(e,t));do try{JO();break}catch(s){ZA(e,s)}while(!0);if(Jb(),Kt=n,Dh.current=r,Yn!==null)throw Error(Ae(261));return pr=null,gr=0,nr}function JO(){for(;Yn!==null;)tP(Yn)}function XO(){for(;Yn!==null&&!v2();)tP(Yn)}function tP(e){var t=sP(e.alternate,e,is);e.memoizedProps=e.pendingProps,t===null?nP(e):Yn=t,ck.current=null}function nP(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=VO(n,t),n!==null){n.flags&=32767,Yn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{nr=6,Yn=null;return}}else if(n=WO(n,t,is),n!==null){Yn=n;return}if(t=t.sibling,t!==null){Yn=t;return}Yn=t=e}while(t!==null);nr===0&&(nr=5)}function Sa(e,t,n){var r=sn,s=Ps.transition;try{Ps.transition=null,sn=1,QO(e,t,n,r)}finally{Ps.transition=s,sn=r}return null}function QO(e,t,n,r){do lc();while(Oo!==null);if(Kt&6)throw Error(Ae(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Ae(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(R2(e,o),e===pr&&(Yn=pr=null,gr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||hp||(hp=!0,iP(vh,function(){return lc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Ps.transition,Ps.transition=null;var a=sn;sn=1;var l=Kt;Kt|=4,ck.current=null,qO(e,n),JA(n,e),wO(Uw),Nh=!!qw,Uw=qw=null,e.current=n,UO(n),S2(),Kt=l,sn=a,Ps.transition=o}else e.current=n;if(hp&&(hp=!1,Oo=e,zh=s),o=e.pendingLanes,o===0&&(Ko=null),C2(n.stateNode),Qr(e,Wn()),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(Fh)throw Fh=!1,e=px,px=null,e;return zh&1&&e.tag!==0&&lc(),o=e.pendingLanes,o&1?e===hx?rd++:(rd=0,hx=e):rd=0,aa(),null}function lc(){if(Oo!==null){var e=LE(zh),t=Ps.transition,n=sn;try{if(Ps.transition=null,sn=16>e?16:e,Oo===null)var r=!1;else{if(e=Oo,Oo=null,zh=0,Kt&6)throw Error(Ae(331));var s=Kt;for(Kt|=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 d=Qe;switch(d.tag){case 0:case 11:case 15:td(8,d,o)}var f=d.child;if(f!==null)f.return=d,Qe=f;else for(;Qe!==null;){d=Qe;var p=d.sibling,h=d.return;if(UA(d),d===u){Qe=null;break}if(p!==null){p.return=h,Qe=p;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:td(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:Lm(9,l)}}catch(j){Fn(l,l.return,j)}if(l===a){Qe=null;break e}var N=l.sibling;if(N!==null){N.return=l.return,Qe=N;break e}Qe=l.return}}if(Kt=s,aa(),Ni&&typeof Ni.onPostCommitFiberRoot=="function")try{Ni.onPostCommitFiberRoot(Em,e)}catch{}r=!0}return r}finally{sn=n,Ps.transition=t}}return!1}function HN(e,t,n){t=vc(n,t),t=LA(e,t,1),e=Vo(e,t,1),t=Lr(),e!==null&&(nf(e,1,t),Qr(e,t))}function Fn(e,t,n){if(e.tag===3)HN(e,e,n);else for(;t!==null;){if(t.tag===3){HN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ko===null||!Ko.has(r))){e=vc(n,e),e=OA(t,e,1),t=Vo(t,e,1),e=Lr(),t!==null&&(nf(t,1,e),Qr(t,e));break}}t=t.return}}function ZO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Lr(),e.pingedLanes|=e.suspendedLanes&n,pr===e&&(gr&n)===n&&(nr===4||nr===3&&(gr&130023424)===gr&&500>Wn()-dk?$a(e,0):uk|=n),Qr(e,t)}function rP(e,t){t===0&&(e.mode&1?(t=sp,sp<<=1,!(sp&130023424)&&(sp=4194304)):t=1);var n=Lr();e=io(e,t),e!==null&&(nf(e,t,n),Qr(e,n))}function eD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),rP(e,n)}function tD(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Ae(314))}r!==null&&r.delete(t),rP(e,n)}var sP;sP=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Jr.current)Ur=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ur=!1,HO(e,t,n);Ur=!!(e.flags&131072)}else Ur=!1,Cn&&t.flags&1048576&&lA(t,Ih,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;th(e,t),e=t.pendingProps;var s=wc(t,_r.current);ac(t,n),s=sk(null,t,r,e,s,n);var o=ik();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,Xr(r)?(o=!0,Ah(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Zb(t),s.updater=$m,t.stateNode=s,s._reactInternals=t,nx(t,r,e,n),t=ix(null,t,r,!0,o,n)):(t.tag=0,Cn&&o&&qb(t),Mr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(th(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=rD(r),e=Vs(r,e),s){case 0:t=sx(null,t,r,e,n);break e;case 1:t=RN(null,t,r,e,n);break e;case 11:t=PN(null,t,r,e,n);break e;case 14:t=IN(null,t,r,Vs(r.type,e),n);break e}throw Error(Ae(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),sx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),RN(e,t,r,s,n);case 3:e:{if(BA(t),e===null)throw Error(Ae(387));r=t.pendingProps,o=t.memoizedState,s=o.element,hA(e,t),Mh(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=vc(Error(Ae(423)),t),t=TN(e,t,r,n,s);break e}else if(r!==s){s=vc(Error(Ae(424)),t),t=TN(e,t,r,n,s);break e}else for(ls=Wo(t.stateNode.containerInfo.firstChild),us=t,Cn=!0,Us=null,n=fA(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(xc(),r===s){t=oo(e,t,n);break e}Mr(e,t,r,n)}t=t.child}return t;case 5:return mA(t),e===null&&Zw(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,Yw(r,s)?a=null:o!==null&&Yw(r,o)&&(t.flags|=32),zA(e,t),Mr(e,t,a,n),t.child;case 6:return e===null&&Zw(t),null;case 13:return HA(e,t,n);case 4:return ek(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=bc(t,null,r,n):Mr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),PN(e,t,r,s,n);case 7:return Mr(e,t,t.pendingProps,n),t.child;case 8:return Mr(e,t,t.pendingProps.children,n),t.child;case 12:return Mr(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,hn(Rh,r._currentValue),r._currentValue=a,o!==null)if(ti(o.value,a)){if(o.children===s.children&&!Jr.current){t=oo(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=Zi(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ex(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Ae(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),ex(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}Mr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,ac(t,n),s=Is(s),r=r(s),t.flags|=1,Mr(e,t,r,n),t.child;case 14:return r=t.type,s=Vs(r,t.pendingProps),s=Vs(r.type,s),IN(e,t,r,s,n);case 15:return DA(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),th(e,t),t.tag=1,Xr(r)?(e=!0,Ah(t)):e=!1,ac(t,n),$A(t,r,s),nx(t,r,s,n),ix(null,t,r,!0,e,n);case 19:return WA(e,t,n);case 22:return FA(e,t,n)}throw Error(Ae(156,t.tag))};function iP(e,t){return RE(e,t)}function nD(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 As(e,t,n,r){return new nD(e,t,n,r)}function mk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rD(e){if(typeof e=="function")return mk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Mb)return 11;if(e===$b)return 14}return 2}function Uo(e,t){var n=e.alternate;return n===null?(n=As(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 sh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")mk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Bl:return La(n.children,s,o,t);case Tb:a=8,s|=8;break;case Cw:return e=As(12,n,t,s|2),e.elementType=Cw,e.lanes=o,e;case _w:return e=As(13,n,t,s),e.elementType=_w,e.lanes=o,e;case Ew:return e=As(19,n,t,s),e.elementType=Ew,e.lanes=o,e;case mE:return Dm(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pE:a=10;break e;case hE:a=9;break e;case Mb:a=11;break e;case $b:a=14;break e;case Ao:a=16,r=null;break e}throw Error(Ae(130,e==null?e:typeof e,""))}return t=As(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function La(e,t,n,r){return e=As(7,e,r,t),e.lanes=n,e}function Dm(e,t,n,r){return e=As(22,e,r,t),e.elementType=mE,e.lanes=n,e.stateNode={isHidden:!1},e}function Ny(e,t,n){return e=As(6,e,null,t),e.lanes=n,e}function jy(e,t,n){return t=As(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function sD(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=iy(0),this.expirationTimes=iy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=iy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function gk(e,t,n,r,s,o,a,l,c){return e=new sD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=As(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zb(o),e}function iD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:zl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function oP(e){if(!e)return Xo;e=e._reactInternals;e:{if(il(e)!==e||e.tag!==1)throw Error(Ae(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Xr(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ae(171))}if(e.tag===1){var n=e.type;if(Xr(n))return oA(e,n,t)}return t}function aP(e,t,n,r,s,o,a,l,c){return e=gk(n,r,!0,e,s,o,a,l,c),e.context=oP(null),n=e.current,r=Lr(),s=qo(n),o=Zi(r,s),o.callback=t??null,Vo(n,o,s),e.current.lanes=s,nf(e,s,r),Qr(e,r),e}function Fm(e,t,n,r){var s=t.current,o=Lr(),a=qo(s);return n=oP(n),t.context===null?t.context=n:t.pendingContext=n,t=Zi(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Vo(s,t,a),e!==null&&(Zs(e,s,a,o),Qp(e,s,a)),a}function Hh(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 WN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function yk(e,t){WN(e,t),(e=e.alternate)&&WN(e,t)}function oD(){return null}var lP=typeof reportError=="function"?reportError:function(e){console.error(e)};function wk(e){this._internalRoot=e}zm.prototype.render=wk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ae(409));Fm(e,t,null,null)};zm.prototype.unmount=wk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;qa(function(){Fm(null,e,null,null)}),t[so]=null}};function zm(e){this._internalRoot=e}zm.prototype.unstable_scheduleHydration=function(e){if(e){var t=FE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ro.length&&t!==0&&t<Ro[n].priority;n++);Ro.splice(n,0,e),n===0&&BE(e)}};function xk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Bm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function VN(){}function aD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=Hh(a);o.call(u)}}var a=aP(t,r,e,0,null,!1,!1,"",VN);return e._reactRootContainer=a,e[so]=a.current,Sd(e.nodeType===8?e.parentNode:e),qa(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Hh(c);l.call(u)}}var c=gk(e,0,!1,null,null,!1,!1,"",VN);return e._reactRootContainer=c,e[so]=c.current,Sd(e.nodeType===8?e.parentNode:e),qa(function(){Fm(t,c,n,r)}),c}function Hm(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=Hh(a);l.call(c)}}Fm(t,a,e,s)}else a=aD(n,t,e,s,r);return Hh(a)}OE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Fu(t.pendingLanes);n!==0&&(Db(t,n|1),Qr(t,Wn()),!(Kt&6)&&(Sc=Wn()+500,aa()))}break;case 13:qa(function(){var r=io(e,1);if(r!==null){var s=Lr();Zs(r,e,1,s)}}),yk(e,1)}};Fb=function(e){if(e.tag===13){var t=io(e,134217728);if(t!==null){var n=Lr();Zs(t,e,134217728,n)}yk(e,134217728)}};DE=function(e){if(e.tag===13){var t=qo(e),n=io(e,t);if(n!==null){var r=Lr();Zs(n,e,t,r)}yk(e,t)}};FE=function(){return sn};zE=function(e,t){var n=sn;try{return sn=e,t()}finally{sn=n}};Dw=function(e,t,n){switch(t){case"input":if(Iw(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=Rm(r);if(!s)throw Error(Ae(90));yE(r),Iw(r,s)}}}break;case"textarea":xE(e,n);break;case"select":t=n.value,t!=null&&rc(e,!!n.multiple,t,!1)}};CE=fk;_E=qa;var lD={usingClientEntryPoint:!1,Events:[sf,Kl,Rm,NE,jE,fk]},ju={findFiberByHostInstance:Aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cD={bundleType:ju.bundleType,version:ju.version,rendererPackageName:ju.rendererPackageName,rendererConfig:ju.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:uo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=PE(e),e===null?null:e.stateNode},findFiberByHostInstance:ju.findFiberByHostInstance||oD,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 mp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mp.isDisabled&&mp.supportsFiber)try{Em=mp.inject(cD),Ni=mp}catch{}}hs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lD;hs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xk(t))throw Error(Ae(200));return iD(e,t,null,n)};hs.createRoot=function(e,t){if(!xk(e))throw Error(Ae(299));var n=!1,r="",s=lP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=gk(e,1,!1,null,null,n,!1,r,s),e[so]=t.current,Sd(e.nodeType===8?e.parentNode:e),new wk(t)};hs.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Ae(188)):(e=Object.keys(e).join(","),Error(Ae(268,e)));return e=PE(t),e=e===null?null:e.stateNode,e};hs.flushSync=function(e){return qa(e)};hs.hydrate=function(e,t,n){if(!Bm(t))throw Error(Ae(200));return Hm(null,e,t,!0,n)};hs.hydrateRoot=function(e,t,n){if(!xk(e))throw Error(Ae(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=lP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=aP(t,null,e,1,n??null,s,!1,o,a),e[so]=t.current,Sd(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 zm(t)};hs.render=function(e,t,n){if(!Bm(t))throw Error(Ae(200));return Hm(null,e,t,!1,n)};hs.unmountComponentAtNode=function(e){if(!Bm(e))throw Error(Ae(40));return e._reactRootContainer?(qa(function(){Hm(null,null,e,!1,function(){e._reactRootContainer=null,e[so]=null})}),!0):!1};hs.unstable_batchedUpdates=fk;hs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Bm(n))throw Error(Ae(200));if(e==null||e._reactInternals===void 0)throw Error(Ae(38));return Hm(e,t,n,!1,r)};hs.version="18.3.1-next-f1338f8080-20240426";function cP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(cP)}catch(e){console.error(e)}}cP(),cE.exports=hs;var cr=cE.exports,KN=cr;Nw.createRoot=KN.createRoot,Nw.hydrateRoot=KN.hydrateRoot;const uP=m.createContext(null);function yx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function uD(){const e=yx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function dD({children:e}){const[t,n]=m.useState(uD);m.useEffect(()=>{const o=()=>n(yx(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=yx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(uP.Provider,{value:s,children:e})}function si(){const e=m.useContext(uP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function fD(){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 qN={};function wx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&qN[t[0]]||(typeof t[0]=="string"&&(qN[t[0]]=new Date),fD(...t))}const dP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function UN(e,t,n){e.loadNamespaces(t,dP(e,n))}function YN(e,t,n,r){typeof n=="string"&&(n=[n]),n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,dP(e,r))}function pD(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 hD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(wx("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}}):pD(e,t,n)}const mD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,gD={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},yD=e=>gD[e],wD=e=>e.replace(mD,yD);let xx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:wD};function xD(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xx={...xx,...e}}function bD(){return xx}let fP;function kD(e){fP=e}function vD(){return fP}const SD={type:"3rdParty",init(e){xD(e.options.react),kD(e)}},ND=m.createContext();class jD{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const CD=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Fr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(ND)||{},o=n||r||vD();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new jD),!o){wx("You will need to pass in an i18next instance by using initReactI18next");const x=(j,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(j)?j[j.length-1]:j,N=[x,{},!1];return N.t=x,N.i18n={},N.ready=!1,N}o.options.react&&o.options.react.wait!==void 0&&wx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...bD(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||s||o.options&&o.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const d=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>hD(x,o,a));function f(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[p,h]=m.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=CD(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:N}=a;b.current=!0,!d&&!l&&(t.lng?YN(o,t.lng,u,()=>{b.current&&h(f)}):UN(o,u,()=>{b.current&&h(f)})),d&&v&&v!==y&&b.current&&h(f);function j(){b.current&&h(f)}return x&&o&&o.on(x,j),N&&o&&o.store.on(N,j),()=>{b.current=!1,x&&o&&x.split(" ").forEach(C=>o.off(C,j)),N&&o&&N.split(" ").forEach(C=>o.store.off(C,j))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(f),g.current=!1},[o,c]);const k=[p,o,d];if(k.t=p,k.i18n=o,k.ready=d,d||!d&&!l)return k;throw new Promise(x=>{t.lng?YN(o,t.lng,u,()=>x()):UN(o,u,()=>x())})}const pP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20fill='none'%20role='img'%20aria-label='AgentFlow'%3e%3ctitle%3eAgentFlow%3c/title%3e%3crect%20width='32'%20height='32'%20rx='9'%20fill='%23131313'/%3e%3crect%20x='4.5'%20y='11'%20width='10.5'%20height='10'%20rx='3'%20fill='%232a2a2a'%20stroke='%237c4dff'%20stroke-width='1.2'/%3e%3cpath%20d='M15.25%2014.25C17.8%2012.2%2019.2%209.8%2022.25%209.25'%20stroke='%23cdbdff'%20stroke-width='1.65'%20stroke-linecap='round'%20/%3e%3cpath%20d='M15.25%2017.75C17.8%2019.8%2019.2%2022.2%2022.25%2022.75'%20stroke='%237c4dff'%20stroke-width='1.65'%20stroke-linecap='round'%20opacity='0.92'%20/%3e%3crect%20x='21.75'%20y='6'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%23e8deff'%20stroke-width='0.95'%20opacity='0.95'/%3e%3crect%20x='21.75'%20y='19'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%239ecaff'%20stroke-width='0.95'%20opacity='0.9'/%3e%3c/svg%3e",_D=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{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:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],ED=[{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 AD(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function PD({authUser:e,onLogout:t}){const{path:n,navigate:r}=si(),{t:s}=Fr(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:pP,alt:"",width:"36",height:"36",decoding:"async"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),i.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),i.jsx("nav",{className:"af-nav",children:_D.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(AD(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&&ED.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 ID="agentflow.pipelineRecent",RD=15;function TD(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function MD(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(ID);return e?TD(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 $D(e,t){const n=e.filter(r=>r.id===t);return n.length===0||n.some(r=>(r.source??"user")==="user")?"user":n.some(r=>r.source==="workspace")?"workspace":n.some(r=>r.source==="admin")?"admin":n.some(r=>r.source==="builtin")?"builtin":n[0].source??"user"}function GN(e,t){const n=Date.now(),r=Math.max(0,n-e),s=Math.floor(r/1e3);if(s<60)return t("flow:time.justNow");const o=Math.floor(s/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const d=Math.floor(a/24);return d<7?t("flow:time.daysAgo",{n:d}):`${l.getMonth()+1}/${l.getDate()}`}function LD(e,t,n){const r=[];for(const s of e)!s||typeof s.flowId!="string"||typeof s.at!="number"||r.push({flowId:s.flowId,flowSource:$D(n,s.flowId),kind:"executed",at:s.at});for(const s of t)r.push({flowId:s.flowId,flowSource:s.flowSource,kind:"opened",at:s.at});return r.sort((s,o)=>o.at-s.at),r.slice(0,RD)}var os=Uint8Array,Ql=Uint16Array,OD=Int32Array,hP=new os([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]),mP=new os([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]),DD=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gP=function(e,t){for(var n=new Ql(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new OD(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}},yP=gP(hP,2),wP=yP.b,FD=yP.r;wP[28]=258,FD[258]=28;var zD=gP(mP,0),BD=zD.b,bx=new Ql(32768);for(var kn=0;kn<32768;++kn){var No=(kn&43690)>>1|(kn&21845)<<1;No=(No&52428)>>2|(No&13107)<<2,No=(No&61680)>>4|(No&3855)<<4,bx[kn]=((No&65280)>>8|(No&255)<<8)>>1}var sd=function(e,t,n){for(var r=e.length,s=0,o=new Ql(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new Ql(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new Ql(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],d=t-e[s],f=a[e[s]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)l[bx[f]>>c]=u}else for(l=new Ql(r),s=0;s<r;++s)e[s]&&(l[s]=bx[a[e[s]-1]++]>>15-e[s]);return l},af=new os(288);for(var kn=0;kn<144;++kn)af[kn]=8;for(var kn=144;kn<256;++kn)af[kn]=9;for(var kn=256;kn<280;++kn)af[kn]=7;for(var kn=280;kn<288;++kn)af[kn]=8;var xP=new os(32);for(var kn=0;kn<32;++kn)xP[kn]=5;var HD=sd(af,9,1),WD=sd(xP,5,1),Cy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Hs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},_y=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},VD=function(e){return(e+7)/8|0},bk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new os(e.subarray(t,n))},KD=["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"],Ns=function(e,t,n){var r=new Error(t||KD[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ns),!n)throw r;return r},qD=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new os(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new os(s*3));var u=function(ce){var de=n.length;if(ce>de){var me=new os(Math.max(de*2,ce));me.set(n),n=me}},d=t.f||0,f=t.p||0,p=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!h){d=Hs(e,f,1);var k=Hs(e,f+1,3);if(f+=3,k)if(k==1)h=HD,y=WD,v=9,b=5;else if(k==2){var C=Hs(e,f,31)+257,P=Hs(e,f+10,15)+4,I=C+Hs(e,f+5,31)+1;f+=14;for(var F=new os(I),$=new os(19),D=0;D<P;++D)$[DD[D]]=Hs(e,f+D*3,7);f+=P*3;for(var z=Cy($),O=(1<<z)-1,M=sd($,z,1),D=0;D<I;){var K=M[Hs(e,f,O)];f+=K&15;var x=K>>4;if(x<16)F[D++]=x;else{var H=0,L=0;for(x==16?(L=3+Hs(e,f,3),f+=2,H=F[D-1]):x==17?(L=3+Hs(e,f,7),f+=3):x==18&&(L=11+Hs(e,f,127),f+=7);L--;)F[D++]=H}}var T=F.subarray(0,C),W=F.subarray(C);v=Cy(T),b=Cy(W),h=sd(T,v,1),y=sd(W,b,1)}else Ns(1);else{var x=VD(f)+4,N=e[x-4]|e[x-3]<<8,j=x+N;if(j>s){c&&Ns(0);break}l&&u(p+N),n.set(e.subarray(x,j),p),t.b=p+=N,t.p=f=j*8,t.f=d;continue}if(f>g){c&&Ns(0);break}}l&&u(p+131072);for(var E=(1<<v)-1,Q=(1<<b)-1,V=f;;V=f){var H=h[_y(e,f)&E],B=H>>4;if(f+=H&15,f>g){c&&Ns(0);break}if(H||Ns(2),B<256)n[p++]=B;else if(B==256){V=f,h=null;break}else{var se=B-254;if(B>264){var D=B-257,ue=hP[D];se=Hs(e,f,(1<<ue)-1)+wP[D],f+=ue}var G=y[_y(e,f)&Q],ee=G>>4;G||Ns(3),f+=G&15;var W=BD[ee];if(ee>3){var ue=mP[ee];W+=_y(e,f)&(1<<ue)-1,f+=ue}if(f>g){c&&Ns(0);break}l&&u(p+131072);var te=p+se;if(p<W){var ne=o-W,Z=Math.min(W,te);for(ne+p<0&&Ns(3);p<Z;++p)n[p]=r[ne+p]}for(;p<te;++p)n[p]=n[p-W]}}t.l=h,t.p=V,t.b=p,t.f=d,h&&(d=1,t.m=v,t.d=y,t.n=b)}while(!d);return p!=n.length&&a?bk(n,0,p):n.subarray(0,p)},UD=new os(0),xi=function(e,t){return e[t]|e[t+1]<<8},Ys=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ey=function(e,t){return Ys(e,t)+Ys(e,t+4)*4294967296};function YD(e,t){return qD(e,{i:2},t&&t.out,t&&t.dictionary)}var kx=typeof TextDecoder<"u"&&new TextDecoder,GD=0;try{kx.decode(UD,{stream:!0}),GD=1}catch{}var JD=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:bk(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 XD(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(kx)return kx.decode(e);var s=JD(e),o=s.s,n=s.r;return n.length&&Ns(8),o}}var QD=function(e,t){return t+30+xi(e,t+26)+xi(e,t+28)},ZD=function(e,t,n){var r=xi(e,t+28),s=XD(e.subarray(t+46,t+46+r),!(xi(e,t+8)&2048)),o=t+46+r,a=Ys(e,t+20),l=n&&a==4294967295?eF(e,o):[a,Ys(e,t+24),Ys(e,t+42)],c=l[0],u=l[1],d=l[2];return[xi(e,t+10),c,u,s,o+xi(e,t+30)+xi(e,t+32),d]},eF=function(e,t){for(;xi(e,t)!=1;t+=4+xi(e,t+2));return[Ey(e,t+12),Ey(e,t+4),Ey(e,t+20)]};function tF(e,t){for(var n={},r=e.length-22;Ys(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Ns(13);var s=xi(e,r+8);if(!s)return{};var o=Ys(e,r+16),a=o==4294967295||s==65535;if(a){var l=Ys(e,r-12);a=Ys(e,l)==101075792,a&&(s=Ys(e,l+32),o=Ys(e,l+48))}for(var c=0;c<s;++c){var u=ZD(e,o,a),d=u[0],f=u[1],p=u[2],h=u[3],y=u[4],v=u[5],b=QD(e,v);o=y,d?d==8?n[h]=YD(e.subarray(b,b+f),{out:new os(p)}):Ns(14,"unknown compression type "+d):n[h]=bk(e,b,b+f)}return n}const nF=8*1024*1024,rF=500;function sF(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 iF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function oF(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 aF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function lF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=tF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=sF(c);if(!d||iF(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>nF||(o+=1,o>rF))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=oF(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 aF.test(l)?l:null}catch{return null}}const Ay=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function cF({file:e,onClose:t,onImported:n}){const{t:r}=Fr(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,d]=m.useState("user"),[f,p]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const j=requestAnimationFrame(()=>{var C;return(C=o.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(j)},[]),m.useEffect(()=>{let j=!1;return(async()=>{const C=g.name||"",P=C.toLowerCase();let I="";if(P.endsWith(".zip")){if(I=await lF(g)||"",!I){const F=C.replace(/\.zip$/i,"");Ay.test(F)&&(I=F)}}else if(P.endsWith(".yaml")||P.endsWith(".yml")){const F=C.replace(/\.ya?ml$/i,"");Ay.test(F)&&(I=F)}j||c(I)})(),()=>{j=!0}},[g]);const k=l.trim(),x=k.length>0&&Ay.test(k);async function N(j){if(j.preventDefault(),!(!x||f)){p(!0),y("");try{const C=new FormData;C.set("flowId",k),C.set("targetSpace",u),C.set("file",g,g.name);const P=await fetch("/api/flows/import",{method:"POST",body:C}),I=await P.json().catch(()=>({}));if(!P.ok){y(typeof I.error=="string"?I.error:r("project:importModal.importFailed"));return}n({id:I.flowId,source:I.flowSource??"user"})}catch(C){y(String((C==null?void 0:C.message)||C))}finally{p(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.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:j=>j.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:N,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename: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:j=>{var P;const C=(P=j.target.files)==null?void 0:P[0];C&&b(C),j.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:j=>c(j.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 j;return(j=a.current)==null?void 0:j.click()},children:r("project:importModal.changeFile")})}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const uF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,JN="af:newPipelineGuide";function dF({open:e,onClose:t,onCreated:n}){const{t:r}=Fr(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("user"),[p,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(JN)==="true"&&g(!0);const P=requestAnimationFrame(()=>{var I;return(I=o.current)==null?void 0:I.focus()});return()=>cancelAnimationFrame(P)},[e]);const k=()=>{localStorage.removeItem(JN),g(!1)};if(!e)return null;const x=a.trim(),N=x.length>0&&uF.test(x);async function j(C){if(C.preventDefault(),!(!N||p)){h(!0),v(""),k();try{const P=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:d})}),I=await P.json().catch(()=>({}));if(!P.ok){v(typeof I.error=="string"?I.error:r("project:newPipelineModal.createFailed"));return}n({id:I.flowId,source:I.flowSource??"user"})}catch(P){v(String((P==null?void 0:P.message)||P))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&(k(),t())},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),b?i.jsx("div",{className:"af-new-pipeline-guide",children:i.jsxs("div",{className:"af-new-pipeline-guide-content",children:[i.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),i.jsxs("div",{className:"af-new-pipeline-guide-text",children:[i.jsx("p",{children:i.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),i.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),i.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:C=>l(C.target.value),"aria-invalid":x.length>0&&!N}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(b?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:C=>u(C.target.value)}),b?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?i.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!N||p,children:r(p?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const bP="agentflow.pipelineViewPreference";function kP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function vP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(bP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function fF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(bP,JSON.stringify(e))}catch{}}function kk(e){return e==="display"?"display":"workspace"}function pF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function SP(e,t){const n=kk(t);return n==="pipeline"&&pF(e==null?void 0:e.source)?"workspace":n}function hF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function mF(e,t,n,r=!1){if(!e)return;const s=vP();s[kP(e,t,r)]={view:kk(n),at:Date.now()},fF(s)}function gF(e,t="workspace"){if(!(e!=null&&e.id))return kk(t);const r=vP()[kP(e.id,e.source??"user",!!e.archived)],s=SP(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!hF(e)?"workspace":s}function yF(e,t="workspace"){var s;const n=SP(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 gp(e,t="workspace"){return yF(e,gF(e,t))}function wF(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),s=Math.max(n.length,r.length);for(let o=0;o<s;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function vx(e){return String((e==null?void 0:e.version)||"").trim()}function xF(e){const t=vx(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 bF({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("keyword"),[p,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[N,j]=m.useState(""),C=m.useCallback(async()=>{x("");try{const[z,O]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await z.json().catch(()=>({}));z.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 K=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof K.error=="string"?K.error:"HTTP "+O.status);o(Array.isArray(K.skills)?K.skills:[]),l(typeof K.skillsRoot=="string"?K.skillsRoot:""),v({})}catch(z){x(String(z.message||z))}},[]);m.useEffect(()=>{C()},[C]);const P=m.useCallback(async()=>{const z=c.trim();if(z){g("search"),x(""),j("");try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent(z)}&mode=${encodeURIComponent(d)}`),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,d]),I=m.useCallback(async(z,O=!1)=>{if(!t)return;const M=z&&typeof z=="object"?z:null,K=String(M?M.slug||M.name||M.collection||M.skillId||M.id:z||"").trim();if(K){g(`install:${K}`),x(""),j("");try{const H=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:O}:{slug:K,target:"agentflow",agent:"codex",force:O},L=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),T=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+L.status);j(O?`已更新 ${K}`:`已安装 ${K}`),await C(),typeof e=="function"&&await e()}catch(H){x(String(H.message||H))}finally{g("")}}},[t,C,e]),F=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),x(""),j("");try{const z=await Promise.all(s.map(async K=>{const H=String(K.name||"").trim();if(!H)return null;try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(H)}&mode=keyword`),T=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+L.status);const W=Array.isArray(T.items)?T.items:[],E=W.find(se=>se.slug===H||se.name===H||se.id===H)||W[0],Q=vx(K),V=String((E==null?void 0:E.version)||"").trim();let B="unknown";return E?Q&&V?B=wF(Q,V)<0?"update":"current":V&&(B="remote-only"):B="missing",[H,{state:B,latestVersion:V,installedVersion:Q,summary:(E==null?void 0:E.summary)||""}]}catch(L){return[H,{state:"error",error:String(L.message||L),installedVersion:vx(K)}]}})),O={};for(const K of z)K&&(O[K[0]]=K[1]);v(O);const M=Object.values(O).filter(K=>K.state==="update").length;j(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),$=m.useCallback(async z=>{if(!t)return;const O=String(z||"").trim();if(O){g(`uninstall:${O}`),x(""),j("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:O,target:"agentflow",agent:"codex"})}),K=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof K.error=="string"?K.error:"HTTP "+M.status);j(`已卸载 ${O}`),await C(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{g("")}}},[t,C,e]),D=m.useCallback(async()=>{if(t){g("update-cli"),x(""),j("");try{const z=await fetch("/api/skillhub/update",{method:"POST"}),O=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+z.status);j("SkillHub CLI 已更新"),await C()}catch(z){x(String(z.message||z))}finally{g("")}}},[t,C]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",i.jsx("code",{children:a})]}):null]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:!!b,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:F,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:d,onChange:z=>{f(z.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:z=>u(z.target.value),onKeyDown:z=>{z.key==="Enter"&&P()},placeholder:d==="collectionId"?"输入 collection id,例如 1":d==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>P(),disabled:!c.trim()||b==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):null,N?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:N}):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(z=>{const O=y[z.name],M=!O||O.state==="update"||O.state==="remote-only"||O.state==="unknown"||O.state==="error",K=b===`install:${z.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:z.displayName||z.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:xF(z)}),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:()=>I(z.name,!0),disabled:!t||!!b||!M,children:K}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>$(z.name),disabled:!t||!!b,children:"卸载"})]})]},`${z.agent}:${z.path}:${z.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:p.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:p.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):p.map(z=>{const O=z.slug||z.name,M=z.kind==="collection"||z.collection,K=!M&&s.some(H=>H.name===O||H.name===z.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:z.name||O}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${z.collection}`:O,z.skillId?` · id:${z.skillId}`:"",z.version?` · ${z.version}`:""]}),z.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:z.summary}):null]}),i.jsx("button",{type:"button",className:K?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>I(z,K),disabled:!t||!!b,children:K?"更新":M?"安装合集":"安装"})]},z.id||O)})})]})]})]})}function Oa(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 kF(e){return{version:1,collections:Oa({collections:e})}}function vF(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function NP(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(vF(s)))||""}}function Qo(e,t){const n=NP(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function SF(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 NF(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function jF(e,t,n){const r=Qo(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 CF(e,t,n){const r=String(e).trim().toLowerCase(),s=Oa({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return Qo(s,t)}function _F(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Oa({collections:r}),l=CF(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const d=JSON.parse(u);if(Array.isArray(d)){const f=NP(n),p=Array.from(new Set(d.map(f).filter(Boolean)));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),y=new Set(l),v=l.length>0&&l.every(g=>h.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=Qo(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:p}}}catch{}return c}function Al(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 EF(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function AF(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 Sx(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 jP(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 PF="project:defaultCardDesc";function CP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(PF)}function IF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bn({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(`(${IF(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 RF(e,t,n){const r=[String(e.id),CP(e,n),jP(e),Sx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
|
|
41
|
+
`).toLowerCase()}function TF(e,t,n){return t?RF(e,t,n).includes(t):!0}function MF(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 Py(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 QN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const $F=["all","agent","control","provide","marketplace"],LF=["all","agent","control","provide"],_P="agentflow.projects.activityPanelOpen",Nx="agentflow.projects.activitySelected";function OF(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(_P);return e!=="0"}function ZN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function DF(){return typeof localStorage>"u"?"":localStorage.getItem(Nx)||""}function yp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Hn(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 FF(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 jo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function EP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.instances;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):t&&typeof t=="object"?Object.entries(t).map(([r,s])=>({...s&&typeof s=="object"?s:{},instanceId:(s==null?void 0:s.instanceId)||r})):[]}function AP(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 jx(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 ej(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||jx(e,t))}function zF(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function tj(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 BF(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 Iy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function HF(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 WF(e,t){const n=e.map(d=>d.id),r=new Set(n),s=new Map(n.map(d=>[d,0])),o=new Map(n.map(d=>[d,[]]));t.forEach(d=>{var f;!r.has(d.sourceId)||!r.has(d.targetId)||(s.set(d.targetId,(s.get(d.targetId)||0)+1),(f=o.get(d.sourceId))==null||f.push(d.targetId))});const a=new Map,l=n.filter(d=>(s.get(d)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(d=>a.set(d,0));for(let d=0;d<l.length;d+=1){const f=l[d],p=(a.get(f)||0)+1;for(const h of o.get(f)||[])(!a.has(h)||p>a.get(h))&&(a.set(h,p),l.push(h))}n.forEach((d,f)=>{a.has(d)||a.set(d,f%3)});const c=new Map,u=new Map;return n.forEach(d=>{const f=a.get(d)||0,p=c.get(f)||0;c.set(f,p+1),u.set(d,{x:f*190,y:p*86})}),u}function VF(e){var v,b,g,k;const t=EP(e),n=AP(e),r=new Map(t.map((x,N)=>[jx(x,N),ej(x,N)])),s=t.map((x,N)=>({id:jx(x,N),title:ej(x,N),meta:zF(x)})),o=n.map((x,N)=>{const j=tj(x,"source"),C=tj(x,"target");return{key:(x==null?void 0:x.id)||`${j}-${C}-${N}`,sourceId:j,targetId:C,source:r.get(j)||j||"?",target:r.get(C)||C||"?",label:BF(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=WF(s,o),u=s.map(x=>{const N=HF(a[x.id])||c.get(x.id)||{x:0,y:0},j=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},C=Number(j.width),P=Number(j.height),I=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),F=Math.max(48,Math.min(76,Number.isFinite(P)?P*.46:54));return{...x,x:N.x,y:N.y,width:I,height:F}}),d=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const N=d.get(x.sourceId),j=d.get(x.targetId);if(!N||!j)return null;const C=N.x+N.width,P=N.y+N.height/2,I=j.x,F=j.y+j.height/2,$=Math.max(48,Math.abs(I-C)*.45);return{...x,path:`M ${C} ${P} C ${C+$} ${P}, ${I-$} ${F}, ${I} ${F}`,labelX:(C+I)/2,labelY:(P+F)/2}}).filter(Boolean),p=u.reduce((x,N)=>({minX:Math.min(x.minX,N.x),minY:Math.min(x.minY,N.y),maxX:Math.max(x.maxX,N.x+N.width),maxY:Math.max(x.maxY,N.y+N.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Pl({resourceKind:e="",authUser:t=null}){var Pe,xt,Lt,qt,zn,On;const{t:n}=Fr(),{navigate:r,path:s}=si(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[d,f]=m.useState([]),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState(""),[N,j]=m.useState(!1),[C,P]=m.useState([]),[I,F]=m.useState(""),[$,D]=m.useState(""),[z,O]=m.useState(!1),[M,K]=m.useState(!1),[H,L]=m.useState(!1),[T,W]=m.useState(null),[E,Q]=m.useState(!1),[V,B]=m.useState(""),[se,ue]=m.useState(OF),[G,ee]=m.useState(DF),[te,ne]=m.useState("all"),[Z,ce]=m.useState(""),[de,me]=m.useState("overview"),[$e,Ce]=m.useState({}),[_e,Be]=m.useState(""),[ot,yt]=m.useState({}),[Te,st]=m.useState(""),[gt,xe]=m.useState(""),[Fe,lt]=m.useState({}),[oe,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,Ht]=m.useState(""),[Qt,jt]=m.useState(""),[yn,on]=m.useState(""),[re,Re]=m.useState(!1),[Je,Ze]=m.useState(""),[Tt,At]=m.useState({hiddenBuiltins:[],promoted:[]}),Vn=m.useRef(0),Sn=m.useRef(0),xr=m.useRef(0),wn=m.useCallback(async()=>{var pe,Oe;const q=++Sn.current;F("");try{const Ee=await fetch("/api/flows");if(q!==Sn.current)return;if(!Ee.ok)throw new Error("HTTP "+Ee.status);const et=await Ee.json();if(q!==Sn.current)return;u(Array.isArray(et)?et:[])}catch(Ee){if(q!==Sn.current)return;u([]),F(String(Ee.message||Ee))}try{const Ee=await fetch("/api/pipeline-recent-runs");if(q!==Sn.current)return;if(Ee.ok){const et=await Ee.json();if(q!==Sn.current)return;P(Array.isArray(et.runs)?et.runs:[])}else P([])}catch{if(q!==Sn.current)return;P([])}if(t!=null&&t.isAdmin)try{const Ee=await fetch("/api/admin/builtin-flows");if(q!==Sn.current)return;const et=await Ee.json().catch(()=>({}));Ee.ok&&At({hiddenBuiltins:Array.isArray((pe=et==null?void 0:et.config)==null?void 0:pe.hiddenBuiltins)?et.config.hiddenBuiltins:[],promoted:Array.isArray((Oe=et==null?void 0:et.config)==null?void 0:Oe.promoted)?et.config.promoted:[]})}catch{if(q!==Sn.current)return;At({hiddenBuiltins:[],promoted:[]})}else At({hiddenBuiltins:[],promoted:[]});O(!0)},[t==null?void 0:t.isAdmin]),Xn=m.useCallback(async(q,pe)=>{if(!(t!=null&&t.isAdmin)||!(q!=null&&q.id))return;const Oe=`${pe}:${q.source}:${q.id}`;Ze(Oe),F("");try{const Ee=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:pe,flowId:q.id,ownerUserId:q.ownerUserId||t.userId})}),et=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(et.error||"更新内置配置失败");await wn()}catch(Ee){F(String(Ee.message||Ee))}finally{Ze("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,wn]),Kn=m.useCallback(async()=>{const q=++xr.current;D(""),K(!1);const pe="/api/nodes",Oe=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),v([]),ce("");try{const[Ee,et,Nn,kt]=await Promise.all([fetch(pe),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(Oe)]),Ut=await Ee.json().catch(()=>({})),jn=await et.json().catch(()=>({})),go=await Nn.json().catch(()=>({})),at=await kt.json().catch(()=>({}));if(!Ee.ok)throw new Error(Ut.error||"Nodes HTTP "+Ee.status);if(!et.ok)throw new Error(jn.error||"Skills HTTP "+et.status);if(!Nn.ok)throw new Error(go.error||"Collections HTTP "+Nn.status);if(!kt.ok)throw new Error(at.error||"Flow snippets HTTP "+kt.status);if(q!==xr.current)return;f(Array.isArray(Ut.nodes)?Ut.nodes:Array.isArray(Ut)?Ut:[]),h(Array.isArray(jn.skills)?jn.skills:[]),g(Oa(go)),v(Array.isArray(at.snippets)?at.snippets:[])}catch(Ee){if(q!==xr.current)return;f([]),h([]),v([]),g([]),D(String(Ee.message||Ee))}finally{if(q!==xr.current)return;K(!0)}},[e]);m.useEffect(()=>{O(!1),wn(),Kn()},[wn,Kn]),m.useEffect(()=>{try{localStorage.setItem(_P,se?"1":"0")}catch{}},[se]),m.useEffect(()=>{try{G?localStorage.setItem(Nx,G):localStorage.removeItem(Nx)}catch{}},[G]),m.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(pe=>pe.json()).then(pe=>{q||Re(!!pe.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const hr=m.useCallback(async q=>{if(!o)return;const pe=Oa({collections:q});j(!0),D("");try{const Oe=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(kF(pe))}),Ee=await Oe.json().catch(()=>({}));if(!Oe.ok)throw new Error(Ee.error||"Collections HTTP "+Oe.status);g(Oa(Ee))}catch(Oe){D(String(Oe.message||Oe))}finally{j(!1)}},[o]),ts=m.useCallback(()=>{if(!o)return;const q=k.trim();if(!q)return;const pe=q.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Oe=new Set(b.map(kt=>kt.id));let Ee=pe,et=2;for(;Oe.has(Ee);)Ee=`${pe}-${et++}`;const Nn=Date.now();hr([...b,{id:Ee,name:q,skillKeys:[],createdAt:Nn,updatedAt:Nn}]),x(""),ne(`collection:${Ee}`)},[o,k,hr,b]),Ar=m.useCallback(q=>{if(!o)return;const pe=b.find(Ee=>Ee.id===q);if(pe!=null&&pe.builtin)return;const Oe=b.filter(Ee=>Ee.id!==q);te===`collection:${q}`&&ne("all"),hr(Oe)},[o,te,hr,b]),gs=m.useCallback((q,pe,Oe)=>{if(!o)return;const Ee=String(pe||"").trim();if(!Ee)return;const et=Date.now(),Nn=b.map(kt=>{if(kt.id!==q)return kt;const Ut=new Set(kt.skillKeys||[]);return Oe?Ut.add(Ee):Ut.delete(Ee),{...kt,skillKeys:Array.from(Ut),updatedAt:et}});hr(Nn)},[o,hr,b]),ys=m.useCallback(async q=>{const pe=q==null?void 0:q.packageId,Oe=q==null?void 0:q.version;if(!pe||!Oe||!window.confirm(n("project:deleteMyNodeConfirm",{id:pe,version:Oe})))return;const Ee=Hn(q);Ue(Ee),Ht(""),D("");try{const et=new URLSearchParams({id:pe,version:Oe}),Nn=await fetch(`/api/marketplace/node?${et.toString()}`,{method:"DELETE"}),kt=await Nn.json().catch(()=>({}));if(!Nn.ok||(kt==null?void 0:kt.ok)===!1){const Ut=Array.isArray(kt==null?void 0:kt.usage)&&kt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:kt.usage.length})}`:"";throw new Error(((kt==null?void 0:kt.error)||"Delete failed")+Ut)}Ht(n("project:deleteMyNodeSuccess",{id:pe,version:Oe})),yt(Ut=>{const jn={...Ut};return delete jn[Ee],jn}),lt(Ut=>{const jn={};for(const[go,at]of Object.entries(Ut))go.startsWith(`${Ee}:`)||(jn[go]=at);return jn}),ce(""),await Kn()}catch(et){Ht(String(et.message||et))}finally{Ue("")}},[Kn,n]),cn=m.useCallback(async q=>{const pe=q==null?void 0:q.id,Oe=(q==null?void 0:q.version)||"1.0.0";if(!pe||!Oe||!window.confirm(n("project:deleteMyFlowConfirm",{id:pe,version:Oe})))return;const Ee=jo(q);jt(Ee),on(""),D("");try{const et=new URLSearchParams({id:pe,version:Oe}),Nn=await fetch(`/api/marketplace/flow-snippet?${et.toString()}`,{method:"DELETE"}),kt=await Nn.json().catch(()=>({}));if(!Nn.ok||(kt==null?void 0:kt.ok)===!1)throw new Error((kt==null?void 0:kt.error)||"Delete failed");on(n("project:deleteMyFlowSuccess",{id:pe,version:Oe})),ce(""),await Kn()}catch(et){on(String(et.message||et))}finally{jt("")}},[Kn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ne("all"),ce(""),me("overview");return}l(q=>q==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const q=new URLSearchParams(window.location.search),pe=q.get("tab");let Oe=!1;if(pe==="nodes"){r("/nodes");return}if(pe==="my-nodes"){r("/my-nodes");return}if(pe==="my-flows"){r("/my-flows");return}if(pe==="skills"){r("/skills");return}if(pe==="archived"?(l("archived"),q.delete("tab"),Oe=!0):pe&&(l("all"),q.delete("tab"),Oe=!0),q.get("new")==="1"&&(L(!0),q.delete("new"),Oe=!0),Oe){const Ee=q.toString();window.history.replaceState({},"",Ee?`/projects?${Ee}`:"/projects")}},[s,r]);const rr=m.useMemo(()=>LD(C,MD(),c),[C,c,s]),Pr=m.useMemo(()=>rr.filter(q=>MF(V,q)),[rr,V]),dn=V.trim().toLowerCase(),Qn=m.useMemo(()=>a==="archived"?c.filter(q=>q.archived):c.filter(q=>!q.archived),[c,a]),br=m.useMemo(()=>Qn.filter(q=>TF(q,dn,n)),[Qn,dn,n]),sr=m.useMemo(()=>new Set((Tt.promoted||[]).map(q=>String((q==null?void 0:q.id)||"").trim()).filter(Boolean)),[Tt.promoted]),Ct=m.useMemo(()=>(Tt.hiddenBuiltins||[]).map(q=>String(q||"").trim()).filter(Boolean),[Tt.hiddenBuiltins]),Gt=a==="nodes"||a==="my-nodes",_t=a==="my-nodes",le=a==="my-flows",ve=m.useMemo(()=>d.filter(q=>_t&&!FF(q,t)?!1:(te==="all"||(te==="marketplace"?q.source==="marketplace":q.type===te))&&Py(V,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[t,d,_t,V,te]),it=m.useMemo(()=>{const q=new Map;for(const pe of b)q.set(pe.id,new Set(Qo(pe,p)));return q},[p,b]),Dt=m.useMemo(()=>[{id:"all",label:"全部"},...b.map(q=>{var pe;return{id:`collection:${q.id}`,label:q.name,count:((pe=it.get(q.id))==null?void 0:pe.size)||0,collection:q}}),{id:"ungrouped",label:"未分组"}],[it,b]),Jt=m.useMemo(()=>p.filter(q=>{var Ee;const pe=Hn(q);let Oe=te==="all";if(te.startsWith("collection:")){const et=te.slice(11);Oe=!!((Ee=it.get(et))!=null&&Ee.has(pe))}else te==="ungrouped"&&(Oe=!Array.from(it.values()).some(et=>et.has(pe)));return Oe&&Py(V,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[p,V,te,it]),tn=m.useMemo(()=>y.filter(q=>Py(V,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[y,V]),Zn=Gt||le||a==="skills",mt=m.useMemo(()=>ve.find(q=>Hn(q)===Z)||ve[0]||null,[ve,Z]),nn=m.useMemo(()=>Jt.find(q=>Hn(q)===Z)||Jt[0]||null,[Jt,Z]),Wt=m.useMemo(()=>tn.find(q=>jo(q)===Z)||tn[0]||null,[tn,Z]),kr=nn?$e[Hn(nn)]:null,tt=mt?ot[Hn(mt)]:null,Ln=mt&>?Fe[`${Hn(mt)}:${gt}`]:null,$i=n(Gt?"project:searchNodes":le?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!nn)return;const q=Hn(nn);if($e[q])return;let pe=!1;return Be(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then(Oe=>Oe.json().then(Ee=>({ok:Oe.ok,json:Ee}))).then(({ok:Oe,json:Ee})=>{pe||Oe&&Ee.skill&&Ce(et=>({...et,[q]:Ee.skill}))}).catch(()=>{}).finally(()=>{pe||Be("")}),()=>{pe=!0}},[a,nn,$e]),m.useEffect(()=>{if(!Gt||!mt)return;const q=Hn(mt);if(ot[q])return;let pe=!1;return st(q),fetch(`/api/nodes/detail?id=${encodeURIComponent(mt.id)}`).then(Oe=>Oe.json().then(Ee=>({ok:Oe.ok,json:Ee}))).then(({ok:Oe,json:Ee})=>{pe||Oe&&yt(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{pe||st("")}),()=>{pe=!0}},[Gt,mt,ot]),m.useEffect(()=>{if(!Gt)return;const q=Array.isArray(tt==null?void 0:tt.files)?tt.files:[];xe(pe=>{var Oe;return pe&&q.some(Ee=>Ee.path===pe)?pe:((Oe=q[0])==null?void 0:Oe.path)||""})},[Gt,tt]),m.useEffect(()=>{if(!Gt||!mt||!gt)return;const q=`${Hn(mt)}:${gt}`;if(Fe[q])return;let pe=!1;return ke(q),fetch(`/api/nodes/file?id=${encodeURIComponent(mt.id)}&path=${encodeURIComponent(gt)}`).then(Oe=>Oe.json().then(Ee=>({ok:Oe.ok,json:Ee}))).then(({ok:Oe,json:Ee})=>{pe||Oe&<(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{pe||ke("")}),()=>{pe=!0}},[Gt,mt,gt,Fe]),m.useEffect(()=>{Ht("")},[Z,a]);const zr=q=>{r(gp(q,"workspace"))},mo=q=>{ee(ZN(q)),r(gp({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},ai=m.useCallback(q=>{var pe,Oe;q.preventDefault(),q.stopPropagation(),(Oe=(pe=q.dataTransfer)==null?void 0:pe.types)!=null&&Oe.includes("Files")&&(Vn.current+=1,Q(!0))},[]),Ts=m.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Vn.current-=1,Vn.current<=0&&(Vn.current=0,Q(!1))},[]),ie=m.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),Se=m.useCallback(q=>{var Ee,et;q.preventDefault(),q.stopPropagation(),Vn.current=0,Q(!1);const pe=(et=(Ee=q.dataTransfer)==null?void 0:Ee.files)==null?void 0:et[0];if(!pe)return;const Oe=pe.name.toLowerCase();!Oe.endsWith(".yaml")&&!Oe.endsWith(".yml")&&!Oe.endsWith(".zip")||W(pe)},[]);return i.jsxs("div",{className:"af-projects"+(E?" af-projects--drop-target":""),onDragEnter:ai,onDragLeave:Ts,onDragOver:ie,onDrop:Se,children:[i.jsxs("header",{className:"af-projects-top",children:[e?i.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):i.jsxs("div",{className:"af-projects-tabs",children:[i.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),i.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),i.jsxs("div",{className:"af-projects-top-right",children:[i.jsxs("div",{className:"af-search-wrap",children:[i.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),i.jsx("input",{className:"af-search"+(V.trim()?" af-search--has-clear":""),type:"search",placeholder:$i,"aria-label":$i,autoComplete:"off",value:V,onChange:q=>B(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(B(""),q.currentTarget.blur())}}),V.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>B(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Zn?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>Kn(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(se?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":se,"aria-controls":"af-recent-activity-panel",onClick:()=>ue(q=>!q),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>L(!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:dn?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?ve.length:a==="my-flows"?tn.length:a==="skills"?Jt.length:br.length}):a==="my-nodes"?n("project:myNodesHint",{count:ve.length}):a==="my-flows"?n("project:myFlowsHint",{count:tn.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:p.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),I?i.jsx("p",{className:"af-err af-projects-api-hint",children:I}):null,$&&Zn?i.jsx("p",{className:"af-err af-projects-api-hint",children:$}):null]}),Zn?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(bF,{onChanged:Kn,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:le?"schema":Gt?_t?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(le?"project:myFlowsPurposeTitle":_t?"project:myNodesPurposeTitle":Gt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(le?"project:myFlowsPurposeDesc":_t?"project:myNodesPurposeDesc":Gt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),le?null:i.jsxs(i.Fragment,{children:[Gt?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(_t?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ne("all"),ce("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(_t?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ne("all"),ce("")},children:n("project:nodeScopeMine")})]}):null,i.jsx("div",{className:"af-resource-filter-row",children:(Gt?(_t?LF:$F).map(q=>({id:q,label:n(`project:resourceFilter.${q}`)})):Dt).map(q=>q.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(te===q.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ne(q.id),ce("")},children:[q.label,i.jsx("em",{children:q.count}),q.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!q.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Ar(q.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},q.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(te===q.id?" af-resource-filter--active":""),onClick:()=>{ne(q.id),ce("")},children:q.label},q.id))})]}),a==="skills"&&o?i.jsx("div",{className:"af-skill-collections-manager",children:i.jsxs("div",{className:"af-skill-collections-create",children:[i.jsx("input",{className:"af-set-input af-set-input--sm",value:k,onChange:q=>x(q.target.value),onKeyDown:q=>{q.key==="Enter"&&ts()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!k.trim()||N,onClick:()=>ts(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Gt?i.jsx("div",{className:"af-resource-grid",children:ve.length>0?ve.map(q=>i.jsxs("button",{type:"button",className:"af-resource-card"+(mt&&Hn(q)===Hn(mt)?" af-resource-card--active":""),onClick:()=>ce(Hn(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Al(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:i.jsx(Bn,{query:V,children:q.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Bn,{query:V,children:XN(q.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Bn,{query:V,children:q.label||q.displayName||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Bn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Bn,{query:V,children:q.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(q.inputs||{}).length,outputs:Object.keys(q.outputs||{}).length})})]}),q.packageId?i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Bn,{query:V,children:`${q.packageId}${q.version?` / ${q.version}`:""}`})})]}):null]},`${q.id}:${q.source||""}:${q.packageId||""}`)):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:dn?n("project:noNodeMatch",{query:V.trim()}):n(_t?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):le?i.jsx("div",{className:"af-resource-grid",children:tn.length>0?tn.map(q=>{const pe=EP(q),Oe=AP(q),Ee=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):pe.length,et=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):Oe.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Wt&&jo(q)===jo(Wt)?" af-resource-card--active":""),onClick:()=>ce(jo(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Al("primary"),children:i.jsx(Bn,{query:V,children:q.version?`v${q.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Bn,{query:V,children:q.displayName||q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Bn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ee,edges:et})}),i.jsx("span",{children:i.jsx(Bn,{query:V,children:q.id})})]}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Bn,{query:V,children:QN(q)})})]})]},jo(q))}):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:dn?n("project:noFlowSnippetMatch",{query:V.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:Jt.length>0?Jt.map(q=>{const pe=Hn(q),Oe=b.filter(Ee=>{var et;return(et=it.get(Ee.id))==null?void 0:et.has(pe)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(nn&&pe===Hn(nn)?" af-resource-card--active":""),onClick:()=>ce(pe),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Al(q.source==="builtin"?"muted":"primary"),children:i.jsx(Bn,{query:V,children:q.sourceLabel||q.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Bn,{query:V,children:q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Bn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Bn,{query:V,children:q.path||q.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[Oe.slice(0,3).map(Ee=>i.jsx("span",{children:Ee.name},Ee.id)),Oe.length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},q.key||`${q.source}:${q.name}`)}):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:dn?n("project:noSkillMatch",{query:V.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"&&Ct.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:Ct.map(q=>{const pe=Je===`show-builtin:builtin:${q}`;return i.jsxs("button",{type:"button",disabled:pe,onClick:()=>Xn({id:q,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:q}),i.jsx("em",{children:pe?"恢复中":"恢复"})]},q)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[br.length>0?br.map(q=>{var Nn,kt;const pe=(t==null?void 0:t.isAdmin)&&q.source==="user"&&!q.archived&&!sr.has(q.id),Oe=(t==null?void 0:t.isAdmin)&&q.source==="admin",Ee=(t==null?void 0:t.isAdmin)&&q.source==="builtin",et=Je.endsWith(`:${q.source}:${q.id}`);return i.jsx("div",{className:EF(q.source),role:"button",tabIndex:0,onClick:()=>zr(q),onKeyDown:Ut=>{(Ut.key==="Enter"||Ut.key===" ")&&(Ut.preventDefault(),zr(q))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Al(Sx(q.source,n).tone),children:i.jsx(Bn,{query:V,children:Sx(q.source,n).label})}),q.source==="workspace"&&((Nn=q.collaboration)!=null&&Nn.role)?i.jsx("span",{className:Al(q.collaboration.role==="owner"?"primary":"muted"),children:q.collaboration.role==="owner"?"我创建的":`${q.collaboration.ownerUsername||q.collaboration.ownerId} 分享`}):null,q.archived?i.jsx("span",{className:Al("muted"),children:i.jsx(Bn,{query:V,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Bn,{query:V,children:q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Bn,{query:V,children:CP(q,n)})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Bn,{query:V,children:jP(q)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:Ut=>Ut.stopPropagation(),onKeyDown:Ut=>Ut.stopPropagation(),children:[pe?i.jsx("button",{type:"button",disabled:et,onClick:()=>Xn(q,"promote"),children:"设为内置"}):null,Oe?i.jsx("button",{type:"button",disabled:et,onClick:()=>Xn(q,"unpromote"),children:"取消内置"}):null,Ee?i.jsx("button",{type:"button",disabled:et,onClick:()=>Xn(q,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}:${((kt=q.collaboration)==null?void 0:kt.id)||"own"}`)}):z?Qn.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(I?"project:loadFailed":"project:noPipelines")}),!I&&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:V.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:()=>L(!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")})]}),re?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")})]})]})]})]}),Zn?i.jsx("aside",{className:"af-resource-detail","aria-label":n(Gt?"project:nodeDetail":le?"project:flowDetail":"project:skillDetail"),children:Gt&&mt?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:mt.label||mt.displayName||mt.id}),i.jsx("p",{children:mt.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(q=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(de===q?" af-resource-detail-tab--active":""),onClick:()=>me(q),children:n(`project:nodeDetailTabs.${q}`)},q))}),Te===Hn(mt)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):de==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:mt.description||((Pe=tt==null?void 0:tt.node)==null?void 0:Pe.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:mt.type||((xt=tt==null?void 0:tt.node)==null?void 0:xt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:XN(mt.source,n)})]}),mt.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:mt.packageId})]}):null,mt.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:mt.version})]}):null,mt.packageDir||tt!=null&&tt.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:mt.packageDir||(tt==null?void 0:tt.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(tt==null?void 0:tt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),_t&&mt.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:Ke===Hn(mt),onClick:()=>ys(mt),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ke===Hn(mt)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),be?i.jsx("p",{className:"af-resource-action-message",children:be}):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")})]})]}):de==="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")}),yp(((Lt=tt==null?void 0:tt.node)==null?void 0:Lt.inputs)||mt.inputs).length>0?yp(((qt=tt==null?void 0:tt.node)==null?void 0:qt.inputs)||mt.inputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),yp(((zn=tt==null?void 0:tt.node)==null?void 0:zn.outputs)||mt.outputs).length>0?yp(((On=tt==null?void 0:tt.node)==null?void 0:On.outputs)||mt.outputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):de==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),tt!=null&&tt.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(tt.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),tt!=null&&tt.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:tt.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):de==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(tt==null?void 0:tt.files)&&tt.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:tt.files.map(q=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(gt===q.path?" af-node-file-item--active":""),onClick:()=>xe(q.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:q.path})]},q.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[oe===`${Hn(mt)}:${gt}`?n("project:loadingResources"):Ln!=null&&Ln.binary?n("project:binaryFile"):(Ln==null?void 0:Ln.content)||n("project:selectNodeFile"),Ln!=null&&Ln.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(tt==null?void 0:tt.usage)&&tt.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:tt.usage.map(q=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:q.flowId}),i.jsxs("span",{children:[q.flowSource,q.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:q.instances.map(pe=>pe.label||pe.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):le&&Wt?(()=>{const q=VF(Wt);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:Wt.displayName||Wt.name||Wt.id}),i.jsx("p",{children:Wt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Wt.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:Wt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:QN(Wt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Wt.nodeCount))?Number(Wt.nodeCount):q.nodes.length,edges:Number.isFinite(Number(Wt.edgeCount))?Number(Wt.edgeCount):q.edges.length})})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:myFlowsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myFlowManagement")}),i.jsx("p",{children:n("project:deleteMyFlowHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Qt===jo(Wt),onClick:()=>cn(Wt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),Qt===jo(Wt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),yn?i.jsx("p",{className:"af-resource-action-message",children:yn}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),q.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:q.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:i.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),i.jsx("g",{className:"af-flow-snippet-map__edges",children:q.diagram.edges.map(pe=>i.jsxs("g",{children:[i.jsx("path",{d:pe.path}),pe.label?i.jsx("text",{x:pe.labelX,y:pe.labelY-5,textAnchor:"middle",children:Iy(pe.label,18)}):null]},pe.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:q.diagram.nodes.map((pe,Oe)=>i.jsxs("g",{transform:`translate(${pe.x} ${pe.y})`,children:[i.jsx("rect",{width:pe.width,height:pe.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:pe.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:pe.height/2+4,textAnchor:"middle",children:Oe+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:pe.height/2-3,children:Iy(pe.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:pe.height/2+16,children:Iy(pe.meta||pe.id,20)})]},pe.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(Wt.snippet||{},null,2)})]})]})]})})():a==="skills"&&nn?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:nn.name||nn.id}),i.jsx("p",{children:nn.sourceLabel||nn.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:nn.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:nn.sourceLabel||nn.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:nn.path||nn.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),b.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:b.map(q=>{const pe=Hn(nn),Oe=it.get(q.id)||new Set,Ee=Oe.has(pe);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ee,disabled:N||!o,onChange:et=>gs(q.id,pe,et.target.checked)}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[Oe.size," skills"]})]})]},q.id)})})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:skillsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:skillPreview")}),i.jsx("pre",{className:"af-resource-skill-preview",children:_e===Hn(nn)?n("project:loadingResources"):(kr==null?void 0:kr.body)||(kr==null?void 0:kr.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"+(se?"":" af-activity--hidden"),"aria-hidden":!se,"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:Pr.length===0?i.jsx("p",{className:"af-activity-empty",children:rr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Pr.map(q=>{const pe=G===ZN(q);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(pe?" af-activity-row--active":""),"aria-current":pe?"page":void 0,onClick:()=>mo(q),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Bn,{query:V,children:q.flowId})}),i.jsx("span",{className:"af-activity-time",children:GN(q.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:AF(q.kind),children:q.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[q.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",GN(q.at,n)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`)})})]})]}),i.jsx(dF,{open:H,onClose:()=>L(!1),onCreated:async q=>{L(!1),await wn();const pe=q.source??"user";r(gp({id:q.id,source:pe},"workspace"))}}),T?i.jsx(cF,{file:T,onClose:()=>W(null),onImported:async q=>{W(null),await wn();const pe=q.source??"user";r(gp({id:q.id,source:pe},"workspace"))}},`${T.name}-${T.size}-${T.lastModified}`):null]})}function Jn(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=Jn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var KF={value:()=>{}};function Wm(){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 ih(n)}function ih(e){this._=e}function qF(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}})}ih.prototype=Wm.prototype={constructor:ih,on:function(e,t){var n=this._,r=qF(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=UF(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]=nj(n[s],e.name,t);else if(t==null)for(s in n)n[s]=nj(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 ih(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 UF(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function nj(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=KF,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cx="http://www.w3.org/1999/xhtml";const rj={svg:"http://www.w3.org/2000/svg",xhtml:Cx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),rj.hasOwnProperty(t)?{space:rj[t],local:e}:e}function YF(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cx&&t.documentElement.namespaceURI===Cx?t.createElement(e):t.createElementNS(n,e)}}function GF(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function PP(e){var t=Vm(e);return(t.local?GF:YF)(t)}function JF(){}function vk(e){return e==null?JF:function(){return this.querySelector(e)}}function XF(e){typeof e!="function"&&(e=vk(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,u,d=0;d<a;++d)(c=o[d])&&(u=e.call(c,c.__data__,d,o))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new ps(r,this._parents)}function QF(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ZF(){return[]}function IP(e){return e==null?ZF:function(){return this.querySelectorAll(e)}}function ez(e){return function(){return QF(e.apply(this,arguments))}}function tz(e){typeof e=="function"?e=ez(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 ps(r,s)}function RP(e){return function(){return this.matches(e)}}function TP(e){return function(t){return t.matches(e)}}var nz=Array.prototype.find;function rz(e){return function(){return nz.call(this.children,e)}}function sz(){return this.firstElementChild}function iz(e){return this.select(e==null?sz:rz(typeof e=="function"?e:TP(e)))}var oz=Array.prototype.filter;function az(){return Array.from(this.children)}function lz(e){return function(){return oz.call(this.children,e)}}function cz(e){return this.selectAll(e==null?az:lz(typeof e=="function"?e:TP(e)))}function uz(e){typeof e!="function"&&(e=RP(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 ps(r,this._parents)}function MP(e){return new Array(e.length)}function dz(){return new ps(this._enter||this._groups.map(MP),this._parents)}function Wh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Wh.prototype={constructor:Wh,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 fz(e){return function(){return e}}function pz(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 Wh(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function hz(e,t,n,r,s,o,a){var l,c,u=new Map,d=t.length,f=o.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,o[l],l,o)+"",(c=u.get(h))?(r[l]=c,c.__data__=o[l],u.delete(h)):n[l]=new Wh(e,o[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function mz(e){return e.__data__}function gz(e,t){if(!arguments.length)return Array.from(this,mz);var n=t?hz:pz,r=this._parents,s=this._groups;typeof e!="function"&&(e=fz(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var d=r[u],f=s[u],p=f.length,h=yz(e.call(d,d&&d.__data__,u,r)),y=h.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(p);n(d,f,v,b,g,h,t);for(var k=0,x=0,N,j;k<y;++k)if(N=v[k]){for(k>=x&&(x=k+1);!(j=b[x])&&++x<y;);N._next=j||null}}return a=new ps(a,r),a._enter=l,a._exit=c,a}function yz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function wz(){return new ps(this._exit||this._groups.map(MP),this._parents)}function xz(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 bz(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,a=Math.min(s,o),l=new Array(s),c=0;c<a;++c)for(var u=n[c],d=r[c],f=u.length,p=l[c]=new Array(f),h,y=0;y<f;++y)(h=u[y]||d[y])&&(p[y]=h);for(;c<s;++c)l[c]=n[c];return new ps(l,this._parents)}function kz(){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 vz(e){e||(e=Sz);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=s[o]=new Array(l),u,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new ps(s,this._parents).order()}function Sz(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Nz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function jz(){return Array.from(this)}function Cz(){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 _z(){let e=0;for(const t of this)++e;return e}function Ez(){return!this.node()}function Az(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 Pz(e){return function(){this.removeAttribute(e)}}function Iz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Rz(e,t){return function(){this.setAttribute(e,t)}}function Tz(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Mz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function $z(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 Lz(e,t){var n=Vm(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?Iz:Pz:typeof t=="function"?n.local?$z:Mz:n.local?Tz:Rz)(n,t))}function $P(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Oz(e){return function(){this.style.removeProperty(e)}}function Dz(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Fz(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function zz(e,t,n){return arguments.length>1?this.each((t==null?Oz:typeof t=="function"?Fz:Dz)(e,t,n??"")):Nc(this.node(),e)}function Nc(e,t){return e.style.getPropertyValue(t)||$P(e).getComputedStyle(e,null).getPropertyValue(t)}function Bz(e){return function(){delete this[e]}}function Hz(e,t){return function(){this[e]=t}}function Wz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Vz(e,t){return arguments.length>1?this.each((t==null?Bz:typeof t=="function"?Wz:Hz)(e,t)):this.node()[e]}function LP(e){return e.trim().split(/^|\s+/)}function Sk(e){return e.classList||new OP(e)}function OP(e){this._node=e,this._names=LP(e.getAttribute("class")||"")}OP.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 DP(e,t){for(var n=Sk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function FP(e,t){for(var n=Sk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Kz(e){return function(){DP(this,e)}}function qz(e){return function(){FP(this,e)}}function Uz(e,t){return function(){(t.apply(this,arguments)?DP:FP)(this,e)}}function Yz(e,t){var n=LP(e+"");if(arguments.length<2){for(var r=Sk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Uz:t?Kz:qz)(n,t))}function Gz(){this.textContent=""}function Jz(e){return function(){this.textContent=e}}function Xz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Qz(e){return arguments.length?this.each(e==null?Gz:(typeof e=="function"?Xz:Jz)(e)):this.node().textContent}function Zz(){this.innerHTML=""}function e3(e){return function(){this.innerHTML=e}}function t3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function n3(e){return arguments.length?this.each(e==null?Zz:(typeof e=="function"?t3:e3)(e)):this.node().innerHTML}function r3(){this.nextSibling&&this.parentNode.appendChild(this)}function s3(){return this.each(r3)}function i3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function o3(){return this.each(i3)}function a3(e){var t=typeof e=="function"?e:PP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function l3(){return null}function c3(e,t){var n=typeof e=="function"?e:PP(e),r=t==null?l3:typeof t=="function"?t:vk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function u3(){var e=this.parentNode;e&&e.removeChild(this)}function d3(){return this.each(u3)}function f3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function p3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function h3(e){return this.select(e?p3:f3)}function m3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function g3(e){return function(t){e.call(this,t,this.__data__)}}function y3(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function w3(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function x3(e,t,n){return function(){var r=this.__on,s,o=g3(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 b3(e,t,n){var r=y3(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<o;++s)if((a=r[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?x3:w3,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function zP(e,t,n){var r=$P(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 k3(e,t){return function(){return zP(this,e,t)}}function v3(e,t){return function(){return zP(this,e,t.apply(this,arguments))}}function S3(e,t){return this.each((typeof t=="function"?v3:k3)(e,t))}function*N3(){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 BP=[null];function ps(e,t){this._groups=e,this._parents=t}function lf(){return new ps([[document.documentElement]],BP)}function j3(){return this}ps.prototype=lf.prototype={constructor:ps,select:XF,selectAll:tz,selectChild:iz,selectChildren:cz,filter:uz,data:gz,enter:dz,exit:wz,join:xz,merge:bz,selection:j3,order:kz,sort:vz,call:Nz,nodes:jz,node:Cz,size:_z,empty:Ez,each:Az,attr:Lz,style:zz,property:Vz,classed:Yz,text:Qz,html:n3,raise:s3,lower:o3,append:a3,insert:c3,remove:d3,clone:h3,datum:m3,on:b3,dispatch:S3,[Symbol.iterator]:N3};function as(e){return typeof e=="string"?new ps([[document.querySelector(e)]],[document.documentElement]):new ps([[e]],BP)}function C3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function qs(e,t){if(e=C3(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 _3={passive:!1},Rd={capture:!0,passive:!1};function Ry(e){e.stopImmediatePropagation()}function cc(e){e.preventDefault(),e.stopImmediatePropagation()}function HP(e){var t=e.document.documentElement,n=as(e).on("dragstart.drag",cc,Rd);"onselectstart"in t?n.on("selectstart.drag",cc,Rd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function WP(e,t){var n=e.document.documentElement,r=as(e).on("dragstart.drag",null);t&&(r.on("click.drag",cc,Rd),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 wp=e=>()=>e;function _x(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}_x.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function E3(e){return!e.ctrlKey&&!e.button}function A3(){return this.parentNode}function P3(e,t){return t??{x:e.x,y:e.y}}function I3(){return navigator.maxTouchPoints||"ontouchstart"in this}function VP(){var e=E3,t=A3,n=P3,r=I3,s={},o=Wm("start","drag","end"),a=0,l,c,u,d,f=0;function p(N){N.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,_3).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(N,j){if(!(d||!e.call(this,N,j))){var C=x(this,t.call(this,N,j),N,j,"mouse");C&&(as(N.view).on("mousemove.drag",y,Rd).on("mouseup.drag",v,Rd),HP(N.view),Ry(N),u=!1,l=N.clientX,c=N.clientY,C("start",N))}}function y(N){if(cc(N),!u){var j=N.clientX-l,C=N.clientY-c;u=j*j+C*C>f}s.mouse("drag",N)}function v(N){as(N.view).on("mousemove.drag mouseup.drag",null),WP(N.view,u),cc(N),s.mouse("end",N)}function b(N,j){if(e.call(this,N,j)){var C=N.changedTouches,P=t.call(this,N,j),I=C.length,F,$;for(F=0;F<I;++F)($=x(this,P,N,j,C[F].identifier,C[F]))&&(Ry(N),$("start",N,C[F]))}}function g(N){var j=N.changedTouches,C=j.length,P,I;for(P=0;P<C;++P)(I=s[j[P].identifier])&&(cc(N),I("drag",N,j[P]))}function k(N){var j=N.changedTouches,C=j.length,P,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<C;++P)(I=s[j[P].identifier])&&(Ry(N),I("end",N,j[P]))}function x(N,j,C,P,I,F){var $=o.copy(),D=qs(F||C,j),z,O,M;if((M=n.call(N,new _x("beforestart",{sourceEvent:C,target:p,identifier:I,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:$}),P))!=null)return z=M.x-D[0]||0,O=M.y-D[1]||0,function K(H,L,T){var W=D,E;switch(H){case"start":s[I]=K,E=a++;break;case"end":delete s[I],--a;case"drag":D=qs(T||L,j),E=a;break}$.call(H,N,new _x(H,{sourceEvent:L,subject:M,target:p,identifier:I,active:E,x:D[0]+z,y:D[1]+O,dx:D[0]-W[0],dy:D[1]-W[1],dispatch:$}),P)}}return p.filter=function(N){return arguments.length?(e=typeof N=="function"?N:wp(!!N),p):e},p.container=function(N){return arguments.length?(t=typeof N=="function"?N:wp(N),p):t},p.subject=function(N){return arguments.length?(n=typeof N=="function"?N:wp(N),p):n},p.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:wp(!!N),p):r},p.on=function(){var N=o.on.apply(o,arguments);return N===o?p:N},p.clickDistance=function(N){return arguments.length?(f=(N=+N)*N,p):Math.sqrt(f)},p}function Nk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function KP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function cf(){}var Td=.7,Vh=1/Td,uc="\\s*([+-]?\\d+)\\s*",Md="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ci="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",R3=/^#([0-9a-f]{3,8})$/,T3=new RegExp(`^rgb\\(${uc},${uc},${uc}\\)$`),M3=new RegExp(`^rgb\\(${Ci},${Ci},${Ci}\\)$`),$3=new RegExp(`^rgba\\(${uc},${uc},${uc},${Md}\\)$`),L3=new RegExp(`^rgba\\(${Ci},${Ci},${Ci},${Md}\\)$`),O3=new RegExp(`^hsl\\(${Md},${Ci},${Ci}\\)$`),D3=new RegExp(`^hsla\\(${Md},${Ci},${Ci},${Md}\\)$`),sj={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};Nk(cf,Ua,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ij,formatHex:ij,formatHex8:F3,formatHsl:z3,formatRgb:oj,toString:oj});function ij(){return this.rgb().formatHex()}function F3(){return this.rgb().formatHex8()}function z3(){return qP(this).formatHsl()}function oj(){return this.rgb().formatRgb()}function Ua(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=R3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?aj(t):n===3?new Yr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?xp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?xp(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=T3.exec(e))?new Yr(t[1],t[2],t[3],1):(t=M3.exec(e))?new Yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=$3.exec(e))?xp(t[1],t[2],t[3],t[4]):(t=L3.exec(e))?xp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=O3.exec(e))?uj(t[1],t[2]/100,t[3]/100,1):(t=D3.exec(e))?uj(t[1],t[2]/100,t[3]/100,t[4]):sj.hasOwnProperty(e)?aj(sj[e]):e==="transparent"?new Yr(NaN,NaN,NaN,0):null}function aj(e){return new Yr(e>>16&255,e>>8&255,e&255,1)}function xp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Yr(e,t,n,r)}function B3(e){return e instanceof cf||(e=Ua(e)),e?(e=e.rgb(),new Yr(e.r,e.g,e.b,e.opacity)):new Yr}function Ex(e,t,n,r){return arguments.length===1?B3(e):new Yr(e,t,n,r??1)}function Yr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Nk(Yr,Ex,KP(cf,{brighter(e){return e=e==null?Vh:Math.pow(Vh,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Td:Math.pow(Td,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Yr(Da(this.r),Da(this.g),Da(this.b),Kh(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:lj,formatHex:lj,formatHex8:H3,formatRgb:cj,toString:cj}));function lj(){return`#${Ra(this.r)}${Ra(this.g)}${Ra(this.b)}`}function H3(){return`#${Ra(this.r)}${Ra(this.g)}${Ra(this.b)}${Ra((isNaN(this.opacity)?1:this.opacity)*255)}`}function cj(){const e=Kh(this.opacity);return`${e===1?"rgb(":"rgba("}${Da(this.r)}, ${Da(this.g)}, ${Da(this.b)}${e===1?")":`, ${e})`}`}function Kh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Da(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ra(e){return e=Da(e),(e<16?"0":"")+e.toString(16)}function uj(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Gs(e,t,n,r)}function qP(e){if(e instanceof Gs)return new Gs(e.h,e.s,e.l,e.opacity);if(e instanceof cf||(e=Ua(e)),!e)return new Gs;if(e instanceof Gs)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 Gs(a,l,c,e.opacity)}function W3(e,t,n,r){return arguments.length===1?qP(e):new Gs(e,t,n,r??1)}function Gs(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Nk(Gs,W3,KP(cf,{brighter(e){return e=e==null?Vh:Math.pow(Vh,e),new Gs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Td:Math.pow(Td,e),new Gs(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 Yr(Ty(e>=240?e-240:e+120,s,r),Ty(e,s,r),Ty(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Gs(dj(this.h),bp(this.s),bp(this.l),Kh(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=Kh(this.opacity);return`${e===1?"hsl(":"hsla("}${dj(this.h)}, ${bp(this.s)*100}%, ${bp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function dj(e){return e=(e||0)%360,e<0?e+360:e}function bp(e){return Math.max(0,Math.min(1,e||0))}function Ty(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 jk=e=>()=>e;function V3(e,t){return function(n){return e+n*t}}function K3(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 q3(e){return(e=+e)==1?UP:function(t,n){return n-t?K3(t,n,e):jk(isNaN(t)?n:t)}}function UP(e,t){var n=t-e;return n?V3(e,n):jk(isNaN(e)?t:e)}const qh=function e(t){var n=q3(t);function r(s,o){var a=n((s=Ex(s)).r,(o=Ex(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=UP(s.opacity,o.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function U3(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 Y3(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function G3(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]=id(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 J3(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function gi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function X3(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]=id(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Ax=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,My=new RegExp(Ax.source,"g");function Q3(e){return function(){return e}}function Z3(e){return function(t){return e(t)+""}}function YP(e,t){var n=Ax.lastIndex=My.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Ax.exec(e))&&(s=My.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:gi(r,s)})),n=My.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?Z3(c[0].x):Q3(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function id(e,t){var n=typeof t,r;return t==null||n==="boolean"?jk(t):(n==="number"?gi:n==="string"?(r=Ua(t))?(t=r,qh):YP:t instanceof Ua?qh:t instanceof Date?J3:Y3(t)?U3:Array.isArray(t)?G3:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?X3:gi)(e,t)}var fj=180/Math.PI,Px={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function GP(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)*fj,skewX:Math.atan(c)*fj,scaleX:a,scaleY:l}}var kp;function eB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Px:GP(t.a,t.b,t.c,t.d,t.e,t.f)}function tB(e){return e==null||(kp||(kp=document.createElementNS("http://www.w3.org/2000/svg","g")),kp.setAttribute("transform",e),!(e=kp.transform.baseVal.consolidate()))?Px:(e=e.matrix,GP(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,d,f,p,h,y){if(u!==f||d!==p){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:gi(u,f)},{i:v-2,x:gi(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:gi(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:gi(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,y){if(u!==f||d!==p){var v=h.push(s(h)+"scale(",null,",",null,")");y.push({i:v-4,x:gi(u,f)},{i:v-2,x:gi(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),o(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var y=-1,v=p.length,b;++y<v;)f[(b=p[y]).i]=b.x(h);return f.join("")}}}var nB=JP(eB,"px, ","px)","deg)"),rB=JP(tB,", ",")",")"),sB=1e-12;function pj(e){return((e=Math.exp(e))+1/e)/2}function iB(e){return((e=Math.exp(e))-1/e)/2}function oB(e){return((e=Math.exp(2*e))-1)/(e+1)}const oh=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],u=o[2],d=a[0],f=a[1],p=a[2],h=d-l,y=f-c,v=h*h+y*y,b,g;if(v<sB)g=Math.log(p/u)/t,b=function(P){return[l+P*h,c+P*y,u*Math.exp(t*P*g)]};else{var k=Math.sqrt(v),x=(p*p-u*u+r*v)/(2*u*n*k),N=(p*p-u*u-r*v)/(2*p*n*k),j=Math.log(Math.sqrt(x*x+1)-x),C=Math.log(Math.sqrt(N*N+1)-N);g=(C-j)/t,b=function(P){var I=P*g,F=pj(j),$=u/(n*k)*(F*oB(t*I+j)-iB(j));return[l+$*h,c+$*y,u*F/pj(t*I+j)]}}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 jc=0,Bu=0,Cu=0,XP=1e3,Uh,Hu,Yh=0,Ya=0,Km=0,$d=typeof performance=="object"&&performance.now?performance:Date,QP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ck(){return Ya||(QP(aB),Ya=$d.now()+Km)}function aB(){Ya=0}function Gh(){this._call=this._time=this._next=null}Gh.prototype=ZP.prototype={constructor:Gh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Ck():+n)+(t==null?0:+t),!this._next&&Hu!==this&&(Hu?Hu._next=this:Uh=this,Hu=this),this._call=e,this._time=n,Ix()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ix())}};function ZP(e,t,n){var r=new Gh;return r.restart(e,t,n),r}function lB(){Ck(),++jc;for(var e=Uh,t;e;)(t=Ya-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jc}function hj(){Ya=(Yh=$d.now())+Km,jc=Bu=0;try{lB()}finally{jc=0,uB(),Ya=0}}function cB(){var e=$d.now(),t=e-Yh;t>XP&&(Km-=t,Yh=e)}function uB(){for(var e,t=Uh,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:Uh=n);Hu=e,Ix(r)}function Ix(e){if(!jc){Bu&&(Bu=clearTimeout(Bu));var t=e-Ya;t>24?(e<1/0&&(Bu=setTimeout(hj,e-$d.now()-Km)),Cu&&(Cu=clearInterval(Cu))):(Cu||(Yh=$d.now(),Cu=setInterval(cB,XP)),jc=1,QP(hj))}}function mj(e,t,n){var r=new Gh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var dB=Wm("start","end","cancel","interrupt"),fB=[],eI=0,gj=1,Rx=2,ah=3,yj=4,Tx=5,lh=6;function qm(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;pB(e,n,{name:t,index:r,group:s,on:dB,tween:fB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:eI})}function _k(e,t){var n=ii(e,t);if(n.state>eI)throw new Error("too late; already scheduled");return n}function Ti(e,t){var n=ii(e,t);if(n.state>ah)throw new Error("too late; already running");return n}function ii(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function pB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=ZP(o,0,n.time);function o(u){n.state=gj,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==gj)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===ah)return mj(a);h.state===yj?(h.state=lh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=lh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(mj(function(){n.state===ah&&(n.state=yj,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Rx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Rx){for(n.state=ah,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Tx,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Tx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=lh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function ch(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>Rx&&r.state<Tx,r.state=lh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function hB(e){return this.each(function(){ch(this,e)})}function mB(e,t){var n,r;return function(){var s=Ti(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 gB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Ti(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 yB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ii(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?mB:gB)(n,e,t))}function Ek(e,t,n){var r=e._id;return e.each(function(){var s=Ti(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ii(s,r).value[t]}}function tI(e,t){var n;return(typeof t=="number"?gi:t instanceof Ua?qh:(n=Ua(t))?(t=n,qh):YP)(e,t)}function wB(e){return function(){this.removeAttribute(e)}}function xB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bB(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 kB(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 vB(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 SB(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 NB(e,t){var n=Vm(e),r=n==="transform"?rB:tI;return this.attrTween(e,typeof t=="function"?(n.local?SB:vB)(n,r,Ek(this,"attr."+e,t)):t==null?(n.local?xB:wB)(n):(n.local?kB:bB)(n,r,t))}function jB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function CB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _B(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&CB(e,o)),n}return s._value=t,s}function EB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&jB(e,o)),n}return s._value=t,s}function AB(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=Vm(e);return this.tween(n,(r.local?_B:EB)(r,t))}function PB(e,t){return function(){_k(this,e).delay=+t.apply(this,arguments)}}function IB(e,t){return t=+t,function(){_k(this,e).delay=t}}function RB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?PB:IB)(t,e)):ii(this.node(),t).delay}function TB(e,t){return function(){Ti(this,e).duration=+t.apply(this,arguments)}}function MB(e,t){return t=+t,function(){Ti(this,e).duration=t}}function $B(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?TB:MB)(t,e)):ii(this.node(),t).duration}function LB(e,t){if(typeof t!="function")throw new Error;return function(){Ti(this,e).ease=t}}function OB(e){var t=this._id;return arguments.length?this.each(LB(t,e)):ii(this.node(),t).ease}function DB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ti(this,e).ease=n}}function FB(e){if(typeof e!="function")throw new Error;return this.each(DB(this._id,e))}function zB(e){typeof e!="function"&&(e=RP(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 ao(r,this._parents,this._name,this._id)}function BB(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=n[l],d=c.length,f=a[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new ao(a,this._parents,this._name,this._id)}function HB(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 WB(e,t,n){var r,s,o=HB(t)?_k:Ti;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function VB(e,t){var n=this._id;return arguments.length<2?ii(this.node(),n).on.on(e):this.each(WB(n,e,t))}function KB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function qB(){return this.on("end.remove",KB(this._id))}function UB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vk(e));for(var r=this._groups,s=r.length,o=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,u=o[a]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,qm(u[p],t,n,p,u,ii(d,n)));return new ao(o,this._parents,t,n)}function YB(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,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,y=ii(d,n),v=0,b=p.length;v<b;++v)(h=p[v])&&qm(h,t,n,v,p,y);o.push(p),a.push(d)}return new ao(o,a,t,n)}var GB=lf.prototype.constructor;function JB(){return new GB(this._groups,this._parents)}function XB(e,t){var n,r,s;return function(){var o=Nc(this,e),a=(this.style.removeProperty(e),Nc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function nI(e){return function(){this.style.removeProperty(e)}}function QB(e,t,n){var r,s=n+"",o;return function(){var a=Nc(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=Nc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Nc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function eH(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Ti(this,e),u=c.on,d=c.value[o]==null?l||(l=nI(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function tH(e,t,n){var r=(e+="")=="transform"?nB:tI;return t==null?this.styleTween(e,XB(e,r)).on("end.style."+e,nI(e)):typeof t=="function"?this.styleTween(e,ZB(e,r,Ek(this,"style."+e,t))).each(eH(this._id,e)):this.styleTween(e,QB(e,r,t),n).on("end.style."+e,null)}function nH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function rH(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&nH(e,a,n)),r}return o._value=t,o}function sH(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,rH(e,t,n??""))}function iH(e){return function(){this.textContent=e}}function oH(e){return function(){var t=e(this);this.textContent=t??""}}function aH(e){return this.tween("text",typeof e=="function"?oH(Ek(this,"text",e)):iH(e==null?"":e+""))}function lH(e){return function(t){this.textContent=e.call(this,t)}}function cH(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&lH(s)),t}return r._value=e,r}function uH(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,cH(e))}function dH(){for(var e=this._name,t=this._id,n=rI(),r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var d=ii(c,t);qm(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ao(r,this._parents,e,n)}function fH(){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=Ti(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&o()})}var pH=0;function ao(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function rI(){return++pH}var Hi=lf.prototype;ao.prototype={constructor:ao,select:UB,selectAll:YB,selectChild:Hi.selectChild,selectChildren:Hi.selectChildren,filter:zB,merge:BB,selection:JB,transition:dH,call:Hi.call,nodes:Hi.nodes,node:Hi.node,size:Hi.size,empty:Hi.empty,each:Hi.each,on:VB,attr:NB,attrTween:AB,style:tH,styleTween:sH,text:aH,textTween:uH,remove:qB,tween:yB,delay:RB,duration:$B,ease:OB,easeVarying:FB,end:fH,[Symbol.iterator]:Hi[Symbol.iterator]};function hH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var mH={time:null,delay:0,duration:250,ease:hH};function gH(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 yH(e){var t,n;e instanceof ao?(t=e._id,e=e._name):(t=rI(),(n=mH).time=Ck(),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])&&qm(c,e,t,u,a,n||gH(c,t));return new ao(r,this._parents,e,t)}lf.prototype.interrupt=hB;lf.prototype.transition=yH;const vp=e=>()=>e;function wH(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Ji(e,t,n){this.k=e,this.x=t,this.y=n}Ji.prototype={constructor:Ji,scale:function(e){return e===1?this:new Ji(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ji(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 Um=new Ji(1,0,0);sI.prototype=Ji.prototype;function sI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Um;return e.__zoom}function $y(e){e.stopImmediatePropagation()}function _u(e){e.preventDefault(),e.stopImmediatePropagation()}function xH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function bH(){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 wj(){return this.__zoom||Um}function kH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vH(){return navigator.maxTouchPoints||"ontouchstart"in this}function SH(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 iI(){var e=xH,t=bH,n=SH,r=kH,s=vH,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=oh,u=Wm("start","zoom","end"),d,f,p,h=500,y=150,v=0,b=10;function g(M){M.property("__zoom",wj).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",$).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,K,H,L){var T=M.selection?M.selection():M;T.property("__zoom",wj),M!==T?j(M,K,H,L):T.interrupt().each(function(){C(this,arguments).event(L).start().zoom(null,typeof K=="function"?K.apply(this,arguments):K).end()})},g.scaleBy=function(M,K,H,L){g.scaleTo(M,function(){var T=this.__zoom.k,W=typeof K=="function"?K.apply(this,arguments):K;return T*W},H,L)},g.scaleTo=function(M,K,H,L){g.transform(M,function(){var T=t.apply(this,arguments),W=this.__zoom,E=H==null?N(T):typeof H=="function"?H.apply(this,arguments):H,Q=W.invert(E),V=typeof K=="function"?K.apply(this,arguments):K;return n(x(k(W,V),E,Q),T,a)},H,L)},g.translateBy=function(M,K,H,L){g.transform(M,function(){return n(this.__zoom.translate(typeof K=="function"?K.apply(this,arguments):K,typeof H=="function"?H.apply(this,arguments):H),t.apply(this,arguments),a)},null,L)},g.translateTo=function(M,K,H,L,T){g.transform(M,function(){var W=t.apply(this,arguments),E=this.__zoom,Q=L==null?N(W):typeof L=="function"?L.apply(this,arguments):L;return n(Um.translate(Q[0],Q[1]).scale(E.k).translate(typeof K=="function"?-K.apply(this,arguments):-K,typeof H=="function"?-H.apply(this,arguments):-H),W,a)},L,T)};function k(M,K){return K=Math.max(o[0],Math.min(o[1],K)),K===M.k?M:new Ji(K,M.x,M.y)}function x(M,K,H){var L=K[0]-H[0]*M.k,T=K[1]-H[1]*M.k;return L===M.x&&T===M.y?M:new Ji(M.k,L,T)}function N(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function j(M,K,H,L){M.on("start.zoom",function(){C(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(L).end()}).tween("zoom",function(){var T=this,W=arguments,E=C(T,W).event(L),Q=t.apply(T,W),V=H==null?N(Q):typeof H=="function"?H.apply(T,W):H,B=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),se=T.__zoom,ue=typeof K=="function"?K.apply(T,W):K,G=c(se.invert(V).concat(B/se.k),ue.invert(V).concat(B/ue.k));return function(ee){if(ee===1)ee=ue;else{var te=G(ee),ne=B/te[2];ee=new Ji(ne,V[0]-te[0]*ne,V[1]-te[1]*ne)}E.zoom(null,ee)}})}function C(M,K,H){return!H&&M.__zooming||new P(M,K)}function P(M,K){this.that=M,this.args=K,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,K),this.taps=0}P.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,K){return this.mouse&&M!=="mouse"&&(this.mouse[1]=K.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=K.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=K.invert(this.touch1[0])),this.that.__zoom=K,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var K=as(this.that).datum();u.call(M,this.that,new wH(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),K)}};function I(M,...K){if(!e.apply(this,arguments))return;var H=C(this,K).event(M),L=this.__zoom,T=Math.max(o[0],Math.min(o[1],L.k*Math.pow(2,r.apply(this,arguments)))),W=qs(M);if(H.wheel)(H.mouse[0][0]!==W[0]||H.mouse[0][1]!==W[1])&&(H.mouse[1]=L.invert(H.mouse[0]=W)),clearTimeout(H.wheel);else{if(L.k===T)return;H.mouse=[W,L.invert(W)],ch(this),H.start()}_u(M),H.wheel=setTimeout(E,y),H.zoom("mouse",n(x(k(L,T),H.mouse[0],H.mouse[1]),H.extent,a));function E(){H.wheel=null,H.end()}}function F(M,...K){if(p||!e.apply(this,arguments))return;var H=M.currentTarget,L=C(this,K,!0).event(M),T=as(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",B,!0),W=qs(M,H),E=M.clientX,Q=M.clientY;HP(M.view),$y(M),L.mouse=[W,this.__zoom.invert(W)],ch(this),L.start();function V(se){if(_u(se),!L.moved){var ue=se.clientX-E,G=se.clientY-Q;L.moved=ue*ue+G*G>v}L.event(se).zoom("mouse",n(x(L.that.__zoom,L.mouse[0]=qs(se,H),L.mouse[1]),L.extent,a))}function B(se){T.on("mousemove.zoom mouseup.zoom",null),WP(se.view,L.moved),_u(se),L.event(se).end()}}function $(M,...K){if(e.apply(this,arguments)){var H=this.__zoom,L=qs(M.changedTouches?M.changedTouches[0]:M,this),T=H.invert(L),W=H.k*(M.shiftKey?.5:2),E=n(x(k(H,W),L,T),t.apply(this,K),a);_u(M),l>0?as(this).transition().duration(l).call(j,E,L,M):as(this).call(g.transform,E,L,M)}}function D(M,...K){if(e.apply(this,arguments)){var H=M.touches,L=H.length,T=C(this,K,M.changedTouches.length===L).event(M),W,E,Q,V;for($y(M),E=0;E<L;++E)Q=H[E],V=qs(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],T.touch0?!T.touch1&&T.touch0[2]!==V[2]&&(T.touch1=V,T.taps=0):(T.touch0=V,W=!0,T.taps=1+!!d);d&&(d=clearTimeout(d)),W&&(T.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),ch(this),T.start())}}function z(M,...K){if(this.__zooming){var H=C(this,K).event(M),L=M.changedTouches,T=L.length,W,E,Q,V;for(_u(M),W=0;W<T;++W)E=L[W],Q=qs(E,this),H.touch0&&H.touch0[2]===E.identifier?H.touch0[0]=Q:H.touch1&&H.touch1[2]===E.identifier&&(H.touch1[0]=Q);if(E=H.that.__zoom,H.touch1){var B=H.touch0[0],se=H.touch0[1],ue=H.touch1[0],G=H.touch1[1],ee=(ee=ue[0]-B[0])*ee+(ee=ue[1]-B[1])*ee,te=(te=G[0]-se[0])*te+(te=G[1]-se[1])*te;E=k(E,Math.sqrt(ee/te)),Q=[(B[0]+ue[0])/2,(B[1]+ue[1])/2],V=[(se[0]+G[0])/2,(se[1]+G[1])/2]}else if(H.touch0)Q=H.touch0[0],V=H.touch0[1];else return;H.zoom("touch",n(x(E,Q,V),H.extent,a))}}function O(M,...K){if(this.__zooming){var H=C(this,K).event(M),L=M.changedTouches,T=L.length,W,E;for($y(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),W=0;W<T;++W)E=L[W],H.touch0&&H.touch0[2]===E.identifier?delete H.touch0:H.touch1&&H.touch1[2]===E.identifier&&delete H.touch1;if(H.touch1&&!H.touch0&&(H.touch0=H.touch1,delete H.touch1),H.touch0)H.touch0[1]=this.__zoom.invert(H.touch0[0]);else if(H.end(),H.taps===2&&(E=qs(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<b)){var Q=as(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:vp(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:vp(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:vp(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:vp([[+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 Ii={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."},Ld=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],oI=["Enter"," ","Escape"],aI={"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 Cc;(function(e){e.Strict="strict",e.Loose="loose"})(Cc||(Cc={}));var Fa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fa||(Fa={}));var Od;(function(e){e.Partial="partial",e.Full="full"})(Od||(Od={}));const lI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Mo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Mo||(Mo={}));var bi;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(bi||(bi={}));var qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(qe||(qe={}));const xj={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};function cI(e){return e===null?null:e?"valid":"invalid"}const uI=e=>"id"in e&&"source"in e&&"target"in e,NH=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ak=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),uf=(e,t=[0,0])=>{const{width:n,height:r}=fo(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},jH=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const o=typeof s=="string";let a=!t.nodeLookup&&!o?s:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(s):Ak(s)?s:t.nodeLookup.get(s.id));const l=a?Jh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ym(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Gm(n)},df=(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=Ym(n,Jh(s)),r=!0)}),r?Gm(n):{x:0,y:0,width:0,height:0}},Pk=(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:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,y=d.height??u.height??u.initialHeight??null,v=Dd(l,Ec(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},CH=(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 _H(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 EH({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=_H(e,a),c=df(l),u=Ik(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 dI({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Ii.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(f=[[c,u],[c+h,u+y]])}else l&&Ac(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ac(f)?Ga(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Ii.error015())),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function AH({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=o.has(p.id),y=!h&&p.parentId&&a.find(v=>v.id===p.parentId);(h||y)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=CH(a,c);for(const p of c)l.has(p.id)&&!d.find(y=>y.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const _c=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ga=(e={x:0,y:0},t,n)=>({x:_c(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:_c(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function fI(e,t,n){const{width:r,height:s}=fo(n),{x:o,y:a}=n.internals.positionAbsolute;return Ga(e,[[o,a],[o+r,a+s]],t)}const bj=(e,t,n)=>e<t?_c(Math.abs(e-t),1,t)/t:e>n?-_c(Math.abs(e-n),1,t)/t:0,pI=(e,t,n=15,r=40)=>{const s=bj(e.x,r,t.width-r)*n,o=bj(e.y,r,t.height-r)*n;return[s,o]},Ym=(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)}),Mx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Gm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ec=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Ak(e)?e.internals.positionAbsolute:uf(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}},Jh=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Ak(e)?e.internals.positionAbsolute:uf(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)}},hI=(e,t)=>Gm(Ym(Mx(e),Mx(t))),Dd=(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)},kj=e=>Js(e.width)&&Js(e.height)&&Js(e.x)&&Js(e.y),Js=e=>!isNaN(e)&&isFinite(e),PH=(e,t)=>{},ff=(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?ff(l,a):l},Xh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Il(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 IH(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Il(e,n),s=Il(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Il(e.top??e.y??0,n),s=Il(e.bottom??e.y??0,n),o=Il(e.left??e.x??0,t),a=Il(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 RH(e,t,n,r,s,o){const{x:a,y:l}=Xh(e,[t,n,r]),{x:c,y:u}=Xh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Ik=(e,t,n,r,s,o)=>{const a=IH(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=_c(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,y=n/2-p*d,v=RH(e,h,y,d,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:h-b.left+b.right,y:y-b.top+b.bottom,zoom:d}},Fd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ac(e){return e!=null&&e!=="parent"}function fo(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 mI(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 gI(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 vj(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function TH(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function MH(e){return{...aI,...e||{}}}function od(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=Xs(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?ff(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Rk=e=>({width:e.offsetWidth,height:e.offsetHeight}),yI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},$H=["INPUT","SELECT","TEXTAREA"];function wI(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:$H.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const xI=e=>"clientX"in e,Xs=(e,t)=>{var o,a;const n=xI(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)}},Sj=(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,...Rk(a)}})};function bI({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+o*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function Sp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Nj({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case qe.Left:return[t-Sp(t-r,o),n];case qe.Right:return[t+Sp(r-t,o),n];case qe.Top:return[t,n-Sp(n-s,o)];case qe.Bottom:return[t,n+Sp(s-n,o)]}}function kI({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top,curvature:a=.25}){const[l,c]=Nj({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=Nj({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,y]=bI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,h,y]}function vI({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 LH({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 OH({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=Ym(Jh(e),Jh(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 Dd(a,Gm(o))>0}const DH=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,FH=(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)),uh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||DH;let s;return uI(e)?s={...e}:s={...e,id:r(e)},FH(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function SI({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=vI({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const jj={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}},zH=({source:e,sourcePosition:t=qe.Bottom,target:n})=>t===qe.Left||t===qe.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Cj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function BH({source:e,sourcePosition:t=qe.Bottom,target:n,targetPosition:r=qe.Top,center:s,offset:o,stepPosition:a}){const l=jj[t],c=jj[r],u={x:e.x+l.x*o,y:e.y+l.y*o},d={x:n.x+c.x*o,y:n.y+c.y*o},f=zH({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,N]=vI({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??u.x+(d.x-u.x)*a,b=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,b=s.y??u.y+(d.y-u.y)*a);const I=[{x:v,y:u.y},{x:v,y:d.y}],F=[{x:u.x,y:b},{x:d.x,y:b}];l[p]===h?y=p==="x"?I:F:y=p==="x"?F:I}else{const I=[{x:u.x,y:d.y}],F=[{x:d.x,y:u.y}];if(p==="x"?y=l.x===h?F:I:y=l.y===h?I:F,t===r){const M=Math.abs(e[p]-n[p]);if(M<=o){const K=Math.min(o-1,o-M);l[p]===h?g[p]=(u[p]>e[p]?-1:1)*K:k[p]=(d[p]>n[p]?-1:1)*K}}if(t!==r){const M=p==="x"?"y":"x",K=l[p]===c[M],H=u[M]>d[M],L=u[M]<d[M];(l[p]===1&&(!K&&H||K&&L)||l[p]!==1&&(!K&&L||K&&H))&&(y=p==="x"?I:F)}const $={x:u.x+g.x,y:u.y+g.y},D={x:d.x+k.x,y:d.y+k.y},z=Math.max(Math.abs($.x-y[0].x),Math.abs(D.x-y[0].x)),O=Math.max(Math.abs($.y-y[0].y),Math.abs(D.y-y[0].y));z>=O?(v=($.x+D.x)/2,b=y[0].y):(v=y[0].x,b=($.y+D.y)/2)}const j={x:u.x+g.x,y:u.y+g.y},C={x:d.x+k.x,y:d.y+k.y};return[[e,...j.x!==y[0].x||j.y!==y[0].y?[j]:[],...y,...C.x!==y[y.length-1].x||C.y!==y[y.length-1].y?[C]:[],n],v,b,x,N]}function HH(e,t,n,r){const s=Math.min(Cj(e,t)/2,Cj(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${o+s*u},${a}Q ${o},${a} ${o},${a+s*d}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${a+s*c}Q ${o},${a} ${o+s*l},${a}`}function $x({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,y,v]=BH({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:d});let b=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)b+=HH(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,p,h,y,v]}function _j(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function WH(e){var f;const{sourceNode:t,targetNode:n}=e;if(!_j(t)||!_j(n))return null;const r=t.internals.handleBounds||Ej(t.handles),s=n.internals.handleBounds||Ej(n.handles),o=Aj((r==null?void 0:r.source)??[],e.sourceHandle),a=Aj(e.connectionMode===Cc.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!o||!a)return(f=e.onError)==null||f.call(e,"008",Ii.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||qe.Bottom,c=(a==null?void 0:a.position)||qe.Top,u=Ja(t,o,l),d=Ja(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function Ej(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 Ja(e,t,n=qe.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??fo(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case qe.Top:return{x:s+a/2,y:o};case qe.Right:return{x:s+a,y:o+l/2};case qe.Bottom:return{x:s+a/2,y:o+l};case qe.Left:return{x:s,y:o+l/2}}}function Aj(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Lx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function VH(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=Lx(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 NI=1e3,KH=10,Tk={nodeOrigin:[0,0],nodeExtent:Ld,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},qH={...Tk,checkEquality:!0};function Mk(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function UH(e,t,n){const r=Mk(Tk,n);for(const s of e.values())if(s.parentId)Lk(s,e,t,r);else{const o=uf(s,r.nodeOrigin),a=Ac(s.extent)?s.extent:r.nodeExtent,l=Ga(o,a,fo(s));s.internals.positionAbsolute=l}}function YH(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 $k(e){return e==="manual"}function Ox(e,t,n,r={}){var d,f;const s=Mk(qH,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!$k(s.zIndexMode)?NI:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const y=uf(p,s.nodeOrigin),v=Ac(p.extent)?p.extent:s.nodeExtent,b=Ga(y,v,fo(p));h={...s.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:YH(p,h),z:jI(p,l,s.zIndexMode),userNode:p}},t.set(p.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),p.parentId&&Lk(h,t,n,r,o),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function GH(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 Lk(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Mk(Tk,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}GH(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*KH),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=o&&!$k(c)?NI:0,{x:p,y:h,z:y}=JH(e,d,a,l,f,c),{positionAbsolute:v}=e.internals,b=p!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:p,y:h}:v,z:y}})}function jI(e,t,n){const r=Js(e.zIndex)?e.zIndex:0;return $k(n)?r:r+(e.selected?t:0)}function JH(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=fo(e),u=uf(e,n),d=Ac(e.extent)?Ga(u,e.extent,c):u;let f=Ga({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=fI(f,c,t));const p=jI(e,s,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Ok(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)??Ec(c),d=hI(u,l.rect);o.set(l.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=fo(c),p=c.origin??r,h=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,y=l.y<d.y?Math.round(Math.abs(d.y-l.y)):0,v=Math.max(f.width,Math.round(l.width)),b=Math.max(f.height,Math.round(l.height)),g=(v-f.width)*p[0],k=(b-f.height)*p[1];(h>0||y>0||g||k)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(N=>{e.some(j=>j.id===N.id)||s.push({id:N.id,type:"position",position:{x:N.position.x+h,y:N.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?p[0]*h-g:0),height:b+(y?p[1]*y-k:0)}})}),s}function XH(e,t,n,r,s,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const y=t.get(h.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Rk(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=Ac(y.extent)?y.extent:o;let{positionAbsolute:N}=y.internals;y.parentId&&y.extent==="parent"?N=fI(N,v,t.get(y.parentId)):x&&(N=Ga(N,x,v));const j={...y,measured:v,internals:{...y.internals,positionAbsolute:N,handleBounds:{source:Sj("source",h.nodeElement,k,f,y.id),target:Sj("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,j),y.parentId&&Lk(j,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:Ec(j,s)}))}}if(p.length>0){const h=Ok(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function QH({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 Pj(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 CI(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:o,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:o,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${o}-${l}`,d=`${o}-${l}--${s}-${a}`;Pj("source",c,d,e,s,a),Pj("target",c,u,e,o,l),t.set(r.id,r)}}function _I(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_I(n,t):!1}function Ij(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 ZH(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!_I(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 Ly({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.position,dragging:r})}if(!e)return[s[0],s];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:s[0],s]}function e4({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=ff(o,t);return{x:a.x-o.x,y:a.y-o.y}}function t4({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:N,isSelectable:j,nodeId:C,nodeClickDistance:P=0}){p=as(N);function I({x:z,y:O}){const{nodeLookup:M,nodeExtent:K,snapGrid:H,snapToGrid:L,nodeOrigin:T,onNodeDrag:W,onSelectionDrag:E,onError:Q,updateNodePositions:V}=t();o={x:z,y:O};let B=!1;const se=l.size>1,ue=se&&K?Mx(df(l)):null,G=se&&L?e4({dragItems:l,snapGrid:H,x:z,y:O}):null;for(const[ee,te]of l){if(!M.has(ee))continue;let ne={x:z-te.distance.x,y:O-te.distance.y};L&&(ne=G?{x:Math.round(ne.x+G.x),y:Math.round(ne.y+G.y)}:ff(ne,H));let Z=null;if(se&&K&&!te.extent&&ue){const{positionAbsolute:me}=te.internals,$e=me.x-ue.x+K[0][0],Ce=me.x+te.measured.width-ue.x2+K[1][0],_e=me.y-ue.y+K[0][1],Be=me.y+te.measured.height-ue.y2+K[1][1];Z=[[$e,_e],[Ce,Be]]}const{position:ce,positionAbsolute:de}=dI({nodeId:ee,nextPosition:ne,nodeLookup:M,nodeExtent:Z||K,nodeOrigin:T,onError:Q});B=B||te.position.x!==ce.x||te.position.y!==ce.y,te.position=ce,te.internals.positionAbsolute=de}if(y=y||B,!!B&&(V(l,!0),v&&(r||W||!C&&E))){const[ee,te]=Ly({nodeId:C,dragItems:l,nodeLookup:M});r==null||r(v,l,ee,te),W==null||W(v,ee,te),C||E==null||E(v,te)}}async function F(){if(!d)return;const{transform:z,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:K}=t();if(!K){c=!1,cancelAnimationFrame(a);return}const[H,L]=pI(u,d,M);(H!==0||L!==0)&&(o.x=(o.x??0)-H/z[2],o.y=(o.y??0)-L/z[2],await O({x:H,y:L})&&I(o)),a=requestAnimationFrame(F)}function $(z){var se;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:K,transform:H,snapGrid:L,snapToGrid:T,selectNodesOnDrag:W,onNodeDragStart:E,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!W||!j)&&!M&&C&&((se=O.get(C))!=null&&se.selected||V()),j&&W&&C&&(e==null||e(C));const B=od(z.sourceEvent,{transform:H,snapGrid:L,snapToGrid:T,containerBounds:d});if(o=B,l=ZH(O,K,B,C),l.size>0&&(n||E||!C&&Q)){const[ue,G]=Ly({nodeId:C,dragItems:l,nodeLookup:O});n==null||n(z.sourceEvent,l,ue,G),E==null||E(z.sourceEvent,ue,G),C||Q==null||Q(z.sourceEvent,G)}}const D=VP().clickDistance(P).on("start",z=>{const{domNode:O,nodeDragThreshold:M,transform:K,snapGrid:H,snapToGrid:L}=t();d=(O==null?void 0:O.getBoundingClientRect())||null,h=!1,y=!1,v=z.sourceEvent,M===0&&$(z),o=od(z.sourceEvent,{transform:K,snapGrid:H,snapToGrid:L,containerBounds:d}),u=Xs(z.sourceEvent,d)}).on("drag",z=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:K,snapToGrid:H,nodeDragThreshold:L,nodeLookup:T}=t(),W=od(z.sourceEvent,{transform:M,snapGrid:K,snapToGrid:H,containerBounds:d});if(v=z.sourceEvent,(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1||C&&!T.has(C))&&(h=!0),!h){if(!c&&O&&f&&(c=!0,F()),!f){const E=Xs(z.sourceEvent,d),Q=E.x-u.x,V=E.y-u.y;Math.sqrt(Q*Q+V*V)>L&&$(z)}(o.x!==W.xSnapped||o.y!==W.ySnapped)&&l&&f&&(u=Xs(z.sourceEvent,d),I(W))}}).on("end",z=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:K,onSelectionDragStop:H}=t();if(y&&(M(l,!1),y=!1),s||K||!C&&H){const[L,T]=Ly({nodeId:C,dragItems:l,nodeLookup:O,dragging:!1});s==null||s(z.sourceEvent,l,L,T),K==null||K(z.sourceEvent,L,T),C||H==null||H(z.sourceEvent,T)}}}).filter(z=>{const O=z.target;return!z.button&&(!k||!Ij(O,`.${k}`,N))&&(!x||Ij(O,x,N))});p.call(D)}function g(){p==null||p.on(".drag",null)}return{update:b,destroy:g}}function n4(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())Dd(s,Ec(o))>0&&r.push(o);return r}const r4=250;function s4(e,t,n,r){var l,c;let s=[],o=1/0;const a=n4(e,n,t+r4);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:h}=Ja(u,f,f.position,!0),y=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(s=[{...f,x:p,y:h}],o=y):y===o&&s.push({...f,x:p,y:h}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function EI(e,t,n,r,s,o=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...Ja(a,c,c.position,!0)}:c}function AI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function i4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const PI=()=>!0;function o4(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=PI,onReconnectEnd:k,updateConnection:x,getTransform:N,getFromHandle:j,autoPanSpeed:C,dragThreshold:P=1,handleDomNode:I}){const F=yI(e.target);let $=0,D;const{x:z,y:O}=Xs(e),M=AI(o,I),K=l==null?void 0:l.getBoundingClientRect();let H=!1;if(!K||!M)return;const L=EI(s,M,r,c,t);if(!L)return;let T=Xs(e,K),W=!1,E=null,Q=!1,V=null;function B(){if(!d||!K)return;const[ce,de]=pI(T,K,C);p({x:ce,y:de}),$=requestAnimationFrame(B)}const se={...L,nodeId:s,type:M,position:L.position},ue=c.get(s);let ee={inProgress:!0,isValid:null,from:Ja(ue,se,qe.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:ue,to:T,toHandle:null,toPosition:xj[se.position],toNode:null,pointer:T};function te(){H=!0,x(ee),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}P===0&&te();function ne(ce){if(!H){const{x:Be,y:ot}=Xs(ce),yt=Be-z,Te=ot-O;if(!(yt*yt+Te*Te>P*P))return;te()}if(!j()||!se){Z(ce);return}const de=N();T=Xs(ce,K),D=s4(pf(T,de,!1,[1,1]),n,c,se),W||(B(),W=!0);const me=II(ce,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:F,lib:u,flowId:f,nodeLookup:c});V=me.handleDomNode,E=me.connection,Q=i4(!!D,me.isValid);const $e=c.get(s),Ce=$e?Ja($e,se,qe.Left,!0):ee.from,_e={...ee,from:Ce,isValid:Q,to:me.toHandle&&Q?Xh({x:me.toHandle.x,y:me.toHandle.y},de):T,toHandle:me.toHandle,toPosition:Q&&me.toHandle?me.toHandle.position:xj[se.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null,pointer:T};x(_e),ee=_e}function Z(ce){if(!("touches"in ce&&ce.touches.length>0)){if(H){(D||V)&&E&&Q&&(v==null||v(E));const{inProgress:de,...me}=ee,$e={...me,toPosition:ee.toHandle?ee.toPosition:null};b==null||b(ce,$e),o&&(k==null||k(ce,$e))}h(),cancelAnimationFrame($),W=!1,Q=!1,E=null,V=null,F.removeEventListener("mousemove",ne),F.removeEventListener("mouseup",Z),F.removeEventListener("touchmove",ne),F.removeEventListener("touchend",Z)}}F.addEventListener("mousemove",ne),F.addEventListener("mouseup",Z),F.addEventListener("touchmove",ne),F.addEventListener("touchend",Z)}function II(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=PI,nodeLookup:d}){const f=o==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y}=Xs(e),v=a.elementFromPoint(h,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:p,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=AI(void 0,b),x=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),j=b.classList.contains("connectable"),C=b.classList.contains("connectableend");if(!x||!k)return g;const P={source:f?x:r,sourceHandle:f?N:s,target:f?r:x,targetHandle:f?s:N};g.connection=P;const F=j&&C&&(n===Cc.Strict?f&&k==="source"||!f&&k==="target":x!==r||N!==s);g.isValid=F&&u(P),g.toHandle=EI(x,k,N,d,n,!0)}return g}const Dx={onPointerDown:o4,isValid:II};function a4({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=as(e);function o({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const N=n(),j=x.sourceEvent.ctrlKey&&Fd()?10:1,C=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,P=N[2]*Math.pow(2,C*j);t.scaleTo(P)};let v=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(v=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},g=x=>{const N=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const j=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],C=[j[0]-v[0],j[1]-v[1]];v=j;const P=r()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),I={x:N[0]-C[0]*P,y:N[1]-C[1]*P},F=[[0,0],[c,u]];t.setViewportConstrained({x:I.x,y:I.y,zoom:N[2]},F,l)},k=iI().on("start",b).on("zoom",f?g:null).on("zoom.wheel",p?y:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:qs}}const Jm=e=>({x:e.x,y:e.y,zoom:e.k}),Oy=({x:e,y:t,zoom:n})=>Um.translate(e,t).scale(n),Zl=(e,t)=>e.target.closest(`.${t}`),RI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),l4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Dy=(e,t=0,n=l4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},TI=e=>{const t=e.ctrlKey&&Fd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function c4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Zl(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const b=qs(d),g=TI(d),k=f*Math.pow(2,g);r.scaleTo(n,k,b,d);return}const p=d.deltaMode===1?20:1;let h=s===Fa.Vertical?0:d.deltaX*p,y=s===Fa.Horizontal?0:d.deltaY*p;!Fd()&&d.shiftKey&&s!==Fa.Vertical&&(h=d.deltaY*p,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=Jm(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,v))}}function u4({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=Zl(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function d4({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=Jm(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 f4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&RI(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,Jm(o.transform)))}}function p4({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&&RI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Jm(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function h4({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var b;const p=e||t,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Zl(f,`${u}-flow__node`)||Zl(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!o&&!n||a||d&&!y||Zl(f,l)&&y||Zl(f,c)&&(!y||s&&y&&!e)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&((b=f.touches)==null?void 0:b.length)>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function m4({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=iI().scaleExtent([t,n]).translateExtent(r),p=as(e).call(f);k({x:s.x,y:s.y,zoom:_c(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),y=p.on("dblclick.zoom");f.wheelDelta(TI);function v(D,z){return p?new Promise(O=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?id:oh).transform(Dy(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function b({noWheelClassName:D,noPanClassName:z,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:K,panOnDrag:H,panOnScrollMode:L,panOnScrollSpeed:T,preventScrolling:W,zoomOnPinch:E,zoomOnScroll:Q,zoomOnDoubleClick:V,zoomActivationKeyPressed:B,lib:se,onTransformChange:ue,connectionInProgress:G,paneClickDistance:ee,selectionOnDrag:te}){M&&!u.isZoomingOrPanning&&g();const ne=K&&!B&&!M;f.clickDistance(te?1/0:!Js(ee)||ee<0?0:ee);const Z=ne?c4({zoomPanValues:u,noWheelClassName:D,d3Selection:p,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:T,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):u4({noWheelClassName:D,preventScrolling:W,d3ZoomHandler:h});if(p.on("wheel.zoom",Z,{passive:!1}),!M){const de=d4({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const me=f4({zoomPanValues:u,panOnDrag:H,onPaneContextMenu:!!O,onPanZoom:o,onTransformChange:ue});f.on("zoom",me);const $e=p4({zoomPanValues:u,panOnDrag:H,panOnScroll:K,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});f.on("end",$e)}const ce=h4({zoomActivationKeyPressed:B,panOnDrag:H,zoomOnScroll:Q,panOnScroll:K,zoomOnDoubleClick:V,zoomOnPinch:E,userSelectionActive:M,noPanClassName:z,noWheelClassName:D,lib:se,connectionInProgress:G});f.filter(ce),V?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(D,z,O){const M=Oy(D),K=f==null?void 0:f.constrain()(M,z,O);return K&&await v(K),new Promise(H=>H(K))}async function x(D,z){const O=Oy(D);return await v(O,z),new Promise(M=>M(O))}function N(D){if(p){const z=Oy(D),O=p.property("__zoom");(O.k!==D.zoom||O.x!==D.x||O.y!==D.y)&&(f==null||f.transform(p,z,null,{sync:!0}))}}function j(){const D=p?sI(p.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function C(D,z){return p?new Promise(O=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?id:oh).scaleTo(Dy(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function P(D,z){return p?new Promise(O=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?id:oh).scaleBy(Dy(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function I(D){f==null||f.scaleExtent(D)}function F(D){f==null||f.translateExtent(D)}function $(D){const z=!Js(D)||D<0?0:D;f==null||f.clickDistance(z)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:j,scaleTo:C,scaleBy:P,setScaleExtent:I,setTranslateExtent:F,syncViewport:N,setClickDistance:$}}var Pc;(function(e){e.Line="line",e.Handle="handle"})(Pc||(Pc={}));function g4({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 Rj(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 Co(e,t){return Math.max(0,t-e)}function _o(e,t){return Math.max(0,e-t)}function Np(e,t,n){return Math.max(0,t-e,e-n)}function Tj(e,t){return e?!t:t}function y4(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:N,width:j,height:C,aspectRatio:P}=e;let I=Math.floor(d?h-e.pointerX:0),F=Math.floor(f?y-e.pointerY:0);const $=j+(c?-I:I),D=C+(u?-F:F),z=-o[0]*j,O=-o[1]*C;let M=Np($,v,b),K=Np(D,g,k);if(a){let T=0,W=0;c&&I<0?T=Co(x+I+z,a[0][0]):!c&&I>0&&(T=_o(x+$+z,a[1][0])),u&&F<0?W=Co(N+F+O,a[0][1]):!u&&F>0&&(W=_o(N+D+O,a[1][1])),M=Math.max(M,T),K=Math.max(K,W)}if(l){let T=0,W=0;c&&I>0?T=_o(x+I,l[0][0]):!c&&I<0&&(T=Co(x+$,l[1][0])),u&&F>0?W=_o(N+F,l[0][1]):!u&&F<0&&(W=Co(N+D,l[1][1])),M=Math.max(M,T),K=Math.max(K,W)}if(s){if(d){const T=Np($/P,g,k)*P;if(M=Math.max(M,T),a){let W=0;!c&&!u||c&&!u&&p?W=_o(N+O+$/P,a[1][1])*P:W=Co(N+O+(c?I:-I)/P,a[0][1])*P,M=Math.max(M,W)}if(l){let W=0;!c&&!u||c&&!u&&p?W=Co(N+$/P,l[1][1])*P:W=_o(N+(c?I:-I)/P,l[0][1])*P,M=Math.max(M,W)}}if(f){const T=Np(D*P,v,b)/P;if(K=Math.max(K,T),a){let W=0;!c&&!u||u&&!c&&p?W=_o(x+D*P+z,a[1][0])/P:W=Co(x+(u?F:-F)*P+z,a[0][0])/P,K=Math.max(K,W)}if(l){let W=0;!c&&!u||u&&!c&&p?W=Co(x+D*P,l[1][0])/P:W=_o(x+(u?F:-F)*P,l[0][0])/P,K=Math.max(K,W)}}}F=F+(F<0?K:-K),I=I+(I<0?M:-M),s&&(p?$>D*P?F=(Tj(c,u)?-I:I)/P:I=(Tj(c,u)?-F:F)*P:d?(F=I/P,u=c):(I=F*P,c=u));const H=c?x+I:x,L=u?N+F:N;return{width:j+(c?-I:I),height:C+(u?-F:F),x:o[0]*I*(c?-1:1)+H,y:o[1]*F*(u?-1:1)+L}}const MI={width:0,height:0,x:0,y:0},w4={...MI,pointerX:0,pointerY:0,aspectRatio:1};function x4(e){return[[0,0],[e.measured.width,e.measured.height]]}function b4(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 k4({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=as(e);let a={controlDirection:Rj("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...MI},k={...w4};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Rj(u)};let x,N=null,j=[],C,P,I,F=!1;const $=VP().on("start",D=>{const{nodeLookup:z,transform:O,snapGrid:M,snapToGrid:K,nodeOrigin:H,paneDomNode:L}=n();if(x=z.get(t),!x)return;N=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:T,ySnapped:W}=od(D.sourceEvent,{transform:O,snapGrid:M,snapToGrid:K,containerBounds:N});g={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},k={...g,pointerX:T,pointerY:W,aspectRatio:g.width/g.height},C=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(C=z.get(x.parentId),P=C&&x.extent==="parent"?x4(C):void 0),j=[],I=void 0;for(const[E,Q]of z)if(Q.parentId===t&&(j.push({id:E,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=b4(Q,x,Q.origin??H);I?I=[[Math.min(V[0][0],I[0][0]),Math.min(V[0][1],I[0][1])],[Math.max(V[1][0],I[1][0]),Math.max(V[1][1],I[1][1])]]:I=V}h==null||h(D,{...g})}).on("drag",D=>{const{transform:z,snapGrid:O,snapToGrid:M,nodeOrigin:K}=n(),H=od(D.sourceEvent,{transform:z,snapGrid:O,snapToGrid:M,containerBounds:N}),L=[];if(!x)return;const{x:T,y:W,width:E,height:Q}=g,V={},B=x.origin??K,{width:se,height:ue,x:G,y:ee}=y4(k,a.controlDirection,H,a.boundaries,a.keepAspectRatio,B,P,I),te=se!==E,ne=ue!==Q,Z=G!==T&&te,ce=ee!==W&≠if(!Z&&!ce&&!te&&!ne)return;if((Z||ce||B[0]===1||B[1]===1)&&(V.x=Z?G:g.x,V.y=ce?ee:g.y,g.x=V.x,g.y=V.y,j.length>0)){const Ce=G-T,_e=ee-W;for(const Be of j)Be.position={x:Be.position.x-Ce+B[0]*(se-E),y:Be.position.y-_e+B[1]*(ue-Q)},L.push(Be)}if((te||ne)&&(V.width=te&&(!a.resizeDirection||a.resizeDirection==="horizontal")?se:g.width,V.height=ne&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:g.height,g.width=V.width,g.height=V.height),C&&x.expandParent){const Ce=B[0]*(V.width??0);V.x&&V.x<Ce&&(g.x=Ce,k.x=k.x-(V.x-Ce));const _e=B[1]*(V.height??0);V.y&&V.y<_e&&(g.y=_e,k.y=k.y-(V.y-_e))}const de=g4({width:g.width,prevWidth:E,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&&(F=!0,y==null||y(D,me),r(V,L))}).on("end",D=>{F&&(v==null||v(D,{...g}),s==null||s({...g}),F=!1)});o.call($)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var $I={exports:{}},LI={},OI={exports:{}},DI={};/**
|
|
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 Ic=m;function v4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var S4=typeof Object.is=="function"?Object.is:v4,N4=Ic.useState,j4=Ic.useEffect,C4=Ic.useLayoutEffect,_4=Ic.useDebugValue;function E4(e,t){var n=t(),r=N4({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return C4(function(){s.value=n,s.getSnapshot=t,Fy(s)&&o({inst:s})},[e,n,t]),j4(function(){return Fy(s)&&o({inst:s}),e(function(){Fy(s)&&o({inst:s})})},[e]),_4(n),n}function Fy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!S4(e,n)}catch{return!0}}function A4(e,t){return t()}var P4=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?A4:E4;DI.useSyncExternalStore=Ic.useSyncExternalStore!==void 0?Ic.useSyncExternalStore:P4;OI.exports=DI;var FI=OI.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 Xm=m,I4=FI;function R4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var T4=typeof Object.is=="function"?Object.is:R4,M4=I4.useSyncExternalStore,$4=Xm.useRef,L4=Xm.useEffect,O4=Xm.useMemo,D4=Xm.useDebugValue;LI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=$4(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=O4(function(){function c(h){if(!u){if(u=!0,d=h,h=r(h),s!==void 0&&a.hasValue){var y=a.value;if(s(y,h))return f=y}return f=h}if(y=f,T4(d,h))return y;var v=r(h);return s!==void 0&&s(y,v)?(d=h,y):(d=h,f=v)}var u=!1,d,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=M4(e,o[0],o[1]);return L4(function(){a.hasValue=!0,a.value=l},[l]),D4(l),l};$I.exports=LI;var F4=$I.exports;const z4=sa(F4),B4={},Mj=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(B4?"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},H4=e=>e?Mj(e):Mj,{useDebugValue:W4}=ft,{useSyncExternalStoreWithSelector:V4}=z4,K4=e=>e;function zI(e,t=K4,n){const r=V4(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return W4(r),r}const $j=(e,t)=>{const n=H4(e),r=(s,o=t)=>zI(n,s,o);return Object.assign(r,n),r},q4=(e,t)=>e?$j(e,t):$j;function _n(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 Qm=m.createContext(null),U4=Qm.Provider,BI=Ii.error001();function Bt(e,t){const n=m.useContext(Qm);if(n===null)throw new Error(BI);return zI(n,e,t)}function gn(){const e=m.useContext(Qm);if(e===null)throw new Error(BI);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Lj={display:"none"},Y4={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},HI="react-flow__node-desc",WI="react-flow__edge-desc",G4="react-flow__aria-live",J4=e=>e.ariaLiveMessage,X4=e=>e.ariaLabelConfig;function Q4({rfId:e}){const t=Bt(J4);return i.jsx("div",{id:`${G4}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Y4,children:t})}function Z4({rfId:e,disableKeyboardA11y:t}){const n=Bt(X4);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${HI}-${e}`,style:Lj,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${WI}-${e}`,style:Lj,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(Q4,{rfId:e})]})}const Zm=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Jn(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});Zm.displayName="Panel";function e5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(Zm,{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 t5=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}},jp=e=>e.id;function n5(e,t){return _n(e.selectedNodes.map(jp),t.selectedNodes.map(jp))&&_n(e.selectedEdges.map(jp),t.selectedEdges.map(jp))}function r5({onSelectionChange:e}){const t=gn(),{selectedNodes:n,selectedEdges:r}=Bt(t5,n5);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 s5=e=>!!e.onSelectionChangeHandlers;function i5({onSelectionChange:e}){const t=Bt(s5);return e||t?i.jsx(r5,{onSelectionChange:e}):null}const Fx=typeof window<"u"?m.useLayoutEffect:m.useEffect,VI=[0,0],o5={x:0,y:0,zoom:1},a5=["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"],Oj=[...a5,"rfId"],l5=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}),Dj={translateExtent:Ld,nodeOrigin:VI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function c5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Bt(l5,_n),u=gn();Fx(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Dj,l()}),[]);const d=m.useRef(Dj);return Fx(()=>{for(const f of Oj){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?o(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:MH(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},Oj.map(f=>e[f])),null}function Fj(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function u5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=Fj(),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=Fj())!=null&&r.matches?"dark":"light"}const zj=typeof document<"u"?document:null;function zd(e=null,t={target:zj,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
61
|
+
`).replace(`
|
|
62
|
+
|
|
63
|
+
`,`
|
|
64
|
+
+`).split(`
|
|
65
|
+
`)),d=u.reduce((f,p)=>f.concat(...p),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??zj,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var b,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&wI(h))return!1;const v=Hj(h.code,l);if(o.current.add(h[v]),Bj(a,o.current,!1)){const k=((g=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:g[0])||h.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const y=Hj(h.code,l);Bj(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.key==="Meta"&&o.current.clear(),s.current=!1},p=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function Bj(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Hj(e,t){return t.includes(e)?"code":"key"}const d5=()=>{const e=gn();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=Ik(t,r,s,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},d=n.snapGrid??s,f=n.snapToGrid??o;return pf(u,r,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=Xh(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function KI(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)f5(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 f5(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 ad(e,t){return KI(e,t)}function Qh(e,t){return KI(e,t)}function Na(e,t){return{id:e,type:"select",selected:t}}function ec(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(Na(o.id,a)))}return r}function Wj({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 Vj(e){return{id:e.id,type:"remove"}}const Kj=e=>NH(e),p5=e=>uI(e);function qI(e){return m.forwardRef(e)}function qj(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>h5(()=>n(s=>s+BigInt(1))));return Fx(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function h5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const UI=m.createContext(null);function m5({children:e}){const t=gn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=Wj({items:v,lookup:p});for(const g of y.values())b=g(b);d&&u(v),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=qj(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;d?u(h):f&&f(Wj({items:h,lookup:p}))},[]),o=qj(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(UI.Provider,{value:a,children:e})}function g5(){const e=m.useContext(UI);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const y5=e=>!!e.panZoom;function Fc(){const e=d5(),t=gn(),n=g5(),r=Bt(y5),s=m.useMemo(()=>{const o=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var g,k;const{nodeLookup:p,nodeOrigin:h}=t.getState(),y=Kj(f)?f:p.get(f.id),v=y.parentId?gI(y.position,y.measured,y.parentId,p,h):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Ec(b)},u=(f,p,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&Kj(b)?b:{...v,...b}}return v}))},d=(f,p,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&p5(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var p;return(p=o(f))==null?void 0:p.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(p=>({...p}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const p=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:h}=t.getState(),[y,v,b]=h;return{nodes:f.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:N}=t.getState(),{nodes:j,edges:C}=await AH({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:y,onBeforeDelete:N}),P=C.length>0,I=j.length>0;if(P){const F=C.map(Vj);b==null||b(C),k(F)}if(I){const F=j.map(Vj);v==null||v(j),g(F)}return(I||P)&&(x==null||x({nodes:j,edges:C})),{deletedNodes:j,deletedEdges:C}},getIntersectingNodes:(f,p=!0,h)=>{const y=kj(f),v=y?f:c(f),b=h!==void 0;return v?(h||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===f.id||!k.internals.positionAbsolute))return!1;const x=Ec(b?g:k),N=Dd(x,v);return p&&N>0||N>=x.width*x.height||N>=v.width*v.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const v=kj(f)?f:c(f);if(!v)return!1;const b=Dd(v,p);return h&&b>0||b>=p.width*p.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,p,h={replace:!1})=>{u(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:d,updateEdgeData:(f,p,h={replace:!1})=>{d(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return jH(f,{nodeLookup:p,nodeOrigin:h})},getHandleConnections:({type:f,id:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${f}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??TH();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(h=>[...h]),p.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const Uj=e=>e.selected,w5=typeof window<"u"?window:void 0;function x5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=gn(),{deleteElements:r}=Fc(),s=zd(e,{actInsideInputWithModifier:!1}),o=zd(t,{target:w5});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(Uj),edges:a.filter(Uj)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function b5(e){const t=gn();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=Rk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Ii.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 eg={position:"absolute",width:"100%",height:"100%",top:0,left:0},k5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function v5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=Fa.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:N}){const j=gn(),C=m.useRef(null),{userSelectionActive:P,lib:I,connectionInProgress:F}=Bt(k5,_n),$=zd(p),D=m.useRef();b5(C);const z=m.useCallback(O=>{g==null||g({x:O[0],y:O[1],zoom:O[2]}),k||j.setState({transform:O})},[g,k]);return m.useEffect(()=>{if(C.current){D.current=m4({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:H=>j.setState(L=>L.paneDragging===H?L:{paneDragging:H}),onPanZoomStart:(H,L)=>{const{onViewportChangeStart:T,onMoveStart:W}=j.getState();W==null||W(H,L),T==null||T(L)},onPanZoom:(H,L)=>{const{onViewportChange:T,onMove:W}=j.getState();W==null||W(H,L),T==null||T(L)},onPanZoomEnd:(H,L)=>{const{onViewportChangeEnd:T,onMoveEnd:W}=j.getState();W==null||W(H,L),T==null||T(L)}});const{x:O,y:M,zoom:K}=D.current.getViewport();return j.setState({panZoom:D.current,transform:[O,M,K],domNode:C.current.closest(".react-flow")}),()=>{var H;(H=D.current)==null||H.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:$,preventScrolling:h,noPanClassName:b,userSelectionActive:P,noWheelClassName:v,lib:I,onTransformChange:z,connectionInProgress:F,selectionOnDrag:N,paneClickDistance:x})},[e,t,n,r,s,o,a,l,$,h,b,P,v,I,z,F,N,x]),i.jsx("div",{className:"react-flow__renderer",ref:C,style:eg,children:y})}const S5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function N5(){const{userSelectionActive:e,userSelectionRect:t}=Bt(S5,_n);return e&&t?i.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const zy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},j5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function C5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Od.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:y}){const v=gn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Bt(j5,_n),N=g&&(e||b),j=m.useRef(null),C=m.useRef(),P=m.useRef(new Set),I=m.useRef(new Set),F=m.useRef(!1),$=T=>{if(F.current||x){F.current=!1;return}c==null||c(T),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},D=T=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){T.preventDefault();return}u==null||u(T)},z=d?T=>d(T):void 0,O=T=>{F.current&&(T.stopPropagation(),F.current=!1)},M=T=>{var ue,G;const{domNode:W}=v.getState();if(C.current=W==null?void 0:W.getBoundingClientRect(),!C.current)return;const E=T.target===j.current;if(!E&&!!T.target.closest(".nokey")||!e||!(o&&E||t)||T.button!==0||!T.isPrimary)return;(G=(ue=T.target)==null?void 0:ue.setPointerCapture)==null||G.call(ue,T.pointerId),F.current=!1;const{x:B,y:se}=Xs(T.nativeEvent,C.current);v.setState({userSelectionRect:{width:0,height:0,startX:B,startY:se,x:B,y:se}}),E||(T.stopPropagation(),T.preventDefault())},K=T=>{const{userSelectionRect:W,transform:E,nodeLookup:Q,edgeLookup:V,connectionLookup:B,triggerNodeChanges:se,triggerEdgeChanges:ue,defaultEdgeOptions:G,resetSelectedElements:ee}=v.getState();if(!C.current||!W)return;const{x:te,y:ne}=Xs(T.nativeEvent,C.current),{startX:Z,startY:ce}=W;if(!F.current){const _e=t?0:s;if(Math.hypot(te-Z,ne-ce)<=_e)return;ee(),a==null||a(T)}F.current=!0;const de={startX:Z,startY:ce,x:te<Z?te:Z,y:ne<ce?ne:ce,width:Math.abs(te-Z),height:Math.abs(ne-ce)},me=P.current,$e=I.current;P.current=new Set(Pk(Q,de,E,n===Od.Partial,!0).map(_e=>_e.id)),I.current=new Set;const Ce=(G==null?void 0:G.selectable)??!0;for(const _e of P.current){const Be=B.get(_e);if(Be)for(const{edgeId:ot}of Be.values()){const yt=V.get(ot);yt&&(yt.selectable??Ce)&&I.current.add(ot)}}if(!vj(me,P.current)){const _e=ec(Q,P.current,!0);se(_e)}if(!vj($e,I.current)){const _e=ec(V,I.current);ue(_e)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},H=T=>{var W,E;T.button===0&&((E=(W=T.target)==null?void 0:W.releasePointerCapture)==null||E.call(W,T.pointerId),!b&&T.target===j.current&&v.getState().userSelectionRect&&($==null||$(T)),v.setState({userSelectionActive:!1,userSelectionRect:null}),F.current&&(l==null||l(T),v.setState({nodesSelectionActive:P.current.size>0})))},L=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Jn(["react-flow__pane",{draggable:L,dragging:k,selection:e}]),onClick:N?void 0:zy($,j),onContextMenu:zy(D,j),onWheel:zy(z,j),onPointerEnter:N?void 0:f,onPointerMove:N?K:p,onPointerUp:N?H:void 0,onPointerDownCapture:N?M:void 0,onClickCapture:N?O:void 0,onPointerLeave:h,ref:j,style:eg,children:[y,i.jsx(N5,{})]})}function zx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Ii.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function YI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=gn(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=t4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{zx({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,r,t,o,e,s,a]),c}const _5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function GI(){const e=gn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,p=_5(a),h=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*h*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!p(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=ff(k,o));const{position:x,positionAbsolute:N}=dI({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});g.position=x,g.internals.positionAbsolute=N,f.set(g.id,g)}c(f)},[])}const Dk=m.createContext(null),E5=Dk.Provider;Dk.Consumer;const JI=()=>m.useContext(Dk),A5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),P5=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===Cc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:d&&u}};function I5({type:e="source",position:t=qe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:d,onTouchStart:f,...p},h){var K,H;const y=a||null,v=e==="target",b=gn(),g=JI(),{connectOnClick:k,noPanClassName:x,rfId:N}=Bt(A5,_n),{connectingFrom:j,connectingTo:C,clickConnecting:P,isPossibleEndHandle:I,connectionInProcess:F,clickConnectionInProcess:$,valid:D}=Bt(P5(g,y,e),_n);g||(H=(K=b.getState()).onError)==null||H.call(K,"010",Ii.error010());const z=L=>{const{defaultEdgeOptions:T,onConnect:W,hasDefaultEdges:E}=b.getState(),Q={...T,...L};if(E){const{edges:V,setEdges:B}=b.getState();B(uh(Q,V))}W==null||W(Q),l==null||l(Q)},O=L=>{if(!g)return;const T=xI(L.nativeEvent);if(s&&(T&&L.button===0||!T)){const W=b.getState();Dx.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:v,handleId:y,nodeId:g,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...E)=>{var Q,V;return(V=(Q=b.getState()).onConnectEnd)==null?void 0:V.call(Q,...E)},updateConnection:W.updateConnection,onConnect:z,isValidConnection:n||((...E)=>{var Q,V;return((V=(Q=b.getState()).isValidConnection)==null?void 0:V.call(Q,...E))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}T?d==null||d(L):f==null||f(L)},M=L=>{const{onClickConnectStart:T,onClickConnectEnd:W,connectionClickStartHandle:E,connectionMode:Q,isValidConnection:V,lib:B,rfId:se,nodeLookup:ue,connection:G}=b.getState();if(!g||!E&&!s)return;if(!E){T==null||T(L.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ee=yI(L.target),te=n||V,{connection:ne,isValid:Z}=Dx.isValid(L.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:Q,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:te,flowId:se,doc:ee,lib:B,nodeLookup:ue});Z&&ne&&z(ne);const ce=structuredClone(G);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,W==null||W(L,ce),b.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${N}-${g}-${y}-${e}`,className:Jn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:P,connectingfrom:j,connectingto:C,valid:D,connectionindicator:r&&(!F||I)&&(F||$?o:s)}]),onMouseDown:O,onTouchStart:O,onClick:k?M:void 0,ref:h,...p,children:c})}const Gn=m.memo(qI(I5));function R5({data:e,isConnectable:t,sourcePosition:n=qe.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(Gn,{type:"source",position:n,isConnectable:t})]})}function T5({data:e,isConnectable:t,targetPosition:n=qe.Top,sourcePosition:r=qe.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(Gn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(Gn,{type:"source",position:r,isConnectable:t})]})}function M5(){return null}function $5({data:e,isConnectable:t,targetPosition:n=qe.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(Gn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Zh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Yj={input:R5,default:T5,output:$5,group:M5};function L5(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 O5=e=>{const{width:t,height:n,x:r,y:s}=df(e.nodeLookup,{filter:o=>!!o.selected});return{width:Js(t)?t:null,height:Js(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 D5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=gn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Bt(O5,_n),c=GI(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const d=!l&&s!==null&&o!==null;if(YI({nodeRef:u,disabled:!d}),!d)return null;const f=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(Zh,h.key)&&(h.preventDefault(),c({direction:Zh[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:Jn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:o}})})}const Gj=typeof window<"u"?window:void 0,F5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function XI({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:N,panOnScrollSpeed:j,panOnScrollMode:C,zoomOnDoubleClick:P,panOnDrag:I,defaultViewport:F,translateExtent:$,minZoom:D,maxZoom:z,preventScrolling:O,onSelectionContextMenu:M,noWheelClassName:K,noPanClassName:H,disableKeyboardA11y:L,onViewportChange:T,isControlledViewport:W}){const{nodesSelectionActive:E,userSelectionActive:Q}=Bt(F5,_n),V=zd(u,{target:Gj}),B=zd(v,{target:Gj}),se=B||I,ue=B||N,G=d&&se!==!0,ee=V||Q||G;return x5({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(v5,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:ue,panOnScrollSpeed:j,panOnScrollMode:C,zoomOnDoubleClick:P,panOnDrag:!V&&se,defaultViewport:F,translateExtent:$,minZoom:D,maxZoom:z,zoomActivationKeyCode:b,preventScrolling:O,noWheelClassName:K,noPanClassName:H,onViewportChange:T,isControlledViewport:W,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(C5,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:se,isSelecting:!!ee,selectionMode:f,selectionKeyPressed:V,paneClickDistance:l,selectionOnDrag:G,children:[e,E&&i.jsx(D5,{onSelectionContextMenu:M,noPanClassName:H,disableKeyboardA11y:L})]})})}XI.displayName="FlowRenderer";const z5=m.memo(XI),B5=e=>t=>e?Pk(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 H5(e){return Bt(m.useCallback(B5(e),[e]),_n)}const W5=e=>e.updateNodeInternals;function V5(){const e=Bt(W5),[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 K5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=gn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!d||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[d,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const f=u.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function q5({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:p,noPanClassName:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:N,isParent:j}=Bt(te=>{const ne=te.nodeLookup.get(e),Z=te.parentLookup.has(e);return{node:ne,internals:ne.internals,isParent:Z}},_n);let C=x.type||"default",P=(b==null?void 0:b[C])||Yj[C];P===void 0&&(k==null||k("003",Ii.error003(C)),C="default",P=(b==null?void 0:b.default)||Yj.default);const I=!!(x.draggable||l&&typeof x.draggable>"u"),F=!!(x.selectable||c&&typeof x.selectable>"u"),$=!!(x.connectable||u&&typeof x.connectable>"u"),D=!!(x.focusable||d&&typeof x.focusable>"u"),z=gn(),O=mI(x),M=K5({node:x,nodeType:C,hasDimensions:O,resizeObserver:f}),K=YI({nodeRef:M,disabled:x.hidden||!I,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:F,nodeClickDistance:g}),H=GI();if(x.hidden)return null;const L=fo(x),T=L5(x),W=F||I||t||n||r||s,E=n?te=>n(te,{...N.userNode}):void 0,Q=r?te=>r(te,{...N.userNode}):void 0,V=s?te=>s(te,{...N.userNode}):void 0,B=o?te=>o(te,{...N.userNode}):void 0,se=a?te=>a(te,{...N.userNode}):void 0,ue=te=>{const{selectNodesOnDrag:ne,nodeDragThreshold:Z}=z.getState();F&&(!ne||!I||Z>0)&&zx({id:e,store:z,nodeRef:M}),t&&t(te,{...N.userNode})},G=te=>{if(!(wI(te.nativeEvent)||y)){if(oI.includes(te.key)&&F){const ne=te.key==="Escape";zx({id:e,store:z,unselect:ne,nodeRef:M})}else if(I&&x.selected&&Object.prototype.hasOwnProperty.call(Zh,te.key)){te.preventDefault();const{ariaLabelConfig:ne}=z.getState();z.setState({ariaLiveMessage:ne["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),H({direction:Zh[te.key],factor:te.shiftKey?4:1})}}},ee=()=>{var $e;if(y||!(($e=M.current)!=null&&$e.matches(":focus-visible")))return;const{transform:te,width:ne,height:Z,autoPanOnNodeFocus:ce,setCenter:de}=z.getState();if(!ce)return;Pk(new Map([[e,x]]),{x:0,y:0,width:ne,height:Z},te,!0).length>0||de(x.position.x+L.width/2,x.position.y+L.height/2,{zoom:te[2]})};return i.jsx("div",{className:Jn(["react-flow__node",`react-flow__node-${C}`,{[h]:I},x.className,{selected:x.selected,selectable:F,parent:j,draggable:I,dragging:K}]),ref:M,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:O?"visible":"hidden",...x.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Q,onMouseLeave:V,onContextMenu:B,onClick:ue,onDoubleClick:se,onKeyDown:D?G:void 0,tabIndex:D?0:void 0,onFocus:D?ee:void 0,role:x.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${HI}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(E5,{value:e,children:i.jsx(P,{id:e,data:x.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:x.selected??!1,selectable:F,draggable:I,deletable:x.deletable??!0,isConnectable:$,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:K,dragHandle:x.dragHandle,zIndex:N.z,parentId:x.parentId,...L})})})}var U5=m.memo(q5);const Y5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function QI(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Bt(Y5,_n),a=H5(e.onlyRenderVisibleElements),l=V5();return i.jsx("div",{className:"react-flow__nodes",style:eg,children:a.map(c=>i.jsx(U5,{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))})}QI.displayName="NodeRenderer";const G5=m.memo(QI);function J5(e){return Bt(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&&OH({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),_n)}const X5=({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"})},Q5=({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"})},Jj={[bi.Arrow]:X5,[bi.ArrowClosed]:Q5};function Z5(e){const t=gn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Jj,e)?Jj[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Ii.error009(e)),null)},[e])}const eW=({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=Z5(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},ZI=({defaultColor:e,rfId:t})=>{const n=Bt(o=>o.edges),r=Bt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>VH(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(eW,{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};ZI.displayName="MarkerDefinitions";var tW=m.memo(ZI);function eR({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d}){const[f,p]=m.useState({x:1,y:0,width:0,height:0}),h=Jn(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.useEffect(()=>{if(y.current){const v=y.current.getBBox();p({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...d,children:[s&&i.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}eR.displayName="EdgeText";const nW=m.memo(eR);function tg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...d,d:e,fill:"none",className:Jn(["react-flow__edge-path",d.className])}),u?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&Js(t)&&Js(n)?i.jsx(nW,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function Xj({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===qe.Left||e===qe.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function tR({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top}){const[a,l]=Xj({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=Xj({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,f,p,h]=bI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,d,f,p,h]}function nR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,N]=tR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),j=e.isInternal?void 0:t;return i.jsx(tg,{id:j,path:k,labelX:x,labelY:N,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const rW=nR({isInternal:!1}),rR=nR({isInternal:!0});rW.displayName="SimpleBezierEdge";rR.displayName="SimpleBezierEdgeInternal";function sR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,sourcePosition:h=qe.Bottom,targetPosition:y=qe.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,N,j]=$x({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),C=e.isInternal?void 0:t;return i.jsx(tg,{id:C,path:x,labelX:N,labelY:j,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:b,interactionWidth:k})})}const iR=sR({isInternal:!1}),oR=sR({isInternal:!0});iR.displayName="SmoothStepEdge";oR.displayName="SmoothStepEdgeInternal";function aR(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(iR,{...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 sW=aR({isInternal:!1}),lR=aR({isInternal:!0});sW.displayName="StepEdge";lR.displayName="StepEdgeInternal";function cR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=SI({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(tg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})})}const iW=cR({isInternal:!1}),uR=cR({isInternal:!0});iW.displayName="StraightEdge";uR.displayName="StraightEdgeInternal";function dR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=qe.Bottom,targetPosition:l=qe.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,N,j]=kI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),C=e.isInternal?void 0:t;return i.jsx(tg,{id:C,path:x,labelX:N,labelY:j,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const oW=dR({isInternal:!1}),fR=dR({isInternal:!0});oW.displayName="BezierEdge";fR.displayName="BezierEdgeInternal";const Qj={default:fR,straight:uR,step:lR,smoothstep:oR,simplebezier:rR},Zj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},aW=(e,t,n)=>n===qe.Left?e-t:n===qe.Right?e+t:e,lW=(e,t,n)=>n===qe.Top?e-t:n===qe.Bottom?e+t:e,e1="react-flow__edgeupdater";function t1({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:Jn([e1,`${e1}-${l}`]),cx:aW(t,r,e),cy:lW(n,r,e),r,stroke:"transparent",fill:"transparent"})}function cW({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:p,setUpdateHover:h}){const y=gn(),v=(N,j)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:P,connectionMode:I,connectionRadius:F,lib:$,onConnectStart:D,cancelConnection:z,nodeLookup:O,rfId:M,panBy:K,updateConnection:H}=y.getState(),L=j.type==="target",T=(Q,V)=>{p(!1),f==null||f(Q,n,j.type,V)},W=Q=>u==null?void 0:u(n,Q),E=(Q,V)=>{p(!0),d==null||d(N,n,j.type),D==null||D(Q,V)};Dx.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:I,connectionRadius:F,domNode:P,handleId:j.id,nodeId:j.nodeId,nodeLookup:O,isTarget:L,edgeUpdaterType:j.type,lib:$,flowId:M,cancelConnection:z,panBy:K,isValidConnection:(...Q)=>{var V,B;return((B=(V=y.getState()).isValidConnection)==null?void 0:B.call(V,...Q))??!0},onConnect:W,onConnectStart:E,onConnectEnd:(...Q)=>{var V,B;return(B=(V=y.getState()).onConnectEnd)==null?void 0:B.call(V,...Q)},onReconnectEnd:T,updateConnection:H,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>v(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=N=>v(N,{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(t1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(t1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function uW({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Bt(de=>de.edgeLookup.get(e));const N=Bt(de=>de.defaultEdgeOptions);x=N?{...N,...x}:x;let j=x.type||"default",C=(v==null?void 0:v[j])||Qj[j];C===void 0&&(g==null||g("011",Ii.error011(j)),j="default",C=(v==null?void 0:v.default)||Qj.default);const P=!!(x.focusable||t&&typeof x.focusable>"u"),I=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),F=!!(x.selectable||r&&typeof x.selectable>"u"),$=m.useRef(null),[D,z]=m.useState(!1),[O,M]=m.useState(!1),K=gn(),{zIndex:H,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V}=Bt(m.useCallback(de=>{const me=de.nodeLookup.get(x.source),$e=de.nodeLookup.get(x.target);if(!me||!$e)return{zIndex:x.zIndex,...Zj};const Ce=WH({id:e,sourceNode:me,targetNode:$e,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:LH({selected:x.selected,zIndex:x.zIndex,sourceNode:me,targetNode:$e,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ce||Zj}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),_n),B=m.useMemo(()=>x.markerStart?`url('#${Lx(x.markerStart,y)}')`:void 0,[x.markerStart,y]),se=m.useMemo(()=>x.markerEnd?`url('#${Lx(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||L===null||T===null||W===null||E===null)return null;const ue=de=>{var _e;const{addSelectedEdges:me,unselectNodesAndEdges:$e,multiSelectionActive:Ce}=K.getState();F&&(K.setState({nodesSelectionActive:!1}),x.selected&&Ce?($e({nodes:[],edges:[x]}),(_e=$.current)==null||_e.blur()):me([e])),s&&s(de,x)},G=o?de=>{o(de,{...x})}:void 0,ee=a?de=>{a(de,{...x})}:void 0,te=l?de=>{l(de,{...x})}:void 0,ne=c?de=>{c(de,{...x})}:void 0,Z=u?de=>{u(de,{...x})}:void 0,ce=de=>{var me;if(!k&&oI.includes(de.key)&&F){const{unselectNodesAndEdges:$e,addSelectedEdges:Ce}=K.getState();de.key==="Escape"?((me=$.current)==null||me.blur(),$e({edges:[x]})):Ce([e])}};return i.jsx("svg",{style:{zIndex:H},children:i.jsxs("g",{className:Jn(["react-flow__edge",`react-flow__edge-${j}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!F&&!s,updating:D,selectable:F}]),onClick:ue,onDoubleClick:G,onContextMenu:ee,onMouseEnter:te,onMouseMove:ne,onMouseLeave:Z,onKeyDown:P?ce:void 0,tabIndex:P?0:void 0,role:x.ariaRole??(P?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":P?`${WI}-${y}`:void 0,ref:$,...x.domAttributes,children:[!O&&i.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:F,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:B,markerEnd:se,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),I&&i.jsx(cW,{edge:x,isReconnectable:I,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,setUpdateHover:z,setReconnecting:M})]})})}var dW=m.memo(uW);const fW=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function pR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Bt(fW,_n),N=J5(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(tW,{defaultColor:e,rfId:n}),N.map(j=>i.jsx(dW,{id:j,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:p,onReconnectStart:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},j))]})}pR.displayName="EdgeRenderer";const pW=m.memo(pR),hW=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function mW({children:e}){const t=Bt(hW);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function gW(e){const t=Fc(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const yW=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function wW(e){const t=Bt(yW),n=gn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function xW(e){return e.connection.inProgress?{...e.connection,to:pf(e.connection.to,e.transform)}:{...e.connection}}function bW(e){return xW}function kW(e){const t=bW();return Bt(t,_n)}const vW=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function SW({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Bt(vW,_n);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:Jn(["react-flow__connection",cI(l)]),children:i.jsx(hR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const hR=({style:e,type:t=Mo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:p,pointer:h}=kW();if(!s)return;if(n)return i.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:p,connectionStatus:cI(r),toNode:d,toHandle:f,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:p};switch(t){case Mo.Bezier:[y]=kI(v);break;case Mo.SimpleBezier:[y]=tR(v);break;case Mo.Step:[y]=$x({...v,borderRadius:0});break;case Mo.SmoothStep:[y]=$x(v);break;default:[y]=SI(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};hR.displayName="ConnectionLine";const NW={};function n1(e=NW){m.useRef(e),gn(),m.useEffect(()=>{},[e])}function jW(){gn(),m.useRef(!1),m.useEffect(()=>{},[])}function mR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:N,multiSelectionKeyCode:j,panActivationKeyCode:C,zoomActivationKeyCode:P,deleteKeyCode:I,onlyRenderVisibleElements:F,elementsSelectable:$,defaultViewport:D,translateExtent:z,minZoom:O,maxZoom:M,preventScrolling:K,defaultMarkerColor:H,zoomOnScroll:L,zoomOnPinch:T,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,zoomOnDoubleClick:V,panOnDrag:B,onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:ne,paneClickDistance:Z,nodeClickDistance:ce,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:$e,onEdgeMouseLeave:Ce,reconnectRadius:_e,onReconnect:Be,onReconnectStart:ot,onReconnectEnd:yt,noDragClassName:Te,noWheelClassName:st,noPanClassName:gt,disableKeyboardA11y:xe,nodeExtent:Fe,rfId:lt,viewport:oe,onViewportChange:ke}){return n1(e),n1(t),jW(),gW(n),wW(oe),i.jsx(z5,{onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:ee,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:Z,deleteKeyCode:I,selectionKeyCode:k,selectionOnDrag:x,selectionMode:N,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:j,panActivationKeyCode:C,zoomActivationKeyCode:P,elementsSelectable:$,zoomOnScroll:L,zoomOnPinch:T,zoomOnDoubleClick:V,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,panOnDrag:B,defaultViewport:D,translateExtent:z,minZoom:O,maxZoom:M,onSelectionContextMenu:f,preventScrolling:K,noDragClassName:Te,noWheelClassName:st,noPanClassName:gt,disableKeyboardA11y:xe,onViewportChange:ke,isControlledViewport:!!oe,children:i.jsxs(mW,{children:[i.jsx(pW,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:Be,onReconnectStart:ot,onReconnectEnd:yt,onlyRenderVisibleElements:F,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:$e,onEdgeMouseLeave:Ce,reconnectRadius:_e,defaultMarkerColor:H,noPanClassName:gt,disableKeyboardA11y:xe,rfId:lt}),i.jsx(SW,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(G5,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ce,onlyRenderVisibleElements:F,noPanClassName:gt,noDragClassName:Te,disableKeyboardA11y:xe,nodeExtent:Fe,rfId:lt}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}mR.displayName="GraphView";const CW=m.memo(mR),r1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:p="basic"}={})=>{const h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=d??[0,0],N=f??Ld;CI(v,b,g);const{nodesInitialized:j}=Ox(k,h,y,{nodeOrigin:x,nodeExtent:N,zIndexMode:p});let C=[0,0,1];if(a&&s&&o){const P=df(h,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:I,y:F,zoom:$}=Ik(P,s,o,c,u,(l==null?void 0:l.padding)??.1);C=[I,F,$]}return{rfId:"1",width:s??0,height:o??0,transform:C,nodes:k,nodesInitialized:j,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:Ld,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Cc.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:{...lI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:PH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:aI,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},_W=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p})=>q4((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:N,height:j,minZoom:C,maxZoom:P}=y();g&&(await EH({nodes:b,width:N,height:j,panZoom:g,minZoom:C,maxZoom:P},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...r1({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:N,fitViewQueued:j,zIndexMode:C,nodesSelectionActive:P}=y(),{nodesInitialized:I,hasSelectedNodes:F}=Ox(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),$=P&&F;j&&I?(v(),h({nodes:b,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:$})):h({nodes:b,nodesInitialized:I,nodesSelectionActive:$})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();CI(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:N,nodeOrigin:j,nodeExtent:C,debug:P,fitViewQueued:I,zIndexMode:F}=y(),{changes:$,updatedInternals:D}=XH(b,k,x,N,j,C,F);D&&(UH(k,x,{nodeOrigin:j,nodeExtent:C,zIndexMode:F}),I?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),($==null?void 0:$.length)>0&&(P&&console.log("React Flow: trigger node changes",$),g==null||g($)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:N,triggerNodeChanges:j,connection:C,updateConnection:P,onNodesChangeMiddlewareMap:I}=y();for(const[F,$]of b){const D=N.get(F),z=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&($!=null&&$.position)),O={id:F,type:"position",position:z?{x:Math.max(0,$.position.x),y:Math.max(0,$.position.y)}:$.position,dragging:g};if(D&&C.inProgress&&C.fromNode.id===D.id){const M=Ja(D,C.fromHandle,qe.Left,!0);P({...C,from:M})}z&&D.parentId&&k.push({id:F,parentId:D.parentId,rect:{...$.internals.positionAbsolute,width:$.measured.width??0,height:$.measured.height??0}}),x.push(O)}if(k.length>0){const{parentLookup:F,nodeOrigin:$}=y(),D=Ok(k,N,F,$);x.push(...D)}for(const F of I.values())x=F(x);j(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:N,debug:j}=y();if(b!=null&&b.length){if(N){const C=ad(b,x);k(C)}j&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:N,debug:j}=y();if(b!=null&&b.length){if(N){const C=Qh(b,x);k(C)}j&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:j}=y();if(g){const C=b.map(P=>Na(P,!0));N(C);return}N(ec(x,new Set([...b]),!0)),j(ec(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:j}=y();if(g){const C=b.map(P=>Na(P,!0));j(C);return}j(ec(k,new Set([...b]))),N(ec(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:C}=y(),P=b||x,I=g||k,F=[];for(const D of P){if(!D.selected)continue;const z=N.get(D.id);z&&(z.selected=!1),F.push(Na(D.id,!1))}const $=[];for(const D of I)D.selected&&$.push(Na(D.id,!1));j(F),C($)},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:N}=y();if(!N)return;const j=g.reduce((P,I)=>I.selected?[...P,Na(I.id,!1)]:P,[]),C=b.reduce((P,I)=>I.selected?[...P,Na(I.id,!1)]:P,[]);k(j),x(C)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:N,elevateNodesOnSelect:j,nodeExtent:C,zIndexMode:P}=y();b[0][0]===C[0][0]&&b[0][1]===C[0][1]&&b[1][0]===C[1][0]&&b[1][1]===C[1][1]||(Ox(g,k,x,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:j,checkEquality:!1,zIndexMode:P}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:N,translateExtent:j}=y();return QH({delta:b,panZoom:N,transform:g,translateExtent:j,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:N,maxZoom:j,panZoom:C}=y();if(!C)return Promise.resolve(!1);const P=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:j;return await C.setViewport({x:x/2-b*P,y:N/2-g*P,zoom:P},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...lI}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...r1()})}},Object.is);function Fk({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:h}){const[y]=m.useState(()=>_W({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:p}));return i.jsx(U4,{value:y,children:i.jsx(m5,{children:h})})}function EW({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h}){return m.useContext(Qm)?i.jsx(i.Fragment,{children:e}):i.jsx(Fk,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:e})}const AW={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function PW({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:j,onNodeDoubleClick:C,onNodeDragStart:P,onNodeDrag:I,onNodeDragStop:F,onNodesDelete:$,onEdgesDelete:D,onDelete:z,onSelectionChange:O,onSelectionDragStart:M,onSelectionDrag:K,onSelectionDragStop:H,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:W,onBeforeDelete:E,connectionMode:Q,connectionLineType:V=Mo.Bezier,connectionLineStyle:B,connectionLineComponent:se,connectionLineContainerStyle:ue,deleteKeyCode:G="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:ne=Od.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:ce=Fd()?"Meta":"Control",zoomActivationKeyCode:de=Fd()?"Meta":"Control",snapToGrid:me,snapGrid:$e,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:_e,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:yt,nodesFocusable:Te,nodeOrigin:st=VI,edgesFocusable:gt,edgesReconnectable:xe,elementsSelectable:Fe=!0,defaultViewport:lt=o5,minZoom:oe=.5,maxZoom:ke=2,translateExtent:Ke=Ld,preventScrolling:Ue=!0,nodeExtent:be,defaultMarkerColor:Ht="#b1b1b7",zoomOnScroll:Qt=!0,zoomOnPinch:jt=!0,panOnScroll:yn=!1,panOnScrollSpeed:on=.5,panOnScrollMode:re=Fa.Free,zoomOnDoubleClick:Re=!0,panOnDrag:Je=!0,onPaneClick:Ze,onPaneMouseEnter:Tt,onPaneMouseMove:At,onPaneMouseLeave:Vn,onPaneScroll:Sn,onPaneContextMenu:xr,paneClickDistance:wn=1,nodeClickDistance:Xn=0,children:Kn,onReconnect:hr,onReconnectStart:ts,onReconnectEnd:Ar,onEdgeContextMenu:gs,onEdgeDoubleClick:ys,onEdgeMouseEnter:cn,onEdgeMouseMove:rr,onEdgeMouseLeave:Pr,reconnectRadius:dn=10,onNodesChange:Qn,onEdgesChange:br,noDragClassName:sr="nodrag",noWheelClassName:Ct="nowheel",noPanClassName:Gt="nopan",fitView:_t,fitViewOptions:le,connectOnClick:ve,attributionPosition:it,proOptions:Dt,defaultEdgeOptions:Jt,elevateNodesOnSelect:tn=!0,elevateEdgesOnSelect:Zn=!1,disableKeyboardA11y:mt=!1,autoPanOnConnect:nn,autoPanOnNodeDrag:Wt,autoPanSpeed:kr,connectionRadius:tt,isValidConnection:Ln,onError:$i,style:zr,id:mo,nodeDragThreshold:ai,connectionDragThreshold:Ts,viewport:ie,onViewportChange:Se,width:Pe,height:xt,colorMode:Lt="light",debug:qt,onScroll:zn,ariaLabelConfig:On,zIndexMode:q="basic",...pe},Oe){const Ee=mo||"1",et=u5(Lt),Nn=m.useCallback(kt=>{kt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),zn==null||zn(kt)},[zn]);return i.jsx("div",{"data-testid":"rf__wrapper",...pe,onScroll:Nn,style:{...zr,...AW},ref:Oe,className:Jn(["react-flow",s,et]),id:mo,role:"application",children:i.jsxs(EW,{nodes:e,edges:t,width:Pe,height:xt,fitView:_t,fitViewOptions:le,minZoom:oe,maxZoom:ke,nodeOrigin:st,nodeExtent:be,zIndexMode:q,children:[i.jsx(c5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:yt,nodesFocusable:Te,edgesFocusable:gt,edgesReconnectable:xe,elementsSelectable:Fe,elevateNodesOnSelect:tn,elevateEdgesOnSelect:Zn,minZoom:oe,maxZoom:ke,nodeExtent:be,onNodesChange:Qn,onEdgesChange:br,snapToGrid:me,snapGrid:$e,connectionMode:Q,translateExtent:Ke,connectOnClick:ve,defaultEdgeOptions:Jt,fitView:_t,fitViewOptions:le,onNodesDelete:$,onEdgesDelete:D,onDelete:z,onNodeDragStart:P,onNodeDrag:I,onNodeDragStop:F,onSelectionDrag:K,onSelectionDragStart:M,onSelectionDragStop:H,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Gt,nodeOrigin:st,rfId:Ee,autoPanOnConnect:nn,autoPanOnNodeDrag:Wt,autoPanSpeed:kr,onError:$i,connectionRadius:tt,isValidConnection:Ln,selectNodesOnDrag:_e,nodeDragThreshold:ai,connectionDragThreshold:Ts,onBeforeDelete:E,debug:qt,ariaLabelConfig:On,zIndexMode:q}),i.jsx(CW,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:N,onNodeContextMenu:j,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:a,connectionLineType:V,connectionLineStyle:B,connectionLineComponent:se,connectionLineContainerStyle:ue,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:G,multiSelectionKeyCode:ce,panActivationKeyCode:Z,zoomActivationKeyCode:de,onlyRenderVisibleElements:Ce,defaultViewport:lt,translateExtent:Ke,minZoom:oe,maxZoom:ke,preventScrolling:Ue,zoomOnScroll:Qt,zoomOnPinch:jt,zoomOnDoubleClick:Re,panOnScroll:yn,panOnScrollSpeed:on,panOnScrollMode:re,panOnDrag:Je,onPaneClick:Ze,onPaneMouseEnter:Tt,onPaneMouseMove:At,onPaneMouseLeave:Vn,onPaneScroll:Sn,onPaneContextMenu:xr,paneClickDistance:wn,nodeClickDistance:Xn,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:W,onReconnect:hr,onReconnectStart:ts,onReconnectEnd:Ar,onEdgeContextMenu:gs,onEdgeDoubleClick:ys,onEdgeMouseEnter:cn,onEdgeMouseMove:rr,onEdgeMouseLeave:Pr,reconnectRadius:dn,defaultMarkerColor:Ht,noDragClassName:sr,noWheelClassName:Ct,noPanClassName:Gt,rfId:Ee,disableKeyboardA11y:mt,nodeExtent:be,viewport:ie,onViewportChange:Se}),i.jsx(i5,{onSelectionChange:O}),Kn,i.jsx(e5,{proOptions:Dt,position:it}),i.jsx(Z4,{rfId:Ee,disableKeyboardA11y:mt})]})})}var gR=qI(PW);function IW(){const e=gn();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 RW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>ad(s,o)),[]);return[t,n,r]}function TW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>Qh(s,o)),[]);return[t,n,r]}function MW({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:Jn(["react-flow__background-pattern",n,r])})}function $W({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Jn(["react-flow__background-pattern","dots",t])})}var Yo;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Yo||(Yo={}));const LW={[Yo.Dots]:1,[Yo.Lines]:1,[Yo.Cross]:6},OW=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function yR({id:e,variant:t=Yo.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:p,patternId:h}=Bt(OW,_n),y=r||LW[t],v=t===Yo.Dots,b=t===Yo.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],N=Array.isArray(o)?o:[o,o],j=b?[x,x]:k,C=[N[0]*p[2]||1+j[0]/2,N[1]*p[2]||1+j[1]/2],P=`${h}${e||""}`;return i.jsxs("svg",{className:Jn(["react-flow__background",u]),style:{...c,...eg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:P,x:p[0]%k[0],y:p[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:v?i.jsx($W,{radius:x/2,className:d}):i.jsx(MW,{dimensions:j,lineWidth:s,variant:t,className:d})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}yR.displayName="Background";const wR=m.memo(yR);function DW(){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 FW(){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 zW(){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 BW(){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 HW(){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 Cp({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Jn(["react-flow__controls-button",t]),...n,children:e})}const WW=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function xR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:p="vertical","aria-label":h}){const y=gn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Bt(WW,_n),{zoomIn:x,zoomOut:N,fitView:j}=Fc(),C=()=>{x(),o==null||o()},P=()=>{N(),a==null||a()},I=()=>{j(s),l==null||l()},F=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},$=p==="horizontal"?"horizontal":"vertical";return i.jsxs(Zm,{className:Jn(["react-flow__controls",$,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Cp,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(DW,{})}),i.jsx(Cp,{onClick:P,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(FW,{})})]}),n&&i.jsx(Cp,{className:"react-flow__controls-fitview",onClick:I,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(zW,{})}),r&&i.jsx(Cp,{className:"react-flow__controls-interactive",onClick:F,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(HW,{}):i.jsx(BW,{})}),d]})}xR.displayName="Controls";m.memo(xR);function VW({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:p,onClick:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:Jn(["react-flow__minimap-node",{selected:p},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?g=>h(g,e):void 0})}const KW=m.memo(VW),qW=e=>e.nodes.map(t=>t.id),By=e=>e instanceof Function?e:()=>e;function UW({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=KW,onClick:a}){const l=Bt(qW,_n),c=By(t),u=By(e),d=By(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(p=>i.jsx(GW,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},p))})}function YW({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:f,width:p,height:h}=Bt(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:N}=fo(b);return{node:b,x:g,y:k,width:x,height:N}},_n);return!u||u.hidden||!mI(u)?null:i.jsx(l,{x:d,y:f,width:p,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const GW=m.memo(YW);var JW=m.memo(UW);const XW=200,QW=150,ZW=e=>!e.hidden,e6=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?hI(df(e.nodeLookup,{filter:ZW}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},t6="react-flow__minimap-desc";function bR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:p="bottom-right",onClick:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:N=5}){const j=gn(),C=m.useRef(null),{boundingRect:P,viewBB:I,rfId:F,panZoom:$,translateExtent:D,flowWidth:z,flowHeight:O,ariaLabelConfig:M}=Bt(e6,_n),K=(e==null?void 0:e.width)??XW,H=(e==null?void 0:e.height)??QW,L=P.width/K,T=P.height/H,W=Math.max(L,T),E=W*K,Q=W*H,V=N*W,B=P.x-(E-P.width)/2-V,se=P.y-(Q-P.height)/2-V,ue=E+V*2,G=Q+V*2,ee=`${t6}-${F}`,te=m.useRef(0),ne=m.useRef();te.current=W,m.useEffect(()=>{if(C.current&&$)return ne.current=a4({domNode:C.current,panZoom:$,getTransform:()=>j.getState().transform,getViewScale:()=>te.current}),()=>{var me;(me=ne.current)==null||me.destroy()}},[$]),m.useEffect(()=>{var me;(me=ne.current)==null||me.update({translateExtent:D,width:z,height:O,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,D,z,O]);const Z=h?me=>{var _e;const[$e,Ce]=((_e=ne.current)==null?void 0:_e.pointer(me))||[0,0];h(me,{x:$e,y:Ce})}:void 0,ce=y?m.useCallback((me,$e)=>{const Ce=j.getState().nodeLookup.get($e).internals.userNode;y(me,Ce)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(Zm,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*W:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Jn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:K,height:H,viewBox:`${B} ${se} ${ue} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:C,onClick:Z,children:[de&&i.jsx("title",{id:ee,children:de}),i.jsx(JW,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-V},${se-V}h${ue+V*2}v${G+V*2}h${-ue-V*2}z
|
|
66
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}bR.displayName="MiniMap";m.memo(bR);const n6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,r6={[Pc.Line]:"right",[Pc.Handle]:"bottom-right"};function s6({nodeId:e,position:t,variant:n=Pc.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=JI(),x=typeof e=="string"?e:k,N=gn(),j=m.useRef(null),C=n===Pc.Handle,P=Bt(m.useCallback(n6(C&&h),[C,h]),_n),I=m.useRef(null),F=t??r6[n];m.useEffect(()=>{if(!(!j.current||!x))return I.current||(I.current=k4({domNode:j.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:D,transform:z,snapGrid:O,snapToGrid:M,nodeOrigin:K,domNode:H}=N.getState();return{nodeLookup:D,transform:z,snapGrid:O,snapToGrid:M,nodeOrigin:K,paneDomNode:H}},onChange:(D,z)=>{const{triggerNodeChanges:O,nodeLookup:M,parentLookup:K,nodeOrigin:H}=N.getState(),L=[],T={x:D.x,y:D.y},W=M.get(x);if(W&&W.expandParent&&W.parentId){const E=W.origin??H,Q=D.width??W.measured.width??0,V=D.height??W.measured.height??0,B={id:W.id,parentId:W.parentId,rect:{width:Q,height:V,...gI({x:D.x??W.position.x,y:D.y??W.position.y},{width:Q,height:V},W.parentId,M,E)}},se=Ok([B],M,K,H);L.push(...se),T.x=D.x?Math.max(E[0]*Q,D.x):void 0,T.y=D.y?Math.max(E[1]*V,D.y):void 0}if(T.x!==void 0&&T.y!==void 0){const E={id:x,type:"position",position:{...T}};L.push(E)}if(D.width!==void 0&&D.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};L.push(Q)}for(const E of z){const Q={...E,type:"position"};L.push(Q)}O(L)},onEnd:({width:D,height:z})=>{const O={id:x,type:"dimensions",resizing:!1,dimensions:{width:D,height:z}};N.getState().triggerNodeChanges([O])}})),I.current.update({controlPosition:F,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var D;(D=I.current)==null||D.destroy()}},[F,l,c,u,d,f,v,b,g,y]);const $=F.split("-");return i.jsx("div",{className:Jn(["react-flow__resize-control","nodrag",...$,n,r]),ref:j,style:{...s,scale:P,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:o})}const zk=m.memo(s6),i6="modulepreload",o6=function(e){return"/"+e},s1={},a6=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=o6(c),c in s1)return;s1[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":i6,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function l6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const c6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,u6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,d6={};function i1(e,t){return(d6.jsx?u6:c6).test(e)}const f6=/[ \t\n\f\r]/g;function p6(e){return typeof e=="object"?e.type==="text"?o1(e.value):!1:o1(e)}function o1(e){return e.replace(f6,"")===""}class hf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}hf.prototype.normal={};hf.prototype.property={};hf.prototype.space=void 0;function kR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new hf(n,r,t)}function Bx(e){return e.toLowerCase()}class es{constructor(t,n){this.attribute=n,this.property=t}}es.prototype.attribute="";es.prototype.booleanish=!1;es.prototype.boolean=!1;es.prototype.commaOrSpaceSeparated=!1;es.prototype.commaSeparated=!1;es.prototype.defined=!1;es.prototype.mustUseProperty=!1;es.prototype.number=!1;es.prototype.overloadedBoolean=!1;es.prototype.property="";es.prototype.spaceSeparated=!1;es.prototype.space=void 0;let h6=0;const St=ol(),Un=ol(),Hx=ol(),Ie=ol(),pn=ol(),dc=ol(),ss=ol();function ol(){return 2**++h6}const Wx=Object.freeze(Object.defineProperty({__proto__:null,boolean:St,booleanish:Un,commaOrSpaceSeparated:ss,commaSeparated:dc,number:Ie,overloadedBoolean:Hx,spaceSeparated:pn},Symbol.toStringTag,{value:"Module"})),Hy=Object.keys(Wx);class Bk extends es{constructor(t,n,r,s){let o=-1;if(super(t,n),a1(this,"space",s),typeof r=="number")for(;++o<Hy.length;){const a=Hy[o];a1(this,Hy[o],(r&Wx[a])===Wx[a])}}}Bk.prototype.defined=!0;function a1(e,t,n){n&&(e[t]=n)}function zc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new Bk(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Bx(r)]=r,n[Bx(o.attribute)]=r}return new hf(t,n,e.space)}const vR=zc({properties:{ariaActiveDescendant:null,ariaAtomic:Un,ariaAutoComplete:null,ariaBusy:Un,ariaChecked:Un,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:pn,ariaCurrent:null,ariaDescribedBy:pn,ariaDetails:null,ariaDisabled:Un,ariaDropEffect:pn,ariaErrorMessage:null,ariaExpanded:Un,ariaFlowTo:pn,ariaGrabbed:Un,ariaHasPopup:null,ariaHidden:Un,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:pn,ariaLevel:Ie,ariaLive:null,ariaModal:Un,ariaMultiLine:Un,ariaMultiSelectable:Un,ariaOrientation:null,ariaOwns:pn,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Un,ariaReadOnly:Un,ariaRelevant:null,ariaRequired:Un,ariaRoleDescription:pn,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Un,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function SR(e,t){return t in e?e[t]:t}function NR(e,t){return SR(e,t.toLowerCase())}const m6=zc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:dc,acceptCharset:pn,accessKey:pn,action:null,allow:null,allowFullScreen:St,allowPaymentRequest:St,allowUserMedia:St,alt:null,as:null,async:St,autoCapitalize:null,autoComplete:pn,autoFocus:St,autoPlay:St,blocking:pn,capture:null,charSet:null,checked:St,cite:null,className:pn,cols:Ie,colSpan:null,content:null,contentEditable:Un,controls:St,controlsList:pn,coords:Ie|dc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:St,defer:St,dir:null,dirName:null,disabled:St,download:Hx,draggable:Un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:St,formTarget:null,headers:pn,height:Ie,hidden:Hx,high:Ie,href:null,hrefLang:null,htmlFor:pn,httpEquiv:pn,id:null,imageSizes:null,imageSrcSet:null,inert:St,inputMode:null,integrity:null,is:null,isMap:St,itemId:null,itemProp:pn,itemRef:pn,itemScope:St,itemType:pn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:St,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:St,muted:St,name:null,nonce:null,noModule:St,noValidate:St,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:St,optimum:Ie,pattern:null,ping:pn,placeholder:null,playsInline:St,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:St,referrerPolicy:null,rel:pn,required:St,reversed:St,rows:Ie,rowSpan:Ie,sandbox:pn,scope:null,scoped:St,seamless:St,selected:St,shadowRootClonable:St,shadowRootDelegatesFocus:St,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:St,useMap:null,value:Un,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:pn,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:St,declare:St,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:St,noHref:St,noShade:St,noWrap:St,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Un,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:St,disableRemotePlayback:St,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:NR}),g6=zc({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:ss,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:pn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:St,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:dc,g2:dc,glyphName:dc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:ss,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:pn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ss,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ss,rev:ss,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ss,requiredFeatures:ss,requiredFonts:ss,requiredFormats:ss,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:ss,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ss,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ss,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:SR}),jR=zc({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()}}),CR=zc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NR}),_R=zc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),y6={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},w6=/[A-Z]/g,l1=/-[a-z]/g,x6=/^data[-\w.:]+$/i;function b6(e,t){const n=Bx(t);let r=t,s=es;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&x6.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(l1,v6);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!l1.test(o)){let a=o.replace(w6,k6);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Bk}return new s(r,t)}function k6(e){return"-"+e.toLowerCase()}function v6(e){return e.charAt(1).toUpperCase()}const S6=kR([vR,m6,jR,CR,_R],"html"),Hk=kR([vR,g6,jR,CR,_R],"svg");function N6(e){return e.join(" ").trim()}var Wk={},c1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,j6=/\n/g,C6=/^\s*/,_6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,E6=/^:\s*/,A6=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,P6=/^[;\s]*/,I6=/^\s+|\s+$/g,R6=`
|
|
67
|
+
`,u1="/",d1="*",Ca="",T6="comment",M6="declaration";function $6(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(y){var v=y.match(j6);v&&(n+=v.length);var b=y.lastIndexOf(R6);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(C6)}function d(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(u1!=e.charAt(0)||d1!=e.charAt(1))){for(var v=2;Ca!=e.charAt(v)&&(d1!=e.charAt(v)||u1!=e.charAt(v+1));)++v;if(v+=2,Ca===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:T6,comment:b})}}function p(){var y=o(),v=c(_6);if(v){if(f(),!c(E6))return l("property missing ':'");var b=c(A6),g=y({type:M6,property:f1(v[0].replace(c1,Ca)),value:b?f1(b[0].replace(c1,Ca)):Ca});return c(P6),g}}function h(){var y=[];d(y);for(var v;v=p();)v!==!1&&(y.push(v),d(y));return y}return u(),h()}function f1(e){return e?e.replace(I6,Ca):Ca}var L6=$6,O6=hd&&hd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wk,"__esModule",{value:!0});Wk.default=F6;const D6=O6(L6);function F6(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,D6.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 ng={};Object.defineProperty(ng,"__esModule",{value:!0});ng.camelCase=void 0;var z6=/^--[a-zA-Z0-9_-]+$/,B6=/-([a-z])/g,H6=/^[^-]+$/,W6=/^-(webkit|moz|ms|o|khtml)-/,V6=/^-(ms)-/,K6=function(e){return!e||H6.test(e)||z6.test(e)},q6=function(e,t){return t.toUpperCase()},p1=function(e,t){return"".concat(t,"-")},U6=function(e,t){return t===void 0&&(t={}),K6(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(V6,p1):e=e.replace(W6,p1),e.replace(B6,q6))};ng.camelCase=U6;var Y6=hd&&hd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},G6=Y6(Wk),J6=ng;function Vx(e,t){var n={};return!e||typeof e!="string"||(0,G6.default)(e,function(r,s){r&&s&&(n[(0,J6.camelCase)(r,t)]=s)}),n}Vx.default=Vx;var X6=Vx;const Q6=sa(X6),ER=AR("end"),Vk=AR("start");function AR(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 Z6(e){const t=Vk(e),n=ER(e);if(t&&n)return{start:t,end:n}}function ld(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?h1(e.position):"start"in e||"end"in e?h1(e):"line"in e||"column"in e?Kx(e):""}function Kx(e){return m1(e&&e.line)+":"+m1(e&&e.column)}function h1(e){return Kx(e&&e.start)+"-"+Kx(e&&e.end)}function m1(e){return e&&typeof e=="number"?e:1}class Er 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=ld(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}}Er.prototype.file="";Er.prototype.name="";Er.prototype.reason="";Er.prototype.message="";Er.prototype.stack="";Er.prototype.column=void 0;Er.prototype.line=void 0;Er.prototype.ancestors=void 0;Er.prototype.cause=void 0;Er.prototype.fatal=void 0;Er.prototype.place=void 0;Er.prototype.ruleId=void 0;Er.prototype.source=void 0;const Kk={}.hasOwnProperty,e8=new Map,t8=/[A-Z]/g,n8=new Set(["table","tbody","thead","tfoot","tr"]),r8=new Set(["td","th"]),PR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function s8(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=f8(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=d8(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"?Hk:S6,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 i8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return o8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return l8(e,t,n);if(t.type==="mdxjsEsm")return a8(e,t);if(t.type==="root")return c8(e,t,n);if(t.type==="text")return u8(e,t)}function i8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Hk,e.schema=s),e.ancestors.push(t);const o=TR(e,t.tagName,!1),a=p8(e,t);let l=Uk(e,t);return n8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!p6(c):!0})),RR(e,a,o,t),qk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function o8(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)}Bd(e,t.position)}function a8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Bd(e,t.position)}function l8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Hk,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:TR(e,t.name,!0),a=h8(e,t),l=Uk(e,t);return RR(e,a,o,t),qk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function c8(e,t,n){const r={};return qk(r,Uk(e,t)),e.create(t,e.Fragment,r,n)}function u8(e,t){return t.value}function RR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qk(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function d8(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 f8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=Vk(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 p8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Kk.call(t.properties,s)){const o=m8(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&r8.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 h8(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 Bd(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 Bd(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function Uk(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:e8;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 m8(e,t,n){const r=b6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?l6(n):N6(n)),r.property==="style"){let s=typeof n=="object"?n:g8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=y8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?y6[r.property]||r.property:r.attribute,n]}}function g8(e,t){try{return Q6(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Er("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=PR+"#cannot-parse-style-attribute",s}}function TR(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=i1(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=i1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Kk.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Bd(e)}function Bd(e,t){const n=new Er("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=PR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function y8(e){const t={};let n;for(n in e)Kk.call(e,n)&&(t[w8(n)]=e[n]);return t}function w8(e){let t=e.replace(t8,x8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function x8(e){return"-"+e.toLowerCase()}const Wy={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"]},b8={};function k8(e,t){const n=b8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return MR(e,r,s)}function MR(e,t,n){if(v8(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 g1(e.children,t,n)}return Array.isArray(e)?g1(e,t,n):""}function g1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=MR(e[s],t,n);return r.join("")}function v8(e){return!!(e&&typeof e=="object")}const y1=document.createElement("i");function Yk(e){const t="&"+e+";";y1.innerHTML=t;const n=y1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ri(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?(Ri(e,e.length,0,t),e):t}const w1={}.hasOwnProperty;function S8(e){const t={};let n=-1;for(;++n<e.length;)N8(t,e[n]);return t}function N8(e,t){let n;for(n in t){const s=(w1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){w1.call(s,a)||(s[a]=[]);const l=o[a];j8(s[a],Array.isArray(l)?l:l?[l]:[])}}}function j8(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ri(e,0,0,r)}function $R(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 fc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ki=la(/[A-Za-z]/),cs=la(/[\dA-Za-z]/),C8=la(/[#-'*+\--9=?A-Z^-~]/);function qx(e){return e!==null&&(e<32||e===127)}const Ux=la(/\d/),_8=la(/[\dA-Fa-f]/),E8=la(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function Zr(e){return e!==null&&(e<0||e===32)}function Xt(e){return e===-2||e===-1||e===32}const A8=la(new RegExp("\\p{P}|\\p{S}","u")),P8=la(/\s/);function la(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Bc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&cs(e.charCodeAt(n+1))&&cs(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 mn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return Xt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Xt(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const I8={tokenize:R8};function R8(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"),mn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return wt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const T8={tokenize:M8},x1={tokenize:$8};function M8(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const N=t.events.length;let j=N,C;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){C=t.events[j][1].end;break}g(r);let P=N;for(;P<t.events.length;)t.events[P][1].end={...C},P++;return Ri(t.events,j+1,0,t.events.slice(N)),t.events.length=P,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(x1,d,f)(x)}function d(x){return s&&k(),g(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function p(x){return t.containerState={},e.attempt(x1,h,y)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function y(x){if(x===null){s&&k(),g(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),v(x)}function v(x){if(x===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return wt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,N){const j=t.sliceStream(x);if(N&&j.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(j),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const P=t.events.length;let I=P,F,$;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){if(F){$=t.events[I][1].end;break}F=!0}for(g(r),C=P;C<t.events.length;)t.events[C][1].end={...$},C++;Ri(t.events,I+1,0,t.events.slice(P)),t.events.length=C}}function g(x){let N=n.length;for(;N-- >x;){const j=n[N];t.containerState=j[1],j[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 $8(e,t,n){return mn(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||Zr(e)||P8(e))return 1;if(A8(e))return 2}function Gk(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 Yx={name:"attention",resolveAll:L8,tokenize:O8};function L8(e,t){let n=-1,r,s,o,a,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};k1(f,-c),k1(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=_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,Gk(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?(d=2,u=_s(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Ri(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function O8(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"),d=b1(c),f=!d||d===2&&s||n.includes(c),p=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?f:f&&(s||!p)),u._close=!!(o===42?p:p&&(d||!f)),t(c)}}function k1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const D8={name:"autolink",tokenize:F8};function F8(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 ki(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||cs(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||cs(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||qx(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):C8(h)?(e.consume(h),u):n(h)}function d(h){return cs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||cs(h))&&r++<63){const y=h===45?p:f;return e.consume(h),y}return n(h)}}const rg={partial:!0,tokenize:z8};function z8(e,t,n){return r;function r(o){return Xt(o)?mn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||wt(o)?t(o):n(o)}}const LR={continuation:{tokenize:H8},exit:W8,name:"blockQuote",tokenize:B8};function B8(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 Xt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function H8(e,t,n){const r=this;return s;function s(a){return Xt(a)?mn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(LR,t,n)(a)}}function W8(e){e.exit("blockQuote")}const OR={name:"characterEscape",tokenize:V8};function V8(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 E8(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const DR={name:"characterReference",tokenize:K8};function K8(e,t,n){const r=this;let s=0,o,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=cs,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=_8,d):(e.enter("characterReferenceValue"),o=7,a=Ux,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===cs&&!Yk(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<o?(e.consume(f),d):n(f)}}const v1={partial:!0,tokenize:U8},S1={concrete:!0,name:"codeFenced",tokenize:q8};function q8(e,t,n){const r=this,s={partial:!0,tokenize:j};let o=0,a=0,l;return c;function c(C){return u(C)}function u(C){const P=r.events[r.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(C)}function d(C){return C===l?(a++,e.consume(C),d):a<3?n(C):(e.exit("codeFencedFenceSequence"),Xt(C)?mn(e,f,"whitespace")(C):f(C))}function f(C){return C===null||wt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(v1,v,N)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(C)):Xt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),mn(e,h,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function h(C){return C===null||wt(C)?f(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||wt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(C)):C===96&&C===l?n(C):(e.consume(C),y)}function v(C){return e.attempt(s,N,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return o>0&&Xt(C)?mn(e,k,"linePrefix",o+1)(C):k(C)}function k(C){return C===null||wt(C)?e.check(v1,v,N)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||wt(C)?(e.exit("codeFlowValue"),k(C)):(e.consume(C),x)}function N(C){return e.exit("codeFenced"),t(C)}function j(C,P,I){let F=0;return $;function $(K){return C.enter("lineEnding"),C.consume(K),C.exit("lineEnding"),D}function D(K){return C.enter("codeFencedFence"),Xt(K)?mn(C,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):z(K)}function z(K){return K===l?(C.enter("codeFencedFenceSequence"),O(K)):I(K)}function O(K){return K===l?(F++,C.consume(K),O):F>=a?(C.exit("codeFencedFenceSequence"),Xt(K)?mn(C,M,"whitespace")(K):M(K)):I(K)}function M(K){return K===null||wt(K)?(C.exit("codeFencedFence"),P(K)):I(K)}}}function U8(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 Vy={name:"codeIndented",tokenize:G8},Y8={partial:!0,tokenize:J8};function G8(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),mn(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):wt(u)?e.attempt(Y8,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||wt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function J8(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):mn(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):wt(a)?s(a):n(a)}}const X8={name:"codeText",previous:Z8,resolve:Q8,tokenize:e9};function Q8(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 Z8(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function e9(e,t,n){let r=0,s,o;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),s=0,d(f)):wt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||wt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class t9{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&&Eu(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),Eu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Eu(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);Eu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Eu(this.left,n.reverse())}}}function Eu(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 FR(e){const t={};let n=-1,r,s,o,a,l,c,u;const d=new t9(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,n9(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=d.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...d.get(s)[1].start},l=d.slice(s,n),l.unshift(r),d.splice(s,n-s+1,l))}}return Ri(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function n9(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],u={};let d,f,p=-1,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(v=p+1,b.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),p=b.length;p--;){const g=l.slice(b[p],b[p+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),p=-1;++p<c.length;)u[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return u}const r9={resolve:i9,tokenize:o9},s9={partial:!0,tokenize:a9};function i9(e){return FR(e),e}function o9(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?o(l):wt(l)?e.check(s9,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 a9(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),mn(e,o,"linePrefix")}function o(a){if(a===null||wt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function zR(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(g){return g===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(g),e.exit(o),p):g===null||g===32||g===41||qx(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function p(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:h)}function y(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function v(g){return!d&&(g===null||g===41||Zr(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,v):g===41?(e.consume(g),d--,v):g===null||g===32||g===40||qx(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 BR(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(o),d}function d(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):wt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||wt(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!Xt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function HR(e,t,n,r,s,o){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(o),u(p))}function u(p){return p===a?(e.exit(o),c(a)):p===null?n(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),mn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||wt(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:d)}function f(p){return p===a||p===92?(e.consume(p),d):d(p)}}function cd(e,t){let n;return r;function r(s){return wt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Xt(s)?mn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const l9={name:"definition",tokenize:u9},c9={partial:!0,tokenize:d9};function u9(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return BR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=fc(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 Zr(h)?cd(e,u)(h):u(h)}function u(h){return zR(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(c9,f,f)(h)}function f(h){return Xt(h)?mn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||wt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function d9(e,t,n){return r;function r(l){return Zr(l)?cd(e,s)(l):n(l)}function s(l){return HR(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return Xt(l)?mn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||wt(l)?t(l):n(l)}}const f9={name:"hardBreakEscape",tokenize:p9};function p9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return wt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const h9={name:"headingAtx",resolve:m9,tokenize:g9};function m9(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"},Ri(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function g9(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||Zr(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||wt(d)?(e.exit("atxHeading"),t(d)):Xt(d)?mn(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Zr(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const y9=["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"],N1=["pre","script","style","textarea"],w9={concrete:!0,name:"htmlFlow",resolveTo:k9,tokenize:v9},x9={partial:!0,tokenize:N9},b9={partial:!0,tokenize:S9};function k9(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 v9(e,t,n){const r=this;let s,o,a,l,c;return u;function u(B){return d(B)}function d(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),p):B===47?(e.consume(B),o=!0,v):B===63?(e.consume(B),s=3,r.interrupt?t:E):ki(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function p(B){return B===45?(e.consume(B),s=2,h):B===91?(e.consume(B),s=5,l=0,y):ki(B)?(e.consume(B),s=4,r.interrupt?t:E):n(B)}function h(B){return B===45?(e.consume(B),r.interrupt?t:E):n(B)}function y(B){const se="CDATA[";return B===se.charCodeAt(l++)?(e.consume(B),l===se.length?r.interrupt?t:z:y):n(B)}function v(B){return ki(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function b(B){if(B===null||B===47||B===62||Zr(B)){const se=B===47,ue=a.toLowerCase();return!se&&!o&&N1.includes(ue)?(s=1,r.interrupt?t(B):z(B)):y9.includes(a.toLowerCase())?(s=6,se?(e.consume(B),g):r.interrupt?t(B):z(B)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):o?k(B):x(B))}return B===45||cs(B)?(e.consume(B),a+=String.fromCharCode(B),b):n(B)}function g(B){return B===62?(e.consume(B),r.interrupt?t:z):n(B)}function k(B){return Xt(B)?(e.consume(B),k):$(B)}function x(B){return B===47?(e.consume(B),$):B===58||B===95||ki(B)?(e.consume(B),N):Xt(B)?(e.consume(B),x):$(B)}function N(B){return B===45||B===46||B===58||B===95||cs(B)?(e.consume(B),N):j(B)}function j(B){return B===61?(e.consume(B),C):Xt(B)?(e.consume(B),j):x(B)}function C(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,P):Xt(B)?(e.consume(B),C):I(B)}function P(B){return B===c?(e.consume(B),c=null,F):B===null||wt(B)?n(B):(e.consume(B),P)}function I(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Zr(B)?j(B):(e.consume(B),I)}function F(B){return B===47||B===62||Xt(B)?x(B):n(B)}function $(B){return B===62?(e.consume(B),D):n(B)}function D(B){return B===null||wt(B)?z(B):Xt(B)?(e.consume(B),D):n(B)}function z(B){return B===45&&s===2?(e.consume(B),H):B===60&&s===1?(e.consume(B),L):B===62&&s===4?(e.consume(B),Q):B===63&&s===3?(e.consume(B),E):B===93&&s===5?(e.consume(B),W):wt(B)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(x9,V,O)(B)):B===null||wt(B)?(e.exit("htmlFlowData"),O(B)):(e.consume(B),z)}function O(B){return e.check(b9,M,V)(B)}function M(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),K}function K(B){return B===null||wt(B)?O(B):(e.enter("htmlFlowData"),z(B))}function H(B){return B===45?(e.consume(B),E):z(B)}function L(B){return B===47?(e.consume(B),a="",T):z(B)}function T(B){if(B===62){const se=a.toLowerCase();return N1.includes(se)?(e.consume(B),Q):z(B)}return ki(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),T):z(B)}function W(B){return B===93?(e.consume(B),E):z(B)}function E(B){return B===62?(e.consume(B),Q):B===45&&s===2?(e.consume(B),E):z(B)}function Q(B){return B===null||wt(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),Q)}function V(B){return e.exit("htmlFlow"),t(B)}}function S9(e,t,n){const r=this;return s;function s(a){return wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function N9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(rg,t,n)}}const j9={name:"htmlText",tokenize:C9};function C9(e,t,n){const r=this;let s,o,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),u):E===47?(e.consume(E),j):E===63?(e.consume(E),x):ki(E)?(e.consume(E),I):n(E)}function u(E){return E===45?(e.consume(E),d):E===91?(e.consume(E),o=0,y):ki(E)?(e.consume(E),k):n(E)}function d(E){return E===45?(e.consume(E),h):n(E)}function f(E){return E===null?n(E):E===45?(e.consume(E),p):wt(E)?(a=f,L(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?H(E):E===45?p(E):f(E)}function y(E){const Q="CDATA[";return E===Q.charCodeAt(o++)?(e.consume(E),o===Q.length?v:y):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):wt(E)?(a=v,L(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),g):v(E)}function g(E){return E===62?H(E):E===93?(e.consume(E),g):v(E)}function k(E){return E===null||E===62?H(E):wt(E)?(a=k,L(E)):(e.consume(E),k)}function x(E){return E===null?n(E):E===63?(e.consume(E),N):wt(E)?(a=x,L(E)):(e.consume(E),x)}function N(E){return E===62?H(E):x(E)}function j(E){return ki(E)?(e.consume(E),C):n(E)}function C(E){return E===45||cs(E)?(e.consume(E),C):P(E)}function P(E){return wt(E)?(a=P,L(E)):Xt(E)?(e.consume(E),P):H(E)}function I(E){return E===45||cs(E)?(e.consume(E),I):E===47||E===62||Zr(E)?F(E):n(E)}function F(E){return E===47?(e.consume(E),H):E===58||E===95||ki(E)?(e.consume(E),$):wt(E)?(a=F,L(E)):Xt(E)?(e.consume(E),F):H(E)}function $(E){return E===45||E===46||E===58||E===95||cs(E)?(e.consume(E),$):D(E)}function D(E){return E===61?(e.consume(E),z):wt(E)?(a=D,L(E)):Xt(E)?(e.consume(E),D):F(E)}function z(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,O):wt(E)?(a=z,L(E)):Xt(E)?(e.consume(E),z):(e.consume(E),M)}function O(E){return E===s?(e.consume(E),s=void 0,K):E===null?n(E):wt(E)?(a=O,L(E)):(e.consume(E),O)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Zr(E)?F(E):(e.consume(E),M)}function K(E){return E===47||E===62||Zr(E)?F(E):n(E)}function H(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function L(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),T}function T(E){return Xt(E)?mn(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):W(E)}function W(E){return e.enter("htmlTextData"),a(E)}}const Jk={name:"labelEnd",resolveAll:P9,resolveTo:I9,tokenize:R9},_9={tokenize:T9},E9={tokenize:M9},A9={tokenize:$9};function P9(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&&Ri(e,0,e.length,n),e}function I9(e,t){let n=e.length,r=0,s,o,a,l;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=_s(l,e.slice(o+1,o+r+3)),l=_s(l,[["enter",d,t]]),l=_s(l,Gk(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=_s(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=_s(l,e.slice(a+1)),l=_s(l,[["exit",c,t]]),Ri(e,o,e.length,l),e}function R9(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return l;function l(p){return o?o._inactive?f(p):(a=r.parser.defined.includes(fc(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(_9,d,a?d:f)(p):p===91?e.attempt(E9,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(A9,d,f)(p)}function d(p){return t(p)}function f(p){return o._balanced=!0,n(p)}}function T9(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return Zr(f)?cd(e,o)(f):o(f)}function o(f){return f===41?d(f):zR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Zr(f)?cd(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?HR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Zr(f)?cd(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function M9(e,t,n){const r=this;return s;function s(l){return BR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(fc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function $9(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 L9={name:"labelStartImage",resolveAll:Jk.resolveAll,tokenize:O9};function O9(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 D9={name:"labelStartLink",resolveAll:Jk.resolveAll,tokenize:F9};function F9(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 Ky={name:"lineEnding",tokenize:z9};function z9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),mn(e,t,"linePrefix")}}const dh={name:"thematicBreak",tokenize:B9};function B9(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||wt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Xt(u)?mn(e,l,"whitespace")(u):l(u))}}const Vr={continuation:{tokenize:K9},exit:U9,name:"list",tokenize:V9},H9={partial:!0,tokenize:Y9},W9={partial:!0,tokenize:q9};function V9(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:Ux(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(dh,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 Ux(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(rg,r.interrupt?n:d,e.attempt(H9,p,f))}function d(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function f(h){return Xt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function K9(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(rg,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,mn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!Xt(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(W9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,mn(e,e.attempt(Vr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function q9(e,t,n){const r=this;return mn(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 U9(e){e.exit(this.containerState.type)}function Y9(e,t,n){const r=this;return mn(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!Xt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const j1={name:"setextUnderline",resolveTo:G9,tokenize:J9};function G9(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 J9(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Xt(u)?mn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||wt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const X9={tokenize:Q9};function Q9(e){const t=this,n=e.attempt(rg,r,e.attempt(this.parser.constructs.flowInitial,s,mn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(r9,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:VR()},eV=WR("string"),tV=WR("text");function WR(e){return{resolveAll:VR(e==="text"?nV:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,l);return a;function a(d){return u(d)?o(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function VR(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 nV(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 rV={42:Vr,43:Vr,45:Vr,48:Vr,49:Vr,50:Vr,51:Vr,52:Vr,53:Vr,54:Vr,55:Vr,56:Vr,57:Vr,62:LR},sV={91:l9},iV={[-2]:Vy,[-1]:Vy,32:Vy},oV={35:h9,42:dh,45:[j1,dh],60:w9,61:j1,95:dh,96:S1,126:S1},aV={38:DR,92:OR},lV={[-5]:Ky,[-4]:Ky,[-3]:Ky,33:L9,38:DR,42:Yx,60:[D8,j9],91:D9,92:[f9,OR],93:Jk,95:Yx,96:X8},cV={null:[Yx,Z9]},uV={null:[42,95]},dV={null:[]},fV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:uV,contentInitial:sV,disable:dV,document:rV,flow:oV,flowInitial:iV,insideSpan:cV,string:aV,text:lV},Symbol.toStringTag,{value:"Module"}));function pV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let a=[],l=[];const c={attempt:P(j),check:P(C),consume:k,enter:x,exit:N,interrupt:P(C,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(D){return a=_s(a,D),b(),a[a.length-1]!==null?[]:(I(t,0),u.events=Gk(o,u.events,u),u.events)}function p(D,z){return mV(h(D),z)}function h(D){return hV(a,D)}function y(){const{_bufferIndex:D,_index:z,line:O,column:M,offset:K}=r;return{_bufferIndex:D,_index:z,line:O,column:M,offset:K}}function v(D){s[D.line]=D.column,$()}function b(){let D;for(;r._index<a.length;){const z=a[r._index];if(typeof z=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<z.length;)g(z.charCodeAt(r._bufferIndex));else g(z)}}function g(D){d=d(D)}function k(D){wt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,$()):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,z){const O=z||{};return O.type=D,O.start=y(),u.events.push(["enter",O,u]),l.push(O),O}function N(D){const z=l.pop();return z.end=y(),u.events.push(["exit",z,u]),z}function j(D,z){I(D,z.from)}function C(D,z){z.restore()}function P(D,z){return O;function O(M,K,H){let L,T,W,E;return Array.isArray(M)?V(M):"tokenize"in M?V([M]):Q(M);function Q(G){return ee;function ee(te){const ne=te!==null&&G[te],Z=te!==null&&G.null,ce=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return V(ce)(te)}}function V(G){return L=G,T=0,G.length===0?H:B(G[T])}function B(G){return ee;function ee(te){return E=F(),W=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?ue():G.tokenize.call(z?Object.assign(Object.create(u),z):u,c,se,ue)(te)}}function se(G){return D(W,E),K}function ue(G){return E.restore(),++T<L.length?B(L[T]):H}}}function I(D,z){D.resolveAll&&!o.includes(D)&&o.push(D),D.resolve&&Ri(u.events,z,u.events.length-z,D.resolve(u.events.slice(z),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function F(){const D=y(),z=u.previous,O=u.currentConstruct,M=u.events.length,K=Array.from(l);return{from:M,restore:H};function H(){r=D,u.previous=z,u.currentConstruct=O,u.events.length=M,l=K,$()}}function $(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function hV(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 mV(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 gV(e){const r={constructs:S8([fV,...(e||{}).extensions||[]]),content:s(I8),defined:[],document:s(T8),flow:s(X9),lazy:{},string:s(eV),text:s(tV)};return r;function s(o){return a;function a(l){return pV(r,o,l)}}}function yV(e){for(;!FR(e););return e}const C1=/[\0\t\n\r]/g;function wV(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,d,f,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(C1.lastIndex=f,u=C1.exec(o),p=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(p),!u){t=o.slice(f);break}if(h===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(o.slice(f,p)),e+=p-f),h){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const xV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function bV(e){return e.replace(xV,kV)}function kV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return $R(n.slice(o?2:1),o?16:10)}return Yk(n)||e}const KR={}.hasOwnProperty;function vV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),SV(n)(yV(gV(n).document().write(wV()(e,t,!0))))}function SV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(yt),autolinkProtocol:F,autolinkEmail:F,atxHeading:o(Ce),blockQuote:o(Z),characterEscape:F,characterReference:F,codeFenced:o(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ce,a),codeText:o(de,a),codeTextData:F,data:F,codeFlowValue:F,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o($e),hardBreakEscape:o(_e),hardBreakTrailing:o(_e),htmlFlow:o(Be,a),htmlFlowData:F,htmlText:o(Be,a),htmlTextData:F,image:o(ot),label:a,link:o(yt),listItem:o(st),listItemValue:p,listOrdered:o(Te,f),listUnordered:o(Te),paragraph:o(gt),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(xe),thematicBreak:o(lt)},exit:{atxHeading:c(),atxHeadingSequence:j,autolink:c(),autolinkEmail:ne,autolinkProtocol:te,blockQuote:c(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:G,characterReference:ee,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:$,codeIndented:c(g),codeText:c(K),codeTextData:$,data:$,definition:c(),definitionDestinationString:N,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(z),hardBreakTrailing:c(z),htmlFlow:c(O),htmlFlowData:$,htmlText:c(M),htmlTextData:$,image:c(L),label:W,labelText:T,lineEnding:D,link:c(H),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:E,resourceTitleString:Q,resource:V,setextHeading:c(I),setextHeadingLineSequence:P,setextHeadingText:C,strong:c(),thematicBreak:c()}};qR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(oe){let ke={type:"root",children:[]};const Ke={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},Ue=[];let be=-1;for(;++be<oe.length;)if(oe[be][1].type==="listOrdered"||oe[be][1].type==="listUnordered")if(oe[be][0]==="enter")Ue.push(be);else{const Ht=Ue.pop();be=s(oe,Ht,be)}for(be=-1;++be<oe.length;){const Ht=t[oe[be][0]];KR.call(Ht,oe[be][1].type)&&Ht[oe[be][1].type].call(Object.assign({sliceSerialize:oe[be][2].sliceSerialize},Ke),oe[be][1])}if(Ke.tokenStack.length>0){const Ht=Ke.tokenStack[Ke.tokenStack.length-1];(Ht[1]||_1).call(Ke,void 0,Ht[0])}for(ke.position={start:Eo(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:Eo(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be<t.transforms.length;)ke=t.transforms[be](ke)||ke;return ke}function s(oe,ke,Ke){let Ue=ke-1,be=-1,Ht=!1,Qt,jt,yn,on;for(;++Ue<=Ke;){const re=oe[Ue];switch(re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{re[0]==="enter"?be++:be--,on=void 0;break}case"lineEndingBlank":{re[0]==="enter"&&(Qt&&!on&&!be&&!yn&&(yn=Ue),on=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:on=void 0}if(!be&&re[0]==="enter"&&re[1].type==="listItemPrefix"||be===-1&&re[0]==="exit"&&(re[1].type==="listUnordered"||re[1].type==="listOrdered")){if(Qt){let Re=Ue;for(jt=void 0;Re--;){const Je=oe[Re];if(Je[1].type==="lineEnding"||Je[1].type==="lineEndingBlank"){if(Je[0]==="exit")continue;jt&&(oe[jt][1].type="lineEndingBlank",Ht=!0),Je[1].type="lineEnding",jt=Re}else if(!(Je[1].type==="linePrefix"||Je[1].type==="blockQuotePrefix"||Je[1].type==="blockQuotePrefixWhitespace"||Je[1].type==="blockQuoteMarker"||Je[1].type==="listItemIndent"))break}yn&&(!jt||yn<jt)&&(Qt._spread=!0),Qt.end=Object.assign({},jt?oe[jt][1].start:re[1].end),oe.splice(jt||Ue,0,["exit",Qt,re[2]]),Ue++,Ke++}if(re[1].type==="listItemPrefix"){const Re={type:"listItem",_spread:!1,start:Object.assign({},re[1].start),end:void 0};Qt=Re,oe.splice(Ue,0,["enter",Re,re[2]]),Ue++,Ke++,yn=void 0,on=!0}}}return oe[ke][1]._spread=Ht,Ke}function o(oe,ke){return Ke;function Ke(Ue){l.call(this,oe(Ue),Ue),ke&&ke.call(this,Ue)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(oe,ke,Ke){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([ke,Ke||void 0]),oe.position={start:Eo(ke.start),end:void 0}}function c(oe){return ke;function ke(Ke){oe&&oe.call(this,Ke),u.call(this,Ke)}}function u(oe,ke){const Ke=this.stack.pop(),Ue=this.tokenStack.pop();if(Ue)Ue[0].type!==oe.type&&(ke?ke.call(this,oe,Ue[0]):(Ue[1]||_1).call(this,oe,Ue[0]));else throw new Error("Cannot close `"+oe.type+"` ("+ld({start:oe.start,end:oe.end})+"): it’s not open");Ke.position.end=Eo(oe.end)}function d(){return k8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(oe){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function h(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=oe}function y(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=oe}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe.replace(/(\r?\n|\r)$/g,"")}function k(oe){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=fc(this.sliceSerialize(oe)).toLowerCase()}function x(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.title=oe}function N(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.url=oe}function j(oe){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Ke=this.sliceSerialize(oe).length;ke.depth=Ke}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function P(oe){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function F(oe){const Ke=this.stack[this.stack.length-1].children;let Ue=Ke[Ke.length-1];(!Ue||Ue.type!=="text")&&(Ue=Fe(),Ue.position={start:Eo(oe.start),end:void 0},Ke.push(Ue)),this.stack.push(Ue)}function $(oe){const ke=this.stack.pop();ke.value+=this.sliceSerialize(oe),ke.position.end=Eo(oe.end)}function D(oe){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ke=ke.children[ke.children.length-1];Ke.position.end=Eo(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(F.call(this,oe),$.call(this,oe))}function z(){this.data.atHardBreak=!0}function O(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function M(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function K(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function H(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ke,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function L(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ke,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function T(oe){const ke=this.sliceSerialize(oe),Ke=this.stack[this.stack.length-2];Ke.label=bV(ke),Ke.identifier=fc(ke).toLowerCase()}function W(){const oe=this.stack[this.stack.length-1],ke=this.resume(),Ke=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ke.type==="link"){const Ue=oe.children;Ke.children=Ue}else Ke.alt=ke}function E(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.url=oe}function Q(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.title=oe}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function se(oe){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=fc(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function ue(oe){this.data.characterReferenceType=oe.type}function G(oe){const ke=this.sliceSerialize(oe),Ke=this.data.characterReferenceType;let Ue;Ke?(Ue=$R(ke,Ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ue=Yk(ke);const be=this.stack[this.stack.length-1];be.value+=Ue}function ee(oe){const ke=this.stack.pop();ke.position.end=Eo(oe.end)}function te(oe){$.call(this,oe);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(oe)}function ne(oe){$.call(this,oe);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(oe)}function Z(){return{type:"blockquote",children:[]}}function ce(){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 $e(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function Be(){return{type:"html",value:""}}function ot(){return{type:"image",title:null,url:"",alt:null}}function yt(){return{type:"link",title:null,url:"",children:[]}}function Te(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function st(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function gt(){return{type:"paragraph",children:[]}}function xe(){return{type:"strong",children:[]}}function Fe(){return{type:"text",value:""}}function lt(){return{type:"thematicBreak"}}}function Eo(e){return{line:e.line,column:e.column,offset:e.offset}}function qR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?qR(e,r):NV(e,r)}}function NV(e,t){let n;for(n in t)if(KR.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 _1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ld({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ld({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ld({start:t.start,end:t.end})+") is still open")}function jV(e){const t=this;t.parser=n;function n(r){return vV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function CV(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 _V(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
70
|
+
`}]}function EV(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 AV(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PV(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IV(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Bc(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 RV(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 TV(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function UR(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 MV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return UR(e,t);const s={src:Bc(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 $V(e,t){const n={src:Bc(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 LV(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 OV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return UR(e,t);const s={href:Bc(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 DV(e,t){const n={href:Bc(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 FV(e,t,n){const r=e.all(t),s=n?zV(n):YR(t),o={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const d=r[l];(s||l!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
|
|
72
|
+
`}),d.type==="element"&&d.tagName==="p"&&!s?a.push(...d.children):a.push(d)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
|
|
73
|
+
`});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function zV(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=YR(n[r])}return t}function YR(e){const t=e.spread;return t??e.children.length>1}function BV(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 HV(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WV(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function VV(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KV(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=Vk(t.children[1]),c=ER(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 qV(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const f=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let y={type:"element",tagName:o,properties:p,children:[]};f&&(y.children=e.all(f),e.patch(f,y),y=e.applyData(f,y)),u.push(y)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function UV(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const E1=9,A1=32;function YV(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(P1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(P1(t.slice(s),s>0,!1)),o.join("")}function P1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===E1||o===A1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===E1||o===A1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function GV(e,t){const n={type:"text",value:YV(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function JV(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const XV={blockquote:CV,break:_V,code:EV,delete:AV,emphasis:PV,footnoteReference:IV,heading:RV,html:TV,imageReference:MV,image:$V,inlineCode:LV,linkReference:OV,link:DV,listItem:FV,list:BV,paragraph:HV,root:WV,strong:VV,table:KV,tableCell:UV,tableRow:qV,text:GV,thematicBreak:JV,toml:_p,yaml:_p,definition:_p,footnoteDefinition:_p};function _p(){}const GR=-1,sg=0,ud=1,em=2,Xk=3,Qk=4,Zk=5,ev=6,JR=7,XR=8,I1=typeof self=="object"?self:globalThis,QV=(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 sg:case GR:return n(a,s);case ud:{const l=n([],s);for(const c of a)l.push(r(c));return l}case em:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case Xk:return n(new Date(a),s);case Qk:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case Zk:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case ev:{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 I1[l](c),s)}case XR: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 I1[o](a),s)};return r},R1=e=>QV(new Map,e)(0),Rl="",{toString:ZV}={},{keys:eK}=Object,Au=e=>{const t=typeof e;if(t!=="object"||!e)return[sg,t];const n=ZV.call(e).slice(8,-1);switch(n){case"Array":return[ud,Rl];case"Object":return[em,Rl];case"Date":return[Xk,Rl];case"RegExp":return[Qk,Rl];case"Map":return[Zk,Rl];case"Set":return[ev,Rl];case"DataView":return[ud,n]}return n.includes("Array")?[ud,n]:n.includes("Error")?[JR,n]:[em,n]},Ep=([e,t])=>e===sg&&(t==="function"||t==="symbol"),tK=(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]=Au(a);switch(l){case sg:{let d=a;switch(c){case"bigint":l=XR,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([GR],a)}return s([l,d],a)}case ud:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const d=[],f=s([l,d],a);for(const p of a)d.push(o(p));return f}case em:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const d=[],f=s([l,d],a);for(const p of eK(a))(e||!Ep(Au(a[p])))&&d.push([o(p),o(a[p])]);return f}case Xk:return s([l,a.toISOString()],a);case Qk:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case Zk:{const d=[],f=s([l,d],a);for(const[p,h]of a)(e||!(Ep(Au(p))||Ep(Au(h))))&&d.push([o(p),o(h)]);return f}case ev:{const d=[],f=s([l,d],a);for(const p of a)(e||!Ep(Au(p)))&&d.push(o(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},T1=(e,{json:t,lossy:n}={})=>{const r=[];return tK(!(t||n),!!t,new Map,r)(e),r},tm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?R1(T1(e,t)):structuredClone(e):(e,t)=>R1(T1(e,t));function nK(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 rK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function sK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||nK,r=e.options.footnoteBackLabel||rK,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),f=String(u.identifier).toUpperCase(),p=Bc(f.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,h);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=d[d.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const k=b.children[b.children.length-1];k&&k.type==="text"?k.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...y)}else d.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...tm(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 QR=function(e){if(e==null)return lK;if(typeof e=="function")return ig(e);if(typeof e=="object")return Array.isArray(e)?iK(e):oK(e);if(typeof e=="string")return aK(e);throw new Error("Expected function, string, or object as test")};function iK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=QR(e[n]);return ig(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function oK(e){const t=e;return ig(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function aK(e){return ig(t);function t(n){return n&&n.type===e}}function ig(e){return t;function t(n,r,s){return!!(cK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function lK(){return!0}function cK(e){return e!==null&&typeof e=="object"&&"type"in e}const ZR=[],uK=!0,M1=!1,dK="skip";function fK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=QR(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=ZR,y,v,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(h=pK(n(c,d)),h[0]===M1))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==dK)for(v=(r?g.children.length:-1)+a,b=d.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===M1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function pK(e){return Array.isArray(e)?e:typeof e=="number"?[uK,e]:e==null?ZR:[e]}function eT(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),fK(e,o,l,s);function l(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return a(c,f,d)}}const Gx={}.hasOwnProperty,hK={};function mK(e,t){const n=t||hK,r=new Map,s=new Map,o=new Map,a={...XV,...n.handlers},l={all:u,applyData:yK,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:gK,wrap:xK};return eT(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:s,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),l;function c(d,f){const p=d.type,h=l.handlers[p];if(Gx.call(l.handlers,p)&&h)return h(l,d,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:v,...b}=d,g=tm(b);return g.children=l.all(d),g}return tm(d)}return(l.options.unknownHandler||wK)(l,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const y=l.one(p[h],d);if(y){if(h&&p[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=$1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=$1(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function gK(e,t){e.position&&(t.position=Z6(e))}function yK(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,tm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function wK(e,t){const n=t.data||{},r="value"in t&&!(Gx.call(n,"hProperties")||Gx.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 xK(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 $1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function L1(e,t){const n=mK(e,t),r=n.one(e,void 0),s=sK(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 bK(e,t){return e&&"run"in e?async function(n,r){const s=L1(n,{file:r,...t});await e.run(s,r)}:function(n,r){return L1(n,{file:r,...e||t})}}function O1(e){if(e)throw e}var fh=Object.prototype.hasOwnProperty,tT=Object.prototype.toString,D1=Object.defineProperty,F1=Object.getOwnPropertyDescriptor,z1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):tT.call(t)==="[object Array]"},B1=function(t){if(!t||tT.call(t)!=="[object Object]")return!1;var n=fh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&fh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||fh.call(t,s)},H1=function(t,n){D1&&n.name==="__proto__"?D1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},W1=function(t,n){if(n==="__proto__")if(fh.call(t,n)){if(F1)return F1(t,n).value}else return;return t[n]},kK=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,u=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=W1(l,n),s=W1(t,n),l!==s&&(d&&s&&(B1(s)||(o=z1(s)))?(o?(o=!1,a=r&&z1(r)?r:[]):a=r&&B1(r)?r:{},H1(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&H1(l,{name:n,newValue:s}));return l};const qy=sa(kK);function Jx(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 vK(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...u){const d=e[++o];let f=-1;if(c){a(c);return}for(;++f<s.length;)(u[f]===null||u[f]===void 0)&&(u[f]=s[f]);s=u,d?SK(d,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function SK(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(u){const d=u;if(l&&n)throw d;return s(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,s):c instanceof Error?s(c):o(c))}function s(a,...l){n||(n=!0,t(a,...l))}function o(a){s(null,a)}}const mi={basename:NK,dirname:jK,extname:CK,join:_K,sep:"/"};function NK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');mf(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else a<0&&(o=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function jK(e){if(mf(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 CK(e){mf(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 _K(...e){let t=-1,n;for(;++t<e.length;)mf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":EK(n)}function EK(e){mf(e);const t=e.codePointAt(0)===47;let n=AK(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function AK(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 mf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const PK={cwd:IK};function IK(){return"/"}function Xx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function RK(e){if(typeof e=="string")e=new URL(e);else if(!Xx(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 TK(e)}function TK(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 Uy=["history","path","basename","stem","extname","dirname"];class nT{constructor(t){let n;t?Xx(t)?n={path:t}:typeof t=="string"||MK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":PK.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Uy.length;){const o=Uy[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)Uy.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?mi.basename(this.path):void 0}set basename(t){Gy(t,"basename"),Yy(t,"basename"),this.path=mi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mi.dirname(this.path):void 0}set dirname(t){V1(this.basename,"dirname"),this.path=mi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mi.extname(this.path):void 0}set extname(t){if(Yy(t,"extname"),V1(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=mi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Xx(t)&&(t=RK(t)),Gy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mi.basename(this.path,this.extname):void 0}set stem(t){Gy(t,"stem"),Yy(t,"stem"),this.path=mi.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 Er(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 Yy(e,t){if(e&&e.includes(mi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mi.sep+"`")}function Gy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function V1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function MK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const $K=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},LK={}.hasOwnProperty;class tv extends $K{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=vK()}copy(){const t=new tv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(qy(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Qy("data",this.frozen),this.namespace[t]=n,this):LK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Qy("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=Ap(t),r=this.parser||this.Parser;return Jy("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Jy("process",this.parser||this.Parser),Xy("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Ap(t),c=r.parse(l);r.run(c,l,function(d,f,p){if(d||!f||!p)return u(d);const h=f,y=r.stringify(h,p);FK(y)?p.value=y:p.result=y,u(d,p)});function u(d,f){d||!f?a(d):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Jy("processSync",this.parser||this.Parser),Xy("processSync",this.compiler||this.Compiler),this.process(t,s),q1("processSync","process",n),r;function s(o,a){n=!0,O1(o),r=a}}run(t,n,r){K1(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=Ap(n);s.run(t,c,u);function u(d,f,p){const h=f||t;d?l(d):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),q1("runSync","run",r),s;function o(a,l){O1(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Ap(n),s=this.compiler||this.Compiler;return Xy("stringify",s),K1(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Qy("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;c(d,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(s.settings=qy(!0,s.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[h,...y]=d;const v=r[p][1];Jx(v)&&Jx(h)&&(h=qy(!0,v,h)),r[p]=[u,h,...y]}}}}const OK=new tv().freeze();function Jy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Xy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Qy(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 K1(e){if(!Jx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function q1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ap(e){return DK(e)?e:new nT(e)}function DK(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function FK(e){return typeof e=="string"||zK(e)}function zK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const BK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",U1=[],Y1={allowDangerousHtml:!0},HK=/^(https?|ircs?|mailto|xmpp)$/i,WK=[{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 rT(e){const t=VK(e),n=KK(e);return qK(t.runSync(t.parse(n),n),e)}function VK(e){const t=e.rehypePlugins||U1,n=e.remarkPlugins||U1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Y1}:Y1;return OK().use(jV).use(n).use(bK,r).use(t)}function KK(e){const t=e.children||"",n=new nT;return typeof t=="string"&&(n.value=t),n}function qK(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||UK;for(const d of WK)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+BK+d.id,void 0);return eT(e,u),s8(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in Wy)if(Object.hasOwn(Wy,h)&&Object.hasOwn(d.properties,h)){const y=d.properties[h],v=Wy[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=c(String(y||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function UK(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||HK.test(e.slice(0,t))?e:""}const YK=new Set(["echarts"]),GK=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),JK=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),XK=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Go(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Xa(e,t){if(!Go(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Go(n[r])&&Go(s)&&(n[r]=Xa(n[r],s));return n}function og(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Go(n)?Xa(n,t):n):Go(e)?Xa(e,t):e}function QK(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 Qx(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)=>Qx(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||JK.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Qx(r,`${t}.${n}`)}}}function ZK(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(!GK.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function e7(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:Xa(e,t)}function t7(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(!Go(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return Xa(o,n)}):Go(e)?Xa(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function n7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:og(e,n)}function G1(e,t="rgba(255, 255, 255, 0.62)"){return og(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 r7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:og(e,n)}function s7(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:og(e,t)}function i7(e,t,n){const r=t7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Go(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??XK,textStyle:Xa(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:e7(e.tooltip),legend:n7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?r7(e.grid,s||o):e.grid,xAxis:G1(e.xAxis),yAxis:G1(e.yAxis),radar:s7(e.radar),series:t}}function o7(e){const t=QK(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(!YK.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");Qx(n);const r=ZK(n.option.series),s=n.title==null?"":String(n.title),o=i7(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 Pp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function a7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function Xi(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!Pp(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==="`"&&!Pp(t,o)){const l=a7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!Pp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&Pp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function sT(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 iT(e){const t=Xi(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function oT(e){return Xi(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function l7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function c7(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 u7({code:e}){const t=m.useMemo(()=>c7(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((d,f)=>{l.set(d.id,{x:28+(n?f*(r+o):f%3*(r+o)),y:28+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(d=>d.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(d=>d.y+s+28));return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-mermaid-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((d,f)=>{const p=l.get(d.from),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:d.label.slice(0,24)})]},d.id)})]})}function d7(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 f7({code:e}){const t=m.useMemo(()=>d7(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,o=26,a=44,l=48,c=Math.max(620,s*2+n.length*r),u=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),d=f=>{const p=Math.max(0,n.findIndex(h=>h.id===f));return s+p*r+r/2};return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-sequence-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((f,p)=>{const h=s+p*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,p)=>{const h=o+a+p*l+24;if(f.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${p}`);const y=d(f.from),v=d(f.to),b=(y+v)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:h,x2:v,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function aT({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(f7,{code:t}):i.jsx(u7,{code:t})})}function p7(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&&l7(l)){o();const u=[];for(;a<t.length;){const d=t[a]||"";if(u.length>0&&(!d.trim()||/^-{3,}\s*$/.test(d)||/^#{1,6}\s+/.test(d)))break;u.push(d),a++}n.push({type:"mermaid",text:u.join(`
|
|
84
|
+
`)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&Xi(l).length>1&&iT(t[a+1])){o();const u=Xi(l),d=oT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Xi(t[a]).length>1;)f.push(sT(Xi(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return o(),n}function J1(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 lT(e){const t=String(e||"").replace(/\r\n/g,`
|
|
85
|
+
`).split(`
|
|
86
|
+
`);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,s+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){s+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){s+=l,o+=1;continue}let d=o;for(;d<r.length&&!/\s|<|>/.test(r[d]);)d+=1;let f=r.slice(o,d),p="";for(;/[.,;:!?)}\]]$/.test(f);)p=f.slice(-1)+p,f=f.slice(0,-1);f?s+=`[${f}](${f})${p}`:s+=r.slice(o,d),o=d}return s}).join(`
|
|
87
|
+
`)}function cT(e,t=!1,n=""){const r=o=>{const a=String(o||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=J1(a,n);return e?e(l,{kind:"link",download:!0}):l},s=(o,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(o.stopPropagation(),!(o.defaultPrevented||o.button!==0)&&(o.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:o})=>i.jsx(i.Fragment,{children:o})}:{},code:({inline:o,className:a,children:l})=>{var d;const c=((d=String(a||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?i.jsx(aT,{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(J1(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 X1({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(rT,{components:cT(t,!0,n),children:lT(e)})}function nv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>p7(e),[e]),s=m.useMemo(()=>cT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(aT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(rT,{components:s,children:lT(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(X1,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((u,d)=>i.jsx("td",{style:{textAlign:o.align[d]||"left"},children:i.jsx(X1,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function h7(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 pi(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 m7(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=>pi(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>pi(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)=>pi(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:pi(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:pi(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>pi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>pi(s[a])):s&&typeof s=="object"?r.map(o=>pi(s[o.key])):r.map((o,a)=>a===0?pi(s):""))}}function g7(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=m7(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&&Xi(s[0]).length>1&&iT(s[1])){const l=Xi(s[0]),c=oT(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>sT(Xi(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=h7(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 rv({content:e}){const t=m.useMemo(()=>g7(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:pi(n[o])},`${s.key}-${o}`))},r))})]})})}function sv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>o7(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:""}),a6(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{o||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||s({loading:!1,error:""}))}).catch(u=>{o||s({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,d;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(d=a==null?void 0:a.dispose)==null||d.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function uT(e){return typeof e>"u"||e===null}function y7(e){return typeof e=="object"&&e!==null}function w7(e){return Array.isArray(e)?e:uT(e)?[]:[e]}function x7(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 b7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function k7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var v7=uT,S7=y7,N7=w7,j7=b7,C7=k7,_7=x7,iv={isNothing:v7,isObject:S7,toArray:N7,repeat:j7,isNegativeZero:C7,extend:_7};function dT(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 Hd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=dT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Hd.prototype=Object.create(Error.prototype);Hd.prototype.constructor=Hd;Hd.prototype.toString=function(t){return this.name+": "+dT(this,t)};var _a=Hd,E7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],A7=["scalar","sequence","mapping"];function P7(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function I7(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(E7.indexOf(n)===-1)throw new _a('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=P7(t.styleAliases||null),A7.indexOf(this.kind)===-1)throw new _a('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var jr=I7;function Q1(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 R7(){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 Zx(e){return this.extend(e)}Zx.prototype.extend=function(t){var n=[],r=[];if(t instanceof jr)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new _a("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof jr))throw new _a("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new _a("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 _a("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof jr))throw new _a("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Zx.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=Q1(s,"implicit"),s.compiledExplicit=Q1(s,"explicit"),s.compiledTypeMap=R7(s.compiledImplicit,s.compiledExplicit),s};var T7=Zx,M7=new jr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),$7=new jr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),L7=new jr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),O7=new T7({explicit:[M7,$7,L7]});function D7(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function F7(){return null}function z7(e){return e===null}var B7=new jr("tag:yaml.org,2002:null",{kind:"scalar",resolve:D7,construct:F7,predicate:z7,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function H7(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 W7(e){return e==="true"||e==="True"||e==="TRUE"}function V7(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var K7=new jr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:H7,construct:W7,predicate:V7,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 q7(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function U7(e){return 48<=e&&e<=55}function Y7(e){return 48<=e&&e<=57}function G7(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(!q7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!U7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!Y7(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function J7(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 X7(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!iv.isNegativeZero(e)}var Q7=new jr("tag:yaml.org,2002:int",{kind:"scalar",resolve:G7,construct:J7,predicate:X7,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"]}}),Z7=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function eq(e){return!(e===null||!Z7.test(e)||e[e.length-1]==="_")}function tq(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 nq=/^[-+]?[0-9]+e/;function rq(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(iv.isNegativeZero(e))return"-0.0";return n=e.toString(10),nq.test(n)?n.replace("e",".e"):n}function sq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||iv.isNegativeZero(e))}var iq=new jr("tag:yaml.org,2002:float",{kind:"scalar",resolve:eq,construct:tq,predicate:sq,represent:rq,defaultStyle:"lowercase"}),oq=O7.extend({implicit:[B7,K7,Q7,iq]}),aq=oq,fT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),pT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function lq(e){return e===null?!1:fT.exec(e)!==null||pT.exec(e)!==null}function cq(e){var t,n,r,s,o,a,l,c=0,u=null,d,f,p;if(t=fT.exec(e),t===null&&(t=pT.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(d=+t[10],f=+(t[11]||0),u=(d*60+f)*6e4,t[9]==="-"&&(u=-u)),p=new Date(Date.UTC(n,r,s,o,a,l,c)),u&&p.setTime(p.getTime()-u),p}function uq(e){return e.toISOString()}var dq=new jr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:lq,construct:cq,instanceOf:Date,represent:uq});function fq(e){return e==="<<"||e===null}var pq=new jr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:fq}),ov=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
94
|
+
\r`;function hq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=ov;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 mq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=ov,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 gq(e){var t="",n=0,r,s,o=e.length,a=ov;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 yq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var wq=new jr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:hq,construct:mq,predicate:yq,represent:gq}),xq=Object.prototype.hasOwnProperty,bq=Object.prototype.toString;function kq(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,bq.call(s)!=="[object Object]")return!1;for(o in s)if(xq.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 vq(e){return e!==null?e:[]}var Sq=new jr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:kq,construct:vq}),Nq=Object.prototype.toString;function jq(e){if(e===null)return!0;var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],Nq.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function Cq(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 _q=new jr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:jq,construct:Cq}),Eq=Object.prototype.hasOwnProperty;function Aq(e){if(e===null)return!0;var t,n=e;for(t in n)if(Eq.call(n,t)&&n[t]!==null)return!1;return!0}function Pq(e){return e!==null?e:{}}var Iq=new jr("tag:yaml.org,2002:set",{kind:"mapping",resolve:Aq,construct:Pq});aq.extend({implicit:[dq,pq],explicit:[wq,Sq,_q,Iq]});function Z1(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 Rq=new Array(256),Tq=new Array(256);for(var Tl=0;Tl<256;Tl++)Rq[Tl]=Z1(Tl)?1:0,Tq[Tl]=Z1(Tl);const Wd=["requirement","planning","code","test","normal"],eC={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function av(e,t){var s,o,a,l,c,u,d,f,p,h,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((s=k==null?void 0:k.data)!=null&&s.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},N=((o=k.data)==null?void 0:o.definitionId)||k.id,j=((a=k.data)==null?void 0:a.inputs)??[],C=((l=k.data)==null?void 0:l.outputs)??[],P=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",I=x.role!=null?String(x.role).trim():"",F=eC[P]||P,$=eC[I]||I,D=Wd.includes(F)?F:Wd.includes($)?$:"normal",z=Array.isArray(j)?j.map(n):Array.isArray(x.input)?x.input.map(ue=>n(ue)):[],O=Array.isArray(C)?C.map(n):Array.isArray(x.output)?x.output.map(ue=>n(ue)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,K=(d=k.data)==null?void 0:d.body,H=K!=null?String(K):x.body!=null?String(x.body):"";let L=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(L===""||L==="default")&&(L=void 0);const T={...x,definitionId:N,label:M,role:D,model:L,input:z,output:O},W=((p=k.data)==null?void 0:p.marketplaceRef)||x.marketplaceRef;W?T.marketplaceRef=String(W):delete T.marketplaceRef;const E=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;E?T.marketplacePackageId=String(E):delete T.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;Q?T.marketplaceVersion=String(Q):delete T.marketplaceVersion,N.startsWith("provide_")||H.trim()===""?delete T.body:T.body=H;const V=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];V.length>0?T.images=V:delete T.images;const B=(b=k.data)==null?void 0:b.script,se=B!=null?String(B):x.script!=null?String(x.script):"";se.trim()===""?delete T.script:T.script=se;for(const ue of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[ue],ee=G!=null?String(G):x[ue]!=null?String(x[ue]):"";ee.trim()===""?delete T[ue]:T[ue]=ee.trim()}delete T.temperature,delete T.maxTokens,delete T.description,r[k.id]=T}return r}function dd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Mq(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 $q(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=>dd(a)),edges:o.map(a=>dd(a)),instances:av(r,n||{})}}function Lq(e,t,n,r,s={}){var f;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=s.offset||{x:48,y:48},a=new Set((t||[]).map(p=>p.id)),l=new Map;for(const p of e.nodes)l.set(p.id,Mq(p.id,a));const c=e.nodes.map(p=>{var y,v;const h=l.get(p.id);return{...dd(p),id:h,selected:!0,dragging:!1,position:{x:Number(((y=p.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=p.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,h)=>{const y=l.get(p.source),v=l.get(p.target);return{...dd(p),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),d={...r||{}};for(const[p,h]of l.entries()){const y=(f=e.instances)==null?void 0:f[p];y&&(d[h]={...dd(y),label:y.label!=null?String(y.label):h})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...u],instances:d,pastedNodeIds:c.map(p=>p.id)}}function Tn(e){switch(nm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function nm(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 Oq(e,t){const n=nm(e),r=nm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const Dq=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function eb(e){const t=nm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&Dq.has(n)?`${t}+${n}`:t}function Fq(e){return eb(e)}function Vd(e,t){if(!e||!t||!Oq(e.type,t.type))return!1;const n=eb(e),r=eb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function zq(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 tb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=zq(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 rm=/\[image\s+(\d+)\]/gi;function po(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 Bq(e){return`image ${po(e).length+1}`}function Hq(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function Wq(e,t){const n=po(e),r=String(t||""),s=new Set;rm.lastIndex=0;let o;for(;o=rm.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function Vq(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 hT(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 fd(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 mT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=po(n);for(const a of r){const l=await Vq(a),c=Bq(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=Hq(s,c)}return{body:s,images:o}}function vs(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Kq(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 qq(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function en(e){e.stopPropagation()}function Uq(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yq(e,t){const n=`\\[${Uq(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
|
|
96
|
+
`).replace(/\n{3,}/g,`
|
|
97
|
+
|
|
98
|
+
`).trimEnd()}function Zy(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Gq(e){const t=String(e||"");let n="",r=0;rm.lastIndex=0;let s;for(;s=rm.exec(t);)n+=Zy(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Zy(s[0])}</span>`,r=s.index+s[0].length;return n+=Zy(t.slice(r)),n||" "}function Jq(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 Xq({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:d=!1}){var Gt,_t;const{t:f}=Fr(),p=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=Kq(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,N=(e==null?void 0:e.nodeStatus)??null,j=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",P=C.startsWith("provide_"),I=C==="provide_bool",F=C==="provide_str",$=C==="provide_file",D=C==="provide_password",z=C==="agent_subAgent",O=C==="control_agent_toBool",M=(z||O)&&!b,K=I?qq(h[0]):!1,H=P?String(((Gt=h[0])==null?void 0:Gt.value)??((_t=h[0])==null?void 0:_t.default)??(e==null?void 0:e.body)??""):"",L=String((e==null?void 0:e.body)||""),T=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),W=!P&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",E=po(e==null?void 0:e.images),Q=I||F||$||D||M||!!W,V=m.useRef(!1),B=m.useRef(!1),se=m.useRef(null),ue=m.useRef(null),G=m.useRef(null),ee=m.useRef(null),te=m.useRef(null),[ne,Z]=m.useState(H),[ce,de]=m.useState(!1),[me,$e]=m.useState(L),[Ce,_e]=m.useState(!1),[Be,ot]=m.useState({visible:!1,top:0,height:100}),[yt,Te]=m.useState(!1),st=m.useCallback(()=>{const le=ue.current;if(!le)return;const ve=Math.max(1,le.scrollHeight),it=Math.max(1,le.clientHeight),Dt=ve>it+1,Jt=Dt?Math.max(12,it/ve*100):100,tn=Math.max(0,100-Jt),Zn=Dt?Math.min(tn,le.scrollTop/Math.max(1,ve-it)*tn):0;ot({visible:Dt,top:Zn,height:Jt})},[]);m.useEffect(()=>{V.current||Z(H)},[n,H]),m.useEffect(()=>{B.current||$e(L)},[n,L]),m.useEffect(()=>{const le=ue.current;if(!le)return;if(M){le.style.minHeight="",le.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const ve=Jq(le,me);le.style.minHeight=`${ve}px`,le.style.height="",G.current&&(G.current.style.minHeight=`${ve}px`,G.current.style.height="")},[me,M]),m.useEffect(()=>{if(!M)return;const le=window.requestAnimationFrame(st),ve=ue.current;if(!ve||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(le);const it=new ResizeObserver(st);return it.observe(ve),()=>{window.cancelAnimationFrame(le),it.disconnect()}},[me,M,st]),m.useEffect(()=>{const le=se.current,ve=e==null?void 0:e.onNodeContentResize;if(!M||!le||!ve||typeof ResizeObserver>"u")return;let it=0;const Dt=()=>{window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>ve(n))},Jt=new ResizeObserver(Dt);return Jt.observe(le),Dt(),()=>{window.cancelAnimationFrame(it),Jt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!yt)return;const le=window.setTimeout(()=>{const ve=te.current;if(!ve)return;ve.focus();const it=ve.value.length;ve.setSelectionRange(it,it)},0);return()=>window.clearTimeout(le)},[yt]);const gt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],xe=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],Fe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],lt=Array.isArray(c==null?void 0:c.codex)?c.codex:[],oe=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!C.startsWith("tool_nodejs"),Ke=new Set(gt.map(vs)),Ue=new Set(xe.map(vs)),be=new Set(Fe.map(vs)),Ht=new Set(lt.map(vs)),Qt=oe?oe.startsWith("cursor:")||oe.startsWith("opencode:")||oe.startsWith("codex:")||oe.startsWith("claude-code:")?oe:be.has(oe)?`claude-code:${oe}`:Ht.has(oe)?`codex:${oe}`:Ue.has(oe)?`opencode:${oe}`:Ke.has(oe)?`cursor:${oe}`:oe:"",jt=oe&&!Qt.startsWith("cursor:")&&!Qt.startsWith("opencode:")&&!Qt.startsWith("codex:")&&!Qt.startsWith("claude-code:")&&!Ke.has(oe)&&!Ue.has(oe)&&!be.has(oe)&&!Ht.has(oe),yn=oe.startsWith("cursor:")?oe.slice(7):oe.startsWith("opencode:")?oe.slice(9):oe.startsWith("codex:")?oe.slice(6):oe.startsWith("claude-code:")?oe.slice(12):oe,on=le=>{if(g)return;const ve=le.target.value;u&&u(n,ve)},re=le=>{le.stopPropagation(),!g&&r&&r(n)},Re=le=>{le.stopPropagation(),s&&s()},Je=le=>{le.stopPropagation(),!g&&(o==null||o(n,le.target.value==="true"?"true":"false"))},Ze=le=>{if(le.stopPropagation(),g)return;const ve=le.target.value;Z(ve),!d&&!V.current&&(o==null||o(n,ve))},Tt=le=>{le.stopPropagation(),V.current=!0},At=le=>{if(le.stopPropagation(),g)return;V.current=!1;const ve=le.currentTarget.value;Z(ve),d||o==null||o(n,ve)},Vn=()=>{g||d&&ne===H||o==null||o(n,ne)},Sn=le=>{if(le.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ne);return}const ve=window.prompt("文件路径",ne);ve!=null&&(Z(ve),o==null||o(n,ve))},xr=le=>{le.stopPropagation(),de(ve=>!ve)},wn=le=>{if($e(le),a==null||a(n,le),l){const ve=Wq(E,le);(ve.length!==E.length||ve.some((it,Dt)=>{var Jt;return it.id!==((Jt=E[Dt])==null?void 0:Jt.id)}))&&l(n,ve)}},Xn=le=>{if(le.stopPropagation(),g)return;const ve=le.target.value;d||B.current?$e(ve):wn(ve)},Kn=le=>{le.stopPropagation(),!g&&(B.current=!0,_e(!0))},hr=le=>{if(le.stopPropagation(),g)return;B.current=!1,_e(!1);const ve=le.currentTarget.value;d?$e(ve):wn(ve)},ts=()=>{g||(B.current=!1,_e(!1),!(d&&me===L)&&wn(me))},Ar=le=>{le.stopPropagation(),le.preventDefault(),!g&&Te(!0)},gs=()=>{Te(!1),ts()},ys=le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),gs())},cn=m.useCallback(le=>{const ve=ue.current;if(!ve)return;const it=Math.max(0,ve.scrollHeight-ve.clientHeight);ve.scrollTop=Math.min(1,Math.max(0,le))*it,st()},[st]),rr=m.useCallback((le,ve=0)=>{const it=ee.current;if(!it)return 0;const Dt=it.getBoundingClientRect(),Jt=Be.height/100*Dt.height,tn=Math.max(1,Dt.height-Jt);return(le-Dt.top-ve)/tn},[Be.height]),Pr=m.useCallback(le=>{var kr,tt;if(!Be.visible)return;le.preventDefault(),le.stopPropagation();const ve=ee.current;if(!ve)return;const it=ve.getBoundingClientRect(),Dt=Be.top/100*it.height,Jt=Be.height/100*it.height,Zn=le.clientY>=it.top+Dt&&le.clientY<=it.top+Dt+Jt?le.clientY-it.top-Dt:Jt/2;cn(rr(le.clientY,Zn));const mt=le.pointerId;(tt=(kr=le.currentTarget).setPointerCapture)==null||tt.call(kr,mt);const nn=Ln=>{Ln.preventDefault(),cn(rr(Ln.clientY,Zn))},Wt=()=>{window.removeEventListener("pointermove",nn),window.removeEventListener("pointerup",Wt),window.removeEventListener("pointercancel",Wt)};window.addEventListener("pointermove",nn),window.addEventListener("pointerup",Wt),window.addEventListener("pointercancel",Wt)},[rr,Be.height,Be.top,Be.visible,cn]),dn=async le=>{if(g)return;const ve=await mT({files:le,body:me,images:E});ve&&($e(ve.body),a==null||a(n,ve.body),l==null||l(n,ve.images))},Qn=(le,ve)=>{if(le.stopPropagation(),g)return;const it=E.filter(Jt=>Jt.id!==ve.id),Dt=Yq(me,ve.label);$e(Dt),a==null||a(n,Dt),l==null||l(n,it)},br=le=>{if(g)return;const ve=hT(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),dn(ve).catch(()=>{}))},sr=le=>{if(g)return;const ve=fd(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),dn(ve).catch(()=>{}))},Ct=()=>{const le=ue.current,ve=G.current;!le||!ve||(ve.scrollTop=le.scrollTop,ve.scrollLeft=le.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(N==="success"?" af-flow-node--done":"")+(N==="failed"?" af-flow-node--failed":"")+(N==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(F?" 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:`${T}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:T}),!b&&ke&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:en,onMouseDown:en,onClick:en,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:Qt,onChange:on,onPointerDown:en,onMouseDown:en,onClick:en,"aria-label":f("flow:node.model"),title:yn||f("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),jt&&i.jsx("option",{value:oe,children:oe}),gt.length>0&&i.jsx("optgroup",{label:"Cursor",children:gt.map(le=>i.jsx("option",{value:`cursor:${vs(le)}`,children:vs(le)},`c-${le}`))}),xe.length>0&&i.jsx("optgroup",{label:"OpenCode",children:xe.map(le=>i.jsx("option",{value:`opencode:${vs(le)}`,children:vs(le)},`o-${le}`))}),lt.length>0&&i.jsx("optgroup",{label:"Codex",children:lt.map(le=>i.jsx("option",{value:`codex:${vs(le)}`,children:vs(le)},`codex-${le}`))}),Fe.length>0&&i.jsx("optgroup",{label:"Claude Code",children:Fe.map(le=>i.jsx("option",{value:`claude-code:${vs(le)}`,children:vs(le)},`cc-${le}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),N==="running"&&!k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),N==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:j!=null&&String(j).trim()!==""?j:"--"}),N==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&P&&!I&&!F&&!$&&!D&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Re,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:re,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:p.map((le,ve)=>{if(le.showOnNode===!1)return null;const it=f("flow:node.inputTooltip",{name:le.name||`#${ve}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),Dt=le.name||`#${ve+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Dt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${ve}`,className:"af-flow-node__handle",style:{background:Tn(le.type)},title:it})]},`in-${ve}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[I?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(K?" af-flow-node__bool-select--true":""),value:K?"true":"false",onChange:Je,onPointerDown:en,onMouseDown:en,onClick:en,"aria-label":"Boolean value",title:K?"true":"false",disabled:g,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):F?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:At,onBlur:Vn,onPointerDown:en,onMouseDown:en,onClick:en,placeholder:"输入文本",rows:2,readOnly:g}):$?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:en,onMouseDown:en,onClick:en,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:At,onBlur:Vn,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:Sn,"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:en,onMouseDown:en,onClick:en,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ce?"text":"password",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:At,onBlur:Vn,placeholder:"输入密码或密钥",title:ce?ne:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:xr,"aria-label":ce?"隐藏密码":"预览密码",title:ce?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ce?"visibility_off":"visibility"})})]}):M?i.jsxs("div",{ref:se,className:"af-flow-node__prompt-stack nodrag"+(Ce?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:Gq(me)+`
|
|
99
|
+
`}}),i.jsx("textarea",{ref:ue,className:"af-flow-node__prompt-editor nodrag",value:me,onChange:Xn,onCompositionStart:Kn,onCompositionEnd:hr,onBlur:ts,onPaste:br,onDrop:sr,onScroll:le=>{Ct(),st()},onPointerDown:en,onMouseDown:en,onClick:en,onKeyDown:en,onDragOver:le=>{fd(le).length>0&&le.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:en,onMouseDown:en,onClick:Ar,"aria-label":"放大编辑",title:"放大编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsx("div",{ref:ee,className:"af-flow-node__prompt-scrollbar"+(Be.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:Pr,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${Be.height}%`,top:`${Be.top}%`}})})]}):null,M&&E.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:E.map((le,ve)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:le.name,children:[i.jsx("img",{src:le.dataUrl,alt:""}),i.jsxs("span",{children:["[",le.label||`image ${ve+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:it=>Qn(it,le),onPointerDown:en,onMouseDown:en,"aria-label":`删除 ${le.label||`image ${ve+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},le.id||ve))}):null,W?i.jsx("span",{className:"af-flow-node__prompt-preview",title:W,children:W}):null,Q?null:i.jsx("span",{className:"af-flow-node__body-title",title:T,children:T})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:h.map((le,ve)=>{if(le.showOnNode===!1)return null;const it=f("flow:node.outputTooltip",{name:le.name||`#${ve}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),Dt=le.name||`#${ve+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Dt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${ve}`,className:"af-flow-node__handle",style:{background:Tn(le.type)},title:it})]},`out-${ve}`)})})]}),yt?cr.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:en,onMouseDown:en,onClick:en,onWheel:en,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:T}),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:gs,"aria-label":"关闭",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("textarea",{ref:te,className:"af-flow-node-full-editor__textarea",value:me,onChange:Xn,onCompositionStart:Kn,onCompositionEnd:hr,onPaste:br,onDrop:sr,onKeyDown:ys,onDragOver:le=>{fd(le).length>0&&le.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const pc="flowNode";function nb(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 Qq={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 Zq(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(Qq[e]||[]).includes(s)?r:s}const eU={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),control_load_mcp:new Set(["workspaceContext","mcpContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext","mcpContext"])},tU={control_cd_workspace:new Set(["mode","label","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"])},nU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},rU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function sU(e,t){if(!rU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function iU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function oU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function gT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function aU(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 lU(e){const t=String(e??"").trim();return t?t.includes("${")?t:gT(t):""}function cU(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(lU).filter(Boolean):[];return[aU(t,n),gT(s),...o].join(" ")}return String(t.command||"").trim()}function tC(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,d,f;const o=n[s],l=n.find(p=>(p==null?void 0:p.name)&&p.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=eU[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&&sU(e,r)?{showOnNode:!0}:{},...(d=nU[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=tU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function uU(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=nb(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 rb(e,t,n,r,s){var T,W,E,Q,V,B,se,ue,G,ee,te,ne,Z,ce,de,me,$e,Ce,_e,Be,ot,yt;const o=((T=e.data)==null?void 0:T.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Te=>Te.id===o),l=t[e.id];let c=[],u=[],d=((W=e.data)==null?void 0:W.label)??e.id,f,p,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(nb)),Array.isArray(l.output)&&(u=l.output.map(nb)),l.label&&(d=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=f??(typeof((E=e.data)==null?void 0:E.role)=="string"?e.data.role:"普通"),k=p??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",N=x!==""?x:void 0,j=h??((V=e.data)==null?void 0:V.body)??"",C=Array.isArray(y)?y:Array.isArray((B=e.data)==null?void 0:B.images)?e.data.images:[],P=cU(a),I=v!==void 0?v:((se=e.data)==null?void 0:se.script)!=null?String(e.data.script):P,F=String(e.id),$=(ue=r==null?void 0:r[s])==null?void 0:ue[F],D=(G=$==null?void 0:$.label)==null?void 0:G.label,z=$==null?void 0:$.body,O=$==null?void 0:$.description;b||(c.length===0&&((ee=a==null?void 0:a.inputs)!=null&&ee.length)&&(c=a.inputs.map(Te=>({...Te}))),u.length===0&&((te=a==null?void 0:a.outputs)!=null&&te.length)&&(u=a.outputs.map(Te=>({...Te}))));const M=oU(a,(a==null?void 0:a.id)??o),K=(l==null?void 0:l.marketplaceRef)||((ne=e.data)==null?void 0:ne.marketplaceRef)||iU(a);if(M==="agent_subAgent"&&!u.some(Te=>(Te==null?void 0:Te.name)==="result")){const Te=(Z=a==null?void 0:a.outputs)==null?void 0:Z.find(st=>(st==null?void 0:st.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=(ce=a==null?void 0:a.inputs)==null?void 0:ce.find(st=>(st==null?void 0:st.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(st=>(st==null?void 0:st.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(st=>(st==null?void 0:st.name)==="prev");c=[Te?{...Te}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Te=>(Te==null?void 0:Te.name)==="next")){const Te=($e=a==null?void 0:a.outputs)==null?void 0:$e.find(st=>(st==null?void 0:st.name)==="next");u=[...u,Te?{...Te}:{type:"node",name:"next",default:""}]}}c=tC(M,c,a==null?void 0:a.inputs),u=tC(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(j).trim()!==""&&(u=u.map((Te,st)=>st===0?{...Te,default:j,value:j}:Te));const H=Zq(M,d,a),L=M==="tool_nodejs"||String(I).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:D||d,displayLabel:H,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...K?{marketplaceRef:K}:{},...l!=null&&l.marketplacePackageId||(Ce=e.data)!=null&&Ce.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||(Be=e.data)!=null&&Be.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((ot=e.data)==null?void 0:ot.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((yt=e.data)==null?void 0:yt.schemaType)??e.type??"agent",role:g,model:k,body:z||j,images:C,script:I,inputs:c,outputs:u,description:O||N,originalLabel:d,originalBody:j,...L?{script:I}:{}}}}function dU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var d,f,p,h;const s=n.get(r.source),o=n.get(r.target),a=((f=(d=s==null?void 0:s.data)==null?void 0:d.outputs)==null?void 0:f.length)??0,l=((h=(p=o==null?void 0:o.data)==null?void 0:p.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&c>=0&&c<a&&u>=0&&u<l})}function nC(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 rC(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function ew(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=nC(t==null?void 0:t.sourceHandle,"output"),o=nC(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,d,f,p;if(c.id===n){const h=rC((u=c.data)==null?void 0:u.outputs,s);if(h!==((d=c.data)==null?void 0:d.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=rC((f=c.data)==null?void 0:f.inputs,o);if(h!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function fU(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 sC(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function pU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function hU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Ws({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(hU,{children:t})]},n))})}function mU({open:e,onClose:t}){const{t:n}=Fr(),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=pU()?"⌘":"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(Ws,{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(Ws,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function gU(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 yU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Fr(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const f=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,N;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((N=g.data)==null?void 0:N.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:gU(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const y=(v=d.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=y=>{const v=f[y];v&&(n(v.id),t())},h=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),p(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-jump-panel__input-wrap",children:[i.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:u,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:y=>{a(y.target.value),c(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:d,className:"af-jump-panel__list",role:"listbox",children:f.map((y,v)=>i.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:b=>{b.preventDefault(),p(v)},children:[i.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&i.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.id))}),i.jsxs("div",{className:"af-jump-panel__hint",children:[i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"↑"}),i.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function iC(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=s=>String(s).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function wU(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),s=n%60;return`${r}m${String(s).padStart(2,"0")}s`}function oC(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 tw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function aC(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 xU({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(null),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),N=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const I=new URLSearchParams;I.set("flowId",e.flowId),I.set("flowSource",e.flowSource||"user"),t?I.set("scheduleNodeId",t):n&&I.set("runNodeId",n),I.set("limit","80");const F=await fetch(`/api/workspace/run-logs?${I.toString()}`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error($.error||"读取日志失败");const D=Array.isArray($.runs)?$.runs:[];l(D),u(z=>{const O=D[0]||null;return O&&String(O.status||"")==="running"&&O.runId!==z?O.runId:z&&D.some(M=>M.runId===z)?z:r&&D.some(M=>M.runId===r)?r:(O==null?void 0:O.runId)||""})}catch(I){g(String(I.message||I)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),j=m.useCallback(async I=>{if(!I){f(null);return}v(!0);try{const F=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&F.set("archived","1");const $=await fetch(`/api/workspace/run-logs/${encodeURIComponent(I)}?${F.toString()}`),D=await $.json().catch(()=>({}));if(!$.ok)throw new Error(D.error||"读取日志详情失败");f(D)}catch(F){f({error:String(F.message||F),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{N()},[N]),m.useEffect(()=>{j(c)},[j,c]),m.useEffect(()=>{const I=a.find($=>$.runId===c),F=window.setInterval(()=>{N(),(!I||I.status==="running")&&c&&j(c)},2e3);return()=>window.clearInterval(F)},[j,N,a,c]);const C=m.useMemo(()=>{const I=Array.isArray(d==null?void 0:d.events)?d.events:[],F=k.trim().toLowerCase();return F?I.filter($=>String($.type||"").toLowerCase().includes(F)||tw($).toLowerCase().includes(F)||oC($).toLowerCase().includes(F)):I},[d==null?void 0:d.events,k]),P=(d==null?void 0:d.run)||a.find(I=>I.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 N(),title:"刷新日志","aria-label":"刷新日志",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?i.jsx("div",{className:"af-work-run-logs__error",children:b}):null,i.jsxs("div",{className:"af-work-run-logs__body",children:[i.jsxs("div",{className:"af-work-run-logs__list",children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),p?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!p&&a.length===0?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(I=>i.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(I.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(I.runId),title:I.runId,children:[i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${aC(I.status)}`,children:I.status||"unknown"}),i.jsx("span",{className:"af-work-run-logs__run-label",children:I.label||I.runNodeId||I.scheduleNodeId||"Workspace Run"}),i.jsx("span",{children:iC(I.startedAt)}),i.jsx("span",{children:wU(I.durationMs)})]},I.runId))]}),i.jsxs("div",{className:"af-work-run-logs__detail",children:[i.jsxs("div",{className:"af-work-run-logs__detail-head",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),P!=null&&P.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:P.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(P==null?void 0:P.runId)||"-"})]}),P?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${aC(P.status)}`,children:P.status}):null]}),i.jsxs("label",{className:"af-work-run-logs__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:k,onChange:I=>x(I.target.value),placeholder:"搜索事件、节点、错误"})]}),y?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,d!=null&&d.error?i.jsx("div",{className:"af-work-run-logs__error",children:d.error}):null,!y&&!C.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:C.map((I,F)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:iC(I.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:I.type||"event"}),tw(I)?i.jsx("span",{className:"af-work-run-logs__event-node",children:tw(I)}):null,i.jsx("pre",{children:oC(I)})]},`${I.ts||F}-${F}`))})]})]})]})}function bU(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 yT(e){const t=bU(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 kU(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 vU(e){return String(e).replace(/<\/script/gi,"<\\/script")}function ag(e){const t=yT(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 lv(e,t=""){const n=yT(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(p=>/(?:^|\/)App\.[jt]sx$/i.test(p))||Object.keys(r).find(p=>/\.[jt]sx?$/i.test(p))||n.entry,o=kU(r[s]||""),a=Object.entries(r).filter(([p])=>/\.css$/i.test(p)).map(([,p])=>String(p||"")).join(`
|
|
101
|
+
|
|
102
|
+
`),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),d=vU(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
|
|
103
|
+
* { box-sizing: border-box; }
|
|
104
|
+
body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
105
|
+
main { min-height: 100vh; padding: 24px; }
|
|
106
|
+
button, input, select, textarea { font: inherit; }
|
|
107
|
+
`;return`<!doctype html>
|
|
108
|
+
<html>
|
|
109
|
+
<head>
|
|
110
|
+
<meta charset="utf-8" />
|
|
111
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
112
|
+
<base target="_blank" />
|
|
113
|
+
<title>${l.replace(/[<&>]/g,p=>({"<":"<",">":">","&":"&"})[p])}</title>
|
|
114
|
+
<style>${f.replace(/<\/style/gi,"<\\/style")}</style>
|
|
115
|
+
</head>
|
|
116
|
+
<body>
|
|
117
|
+
<div id="root"></div>
|
|
118
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
|
|
119
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
|
|
120
|
+
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
|
|
121
|
+
<script>
|
|
122
|
+
window.AGENTFLOW_INPUTS = ${u};
|
|
123
|
+
window.addEventListener("error", (event) => {
|
|
124
|
+
const root = document.getElementById("root");
|
|
125
|
+
if (root && !root.__agentflowRendered) {
|
|
126
|
+
root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'<','>':'>','&':'&'}[ch])) + '</pre>';
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
document.addEventListener("click", (event) => {
|
|
130
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
131
|
+
if (!link) return;
|
|
132
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
133
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
134
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
140
|
+
}, true);
|
|
141
|
+
<\/script>
|
|
142
|
+
<script type="text/babel">
|
|
143
|
+
const { useCallback, useEffect, useMemo, useRef, useState } = React;
|
|
144
|
+
${d}
|
|
145
|
+
const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
|
|
146
|
+
return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
|
|
147
|
+
});
|
|
148
|
+
ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
|
|
149
|
+
document.getElementById("root").__agentflowRendered = true;
|
|
150
|
+
<\/script>
|
|
151
|
+
<script>
|
|
152
|
+
(() => {
|
|
153
|
+
const frameId = ${c};
|
|
154
|
+
const postSize = () => {
|
|
155
|
+
const doc = document.documentElement;
|
|
156
|
+
const body = document.body;
|
|
157
|
+
const height = Math.ceil(Math.max(
|
|
158
|
+
doc ? doc.scrollHeight : 0,
|
|
159
|
+
doc ? doc.offsetHeight : 0,
|
|
160
|
+
doc ? doc.clientHeight : 0,
|
|
161
|
+
body ? body.scrollHeight : 0,
|
|
162
|
+
body ? body.offsetHeight : 0,
|
|
163
|
+
body ? body.clientHeight : 0,
|
|
164
|
+
window.innerHeight || 0
|
|
165
|
+
));
|
|
166
|
+
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
167
|
+
};
|
|
168
|
+
window.addEventListener("load", postSize);
|
|
169
|
+
window.addEventListener("resize", postSize);
|
|
170
|
+
requestAnimationFrame(postSize);
|
|
171
|
+
setTimeout(postSize, 300);
|
|
172
|
+
setTimeout(postSize, 1000);
|
|
173
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
174
|
+
const resizeObserver = new ResizeObserver(postSize);
|
|
175
|
+
resizeObserver.observe(document.documentElement);
|
|
176
|
+
if (document.body) resizeObserver.observe(document.body);
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
<\/script>
|
|
180
|
+
</body>
|
|
181
|
+
</html>`}const wT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),SU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function NU(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function jU(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function lC(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 xT(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(wT.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function bT(e){return{inputNames:lC(e==null?void 0:e.inputs),outputNames:lC(e==null?void 0:e.outputs)}}function CU(e,t,n){const r=bT(t),s=jU(e),o=[];for(const a of s)if(!xT(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 _U(e,t){const n=bT(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=xT(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 EU(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function AU(e){return e.map(t=>{const n=EU(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 PU(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 SU)wT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function IU(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 RU(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 Ip({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:d}=Fr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),N=m.useMemo(()=>po(c),[c]),j=m.useMemo(()=>CU(e,a,d),[e,a,d]),C=j.length>0,P=m.useMemo(()=>_U(e,a),[e,a]),I=m.useMemo(()=>AU(P),[P]),F=m.useMemo(()=>n?null:NU(e,y),[e,y,n]),$=m.useMemo(()=>{if(!F)return[];const H=PU(a,d);return IU(H,F.query)},[F,a,d]);m.useEffect(()=>{g(H=>{const L=Math.max(0,$.length-1);return Math.min(Math.max(0,H),L)})},[$.length]);const D=m.useCallback(()=>{const H=p.current;if(!H||!F||$.length===0){x(null);return}const L=RU(H,y);if(!L){x(null);return}const T=4,W=44,E=13.5*16,Q=Math.min($.length*W+8,E);let V=L.bottom+T;V+Q>window.innerHeight-8&&(V=Math.max(8,L.top-Q-T));const B=288;let se=L.left;se=Math.max(8,Math.min(se,window.innerWidth-B-8)),x({top:V,left:se})},[F,$.length,y]);m.useLayoutEffect(()=>{if(!F||$.length===0){x(null);return}const H=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(H)},[F,$.length,y,e,D]),m.useEffect(()=>{if(!F||$.length===0)return;const H=()=>D();return window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[F,$.length,D]);const z=m.useCallback(H=>{if(!F)return;const{atIndex:L}=F,T=e.slice(0,L)+"${"+H+"}"+e.slice(y);t(T);const W=L+H.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),v(W)})},[F,e,y,t]),O=m.useCallback(()=>{const H=p.current,L=h.current;!H||!L||(L.scrollTop=H.scrollTop,L.scrollLeft=H.scrollLeft,F&&$.length>0&&queueMicrotask(()=>D()))},[F,$.length,D]),M=m.useCallback(H=>{if(!n&&F&&$.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="Enter")){if(H.key==="ArrowDown")H.preventDefault(),g(L=>(L+1)%$.length);else if(H.key==="ArrowUp")H.preventDefault(),g(L=>(L-1+$.length)%$.length);else if(H.key==="Enter"&&!H.shiftKey){H.preventDefault();const L=$[b];L&&z(L.insert)}}},[n,F,$,b,z]),K=m.useCallback(async H=>{if(n||typeof u!="function")return!1;const L=await mT({files:H,body:e,images:N});return L?(t(L.body),u(L.images),queueMicrotask(()=>{const T=p.current;if(!T)return;T.focus();const W=L.body.length;T.setSelectionRange(W,W),v(W)}),!0):!1},[n,N,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[N.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:N.map((H,L)=>i.jsxs("span",{className:"af-body-image-chip",title:H.name,children:[i.jsx("img",{src:H.dataUrl,alt:""}),i.jsxs("span",{children:["[",H.label||`image ${L+1}`,"]"]})]},H.id||L))}):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:I+`
|
|
182
|
+
`}}),i.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?f:void 0,onChange:H=>{t(H.target.value),v(H.target.selectionStart??H.target.value.length)},onSelect:H=>{const L=H.target;L instanceof HTMLTextAreaElement&&v(L.selectionStart??0)},onClick:H=>{const L=H.target;L instanceof HTMLTextAreaElement&&v(L.selectionStart??0)},onKeyUp:H=>{const L=H.target;L instanceof HTMLTextAreaElement&&v(L.selectionStart??L.value.length)},onKeyDown:M,onPaste:H=>{const L=hT(H);L.length!==0&&(H.preventDefault(),K(L).catch(()=>{}))},onDragOver:H=>{fd(H).length>0&&H.preventDefault()},onDrop:H=>{const L=fd(H);L.length!==0&&(H.preventDefault(),K(L).catch(()=>{}))},onScroll:O})]}),F&&$.length>0&&k?cr.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":d("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:$.map((H,L)=>i.jsx("li",{role:"option","aria-selected":L===b,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(L===b?" af-composer-mention-item--active":""),onMouseDown:T=>T.preventDefault(),onMouseEnter:()=>g(L),onClick:()=>z(H.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${H.insert}}`}),H.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:H.subtitle}):null]})},`${H.section}-${H.insert}`))}),document.body):null,C?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:j.map(H=>H.message).join(" · ")}):null]})}const TU=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Pu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function cC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Fr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),u=(f,p,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[p]:h};return p==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},d=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:d})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((f,p)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${d}-${p}`,children:[d,"-",p]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(p,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:p})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{o||u(p,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>u(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${d}-${p}`))]}):null]})}function MU({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:d,ioSlots:f}){const{t:p}=Fr(),[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:N,opencodeList:j,claudeCodeList:C,codexList:P,currentNotInLists:I}=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:[],K=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],H=Array.isArray(s==null?void 0:s.codex)?s.codex:[],L=new Set([...O,...M,...K,...H].map(Pu)),T=((e==null?void 0:e.model)??"").trim(),W=T.startsWith("cursor:")?T.slice(7):T.startsWith("opencode:")?T.slice(9):T.startsWith("codex:")?T.slice(6):T.startsWith("claude-code:")?T.slice(12):T,E=T&&!L.has(W)?T:"";return{cursorList:O,opencodeList:M,claudeCodeList:K,codexList:H,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const F=String(e.script??""),$=n==="tool_nodejs"||F.trim()!=="",D=typeof c=="function"&&!o&&(e==null?void 0:e.newId),z=async()=>{if(D){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):p("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:p("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:z,disabled:!D||g.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[d?i.jsx("p",{className:"af-err af-node-props-err",children:d}):null,g.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>x({newId:O.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange: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:[p("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Wd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>x({role:O.target.value}),disabled:o,children:Wd.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:[p("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?I||O:""})(),onChange:O=>x({model:O.target.value}),disabled:o,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),I?i.jsxs("option",{value:I,children:[I,p("flow:nodeProps.yamlValueNotInList")]}):null,N.length>0?i.jsx("optgroup",{label:"Cursor",children:N.map(O=>i.jsx("option",{value:Pu(O),children:O},`c-${O}`))}):null,j.length>0?i.jsx("optgroup",{label:"OpenCode",children:j.map(O=>i.jsx("option",{value:`opencode:${Pu(O)}`,children:O},`o-${O}`))}):null,P.length>0?i.jsx("optgroup",{label:"Codex",children:P.map(O=>i.jsx("option",{value:`codex:${Pu(O)}`,children:O},`codex-${O}`))}):null,C.length>0?i.jsx("optgroup",{label:"Claude Code",children:C.map(O=>i.jsx("option",{value:`claude-code:${Pu(O)}`,children:O},`cc-${O}`))}):null]})]}),i.jsx(cC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>x({inputs:O}),disabled:o,requiredReadonly:!u}),i.jsx(cC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>x({outputs:O}),disabled:o,requiredReadonly:!u}),$?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Ip,{value:F,onChange:O=>x({script:O}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange: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:p("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Ip,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown: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:p("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Ip,{value:F,onChange:O=>x({script:O}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown: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:p("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Ip,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function $U({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Fr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||d)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),p?i.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||d,children:o(d?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function LU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Fr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),b(""),y(!1);const N=requestAnimationFrame(()=>{var j;return(j=d.current)==null?void 0:j.focus()});return()=>cancelAnimationFrame(N)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(N){if(N.preventDefault(),!k||h)return;y(!0),b("");let j=null;try{const C=new AbortController;j=setTimeout(()=>C.abort(),15e3);const P=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:s,workspaceId:o}),signal:C.signal}),I=await P.json().catch(()=>({}));if(!P.ok){b(typeof I.error=="string"?I.error:c("project:deleteModal.deleteFailed"));return}try{for(let F=localStorage.length-1;F>=0;F--){const $=localStorage.key(F);$&&($.startsWith(`af:composer-sessions:${n}:${r}`)||$.startsWith(`af:composer-active-session:${n}:${r}`)||$.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem($)}}catch{}await l()}catch(C){if((C==null?void 0:C.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((C==null?void 0:C.message)||C))}finally{j&&clearTimeout(j),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&t()},children:i.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:N=>p(N.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 uC=80,OU=220;function DU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function FU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Rp(e,t,n){const r={nodes:Array.isArray(e)?e.map(DU):[],edges:Array.isArray(t)?t.map(FU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function nw(e,t){const n=[...e,t];return n.length>uC?n.slice(n.length-uC):n}function zU({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(j=>j+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=m.useCallback(()=>{v();const j=d.current,C=f.current;return d.current=null,f.current=null,!j||!C||j.signature===C.signature?(C&&(u.current=C),!1):(l.current=nw(l.current,j),c.current=[],u.current=C,y(),!0)},[y,v]),g=m.useCallback((j=[],C=[],P={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Rp(j,C,P),h.current=!1,y()},[y,v]),k=m.useCallback(j=>{h.current=!0,u.current=j,d.current=null,f.current=null,v(),s==null||s(j.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const j=u.current||Rp(e,t,n),C=l.current.pop();return C?(c.current=nw(c.current,j),k(C),!0):(y(),!1)},[y,t,n,b,e,k]),N=m.useCallback(()=>{b();const j=u.current||Rp(e,t,n),C=c.current.pop();return C?(l.current=nw(l.current,j),k(C),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const j=Rp(e,t,n);if(!u.current){u.current=j;return}if(h.current){h.current=!1,u.current=j;return}j.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=j,v(),p.current=window.setTimeout(()=>{b()},OU))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:N,version:o}}function lo(e){return String(e??"").trim()}function dC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(lo(e).toLowerCase())}function BU(e){return e===!1?!0:["false","no","not_required","waived"].includes(lo(e).toLowerCase())}function HU(e,t=""){return lo((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 kT(e){return lo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function vT(e){return kT(e)==="all"}function WU(e,t=[]){const n=lo((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=kT(e),s=HU(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=>lo(l))).has(a)?a:""}function sm(e){const t=lo(e==null?void 0:e.label).toLowerCase(),n=lo((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 VU(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[sm(n)]-t[sm(r)])}function KU(e){const t=lo((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 qU(e,t=[]){if(vT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(sm);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 dC(e==null?void 0:e.implementationNotRequired)||dC(e==null?void 0:e.implementation_not_required)||BU(r)?{kind:"not-required",label:KU(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function sb(e=[]){return e.reduce((t,n)=>t+1+sb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function dr(e){return String(e||"").trim()}function $o(e){return dr(e).toLowerCase()}function im(e){return typeof e=="string"?$o(e):!e||typeof e!="object"||Array.isArray(e)?"":$o(e.kind||e.type||e.persistence||e.durability)}function ST(e,t="http://localhost"){const n=dr(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 NT(e={}){const t=dr(e.href||e.url);if(!t)return!1;const n=$o(e.kind||e.type),r=$o(e.durability),s=$o(e.persistence),o=$o(e.truth||e.stateTruth||e.state_truth),a=$o(e.authority),l=im(e.source)||im(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(dr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(dr).join(" ");if(r==="temporary"||s==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const p=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function jT(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(dr).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 UU(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=dr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(dr(t)?dr(t):jT(e)==="tech-design"&&dr(n)?dr(n):dr(e.title||e.label))}function YU(e={},t="http://localhost"){const n=dr(e.issueKey||e.issue_key||e.issue),r=jT(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=dr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${ST(e.href||e.url,t)}`}function fC(e={}){const t=dr(e.href||e.url),n=$o(e.kind||e.type),r=im(e.source)||im(e.sourceArtifact||e.source_artifact),s=dr(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 GU(e,t){const n=fC(t)>fC(e)?t:e,r=n===t?e:t;return{...r,...n,title:pC(e.title)>=pC(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 pC(e){const t=dr(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 rw(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]=GU(r[a],s)}return r}function JU(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>NT(o)),r=rw(n,o=>ST(o.href||o.url,t)),s=rw(r,o=>dr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return rw(s,o=>YU(o,t))}function $r(e){return String(e||"").trim()}function Rc(e){return typeof e=="string"?$r(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":$r(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function om(e){return/\/api\/prd-workflow\/review\//.test($r((e==null?void 0:e.href)||(e==null?void 0:e.url)))}function CT(e){const t=$r((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=$r(e==null?void 0:e.durability).toLowerCase(),r=$r(e==null?void 0:e.persistence).toLowerCase(),s=Rc(e==null?void 0:e.source)||Rc((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($r).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function XU(e){if(!om(e)||CT(e))return!1;const t=$r((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=$r(e==null?void 0:e.durability).toLowerCase(),r=$r(e==null?void 0:e.persistence).toLowerCase(),s=Rc(e==null?void 0:e.source)||Rc((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($r).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function QU(e){if(om(e))return!1;const t=$r((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=$r(e==null?void 0:e.persistence).toLowerCase(),r=Rc(e==null?void 0:e.source)||Rc((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map($r).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function ZU(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map($r).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function eY(e=[],t={}){const n=Array.isArray(e)?e:[];if(!ZU(t))return n;const r=n.filter(om);if(r.length===0)return n;const s=r.filter(XU),a=s.length>0||n.some(QU)?s.at(-1):r.filter(CT).at(-1);return n.filter(l=>!om(l)||l===a)}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function am(e){return Array.isArray(e)?e.map(am):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,am(e[t])])):e}function eo(e,t){return JSON.stringify(am(e))===JSON.stringify(am(t))}function _T(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function Kd(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function Tp(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function tY(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=Tp(e,["version","instances","edges","ui"]),r=Tp(t,["version","instances","edges","ui"]);if(!eo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return eo(Tp(e.ui,s),Tp(t.ui,s))}function ET(e){const t=Array.isArray(Kd(e).groups)?Kd(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function hC(e){const t=new Set(Object.keys(_T(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 ET(e).keys())t.add(n);return t}function mC(e,t){const n=_T(e),r=Kd(e),s=ET(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 gC(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 nY(e,t){if(!tY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...hC(e),...hC(t)]),r=Array.from(n).filter(s=>!eo(mC(e,s),mC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!eo(gC(e),gC(t)),displayPageChanged:!eo(Kd(e).displayPage||null,Kd(t).displayPage||null)}}function rY(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!s.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function yC(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 wC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function sY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[yC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(yC(r));return s?eo(wC(s),wC(r))?s:{...r,selected:s.selected===!0}:r})}function iY(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 oY({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 aY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function AT(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 lY(e=[]){const t=AT(e);return t.mutated&&!t.active}function cY(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 uY(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 dY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(cY(s)){t.push(s);continue}n.push(s),uY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function ib(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 fY(e=[]){return ib(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 xC(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 pY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function hY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const mY="af:workspace-graph:v2",bC="agentflow.workspace.sidebarCollapsed",Ol=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],gY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),yY={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:""}]},wY={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:""}]},xY={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}]},bY={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}]},kY={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}]},vY={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}]},SY=new Set(["png","jpg","jpeg","gif","webp","svg"]),PT=320,IT=180,RT=960,lm=96,TT=900,ob=520,ab=320,Mp=52,Qa=240,Za=160,lb="display-ref:",qd="0 9 * * *",NY="Asia/Shanghai",jY="0.1.113";function CY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Tr(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.archived&&t.set("archived","1"),t}function cv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
183
|
+
...[truncated ${n.length-t} chars]`:n:""}function _Y(e){const t=cv(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 uv(e,t=80){return(Array.isArray(e)?e:[]).map(_Y).filter(Boolean).slice(-t)}function EY(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=uv(s.messages,40),l=cv(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 AY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=uv(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:cv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function kC(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:uv(n.messages,100),runSessions:AY(n.runSessions)},nodeChats:EY(t.nodeChats)}}function cm(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 SY.has(n)}function Ud(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=Tr(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function PY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function IY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${bC}:${t}`:bC}function RY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function vC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function TY(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 MY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!TY(e)}function $Y(e){const t=String(e||"").trim();if(!t||LY(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 LY(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 OY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function sw(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 iw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function Ea(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 SC(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 DY(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 FY(e){const t=DY(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 MT(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function hc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return MT(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ca(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 Zo(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 dv(e){return ca(e==null?void 0:e.status)==="done"&&Zo(e)!=="observation"}function to(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 ph(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function fv(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 zY(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 BY(e,t){const n=to(e,t),r=ca(e==null?void 0:e.status),s=dv(e),a=`${el(e)} ${fv(e)}`,l=zY(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"||Zo(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"||Zo(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function HY(e){if(!e||typeof e!="object")return"";const t=ca(e.status),n=Zo(e),r=dv(e),o=`${el(e)} ${fv(e)}`,a=pv(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const d=ph(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function um(e){return!e||typeof e!="object"?"":String(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 $T="Asia/Shanghai",WY=new Intl.DateTimeFormat("zh-CN",{timeZone:$T,year:"numeric",month:"2-digit",day:"2-digit"}),VY=new Intl.DateTimeFormat("zh-CN",{timeZone:$T,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function LT(e){const t=um(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function KY(e){const t=LT(e);return t?WY.format(t).replace(/\//g,"-"):"无时间"}function qY(e){const t=LT(e);return t?VY.format(t):""}function UY(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=KY(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 OT(e){const t=ca(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ta(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 YY(e){const t=ca(e==null?void 0:e.status);return Zo(e)==="observation"&&t==="done"?"已观察":OT(t)}function DT(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=ca(e.status),s=Zo(e)==="observation"&&r==="done"?"observed":r;return n("status",OT(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ta(e.platform),e.platform),t}function GY(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{DT(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 JY(e,t){const n=String(t||"all");return!n||n==="all"?!0:DT(e).some(r=>r.key===n)}function XY(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("平台",Ta(e.platform)),t}function pv(e){const t=[],n=(c,u,d={})=>{const f=MT(u);f&&t.push({...d,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",d=0)=>{if(d>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((p,h)=>r(p,`${u} ${h+1}`,d+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",hc(c),c);n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const o=c=>{const u=String(c||"").trim();try{const d=new URL(u,window.location.origin);return`${d.origin}${d.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=/\/api\/prd-workflow\/review\//.test(String(c.href||"")),d=u?`review:${o(c.href)}`:`${c.label}
|
|
184
|
+
${c.href}`,f=l.get(d);if(!f){l.set(d,c);continue}if(u){const p=a(f.label),h=a(c.label);(h>p||h===p&&String(c.label||"").length>String(f.label||"").length)&&l.set(d,c)}}return eY(Array.from(l.values()),e)}function QY(e,t=[]){var a,l,c,u;const n=[],r=new Map,s=String(((l=(a=e==null?void 0:e.overall)==null?void 0:a.requirement)==null?void 0:l.title)||((u=(c=e==null?void 0:e.overall)==null?void 0:c.requirement)==null?void 0:u.name)||"").trim();for(const d of cb(e)){const f=_i(d),p=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();f&&p&&r.set(f,p)}const o=(d,f={})=>{if(!d||typeof d!="object")return;const p=(y,v={})=>{if(!y||typeof y!="object")return;const b=String(f.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),g=y.source||y.sourceArtifact||y.source_artifact||d.sourceArtifact||d.source_artifact||d.source||f.source||null,k=UU({...y,title:y.title||f.documentTitle||(d==null?void 0:d.title)||"",documentTitle:y.documentTitle||y.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(b)||"",requirementTitle:s}),x={label:String(y.label||"ai-doc").trim()||"ai-doc",href:String(y.href||y.url||"").trim(),kind:String(y.kind||y.type||d.kind||d.type||"").trim(),title:k,issueKey:b,platform:f.platform||Ta(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||Zo(d)||f.truth||"",authority:y.authority||d.authority||f.authority||"",confirmed:y.confirmed??d.confirmed??f.confirmed,source:g,documentPath:y.documentPath||y.document_path||y.path||v.documentPath||(g==null?void 0:g.path)||(g==null?void 0:g.documentPath)||(g==null?void 0:g.document_path)||""};x.href&&n.push(x)};for(const y of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:hc(y)},{documentPath:y.path});for(const y of Array.isArray(d==null?void 0:d.links)?d.links:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:hc(y)},{documentPath:y.path});const h=hc(d);h&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:h},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:Ta(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const f of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(f,{issueKey:String((f==null?void 0:f.issueKey)||(f==null?void 0:f.issue_key)||(f==null?void 0:f.issue)||"").trim(),platform:Ta(f==null?void 0:f.platform),documentTitle:String((f==null?void 0:f.documentTitle)||(f==null?void 0:f.document_title)||(f==null?void 0:f.title)||"").trim()});for(const d of cb(e))o(d,{issueKey:_i(d),platform:Ta(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});return JU(n,window.location.origin)}function ZY(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 eG(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 tG(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 nG(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 rG(e){const t=pv(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}
|
|
185
|
+
${o}`;return r.has(a)?!1:(r.add(a),!0)})}function sG(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,s=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=s(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const d of u)d&&typeof d=="object"&&c.issues.push({...d,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)s(tG(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((d,f)=>_i(d,f));return a.forEach((d,f)=>{const p=_i(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=_i(d,f),h=nG(d)||WU(d,u),y=l.get(p);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Yd(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 el(e){if(!e||typeof e!="object")return"";const t=String(e.issueKey||e.issue_key||e.issue||"").trim(),n=String(e.action||e.actionId||e.action_id||Yd(e)||"").trim(),r=String(e.stageKey||e.stage_key||e.stage||e.phase||e.code||e.pointer||n).trim(),s=[r,n,e.code,e.type,e.title].map(o=>String(o||"")).join(" ").toLowerCase();if(t){if(/plan_draft_local|submit-plan|plan-doc/.test(s))return`issue-plan:${t}`;if(/gitlab_issue_missing|ensure-gitlab-issue/.test(s))return`issue-gitlab:${t}`}return r}function dm(e){const t=um(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 cb(e){var s,o,a,l,c,u,d,f,p,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(h=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function iG(e,t){const n=String(t||"").trim();return n&&cb(e).find((r,s)=>_i(r,s)===n)||null}function oG(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 aG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=iG(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=oG(e);if(!a&&!l)return o;const c=el(o),u=`${c} ${fv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=ca(o.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...a?{gitlabIssue:a,gitlab_issue:a}:{},...l?{gitlabEpic:l,gitlab_epic:l}:{},...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:vi(o.artifacts,f)}}function vi(e,t){const n=[],r=new Set,s=o=>{if(!o)return;const a=typeof o=="string"?o:JSON.stringify(o);r.has(a)||(r.add(a),n.push(o))};return(Array.isArray(e)?e:[]).forEach(s),(Array.isArray(t)?t:[]).forEach(s),n}function NC(e,t){const n=dm(t),r=dm(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:to(s,0)||to(t,0)||to(e,0),detail:ph(s)||ph(t)||ph(e),status:o,links:vi(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:vi(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:vi(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:vi(e==null?void 0:e.results,t==null?void 0:t.results),events:vi(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 lG(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var p,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((p=f.conflict)==null?void 0:p.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links:vi(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:vi(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:vi(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:vi(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],p);return}o.set(f,l(o.get(f)||{},p))},u=(f,p)=>f&&o.has(f)?l(p,o.get(f)):p,d=f=>{if(Array.isArray(f))for(const p of f){const h=el(p);if(a(p)){c(h,p);continue}const y=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,NC(n[b],p)),h&&r.set(h,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(h,p)))}};if(d(e==null?void 0:e.actions),d(e==null?void 0:e.workflowActions),d(e==null?void 0:e.workflow_actions),d(e==null?void 0:e.timeline),d(e==null?void 0:e.history),d(e==null?void 0:e.events),d(e==null?void 0:e.runtimeEvents),d(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=Yd(t),p=el(t),h=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=NC(n[h],y))}return n.map((f,p)=>({item:f,index:p,ts:dm(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>aG(e,f.item))}function cG(e){return(Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[]).filter(n=>n&&typeof n=="object").map((n,r)=>({item:n,index:r,ts:dm(n)})).sort((n,r)=>{const s=Number.isFinite(n.ts),o=Number.isFinite(r.ts);return s&&o?r.ts-n.ts||r.index-n.index:s?-1:o?1:r.index-n.index}).slice(0,8).map(n=>n.item)}function uG(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 dG(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)?`(+${Ea(r)} / 总 ${Ea(s)})`:"";return`${t+1}. ${n}${o}`}function FT(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 Dl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function fG(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 pG(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 hG(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 mG(e){var o,a,l;const t=FT(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Dl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=pG(t),u=fG(t),d=Dl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Dl(t.completedAtMs,c==null?void 0:c.completedAtMs),p=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Dl(p.executionTime,p.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),v=y?y.split(`
|
|
186
|
+
`).find(Boolean)||y:"";return{kind:"tool",label:hG(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Dl(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 jC(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=Dl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),d=s.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),f=o.filter(b=>(b==null?void 0:b.kind)==="tool"),p=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),h=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...s.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${Ea(u)}`),d>0&&v.push(`- 模型相关间隔:约 ${Ea(d)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${Ea(p)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${Ea(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(dG(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${Ea(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
|
|
187
|
+
`)}function CC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=FT(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 zT(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 BT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function hv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function HT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function gG(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 yG(e){const t=String(e??"").trim();return t?t.includes("${")?t:HT(t):""}function WT(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(yG).filter(Boolean):[];return[gG(t,n),HT(o),...a].join(" ")}return String(t.command||"").trim()}function Wu(e){const t=String(hv(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 _C(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function fm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Vu(e){return fm(e)}function ub(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function $p(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 EC(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 AC(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 ow(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=tb(s.get(n),e.sourceHandle||"output-0","source"),a=tb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&Vd(o,a))}function wG(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=tb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:Fq(a)}:null}function xG(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"?Vd(t.slot,a):Vd(a,t.slot)))continue;const c=Wu(n);return{def:n,order:r,category:c,categoryRank:Ol.indexOf(c),slot:a,slotIndex:o,displayLabel:Vu(n),description:ub(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 bG(e,t,n){var o,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const d=Array.isArray(s?(o=u.data)==null?void 0:o.inputs:(a=u.data)==null?void 0:a.outputs)?s?u.data.inputs:u.data.outputs:[];for(let f=0;f<d.length;f+=1){const p=d[f];if((p==null?void 0:p.showOnNode)===!1||!(s?Vd(n.slot,p):Vd(p,n.slot)))continue;const y=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},v=(t||[]).some(b=>b.target===y.target&&b.targetHandle===y.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:p,slotIndex:f,handleId:s?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,d)=>{var v,b,g,k,x,N,j,C;const f=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),p=Number(((k=(g=d.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((N=(x=u.node)==null?void 0:x.position)==null?void 0:N.x)||0),y=Number(((C=(j=d.node)==null?void 0:j.position)==null?void 0:C.x)||0);return f-p||h-y||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function tc(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 kG(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 vG(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function SG(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return qd;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} * * *`:qd}function Do(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 mv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Do(t[1],9,0,23)}:${Do(t[2],0,0,59)}`:"09:00"}function Ku(e,t,n,r,s){const o=mv(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()||qd:`${l} ${a} * * *`}function NG(e){const n=String(e||qd).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,o,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(s,10),d=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=d?`${Do(u,9,0,23)}:${Do(c,0,0,59)}`:"09:00";return d&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:d&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:d&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function gv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=SG(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=NG(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=mv(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),d=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=Ku(l,c,u,d,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:NY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function jG(e){const t=gv(JSON.stringify(e||{}));return JSON.stringify(t)}function CG(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function _G(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function PC(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 Lp(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:PC(n.nextRunAt),lastAt:PC(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 pm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function hm(e){return e>0?`Group ${e+1}`:"Group"}function EG(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)||hm(r)).trim()||hm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Qa,Math.round(l)),height:Math.max(Za,Math.round(c))}}).filter(Boolean)}function AG(e){var n;return EG((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:pc,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 db(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(Qa,Math.round(t)),height:Math.max(Za,Math.round(n))}}function qu(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:vG(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 VT(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 PG(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=lg(t);return[VT(e),In(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 IC(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 IG=new Map,RG=[];function Iu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=UT(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(z=>z.id===g),x=hv(k)||g,N=t.find(z=>z.id===x)||k,j=b.marketplaceRef||BT(k),C=WT(k),P=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},I=!!In({definitionId:x,inputs:b.input,outputs:b.output}),F=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,$=za(F,{display:I}),D=$&&!ei(x);return{id:v,type:pc,position:P,...D?{width:$.width,height:$.height}:{},data:{label:b.label||fm(k)||fm(N)||v,definitionId:x,...j?{marketplaceRef:j}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:zT(x,N||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||C||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...D?{nodeSize:$}:{},...I&&D?{displaySize:$}:{}}}}).map(v=>rb(v,r,t)),d=AG(e),f=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!d.some(b=>b.id===String(v.source)||b.id===String(v.target))).map((v,b)=>({id:v.id||`we-${v.source}-${v.target}-${b}`,source:String(v.source),target:String(v.target),sourceHandle:v.sourceHandle??void 0,targetHandle:v.targetHandle??void 0,markerEnd:{type:bi.ArrowClosed}})),p=[...d,...u];return{nodes:p,edges:dU(f,p),instances:r}}function RC(e){return`${lb}${e}`}function Op(e){const t=String(e||"");return t.startsWith(lb)?t.slice(lb.length):t}function fb(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 hh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return tl((p=f==null?void 0:f.data)==null?void 0:p.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const f of r){const p=String(f||"").trim();!p||o.has(p)||!n.has(p)||(o.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,p)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+p*36,y:120+p*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const p=za(u[f],{display:!0});p&&(c[f]=p)});const d=fb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function TC(e,t=[]){return hh(e,t)}const aw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function lw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function MC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function $C(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 TG(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function LC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const KT="af:workspace:canvas-clipboard",qT="agentflow.workspace.canvas-clipboard";function MG(e){return JSON.stringify({type:qT,version:1,clipboard:e})}function $G(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==qT)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function LG(e){try{localStorage.setItem(KT,MG(e))}catch{}}function OG(){try{return $G(localStorage.getItem(KT))}catch{return null}}function DG(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function pb(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 OC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function za(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:OC(n,IT,RT)||PT,height:OC(r,lm,TT)||lm}}function mm(e){const t=za(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function FG(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:ob,height:ab}}function zG(e,t=""){const n=mm(e==null?void 0:e.displaySize);if(n)return n;const r=mm(e==null?void 0:e.nodeSize);if(r)return r;const s=tl(t)||gf(ta((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return FG(s)}function Fl(e){var s,o,a,l,c,u,d,f,p,h,y;if(ei((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!In(e==null?void 0:e.data),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(d=e==null?void 0:e.data)==null?void 0:d.displaySize)==null?void 0:f.height)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return za({width:n,height:r},{display:t})}function Ml(e,t,n){var d,f,p,h,y,v,b,g,k,x,N,j,C;const r=(e||[]).filter(P=>!pm(P)),s=(e||[]).filter(pm),o=UT(av(r,n||{})),a=t.map(P=>({source:P.source,target:P.target,sourceHandle:P.sourceHandle??null,targetHandle:P.targetHandle??null})).filter(P=>!s.some(I=>I.id===P.source||I.id===P.target)),l={},c={},u=[];for(const P of r){l[P.id]={x:((d=P.position)==null?void 0:d.x)||0,y:((f=P.position)==null?void 0:f.y)||0};const I=Fl(P);I&&(c[P.id]=I)}for(const P of s){const I=Number(((h=(p=P.data)==null?void 0:p.nodeSize)==null?void 0:h.width)||P.width||((y=P.measured)==null?void 0:y.width)||0),F=Number(((b=(v=P.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||P.height||((g=P.measured)==null?void 0:g.height)||0);u.push({id:P.id,title:String(((k=P.data)==null?void 0:k.title)||((x=P.data)==null?void 0:x.label)||"Group"),color:String(((N=P.data)==null?void 0:N.color)||"purple"),x:Number(((j=P.position)==null?void 0:j.x)||0),y:Number(((C=P.position)==null?void 0:C.y)||0),width:Math.max(Qa,Math.round(I||Qa)),height:Math.max(Za,Math.round(F||Za))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function UT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!tl(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 tl(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 In(e){const t=tl(e==null?void 0:e.definitionId);return t||(ei(e==null?void 0:e.definitionId)&&lg(e)?gf(ta((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function no(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=In(e),r=ei(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 ea(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 BG(e){let t=String(e||"").replace(/\r\n/g,`
|
|
188
|
+
`).trim();return t.includes(`
|
|
189
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
190
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
191
|
+
$2`)),t}function Ei(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=BG(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
192
|
+
`).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
|
|
193
|
+
`).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function nl(e,t){const n=Tr(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 hb(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 HG(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(`
|
|
194
|
+
`)}).filter(Boolean).join(`
|
|
195
|
+
|
|
196
|
+
`)}function Hc(e){let t=Ei(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 WG(e){const t=Hc(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ma(e,t){return e==="html"?WG(t):""}function YT(e,t=""){const n=Hc(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
197
|
+
(() => {
|
|
198
|
+
const frameId = ${JSON.stringify(String(t||""))};
|
|
199
|
+
const postSize = () => {
|
|
200
|
+
const doc = document.documentElement;
|
|
201
|
+
const body = document.body;
|
|
202
|
+
const height = Math.ceil(Math.max(
|
|
203
|
+
doc ? doc.scrollHeight : 0,
|
|
204
|
+
doc ? doc.offsetHeight : 0,
|
|
205
|
+
doc ? doc.clientHeight : 0,
|
|
206
|
+
body ? body.scrollHeight : 0,
|
|
207
|
+
body ? body.offsetHeight : 0,
|
|
208
|
+
body ? body.clientHeight : 0,
|
|
209
|
+
window.innerHeight || 0
|
|
210
|
+
));
|
|
211
|
+
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
212
|
+
};
|
|
213
|
+
document.addEventListener("click", (event) => {
|
|
214
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
215
|
+
if (!link) return;
|
|
216
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
217
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
218
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
224
|
+
}, true);
|
|
225
|
+
window.addEventListener("load", postSize);
|
|
226
|
+
window.addEventListener("resize", postSize);
|
|
227
|
+
requestAnimationFrame(postSize);
|
|
228
|
+
setTimeout(postSize, 60);
|
|
229
|
+
setTimeout(postSize, 300);
|
|
230
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
231
|
+
const resizeObserver = new ResizeObserver(postSize);
|
|
232
|
+
resizeObserver.observe(document.documentElement);
|
|
233
|
+
if (document.body) resizeObserver.observe(document.body);
|
|
234
|
+
}
|
|
235
|
+
if (typeof MutationObserver !== "undefined") {
|
|
236
|
+
const mutationObserver = new MutationObserver(postSize);
|
|
237
|
+
mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
238
|
+
}
|
|
239
|
+
})();
|
|
240
|
+
<\/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 VG(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 KG(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function qG(e,t){const n=URL.createObjectURL(e);try{KG(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function GT(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 UG(e){const t=GT(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>"}
|
|
241
|
+
${t.documentElement.outerHTML}`:""}function cw(e){var n;if(!e)return null;const t=(n=e.getBoundingClientRect)==null?void 0:n.call(e);return{rectWidth:t!=null&&t.width?Math.round(t.width):null,rectHeight:t!=null&&t.height?Math.round(t.height):null,clientWidth:e.clientWidth||null,clientHeight:e.clientHeight||null,scrollWidth:e.scrollWidth||null,scrollHeight:e.scrollHeight||null,offsetWidth:e.offsetWidth||null,offsetHeight:e.offsetHeight||null}}function YG(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=GT(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,d=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,p={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((f==null?void 0:f.width)||0)||null,displaySizeHeight:Number((f==null?void 0:f.height)||0)||null,rectWidth:s!=null&&s.width?Math.round(s.width):null,rectHeight:s!=null&&s.height?Math.round(s.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:cw(c),displayBody:cw(u),scroller:cw(d)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(g=>Math.ceil(g)).filter(g=>g>0),y=Math.max(1,...h.length?h:[960]),v=Math.max(1,Math.round(Number(n)||(s==null?void 0:s.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:y,height:v,debug:p}}async function GG({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=YG(r,s,o,{...l||{},displaySize:c}),d=UG(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:d||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const p=await f.blob();qG(p,a)}function JG(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 JT(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 XG(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 XT({code:e}){const t=m.useMemo(()=>XG(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((d,f)=>{l.set(d.id,{x:24+(n?f*(r+o):f%3*(r+o)),y:24+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(d=>d.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(d=>d.y+s+24));return i.jsx("div",{className:"af-work-node__mermaid-preview",children:i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((d,f)=>{const p=l.get(d.from),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:d.label.slice(0,22)})]},d.id)})]})})}function fi({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var N,j;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(j=(N=d.currentTarget).setPointerCapture)==null||j.call(N,g);const k=C=>{C.preventDefault(),l(c(C.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[i.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function QT({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=In(e),o=no(e),a=s==="image"?o:Ei(o),l=s==="image"?"":ea(a,s),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),f(""),u(""),nl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),f(""),h(!1),()=>{k=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const y=l?c:a,v=s==="html"?Hc(y):s==="react"?ag(y):Ei(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=Ma(s,v);if(p)return i.jsxs(fi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(d)return i.jsx(fi,{className:"af-work-display-empty",children:d});if(g)return i.jsx(fi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(fi,{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"?lv(v,b.current):YT(v,b.current)},r)});if(s==="image"){const k=Ud(v,t);return i.jsx(fi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:JG(e),loading:"lazy"})})}return s==="markdown"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(nv,{content:v,basePath:l,resolveSrc:(k,x)=>Ud(k,t,x)})}):s==="chart"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(sv,{content:v})}):s==="table"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(rv,{content:v})}):s==="mermaid"?i.jsxs(fi,{className:"af-work-display-body",children:[i.jsx(XT,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(fi,{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 QG({node:e,onClose:t}){var k,x,N,j,C,P,I,F,$,D,z;const n=m.useRef(null),r=In(e==null?void 0:e.data),s=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1),y=no(e==null?void 0:e.data),v=r==="markdown"?Ei(y):"",b=r==="markdown"?ea(v,"markdown"):"",g=r==="markdown"?b?d: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?(f(""),h(!1),()=>{O=!0}):(h(!0),nl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(K=>{O||f(K)}).catch(K=>{var H,L;O||(f(""),(L=(H=e==null?void 0:e.data)==null?void 0:H.onStatus)==null||L.call(H,String(K.message||K)))}).finally(()=>{O||h(!1)}),()=>{O=!0})},[r,b,(j=(N=e==null?void 0:e.data)==null?void 0:N.flowParams)==null?void 0:j.flowId,(P=(C=e==null?void 0:e.data)==null?void 0:C.flowParams)==null?void 0:P.flowSource,(F=(I=e==null?void 0:e.data)==null?void 0:I.flowParams)==null?void 0:F.archived,($=e==null?void 0:e.data)==null?void 0:$.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?cr.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:JT(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||p,onClick:async()=>{var O,M;try{await eM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(K){(M=(O=e==null?void 0:e.data)==null?void 0:O.onStatus)==null||M.call(O,String(K.message||K))}},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(g||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||p,onClick:()=>{u(String(g||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),i.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?i.jsx(ZT,{value:c,onChange:u,onUploadImage:(D=e.data)==null?void 0:D.onUploadWorkspaceImage,readOnly:o}):i.jsx(QT,{data:e.data,flowParams:(z=e.data)==null?void 0:z.flowParams,htmlFrameRef:n})})]})}),document.body):null}function ZG({node:e}){var p,h,y,v,b,g,k,x,N,j;const t=In(e==null?void 0:e.data),n=no(e==null?void 0:e.data),r=t==="image"?n:Ei(n),s=t==="image"?"":ea(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var P;let C=!1;return s?(c(!0),a(""),nl(((P=e==null?void 0:e.data)==null?void 0:P.flowParams)||{},s).then(I=>{C||a(I)}).catch(()=>{C||a("")}).finally(()=>{C||c(!1)}),()=>{C=!0}):(a(""),c(!1),()=>{C=!0})},[s,(h=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=s?o:r,d=t==="html"?Hc(u):t==="react"?ag(u):Ei(u),f=Ma(t,d);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?i.jsx("div",{className:"af-display-picker-preview__empty",children:f}):d.trim()?t==="html"||t==="react"?i.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?lv(d):YT(d)}):t==="image"?i.jsx("img",{src:Ud(d,(N=e==null?void 0:e.data)==null?void 0:N.flowParams),alt:((j=e==null?void 0:e.data)==null?void 0:j.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(nv,{content:d,basePath:s,resolveSrc:(C,P)=>{var I;return Ud(C,(I=e==null?void 0:e.data)==null?void 0:I.flowParams,P)}})}):t==="chart"?i.jsx(sv,{content:d}):t==="table"?i.jsx(rv,{content:d}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(XT,{code:d}),i.jsx("pre",{children:d})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:d}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function ZT({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,d]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),N=k>x+1,j=N?Math.max(12,x/k*100):100,C=Math.max(0,100-j),P=N?Math.min(C,g.scrollTop/Math.max(1,k-x)*C):0;d({visible:N,top:P,height:j})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(f);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[f,e]);const p=m.useCallback(g=>{const k=s.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,f()},[f]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const N=x.getBoundingClientRect(),j=u.height/100*N.height,C=Math.max(1,N.height-j);return(g-N.top-k)/C},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),N=u.top/100*x.height,j=u.height/100*x.height,P=g.clientY>=x.top+N&&g.clientY<=x.top+N+j?g.clientY-x.top-N:j/2;p(h(g.clientY,P));const I=$=>{$.preventDefault(),p(h($.clientY,P))},F=()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F)};window.addEventListener("pointermove",I),window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F)},[h,p,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=s.current,N=Number((x==null?void 0:x.selectionStart)??k.length),j=Number((x==null?void 0:x.selectionEnd)??N),C=k.slice(0,N),P=k.slice(j),I=C&&!C.endsWith(`
|
|
242
|
+
`)?`
|
|
243
|
+
`:"",F=P&&!P.startsWith(`
|
|
244
|
+
`)?`
|
|
245
|
+
`:"",$=`${C}${I}${g}${F}${P}`;t==null||t($),window.requestAnimationFrame(()=>{var z,O;const D=C.length+I.length+g.length;(z=s.current)==null||z.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 N=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(``)}}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(N=>String((N==null?void 0:N.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(cm);k&&(g.preventDefault(),b(k))},children:[i.jsxs("div",{className:"af-work-display-editor__toolbar",children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var g;return(g=o.current)==null?void 0:g.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),i.jsx("input",{ref:o,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:g=>{var x;const k=(x=g.target.files)==null?void 0:x[0];g.target.value="",k&&b(k)}})]}),i.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:g=>t==null?void 0:t(g.target.value),onScroll:f,onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),i.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:y,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function eJ({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=m.useState(a),u=m.useRef(!1),d=String(s.candidateContent||""),f=!!s.running,p=!!(t!=null&&t.readOnly),h=String(s.error||""),y=o.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.stopPropagation(),children:[i.jsxs("div",{className:"af-work-node-chat__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"继续微调"}),i.jsx("span",{children:(t==null?void 0:t.label)||e})]}),i.jsx("button",{type:"button",onClick:()=>{var v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||f||h?i.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:v.role==="assistant"?"AI":"你"}),i.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),f?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?i.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||p,"aria-label":"添加上下文",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),i.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:f||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:v=>{var g;u.current=!1;const b=v.currentTarget.value;c(b),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onChange:v=>{var g;const b=v.target.value;c(b),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onKeyDown:v=>{var b,g;v.isComposing||(b=v.nativeEvent)!=null&&b.isComposing||v.keyCode===229||(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),(g=t==null?void 0:t.onSendNodeChat)==null||g.call(t,e,l))}}),i.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||p||!l.trim(),onClick:()=>{var v;return(v=t==null?void 0:t.onSendNodeChat)==null?void 0:v.call(t,e,l)},"aria-label":"发送",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),d.trim()?i.jsx("div",{className:"af-work-node-chat__messages",children:i.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[i.jsx("span",{children:"AI"}),i.jsx("p",{children:d})]})}):null]}):i.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:v=>{var b;v.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function tJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function nJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function rJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function DC(e,t=""){const n=ea(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function sJ(e,t){const n=rJ(e),r=new Set,s=In(t)||"";ei(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=DC(no(t),s);return o&&r.add(o),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),d=DC(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function FC(e,t){const n=In(t)||"markdown";return`outputs/${nJ((t==null?void 0:t.label)||e||n)}.${tJ(n)}`}async function eM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await hb((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 tM({id:e,data:t,selected:n,deleteNode:r}){var ee,te,ne;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Z,ce)=>({slot:Z,idx:ce})).sort((Z,ce)=>{var _e,Be,ot,yt;const de=String(((_e=Z.slot)==null?void 0:_e.name)||"").trim(),me=String(((Be=ce.slot)==null?void 0:Be.name)||"").trim();if(de==="next"&&me!=="next")return-1;if(me==="next"&&de!=="next")return 1;const $e=String(((ot=Z.slot)==null?void 0:ot.type)||"").trim(),Ce=String(((yt=ce.slot)==null?void 0:yt.type)||"").trim();return $e==="node"&&Ce!=="node"?-1:Ce==="node"&&$e!=="node"?1:Z.idx-ce.idx}),l=In(t),c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[N,j]=m.useState(""),[C,P]=m.useState(!1),[I,F]=m.useState(!1),$=m.useRef(null),D=no(t),z=l==="markdown"?Ei(D):"",O=l==="markdown"?ea(z,"markdown"):"",M=l==="markdown"?O?N:z:"",K=!!(t!=null&&t.readOnly),H=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!O?(j(""),P(!1),()=>{Z=!0}):(P(!0),nl((t==null?void 0:t.flowParams)||{},O).then(ce=>{Z||j(ce)}).catch(ce=>{var de;Z||(j(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ce.message||ce)))}).finally(()=>{Z||P(!1)}),()=>{Z=!0})},[l,O,(ee=t==null?void 0:t.flowParams)==null?void 0:ee.flowId,(te=t==null?void 0:t.flowParams)==null?void 0:te.flowSource,(ne=t==null?void 0:t.flowParams)==null?void 0:ne.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const Z=()=>v(!1);return window.addEventListener("pointerup",Z,!0),window.addEventListener("pointercancel",Z,!0),window.addEventListener("mouseup",Z,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointerup",Z,!0),window.removeEventListener("pointercancel",Z,!0),window.removeEventListener("mouseup",Z,!0),window.removeEventListener("blur",Z)}},[y]),m.useEffect(()=>{b||x(String(M||""))},[M,b]);const L=(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"),T=String((t==null?void 0:t.sourceNodeId)||e),W=(t==null?void 0:t.sharingDisplayNodeId)===T,E=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Te,st,gt,xe,Fe,lt,oe,ke,Ke,Ue;if(l!=="html"||p)return;const Z=no(t),ce=ea(Z,l);let de=Z;if(ce)try{de=await nl((t==null?void 0:t.flowParams)||{},ce)}catch(be){h(!1),console.warn("Failed to read HTML display file before saving image.",be);return}const me=Hc(de);if(!me.trim())return;const $e=Ma(l,me);if($e){console.warn($e);return}const Ce=(st=(Te=u.current)==null?void 0:Te.getBoundingClientRect)==null?void 0:st.call(Te),_e=(xe=(gt=c.current)==null?void 0:gt.querySelector)==null?void 0:xe.call(gt,".af-work-display-body"),Be=(lt=(Fe=c.current)==null?void 0:Fe.querySelector)==null?void 0:lt.call(Fe,".af-visible-scroll-frame__scroller"),ot=Math.round(Math.max(Number((Ce==null?void 0:Ce.width)||0),Number((E==null?void 0:E.width)||0),Number(((oe=c.current)==null?void 0:oe.clientWidth)||0),Number((_e==null?void 0:_e.clientWidth)||0),Number((Be==null?void 0:Be.clientWidth)||0),Math.max(320,Number((E==null?void 0:E.width)||960)-2))),yt=Math.round(Math.max(Number((Ce==null?void 0:Ce.height)||0),Number((E==null?void 0:E.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((_e==null?void 0:_e.clientHeight)||0),Number((Be==null?void 0:Be.clientHeight)||0),Math.max(180,Number((E==null?void 0:E.height)||640)-46)));h(!0);try{await GG({flowParams:(t==null?void 0:t.flowParams)||{},content:me,sourceFilePath:ce,iframe:u.current,width:ot,height:yt,filename:VG((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:_e,scroller:Be},displaySize:E}),(Ke=t==null?void 0:t.onStatus)==null||Ke.call(t,"已导出 HTML 展示截图")}catch(be){const Ht=String((be==null?void 0:be.message)||be||"截图失败");(Ue=t==null?void 0:t.onStatus)==null||Ue.call(t,`HTML 截图失败:${Ht}`),console.warn("Failed to save HTML display as PNG.",be)}finally{h(!1)}},[t,E==null?void 0:E.height,E==null?void 0:E.width,e,l,p]),V=m.useCallback(Z=>{var ce;K||!Z||l!=="image"||(ce=t==null?void 0:t.onUploadImageToDisplayNode)==null||ce.call(t,e,Z)},[t,e,l,K]),B=m.useCallback(Z=>{var ce,de;(ce=Z==null?void 0:Z.stopPropagation)==null||ce.call(Z),!K&&((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,K]),se=m.useCallback(Z=>{var me,$e;K||l!=="image"||!(Array.from(((me=Z.dataTransfer)==null?void 0:me.files)||[]).some(cm)||Array.from((($e=Z.dataTransfer)==null?void 0:$e.items)||[]).some(Ce=>String((Ce==null?void 0:Ce.type)||"").startsWith("image/")))||(Z.preventDefault(),Z.stopPropagation(),Z.dataTransfer.dropEffect="copy",F(!0))},[l,K]),ue=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||F(!1))},[l]),G=m.useCallback(Z=>{var de;if(l!=="image")return;const ce=Array.from(((de=Z.dataTransfer)==null?void 0:de.files)||[]).find(cm);ce&&(Z.preventDefault(),Z.stopPropagation(),F(!1),V(ce))},[l,V]);return i.jsxs("div",{className:"af-work-display-card"+(E?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(I?" af-work-display-card--image-drop":"")+(H?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:E?{width:E.width,height:E.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:se,onDragLeave:ue,onDrop:G,children:[i.jsx(zk,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>v(!0),onResizeEnd:()=>v(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((Z,ce)=>{if(Z.showOnNode===!1)return null;const de=`${4.15+ce*1.75}rem`,me=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:me}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:Tn(Z.type)},title:`${me} · ${Z.type}`})]},`in-${ce}`)}),a.map(({slot:Z,idx:ce},de)=>{if(Z.showOnNode===!1)return null;const me=`${4.15+de*1.75}rem`,$e=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:me},children:$e}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:me,background:Tn(Z.type)},title:`${$e} · ${Z.type}`})]},`out-${ce}`)}),i.jsxs("div",{className:"af-work-display-card__head",children:[i.jsxs("div",{className:"af-work-display-card__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:JT(l)}),i.jsx("strong",{children:L}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,ce,de,me;try{(me=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.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 Z,ce,de,me;try{(me=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.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:()=>f(Z=>Z+1),"aria-label":"刷新",title:"刷新",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:p,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:p?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:K||C,onClick:async()=>{var Z;try{await eM({nodeId:e,data:t,filePath:O,content:k,setFileContent:j}),g(!1)}catch(ce){(Z=t==null?void 0:t.onStatus)==null||Z.call(t,String(ce.message||ce))}},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"done"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String(M||"")),g(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K||C,onClick:Z=>{Z.stopPropagation(),x(String(M||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:$,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var de;const ce=(de=Z.target.files)==null?void 0:de[0];Z.target.value="",ce&&V(ce)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K,onClick:Z=>{var ce;Z.stopPropagation(),(ce=$.current)==null||ce.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onOpenDisplayPreview)==null||ce.call(t,T)},"aria-label":"全屏预览",title:"全屏预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:W,onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onShareDisplayNode)==null||ce.call(t,T)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:W?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K,onClick:B,"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:K,onClick:()=>{var Z;return(Z=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Z.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"save"})}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:K,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?i.jsx(ZT,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:K}):i.jsx(QT,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),i.jsx(eJ,{nodeId:e,data:t})]})}function iJ({id:e,data:t,selected:n,deleteNode:r}){var d,f,p;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d.has)==null?void 0:f.call(d,e))||((p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return i.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:Tn(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(Gn,{type:"source",position:qe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:Tn(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 oJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Ue,be,Ht,Qt,jt,yn,on;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=vJ(t),[d,f]=m.useState(u.task),p=m.useRef(!1),h=m.useRef(u.task),y=((be=(Ue=t==null?void 0:t.runningRunNodeIds)==null?void 0:Ue.has)==null?void 0:be.call(Ue,e))||((Ht=t==null?void 0:t.runningRunNodeIds)==null?void 0:Ht[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(re=>({id:String((re==null?void 0:re.id)||""),label:String((re==null?void 0:re.label)||(re==null?void 0:re.name)||"知识库"),kind:(re==null?void 0:re.kind)==="git"?"git":"local",path:String((re==null?void 0:re.path)||""),repoUrl:String((re==null?void 0:re.repoUrl)||""),branch:String((re==null?void 0:re.branch)||""),mountPath:String((re==null?void 0:re.mountPath)||""),builtin:(re==null?void 0:re.builtin)===!0,exists:(re==null?void 0:re.exists)!==!1,type:String((re==null?void 0:re.type)||"")})).filter(re=>re.path),[a]),[N,j]=m.useState(!1),[C,P]=m.useState(""),[I,F]=m.useState(()=>new Set),[$,D]=m.useState(!1),[z,O]=m.useState(""),[M,K]=m.useState("config"),H=lg(t),L=!!H,T=lM(u.displayType),W=m.useMemo(()=>zG(t,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,T]),E=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:T,displaySize:W,nodeSize:W,body:H,inputs:[{type:"text",name:T==="display_image"?"src":"content",value:H,default:H}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,T,e,H,c,W]),Q=Array.isArray((Qt=t==null?void 0:t.modelLists)==null?void 0:Qt.cursor)?t.modelLists.cursor:[],V=Array.isArray((jt=t==null?void 0:t.modelLists)==null?void 0:jt.opencode)?t.modelLists.opencode:[],B=Array.isArray((yn=t==null?void 0:t.modelLists)==null?void 0:yn.claudeCode)?t.modelLists.claudeCode:[],se=Array.isArray((on=t==null?void 0:t.modelLists)==null?void 0:on.codex)?t.modelLists.codex:[],ue=m.useMemo(()=>new Set(Q.map(Ss)),[Q]),G=m.useMemo(()=>new Set(V.map(Ss)),[V]),ee=m.useMemo(()=>new Set(B.map(Ss)),[B]),te=m.useMemo(()=>new Set(se.map(Ss)),[se]),ne=u.model,Z=m.useMemo(()=>ne?ne.startsWith("cursor:")||ne.startsWith("opencode:")||ne.startsWith("codex:")||ne.startsWith("claude-code:")?ne:ee.has(ne)?`claude-code:${ne}`:te.has(ne)?`codex:${ne}`:G.has(ne)?`opencode:${ne}`:ue.has(ne)?`cursor:${ne}`:ne:"",[ee,te,ue,G,ne]),ce=ne.startsWith("cursor:")?ne.slice(7):ne.startsWith("opencode:")?ne.slice(9):ne.startsWith("codex:")?ne.slice(6):ne.startsWith("claude-code:")?ne.slice(12):ne,de=ce,me=!!ne&&!ue.has(de)&&!G.has(de)&&!ee.has(de)&&!te.has(de),$e=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ce=m.useMemo(()=>new Map(g.map(re=>[re.key,re])),[g]),_e=m.useMemo(()=>{const re=new Set,Re=k.map(Ze=>{const Tt=Qo(Ze,g).map(At=>Ce.get(At)).filter(Boolean);for(const At of Tt)re.add(At.key);return{...Ze,skills:Tt}}).filter(Ze=>Ze.skills.length>0),Je=g.filter(Ze=>!re.has(Ze.key));return{collectionGroups:Re,ungrouped:Je}},[k,Ce,g]);m.useEffect(()=>{F(re=>{let Re=!1;const Je=new Set(re);for(const Ze of _e.collectionGroups)Je.has(Ze.id)||(Je.add(Ze.id),Re=!0);return Re?Je:re})},[_e.collectionGroups]);const Be=m.useMemo(()=>{const re=C.trim().toLowerCase();if(!re)return _e;const Re=Ze=>[Ze==null?void 0:Ze.key,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(Tt=>String(Tt||"").toLowerCase()).join(" ").includes(re);return{collectionGroups:_e.collectionGroups.map(Ze=>{const Tt=[Ze==null?void 0:Ze.id,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(At=>String(At||"").toLowerCase()).join(" ").includes(re);return{...Ze,skills:Tt?Ze.skills:Ze.skills.filter(Re)}}).filter(Ze=>Ze.skills.length>0),ungrouped:_e.ungrouped.filter(Re)}},[_e,C]),ot=mb(N,[Be.collectionGroups.length,Be.ungrouped.length,I.size,u.skillKeys.length,C]),yt=m.useMemo(()=>{const re=z.trim().toLowerCase();return re?x.filter(Re=>[Re.id,Re.label,Re.path,Re.repoUrl,Re.branch,Re.mountPath,Re.type].join(" ").toLowerCase().includes(re)):x},[x,z]),Te=m.useMemo(()=>fM(u.knowledgeContext),[u.knowledgeContext]),st=m.useMemo(()=>new Set(Te.map(re=>re.id||re.path||re.repoPath).filter(Boolean)),[Te]),gt=mb($,[yt.length,Te.length,z]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,p.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!L){K("config");return}y||K("result")},[L,H,y]),m.useEffect(()=>{var Re,Je;if(!(M==="result"&&L))return;(Re=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Re.call(t,e,W),(Je=t==null?void 0:t.onRefreshNodeInternals)==null||Je.call(t,e);const re=window.setTimeout(()=>{var Ze;return(Ze=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:Ze.call(t,e)},120);return()=>window.clearTimeout(re)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,T,L,e,H,W,M]);const xe=re=>{var Re;(Re=t==null?void 0:t.onChangeContextRunConfig)==null||Re.call(t,e,{...u,task:d,...re})},Fe=(re=d)=>{var Je;const Re=String(re??"");Re!==u.task&&(h.current=Re,(Je=t==null?void 0:t.onChangeContextRunConfig)==null||Je.call(t,e,{...u,task:Re}))},lt=(re,Re)=>{const Je=new Set(u.skillKeys);for(const Ze of re){const Tt=String(Ze||"").trim();Tt&&(Re?Je.add(Tt):Je.delete(Tt))}xe({skillKeys:Array.from(Je)})},oe=re=>{F(Re=>{const Je=new Set(Re);return Je.has(re)?Je.delete(re):Je.add(re),Je})},ke=(re,Re)=>{const Je=(re==null?void 0:re.id)||(re==null?void 0:re.path)||"";if(!Je)return;const Ze=x.filter(Tt=>{const At=Tt.id||Tt.path||"";return At===Je?Re:st.has(At)});xe({knowledgeContext:cg(Ze)})},Ke=()=>{xe({knowledgeContext:null})};return M==="result"&&L?i.jsx(tM,{id:e,data:{...E,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):i.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(M==="result"&&L?" 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((re,Re)=>{if(re.showOnNode===!1)return null;const Je=`${2.25+Re*1.75}rem`,Ze=re.name||`#${Re+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Je},children:Ze}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${Re}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Je,background:Tn(re.type)},title:`${Ze} · ${re.type}`})]},`in-${Re}`)}),c.map((re,Re)=>{if(re.showOnNode===!1)return null;const Je=`${2.25+Re*1.75}rem`,Ze=re.name||`#${Re+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Je},children:Ze}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${Re}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Je,background:Tn(re.type)},title:`${Ze} · ${re.type}`})]},`out-${Re}`)}),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:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>re.stopPropagation(),children:[i.jsxs("select",{className:"af-work-context-run-card__model",value:Z,disabled:b,"aria-label":"模型",title:ce||"默认模型",onChange:re=>xe({model:re.target.value}),children:[i.jsx("option",{value:"",children:"默认"}),me?i.jsx("option",{value:ne,children:ne}):null,Q.length?i.jsx("optgroup",{label:"Cursor",children:Q.map(re=>i.jsx("option",{value:`cursor:${Ss(re)}`,children:Ss(re)},`context-cursor-${re}`))}):null,V.length?i.jsx("optgroup",{label:"OpenCode",children:V.map(re=>i.jsx("option",{value:`opencode:${Ss(re)}`,children:Ss(re)},`context-opencode-${re}`))}):null,se.length?i.jsx("optgroup",{label:"Codex",children:se.map(re=>i.jsx("option",{value:`codex:${Ss(re)}`,children:Ss(re)},`context-codex-${re}`))}):null,B.length?i.jsx("optgroup",{label:"Claude Code",children:B.map(re=>i.jsx("option",{value:`claude-code:${Ss(re)}`,children:Ss(re)},`context-claude-${re}`))}):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:ei(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),L?i.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:re=>re.stopPropagation(),children:[i.jsx("button",{type:"button",className:M==="config"?"is-active":"",onClick:()=>K("config"),"aria-label":"切换到任务配置",children:i.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),i.jsx("button",{type:"button",className:M==="result"?"is-active":"",onClick:()=>K("result"),"aria-label":"切换到展示结果",children:i.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-context-run-card__body nodrag",children:[i.jsxs(i.Fragment,{children:[i.jsx("textarea",{value:d,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{p.current=!0},onCompositionEnd:re=>{p.current=!1,f(re.currentTarget.value),Fe(re.currentTarget.value)},onChange:re=>{f(re.target.value)},onBlur:re=>Fe(re.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:re=>{var Re;re.stopPropagation(),N||(Re=t==null?void 0:t.onRefreshSkills)==null||Re.call(t),j(Je=>!Je)},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"})]}),N?i.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:re=>re.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:C,onChange:re=>P(re.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),C?i.jsx("button",{type:"button",onClick:()=>P(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:ot.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:ot.updateMenuScrollbar,children:[Be.collectionGroups.map(re=>{const Re=re.skills.map(At=>At.key),Je=Re.filter(At=>$e.has(At)).length,Ze=Re.length>0&&Je===Re.length,Tt=I.has(re.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Tt?" 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:Ze,disabled:b,onChange:At=>lt(Re,At.target.checked),"aria-label":`选择 ${re.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>oe(re.id),"aria-expanded":!Tt,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:re.name}),re.description?i.jsx("em",{children:re.description}):null]})}),i.jsxs("small",{children:[Je,"/",Re.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>oe(re.id),"aria-label":Tt?`展开 ${re.name}`:`收起 ${re.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Tt?"chevron_right":"expand_more"})})]}),Tt?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:re.skills.map(At=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:$e.has(At.key),disabled:b,onChange:Vn=>lt([At.key],Vn.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:At.name}),At.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:At.description}):null]})]},`${re.id}:${At.key}`))})]},re.id)}),Be.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:Be.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:Be.ungrouped.map(re=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:$e.has(re.key),disabled:b,onChange:Re=>lt([re.key],Re.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:re.name}),re.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:re.description}):null]})]},`ungrouped:${re.key}`))})]}):null,Be.collectionGroups.length===0&&Be.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:()=>xe({skillKeys:[]}),children:"清空"})]}),i.jsx("div",{ref:ot.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(ot.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:ot.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${ot.scrollbar.height}%`,top:`${ot.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:re=>{var Re;re.stopPropagation(),$||(Re=t==null?void 0:t.onRefreshWorkspaces)==null||Re.call(t),D(Je=>!Je)},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"})]}),$?i.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:re=>re.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:z,onChange:re=>O(re.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),z?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:gt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:gt.updateMenuScrollbar,children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"知识库"}),i.jsx("small",{children:yt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:yt.map(re=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:st.has(re.id||re.path),disabled:b,onChange:Re=>ke(re,Re.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:re.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[re.kind==="git"&&re.repoUrl?`${re.repoUrl}${re.branch?` · ${re.branch}`:""}${re.mountPath?` · ${re.mountPath}`:""}`:re.path,re.exists?"":" · 路径未就绪"]})]})]},`${re.id}:${re.path}`))})]}),yt.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:Ke,children:"清空知识库"})]}),i.jsx("div",{ref:gt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(gt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:gt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${gt.scrollbar.height}%`,top:`${gt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:b,onChange:re=>xe({displayType:re.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"})]})]}),H?i.jsx("pre",{className:"af-work-context-run-card__preview",children:H.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:re=>{var Re,Je;re.stopPropagation(),Fe(),y?(Re=t==null?void 0:t.onStopWorkspaceNode)==null||Re.call(t,e):(Je=t==null?void 0:t.onRunWorkspaceNode)==null||Je.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:re=>{var Re;re.stopPropagation(),(Re=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Re.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 aJ({id:e,data:t,selected:n,deleteNode:r}){var P,I,F;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=gv((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},d=((I=(P=t==null?void 0:t.runningRunNodeIds)==null?void 0:P.has)==null?void 0:I.call(P,e))||((F=t==null?void 0:t.runningRunNodeIds)==null?void 0:F[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",f=(t==null?void 0:t.optimizingRun)===!0,p=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=$=>{var D;(D=t==null?void 0:t.onChangeScheduledRunConfig)==null||D.call(t,e,{...a,...$})},v=$=>{y({scheduleType:$,cron:Ku($,a.time,a.weekday,a.monthDay,a.cron)})},b=$=>{y({time:$,cron:Ku(a.scheduleType,$,a.weekday,a.monthDay,a.cron)})},[g,k]=mv(a.time).split(":"),x=($,D)=>{b(`${Do($,9,0,23)}:${Do(D,0,0,59)}`)},N=$=>{y({weekday:$,cron:Ku(a.scheduleType,a.time,$,a.monthDay,a.cron)})},j=$=>{y({monthDay:$,cron:Ku(a.scheduleType,a.time,a.weekday,$,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const C=()=>{h||l===a.cron||y({cron:l})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(d?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(p?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map(($,D)=>{if($.showOnNode===!1)return null;const z=`${2.25+D*1.75}rem`,O=$.name||`#${D+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:z},children:O}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${D}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:z,background:Tn($.type)},title:`${O} · ${$.type}`})]},`in-${D}`)}),o.map(($,D)=>{if($.showOnNode===!1)return null;const z=`${2.25+D*1.75}rem`,O=$.name||`#${D+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:z},children:O}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${D}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:z,background:Tn($.type)},title:`${O} · ${$.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:$=>y({enabled:$.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:$=>v($.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:$=>x($.target.value,k),children:Array.from({length:24},($,D)=>Do(D,0,0,23)).map($=>i.jsxs("option",{value:$,children:[$," 时"]},$))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:$=>x(g,$.target.value),children:Array.from({length:12},($,D)=>Do(D*5,0,0,59)).map($=>i.jsxs("option",{value:$,children:[$," 分"]},$))})]})]}):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:$=>N($.target.value),children:[i.jsx("option",{value:1,children:"周一"}),i.jsx("option",{value:2,children:"周二"}),i.jsx("option",{value:3,children:"周三"}),i.jsx("option",{value:4,children:"周四"}),i.jsx("option",{value:5,children:"周五"}),i.jsx("option",{value:6,children:"周六"}),i.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"日期"}),i.jsx("select",{value:a.monthDay,disabled:h,onChange:$=>j($.target.value),children:Array.from({length:31},($,D)=>D+1).map($=>i.jsxs("option",{value:$,children:[$," 日"]},$))})]}):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:qd,onChange:$=>c($.target.value),onBlur:C,onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[_G(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",CG(u.nextAt)]}),i.jsx("span",{children:d?"running":u.lastStatus||"idle"})]}),u.lastError?i.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,i.jsxs("div",{className:"af-work-schedule-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(d?" af-work-run-card__button--stop":""),disabled:h||f,onClick:$=>{var D,z;$.stopPropagation(),d?(D=t==null?void 0:t.onStopWorkspaceNode)==null||D.call(t,e):(z=t==null?void 0:t.onRunWorkspaceNode)==null||z.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:d?"stop_circle":"play_arrow"}),i.jsx("span",{children:d?"停止":"立即运行"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(f?" af-work-schedule-card__optimize--running":""),disabled:h||d||f,title:"为下游节点提前生成 implementation",onClick:$=>{var D;$.stopPropagation(),(D=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||D.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:f?"sync":"auto_fix_high"}),i.jsx("span",{children:f?"优化中":"优化"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:$=>{var D;$.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 lJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Fc(),o=!!(t!=null&&t.readOnly),a=db(t==null?void 0:t.nodeSize)||{width:Qa,height:Za},l=m.useCallback(c=>{var u,d;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(d=(u=c.target)==null?void 0:u.closest)!=null&&d.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>sM(f,e))},[e,s]);return i.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:i.jsx(zk,{className:"af-work-group-node__resize nodrag",minWidth:Qa,minHeight:Za,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 cJ(e){var y,v,b,g,k,x,N,j,C,P,I,F,$,D,z,O,M,K,H,L,T,W,E,Q,V,B,se,ue;const{setEdges:t,setNodes:n}=Fc(),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 ne,Z,ce;if(s)return;(Z=(ne=e.data)==null?void 0:ne.onCleanupWorkspaceNodeOutputs)==null||Z.call(ne,G,e.data);const ee=ei((ce=e.data)==null?void 0:ce.definitionId)?cM(G):"",te=new Set([G,ee].filter(Boolean));n(de=>de.filter(me=>!te.has(me.id))),t(de=>de.filter(me=>!te.has(me.source)&&!te.has(me.target)))},[e.data,s,t,n]),u=m.useCallback(G=>{var ee,te;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(te=(ee=G.target)==null?void 0:ee.closest)!=null&&te.call(ee,".react-flow__handle, .af-work-display-resize")||(n(ne=>sM(ne,e.id)),t(ne=>pJ(ne)))},[e.id,t,n]),d=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>ne.id===G?{...ne,data:{...ne.data,model:ee}}:ne)),r==null||r(G,{model:ee}))},[s,n,r]),f=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>{var ce;if(ne.id!==G)return ne;const Z=Array.isArray((ce=ne.data)==null?void 0:ce.outputs)&&ne.data.outputs.length?ne.data.outputs.map((de,me)=>me===0?{...de,default:ee,value:ee}:de):[{type:"bool",name:"value",default:ee,value:ee}];return{...ne,data:{...ne.data,body:"",outputs:Z}}})),r==null||r(G,te=>({body:"",outputs:Array.isArray(te==null?void 0:te.outputs)&&te.outputs.length?te.outputs.map((Z,ce)=>ce===0?{...Z,default:ee,value:ee}:Z):[{type:"bool",name:"value",default:ee,value:ee}]})))},[s,n,r]),p=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>ne.id===G?{...ne,data:{...ne.data,body:ee}}:ne)),r==null||r(G,{body:ee}))},[s,n,r]),h=m.useCallback((G,ee)=>{if(s)return;const te=po(ee);n(ne=>ne.map(Z=>Z.id===G?{...Z,data:{...Z.data,images:te}}:Z)),r==null||r(G,{images:te})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(lJ,{...e,deleteNode:c}):tl((k=e.data)==null?void 0:k.definitionId)?i.jsx(tM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(iJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((N=e.data)==null?void 0:N.definitionId)==="workspace_scheduled_run"?i.jsx(aJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ei((j=e.data)==null?void 0:j.definitionId)?i.jsx(oJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(C=e.data)==null?void 0:C.skills,skillCollections:(P=e.data)==null?void 0:P.skillCollections,workspaces:(I=e.data)==null?void 0:I.workspaceTargets}):((F=e.data)==null?void 0:F.definitionId)==="control_load_skills"?i.jsx(AJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:($=e.data)==null?void 0:$.skills,skillCollections:(D=e.data)==null?void 0:D.skillCollections,onChangeSkillKeys:(z=e.data)==null?void 0:z.onChangeLoadSkillKeys}):((O=e.data)==null?void 0:O.definitionId)==="control_load_mcp"?i.jsx(PJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(M=e.data)==null?void 0:M.mcpServers,onChangeMcpNames:(K=e.data)==null?void 0:K.onChangeLoadMcpNames}):((H=e.data)==null?void 0:H.definitionId)==="control_cd_workspace"?i.jsx(IJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(L=e.data)==null?void 0:L.workspaceTargets,onChangeWorkspace:(T=e.data)==null?void 0:T.onChangeLoadWorkspace,onRefreshWorkspaces:(W=e.data)==null?void 0:W.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((E=e.data)!=null&&E.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((V=e.data)==null?void 0:V.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((B=e.data)==null?void 0:B.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((se=e.data)==null?void 0:se.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:i.jsx(zk,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:IT,minHeight:lm,maxWidth:RT,maxHeight:TT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(Xq,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ue=e.data)==null?void 0:ue.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:h})]})}const uJ={[pc]:m.memo(cJ)};function yv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&yv(n.children,t);return t}function nM(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)?nM(r.children,n):null;if(s)return s}return null}function dJ(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function rM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&rM(n.children,t));return t}function Dp(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 fJ(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?s:e}function sM(e,t){const n=String(t||""),r=(e||[]).find(o=>o.id===n),s=(e||[]).reduce((o,a)=>o+(a.selected?1:0),0);return r!=null&&r.selected&&s>1?e:fJ(e,n)}function pJ(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function hJ(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function mJ(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(o,a,l)=>{const c=r[a],u=l?`${l}/${c}`:c,d=a===r.length-1;let f=!1;const p=(Array.isArray(o)?o:[]).map(h=>h.name!==c?h:(f=!0,d?{...h,type:"file",name:c,path:u,icon:tc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:tc(c,!0),children:s(h.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:tc(c),size:n}:{type:"directory",name:c,path:u,icon:tc(c,!0),children:s([],a+1,u)}),hJ(p)};return s(e||[],0,"")}function gJ(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 iM({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const d=u.type==="directory",f=d&&(r==null?void 0:r.has(u.path)),p=n===u.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"af-work-file-row",children:[i.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+u.type+(p?" af-work-file--selected":""),draggable:!d,onDragStart:y=>{d||a==null||a(y,u)},onClick:()=>{o==null||o(u),d&&(s==null||s(u.path))},onDoubleClick:()=>{d||t(u)},title:u.path,children:[d?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:u.icon||tc(u.name,d)}),i.jsx("span",{children:u.name})]}),p?i.jsxs("div",{className:"af-work-file-actions",children:[d?null:i.jsx("button",{type:"button",className:"af-work-file-action",onClick:y=>{y.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),i.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:y=>{y.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),d&&!f&&((h=u.children)!=null&&h.length)?i.jsx(iM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function yJ({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>yv(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||tc(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:gJ(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function zC({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 oM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function wJ(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!oM(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 xJ(e){return(Array.isArray(e)?e:[]).filter(oM)}function Gd(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 bJ(e){const t=Gd((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 Gd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function kJ(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 Gd((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function aM(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 BC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function ta(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 gm(e,t){const n=ta(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 gf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Ss(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function lM(e){const t=gf(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 cM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function uM(e){return e==="display_image"?"src":"content"}function HC(e,t,n){const r=uM(t),s=qu(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 WC(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 VC(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 lg(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 vJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=ta(t,"includeWorkspaceContext","true").toLowerCase(),r=gm(t,"knowledgeContext"),s=gm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:kJ(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?cg([s]):null),workspaceContext:s,displayType:gf(ta(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ei(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function SJ(e){const t=Gd((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 Gd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function NJ(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function dM(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 cg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>dM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function fM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>dM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function jJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=gm(t,"knowledgeContext"),r=gm(t,"workspaceContext");return{sources:fM(n||(r?cg([r]):null)),path:ta(t,"path",""),label:ta(t,"label","")}}function KC(e){var r,s,o,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=uU(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:po((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((d=e.data)==null?void 0:d.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function qC(e,t,n,r=""){var c,u;const s=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(d=>String((d==null?void 0:d.id)||"")===s),a=String(((c=o==null?void 0:o.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[s])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function UC(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 CJ(e,t,n){var d,f;const r=String(((d=e==null?void 0:e.data)==null?void 0:d.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=Wd.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?[]:po(t==null?void 0:t.images),inputs:UC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:UC(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const p of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[p])??"").trim();h?c[p]=h:delete c[p]}return c}function YC({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(!TU.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=CJ(r,s,c),d=r.data||{};if(!(c!==a||d.label!==u.label||d.role!==u.role||d.model!==u.model||d.body!==u.body||JSON.stringify(po(d.images))!==JSON.stringify(u.images)||(d.script??void 0)!==(u.script??void 0)||(d.scriptRef??void 0)!==(u.scriptRef??void 0)||(d.implementationRef??void 0)!==(u.implementationRef??void 0)||(d.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(d.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(d.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let h=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,h=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:h,instances:y}}function _J(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function EJ(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"])_J(e[s],t[s])&&(r[s]=n[s]);return r}function mb(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var N,j;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(j=(N=d.currentTarget).setPointerCapture)==null||j.call(N,g);const k=C=>{C.preventDefault(),l(c(C.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:s,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function AJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=Array.isArray(s)?s:[],d=Array.isArray(o)?o:[],[f,p]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,N]=m.useState({visible:!1,top:0,height:100}),j=m.useMemo(()=>new Set(bJ(t)),[t]),C=m.useMemo(()=>new Map(u.map(L=>[L.key,L])),[u]),P=m.useMemo(()=>Array.from(j).map(L=>{var T;return((T=C.get(L))==null?void 0:T.name)||L}),[C,j]),I=m.useMemo(()=>aM(P,"选择 Skills"),[P]),F=m.useMemo(()=>{const L=new Set,T=d.map(E=>{const Q=Qo(E,u).map(V=>C.get(V)).filter(Boolean);for(const V of Q)L.add(V.key);return{...E,skills:Q}}).filter(E=>E.skills.length>0),W=u.filter(E=>!L.has(E.key));return{collectionGroups:T,ungrouped:W}},[C,d,u]);m.useEffect(()=>{b(L=>{let T=!1;const W=new Set(L);for(const E of F.collectionGroups)W.has(E.id)||(W.add(E.id),T=!0);return T?W:L})},[F.collectionGroups]);const $=m.useMemo(()=>{const L=h.trim().toLowerCase();if(!L)return F;const T=E=>[E==null?void 0:E.key,E==null?void 0:E.name,E==null?void 0:E.description].map(V=>String(V||"").toLowerCase()).join(" ").includes(L);return{collectionGroups:F.collectionGroups.map(E=>{const V=[E==null?void 0:E.id,E==null?void 0:E.name,E==null?void 0:E.description].map(B=>String(B||"").toLowerCase()).join(" ").includes(L)?E.skills:E.skills.filter(T);return{...E,skills:V}}).filter(E=>E.skills.length>0),ungrouped:F.ungrouped.filter(T)}},[F,h]),D=m.useCallback((L,T)=>{const W=new Set(j);for(const E of L)T?W.add(E):W.delete(E);a==null||a(e,Array.from(W))},[e,j,a]),z=m.useCallback(L=>{b(T=>{const W=new Set(T);return W.has(L)?W.delete(L):W.add(L),W})},[]),O=m.useCallback(()=>{const L=g.current;if(!L)return;const T=Math.max(1,L.scrollHeight),W=Math.max(1,L.clientHeight),E=T>W+1,Q=E?Math.max(12,W/T*100):100,V=Math.max(0,100-Q),B=E?Math.min(V,L.scrollTop/Math.max(1,T-W)*V):0;N({visible:E,top:B,height:Q})},[]);m.useEffect(()=>{if(!f)return;const L=requestAnimationFrame(O);return()=>cancelAnimationFrame(L)},[v,$,j.size,f,O]);const M=m.useCallback(L=>{const T=g.current;if(!T)return;const W=Math.max(0,T.scrollHeight-T.clientHeight);T.scrollTop=Math.min(1,Math.max(0,L))*W,O()},[O]),K=m.useCallback((L,T=0)=>{const W=k.current;if(!W)return 0;const E=W.getBoundingClientRect(),Q=x.height/100*E.height,V=Math.max(1,E.height-Q);return(L-E.top-T)/V},[x.height]),H=m.useCallback(L=>{var ee,te;if(!x.visible)return;L.preventDefault(),L.stopPropagation();const T=k.current;if(!T)return;const W=T.getBoundingClientRect(),E=x.top/100*W.height,Q=x.height/100*W.height,B=L.clientY>=W.top+E&&L.clientY<=W.top+E+Q?L.clientY-W.top-E:Q/2;M(K(L.clientY,B));const se=L.pointerId;(te=(ee=L.currentTarget).setPointerCapture)==null||te.call(ee,se);const ue=ne=>{ne.preventDefault(),M(K(ne.clientY,B))},G=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)},[K,M,x.height,x.top,x.visible]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((L,T)=>{if(L.showOnNode===!1)return null;const W=`${2.6+T*1.7}rem`,E=L.name||`#${T+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:W},children:E}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${T}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:W,background:Tn(L.type)},title:`${E} · ${L.type}`})]},`in-${T}`)}),c.map((L,T)=>{if(L.showOnNode===!1)return null;const W=`${2.6+T*1.7}rem`,E=L.name||`#${T+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:W},children:E}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${T}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:W,background:Tn(L.type)},title:`${E} · ${L.type}`})]},`out-${T}`)}),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:L=>{var T;L.stopPropagation(),f||(T=t==null?void 0:t.onRefreshSkills)==null||T.call(t),p(W=>!W)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:I.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:I.head}),I.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:I.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:L=>L.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:L=>y(L.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:[$.collectionGroups.map(L=>{const T=L.skills.map(V=>V.key),W=T.filter(V=>j.has(V)).length,E=T.length>0&&W===T.length,Q=v.has(L.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Q?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:E,onChange:V=>D(T,V.target.checked),"aria-label":`选择 ${L.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>z(L.id),"aria-expanded":!Q,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:L.name}),L.description?i.jsx("em",{children:L.description}):null]})}),i.jsxs("small",{children:[W,"/",T.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>z(L.id),"aria-label":Q?`展开 ${L.name}`:`收起 ${L.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:L.skills.map(V=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:j.has(V.key),onChange:B=>D([V.key],B.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:V.name}),V.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:V.description}):null]})]},`${L.id}:${V.key}`))})]},L.id)}),$.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:$.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:$.ungrouped.map(L=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:j.has(L.key),onChange:T=>D([L.key],T.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:L.name}),L.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:L.description}):null]})]},`ungrouped:${L.key}`))})]}):null,$.collectionGroups.length===0&&$.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),i.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:H,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function PJ({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=m.useState(!1),[d,f]=m.useState(""),p=m.useMemo(()=>new Set(SJ(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[s]),y=m.useMemo(()=>{const b=d.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[d,h]),v=m.useCallback((b,g)=>{const k=new Set(p);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,p,o]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Tn(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(Gn,{type:"source",position:qe.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Tn(b.type)},title:`${x} · ${b.type}`})]},`out-${g}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"hub"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:b=>{var g;b.stopPropagation(),c||(g=t==null?void 0:t.onRefreshMcps)==null||g.call(t),u(k=>!k)},children:[i.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:b=>b.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:d,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),d?i.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{className:"af-work-load-skills-menu",children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"MCP Servers"}),i.jsx("small",{children:y.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:y.map(b=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:p.has(b.name),onChange:g=>v([b.name],g.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:b.name}),b.description||b.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),y.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function IJ({id:e,data:t,selected:n,deleteNode:r,workspaces:s=[],onChangeWorkspace:o,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,d]=m.useState(!1),[f,p]=m.useState(""),h=jJ(t),y=m.useMemo(()=>(Array.isArray(s)?s:[]).map(j=>({id:String((j==null?void 0:j.id)||""),label:String((j==null?void 0:j.label)||(j==null?void 0:j.name)||"知识库"),kind:(j==null?void 0:j.kind)==="git"?"git":"local",path:String((j==null?void 0:j.path)||""),repoUrl:String((j==null?void 0:j.repoUrl)||""),branch:String((j==null?void 0:j.branch)||""),mountPath:String((j==null?void 0:j.mountPath)||""),builtin:(j==null?void 0:j.builtin)===!0,exists:(j==null?void 0:j.exists)!==!1})).filter(j=>j.path),[s]),v=m.useMemo(()=>{const j=f.trim().toLowerCase();return j?y.filter(C=>[C.id,C.label,C.path,C.repoUrl,C.branch,C.mountPath].join(" ").toLowerCase().includes(j)):y},[f,y]),b=m.useMemo(()=>new Set((h.sources||[]).map(j=>j.id||j.path||j.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(j=>j.label||j.id||j.mountPath||j.path),[h.sources]),k=m.useMemo(()=>aM(g,"选择知识库"),[g]),x=mb(u,[v.length,g.length,f]),N=(j,C)=>{const P=(j==null?void 0:j.id)||(j==null?void 0:j.path)||"",I=y.filter(F=>{const $=F.id||F.path||"";return $===P?C:b.has($)});o==null||o(e,I)};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((j,C)=>{if(j.showOnNode===!1)return null;const P=`${2.6+C*1.7}rem`,I=j.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:P},children:I}),i.jsx(Gn,{type:"target",position:qe.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:P,background:Tn(j.type)},title:`${I} · ${j.type}`})]},`in-${C}`)}),c.map((j,C)=>{if(j.showOnNode===!1)return null;const P=`${2.6+C*1.7}rem`,I=j.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:P},children:I}),i.jsx(Gn,{type:"source",position:qe.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:P,background:Tn(j.type)},title:`${I} · ${j.type}`})]},`out-${C}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:j=>{j.stopPropagation(),u||a==null||a(),d(C=>!C)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:k.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:k.head}),k.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:k.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:j=>j.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:j=>p(j.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?i.jsx("button",{type:"button",onClick:()=>p(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"知识库"}),i.jsx("small",{children:v.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:v.map(j=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:b.has(j.id||j.path),onChange:C=>N(j,C.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:j.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[j.kind==="git"&&j.repoUrl?`${j.repoUrl}${j.branch?` · ${j.branch}`:""}${j.mountPath?` · ${j.mountPath}`:""}`:j.path,j.exists?"":" · 路径未就绪"]})]})]},`${j.id}:${j.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 pM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=vT(r),o=VU(rG(r)),a=s?o.filter(p=>!["issue","mr"].includes(sm(p))):o,l=qU(r,o),c=_i(r,t),u=s?"":Ta(r.platform),d=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,s&&d?`${d} 个端侧 Issue`:u,r.status].filter(Boolean);return i.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${s?" af-prd-workflow-issue--aggregate":""}`,children:[i.jsx("strong",{children:eG(r,t)}),i.jsx("small",{children:f.join(" · ")}),i.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[i.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?i.jsx("small",{children:l.detail}):null]}),a.length?i.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(p=>i.jsx("a",{href:p.href,target:"_blank",rel:"noreferrer",children:p.label},`${p.label}-${p.href}`))}):null,d?i.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((p,h)=>i.jsx(pM,{row:p,index:h,child:!0},_i((p==null?void 0:p.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 mM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>hM(n)).filter(Boolean)}function RJ({fieldKey:e,field:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=String(t.label||e||"").trim(),r=String(t.type||"text").trim().toLowerCase(),s=["text","user","chips","list","link"].includes(r)?r:"text",o=mM(t.value);if(!o.length)return null;if(s==="list")return i.jsxs("div",{className:"af-prd-overall-platform__rules",children:[i.jsx("small",{children:n}),i.jsx("ul",{children:o.map((a,l)=>i.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(s==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=String(t.href||t.url||a.href||a.url||"").trim();return i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[i.jsx("small",{children:n}),l?i.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:o[0]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o[0]})]})}return i.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${s}`,children:[i.jsx("small",{children:n}),i.jsx("div",{children:o.map((a,l)=>i.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function TJ({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,o])=>o&&typeof o=="object"&&mM(o.value).length);if(!r.length)return null;const s=e==="progress";return i.jsxs("section",{className:`af-prd-overall-platform${s?" af-prd-overall-platform--compact":""}`,children:[i.jsx("div",{className:"af-prd-overall-platform__head",children:i.jsx("strong",{children:String(t.title||e||"").trim()})}),i.jsx("div",{className:"af-prd-overall-platform__fields",children:r.map(([o,a])=>i.jsx(RJ,{fieldKey:o,field:a},o))})]})}function MJ({globalState:e,tapdId:t}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n.workflow&&typeof n.workflow=="object"&&!Array.isArray(n.workflow)?n.workflow:{},s=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},o=String(n.title||"").trim(),a=String(n.url||"").trim(),l=hM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([f,p])=>f&&p&&typeof p=="object"&&!Array.isArray(p)),d=!!(o||a||l||u.length);return!c&&!d?null:i.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"需求概览"}),l?i.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),o||a||c?i.jsx("div",{className:"af-prd-overall__requirement",children:a?i.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[i.jsx("strong",{children:o||`${r.namespace||"Workflow"} ${c}`}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,d?i.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,p])=>i.jsx(TJ,{sectionKey:f,section:p},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function $J({flowParams:e={},tapdId:t,setTapdId:n,snapshot:r,loading:s,error:o,actionRunning:a,actionOutput:l,pendingConfirm:c,conflict:u,reviewPublishing:d,onRefresh:f,onRunDryRun:p,onConfirmAction:h,onRetryConflict:y,onPublishReview:v}){const[b,g]=m.useState("all"),[k,x]=m.useState("all"),[N,j]=m.useState(!1),[C,P]=m.useState(!1),[I,F]=m.useState(!1),[$,D]=m.useState(""),[z,O]=m.useState(!1),[M,K]=m.useState(""),[H,L]=m.useState(null),T=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),W=Array.isArray(r==null?void 0:r.issues)?r.issues:[],E=sG(r),Q=E.reduce((xe,Fe)=>xe+sb(Fe.issues),0),V=Array.isArray(r==null?void 0:r.artifacts)?r.artifacts:[];Array.isArray(r==null?void 0:r.optionalGaps)&&r.optionalGaps;const B=r!=null&&r.nextAction&&typeof r.nextAction=="object"?r.nextAction:null,se=lG(r,B),ue=QY(r,se),G=V.filter(xe=>!NT({...xe,href:hc(xe)})),ee=m.useMemo(()=>GY(se),[se]);m.useEffect(()=>{k!=="all"&&(ee.some(xe=>xe.key===k)||x("all"))},[k,ee]);const te=se.filter(xe=>JY(xe,k)),ne=UY(te),Z=cG(r),ce=Z.filter(xe=>uG(xe,b)),de=te.filter(xe=>dv(xe)).length,me=r!=null&&r.collaboration&&typeof r.collaboration=="object"?r.collaboration:{},$e=me.activeAction&&typeof me.activeAction=="object"?me.activeAction:null;Array.isArray(r==null?void 0:r.clientObservations)&&r.clientObservations;const Ce=String((r==null?void 0:r.rawOutput)||""),_e=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,Be=FY(T),ot=m.useCallback(async()=>{const xe=String(t||"").trim();if(!xe){L(null);return}P(!0),D(""),K("");try{const Fe=new URLSearchParams({tapdId:xe});e.workflowShare&&Fe.set("workflowShare",e.workflowShare);const lt=await fetch(`/api/prd-workflow/share?${Fe.toString()}`),oe=await lt.json().catch(()=>({}));if(!lt.ok)throw new Error(oe.error||"读取 Workflow 分享状态失败");let ke=oe.share||null;const Ke=oe.canCreate===!0&&!e.workflowShare;if(O(Ke),!ke&&Ke){const Ue=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:xe})}),be=await Ue.json().catch(()=>({}));if(!Ue.ok)throw new Error(be.error||"生成 Workflow 分享链接失败");ke=be.share||null}L(ke)}catch(Fe){D(String(Fe.message||Fe))}finally{P(!1)}},[e,t]),yt=()=>{j(!0),ot()},Te=async()=>{if(!(!t||I||e.workflowShare)){F(!0),D(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),Fe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Fe.error||"生成 Workflow 分享链接失败");L(Fe.share||null),O(!0)}catch(xe){D(String(xe.message||xe))}finally{F(!1)}}},st=async()=>{const xe=await pb((H==null?void 0:H.url)||"");K(xe?"已复制":"复制失败")},gt=async()=>{if(!(!t||I||!(H!=null&&H.canManage))){F(!0),D(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),Fe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Fe.error||"取消 Workflow 分享链接失败");L(null),O(!0)}catch(xe){D(String(xe.message||xe))}finally{F(!1)}}};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--${T.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:SC(T)}),i.jsx("h1",{children:(r==null?void 0:r.pointer)||(t?"等待 prd-flow 返回状态":"选择 TAPD 需求后读取状态")}),i.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?i.jsxs(i.Fragment,{children:["TAPD ",i.jsx("strong",{children:t})," · 独立需求 Workflow"]}):i.jsx(i.Fragment,{children:"尚未选择 TAPD 需求"})}),o?i.jsx("p",{className:"af-prd-workflow-error",children:o}):null,$e||me.subscribers?i.jsxs("div",{className:"af-prd-workflow-collab",children:[$e?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),$e.title||$e.action||"Workflow action"," 执行中",$e.userId?i.jsx("small",{children:$e.userId}):null]}):null,me.subscribers?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),me.subscribers," 个连接"]}):null]}):null]}),i.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:xe=>{xe.preventDefault(),f==null||f()},children:[i.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:Be.map(xe=>i.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${xe.status}`,children:[i.jsx("span",{"aria-hidden":"true"}),i.jsx("small",{children:xe.label})]},xe.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:xe=>n(xe.target.value),placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),i.jsxs("button",{type:"submit",disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"hourglass_empty":"sync"}),s?"读取中":t?"刷新":"读取"]}),i.jsxs("button",{type:"button",disabled:!t,onClick:yt,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享"]})]})]})]}),u?i.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[i.jsxs("div",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),i.jsxs("div",{children:[i.jsx("strong",{children:"状态已变化,需要重新确认"}),i.jsx("p",{children:u.message||"当前 workflow 状态和执行前不一致。"})]})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"执行时 revision"}),i.jsx("dd",{children:u.expectedRevision||"空"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前 revision"}),i.jsx("dd",{children:u.currentRevision||"未知"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前状态"}),i.jsx("dd",{children:[SC(u.currentPhase),u.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),i.jsx("div",{className:"af-prd-workflow-conflict__actions",children:i.jsx("button",{type:"button",onClick:()=>f==null?void 0:f(),disabled:s||a,children:"刷新状态"})})]}):null,i.jsxs("section",{className:"af-prd-workflow__main",children:[i.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[i.jsxs("div",{className:"af-prd-workflow-actions__head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Action 时间线"}),i.jsx("p",{children:se.length?`${de}/${te.length} 已完成${k!=="all"?` · 共 ${se.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),B&&Yd(B)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:B.command||to(B,0)})]}):null]}),ee.length?i.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[i.jsxs("button",{type:"button",className:k==="all"?"is-active":"","aria-pressed":k==="all",onClick:()=>x("all"),children:["全部 ",i.jsx("span",{children:se.length})]}),ee.map(xe=>i.jsxs("button",{type:"button",className:k===xe.key?"is-active":"","aria-pressed":k===xe.key,onClick:()=>x(xe.key),children:[xe.label," ",i.jsx("span",{children:xe.count})]},xe.key))]}):null,i.jsx("div",{className:"af-prd-workflow-action-list",children:te.length?ne.map(xe=>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:xe.day}),i.jsx("small",{children:"北京时间"})]}),i.jsx("div",{className:"af-prd-workflow-action-day__items",children:xe.items.map(({item:Fe,index:lt})=>{const oe=ca(Fe.status),ke=Zo(Fe)==="observation"&&oe==="done"?"observed":oe,Ke=pv(Fe),Ue=qY(Fe),be=XY(Fe),Ht=BY(Fe,lt),Qt=HY(Fe);return i.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${ke}`,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:[Ue?i.jsx("time",{dateTime:um(Fe),children:Ue}):null,i.jsx("strong",{children:Ht})]}),Qt?i.jsx("p",{children:Qt}):null,be.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:be.map(jt=>i.jsxs("span",{children:[i.jsx("b",{children:jt.label}),jt.value]},`${jt.label}-${jt.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:YY(Fe)})]}),Ke.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Ke.map(jt=>i.jsxs("a",{href:jt.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:jt.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${jt.label}-${jt.href}`))}):null]})]},Fe.id||Fe.actionId||`${to(Fe,lt)}-${lt}`)})})]},xe.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(MJ,{globalState:_e,tapdId:t}),G.length?i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:G.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:G.map((xe,Fe)=>{const lt=hc(xe),oe=String(xe.label||xe.title||xe.kind||lt||`Artifact ${Fe+1}`);return lt?i.jsxs("a",{href:lt,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:oe}),i.jsx("small",{children:xe.kind||lt})]},`${lt}-${Fe}`):i.jsxs("div",{children:[i.jsx("span",{children:oe}),i.jsx("small",{children:xe.kind||""})]},`${oe}-${Fe}`)})})]}):null,i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"AI Docs"}),i.jsx("span",{children:ue.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:ue.length?ue.map(xe=>{const Fe=String(xe.title||xe.label||"ai-doc").trim(),lt=[xe.label&&xe.label!==Fe?xe.label:"",xe.platform,xe.issueKey].filter(Boolean);return i.jsxs("a",{className:"af-prd-ai-doc",href:xe.href,target:"_blank",rel:"noreferrer",title:Fe,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:Fe}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:lt.join(" · ")||xe.kind||"ai-doc"})]},xe.href)}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"Issues"}),i.jsx("span",{children:Q||W.length})]}),i.jsx("div",{className:"af-prd-workflow-issues",children:E.length?E.map(xe=>i.jsxs("div",{className:"af-prd-workflow-epic",children:[i.jsxs("div",{className:"af-prd-workflow-epic__head",children:[i.jsx("strong",{children:xe.title||xe.key}),i.jsx("small",{children:sb(xe.issues)})]}),xe.issues.map((Fe,lt)=>i.jsx(pM,{row:Fe,index:lt},_i((Fe==null?void 0:Fe.issue)||{},lt)))]},xe.key)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"运行审计"}),i.jsxs("span",{children:[ce.length,"/",Z.length]})]}),i.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([xe,Fe])=>i.jsx("button",{type:"button",className:b===xe?"is-active":"",onClick:()=>g(xe),children:Fe},xe))}),i.jsx("div",{className:"af-prd-workflow-audit",children:ce.length?ce.map((xe,Fe)=>i.jsxs("div",{children:[i.jsx("strong",{children:to(xe,Fe)}),i.jsx("small",{children:[xe.status,xe.type,um(xe)].filter(Boolean).join(" · ")})]},xe.id||`${xe.type}-${Fe}`)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Ce||l?i.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[i.jsx("div",{className:"af-prd-workflow-card__head",children:i.jsx("h2",{children:"Raw"})}),i.jsx("pre",{children:l||Ce})]}):null]})]}),N?cr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"分享需求 Workflow",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享需求 Workflow"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>j(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("p",{className:"af-display-link-modal__empty",children:["通过只读链接分享 TAPD ",t," 的需求流程;不会分享当前 Project、画布或项目文件。"]}),C?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!C&&(H!=null&&H.url)?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:H.url,readOnly:!0,onFocus:xe=>xe.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:I,onClick:()=>void st(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),H.canManage?i.jsx("button",{type:"button",disabled:I,onClick:()=>void gt(),children:I?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的 AgentFlow 用户可以只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!C&&!(H!=null&&H.url)&&z?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:I,onClick:()=>void Te(),children:I?"生成中...":"生成分享链接"}):null,$?i.jsx("div",{className:"af-flow-snippet-error",children:$}):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:()=>j(!1),children:"完成"})})]})}),document.body):null]})}function GC(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 Ru(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function LJ(e,t,n,r=!0){const s=JSON.parse(JSON.stringify(e||{})),o=Array.isArray(t)?t:[];if(!o.length)return r?n:{};let a=s;for(let c=0;c<o.length-1;c+=1){const u=o[c],d=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(d)?[]:{}),a=a[u]}const l=o[o.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],s}function OJ(){var b0,k0,v0;const{t:e,i18n:t}=Fr(),{navigate:n}=si(),r=Fc(),s=gn(),o=IW(),a=m.useMemo(CY,[]),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.flowId||""}`,[a]),[d,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=RW([]),[k,x]=TW([]),N=m.useRef([]),j=m.useRef([]),C=m.useRef(null),[P,I]=m.useState(()=>hh(null,[])),F=m.useRef(P),[$,D]=m.useState(null),z=m.useRef(null),O=m.useRef(!1),[M,K]=m.useState([]),H=m.useRef(new Map),L=m.useRef(new Map),T=m.useRef(new Set),W=m.useRef(new Set),E=m.useRef(null),Q=m.useRef(null),V=m.useRef([]),B=m.useRef(null),se=m.useRef(null),ue=m.useRef(null),[G,ee]=m.useState(null),[te,ne]=m.useState({}),Z=m.useRef({}),ce=m.useRef(!1),de=m.useRef(null),me=m.useRef(""),$e=m.useRef(null),Ce=m.useRef(Promise.resolve()),_e=m.useRef({running:!1,pending:null}),Be=m.useRef(0),ot=m.useRef(!1),yt=m.useRef(0),Te=m.useRef(null),st=m.useRef(!1),gt=m.useRef(!1),xe=m.useRef(""),Fe=m.useRef(!1),lt=m.useRef(!1),oe=m.useRef(!1),ke=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Ke=m.useRef(!1),Ue=m.useRef(null),[be,Ht]=m.useState([]),Qt=m.useRef([]),[jt,yn]=m.useState(""),[on,re]=m.useState("nodes"),[Re,Je]=m.useState([]),[Ze,Tt]=m.useState(!1),[At,Vn]=m.useState(""),[Sn,xr]=m.useState(!1),[wn,Xn]=m.useState({name:"",id:"",description:""}),[Kn,hr]=m.useState(!1),[ts,Ar]=m.useState(""),[gs,ys]=m.useState(""),cn=m.useRef(null),[rr,Pr]=m.useState(!1),[dn,Qn]=m.useState(!1),[br,sr]=m.useState(""),[Ct,Gt]=m.useState(null),[_t,le]=m.useState(()=>lw()),[ve,it]=m.useState(""),[Dt,Jt]=m.useState(!1),[tn,Zn]=m.useState(""),[mt,nn]=m.useState(!1),[Wt,kr]=m.useState([]),[tt,Ln]=m.useState(!1),[$i,zr]=m.useState(""),[mo,ai]=m.useState(""),[Ts,ie]=m.useState(""),[Se,Pe]=m.useState(!1),[xt,Lt]=m.useState(""),[qt,zn]=m.useState(""),[On,q]=m.useState(!1),[pe,Oe]=m.useState("nodes"),[Ee,et]=m.useState(""),[Nn,kt]=m.useState(0),[Ut,jn]=m.useState(""),go=m.useRef(""),[at,ws]=m.useState(null),Rv=m.useRef(null),[l$,al]=m.useState(""),[ll,Tv]=m.useState([]),[Mv,c$]=m.useState(""),[je,u$]=m.useState(!0),[an,gg]=m.useState(null),[d$,yg]=m.useState(!1),[wg,$v]=m.useState(!1),[Lv,Yc]=m.useState(""),[Gc,Ov]=m.useState(""),[Dv,Fv]=m.useState(""),[En,cl]=m.useState(null),[f$,ua]=m.useState(!1),[xg,ul]=m.useState({}),[vf,zv]=m.useState(!1),[Bv,Jc]=m.useState(""),[bg,p$]=m.useState(""),[h$,dl]=m.useState(()=>new Set),[kg,vg]=m.useState(""),[Xc,Sg]=m.useState({nodeId:"",query:""}),[Hv,Wv]=m.useState(!1),Ng=m.useRef(null),Vv=m.useRef(null),Kv=m.useRef(""),[jg,qv]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[m$,Uv]=m.useState(!1),[da,g$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Li,y$]=m.useState(""),[Ms,w$]=m.useState([]),[Yv,Gv]=m.useState(!1),[$s,Qc]=m.useState([]),[fl,x$]=m.useState([]),[Jv,b$]=m.useState(!1),[Xv,Qv]=m.useState([]),[Zv,eS]=m.useState([]),[ir,k$]=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""}}),[ln,Sf]=m.useState(null),[v$,tS]=m.useState(!1),[S$,pl]=m.useState(""),[Cg,nS]=m.useState(!1),[_g,Nf]=m.useState(""),[xs,jf]=m.useState(null),[Eg,rS]=m.useState(!1),[Zc,eu]=m.useState(null),sS=m.useCallback(w=>{cn.current&&window.clearTimeout(cn.current),ys(w),cn.current=window.setTimeout(()=>{ys(""),cn.current=null},3800)},[]),Br=m.useCallback(w=>{const S=Array.isArray(w)||w instanceof Set?w:[w];for(const _ of S){const A=String(_||"").trim();A&&(T.current.add(A),W.current.add(A))}T.current.size!==0&&(E.current==null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const _=Array.from(T.current);T.current.clear(),_.forEach(A=>o(A))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const _=Array.from(W.current);W.current.clear(),_.forEach(A=>o(A))},80))},[o]);m.useEffect(()=>()=>{E.current!=null&&window.cancelAnimationFrame(E.current),Q.current!=null&&window.clearTimeout(Q.current),T.current.clear(),W.current.clear()},[]);const iS=m.useCallback((w,S)=>{const _=String(w||"").trim(),A=mm(S);!_||!A||(g(R=>R.map(U=>{var ae;if(U.id!==_)return U;const X=mm((ae=U.data)==null?void 0:ae.displaySize),J=X&&X.width===A.width&&X.height===A.height,Y=Math.round(Number(U.width||0))===A.width&&Math.round(Number(U.height||0))===A.height;return J&&Y?U:{...U,width:A.width,height:A.height,data:{...U.data,nodeSize:A,displaySize:A}}})),Br(_))},[Br,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(jg)))}catch{}},[jg]);const Ag=m.useCallback(w=>{const S=Ng.current;if(!S)return null;const _=S.getBoundingClientRect(),A=16,R=150,U=230,X=_.top+A,J=_.bottom-A,Y=Math.max(R,J-X-U);return Math.min(Math.max(w-X,R),Y)},[]),N$=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const S=Ng.current;if(!S)return;let _=Ag(w.clientY);if(!Number.isFinite(_))return;Uv(!0),qv(_);const A=U=>{U.preventDefault();const X=Ag(U.clientY);Number.isFinite(X)&&(_=X,S.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},R=()=>{qv(_),Uv(!1),window.removeEventListener("pointermove",A,!0),window.removeEventListener("pointerup",R,!0),window.removeEventListener("pointercancel",R,!0)};window.addEventListener("pointermove",A,!0),window.addEventListener("pointerup",R,!0),window.addEventListener("pointercancel",R,!0)},[Ag]);m.useEffect(()=>()=>{cn.current&&window.clearTimeout(cn.current),Ue.current&&window.clearTimeout(Ue.current)},[]);const[j$,oS]=m.useState(()=>new Set),[Cf,Pg]=m.useState(!1),Ig=m.useRef(null),aS=m.useRef(null),lS=m.useRef(null),[C$,_$]=m.useState({}),[fa,Rg]=m.useState(""),[ns,cS]=m.useState(!1),[pa,hl]=m.useState([]),[Ls,qn]=m.useState([]),[Hr,bs]=m.useState("workspace"),[tu,ml]=m.useState(!1),uS=m.useRef(null),Tg=m.useRef(null),[nu,gl]=m.useState(null),[E$,Mg]=m.useState(!0),[dS,fS]=m.useState(""),[ha,yo]=m.useState({}),[Ir,pS]=m.useState(null),[hS,mS]=m.useState(!1),yl=m.useMemo(()=>hS?IY(Ir):"",[hS,Ir]),[ru,_f]=m.useState(!0);m.useEffect(()=>{yl&&_f(RY(yl))},[yl]),m.useEffect(()=>{if(yl)try{window.localStorage.setItem(yl,ru?"true":"false")}catch{}},[ru,yl]);const[$g,Ef]=m.useState(!1),[Lg,gS]=m.useState(!1),[Og,yS]=m.useState("pan"),[wS,A$]=m.useState({}),su=m.useRef({}),[xS,ma]=m.useState({}),iu=m.useRef(new Map),ou=m.useRef(new Set),[bS,wl]=m.useState(()=>new Set),[Dg,xl]=m.useState({}),[kS,vS]=m.useState(""),[bce,ge]=m.useState(""),[SS,Os]=m.useState("loading"),[NS,Ds]=m.useState("正在载入 Project"),Oi=m.useMemo(()=>PY(a),[a]),[jS,CS]=m.useState(""),au=a.flowSource||"user",_S=m.useMemo(()=>new Set(Object.values(wS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[wS]),Di=m.useCallback(w=>{const S=su.current||{},_=typeof w=="function"?w(S):w,A=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return su.current=A,A$(A),A},[]),ES=!!(a.flowId&&!a.archived&&(an!=null&&an.role?an.role==="owner":au==="user"||au==="workspace")),lu=!!(au==="workspace"&&(an!=null&&an.role)&&an.role!=="owner"),AS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[SS]||"同步状态",li=m.useCallback(()=>{!ce.current||!je||(Fe.current=!1,Be.current+=1,ot.current=!0,Os("dirty"),Ds("本地修改等待同步"))},[je]);m.useEffect(()=>{a.flowId&&mF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{hl([]),qn([]),bs("workspace"),Mg(!0)},[a]);const An=m.useCallback(async()=>{const w=Tr(a),S=await fetch(`/api/workspace/files?${w.toString()}`),_=await S.json();if(!S.ok)throw new Error(_.error||"读取 workspace 失败");const A=_.files||[];Tv(A),dl(new Set(rM(A))),c$(_.root||"")},[a]),Af=m.useCallback(async()=>{Tt(!0),Vn("");try{const w=await fetch("/api/marketplace/flow-snippets"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取流程片段失败");Je(Array.isArray(S.snippets)?S.snippets:[])}catch(w){Vn(String(w.message||w)),Je([])}finally{Tt(!1)}},[]),PS=m.useCallback(async(w,S,_)=>{var Y,ae,he;if(!ce.current)return;if(!je)throw ge("Readonly workspace"),Os("readonly"),Ds("只读 Project"),new Error("Readonly workspace");Os("saving"),Ds("正在同步修改");const A=Ml(w,S,Z.current);A.ui={...A.ui||{},displayPage:TC(F.current,w)};const R=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:A,baseRevision:me.current,baseGraph:$e.current,clientId:ke.current})}),U=await R.json().catch(()=>({}));if(!R.ok){if(R.status===409||R.status===428){const Ne=Array.isArray(U.conflictItems)?U.conflictItems:[];cl({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:Ne,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),ul(Object.fromEntries(Ne.map((He,Me)=>[String(Me),{mode:"local",manual:Ru(He)}]))),Jc(""),ua(Ne.length>0),Os("conflict"),Ds(U.error||"存在需要处理的字段冲突");const We=Array.isArray(U.conflictPaths)?U.conflictPaths:[],ze=We.length?`${U.error||"Workspace 已被其他成员更新"}:${We.join("、")}`:U.error||"Workspace 已被其他成员更新",Ve=new Error(ze);throw Ve.code="WORKSPACE_REVISION_CONFLICT",Ve.currentRevision=U.currentRevision||"",Ve}const fe=new Error(U.error||"保存 workspace graph 失败");throw Os("error"),Ds(fe.message),fe}const X=Be.current!==_,J=aY({savedGraph:U.graph,sentGraph:A,savedRevision:U.revision,currentRevision:me.current});if(me.current=J.revision,$e.current=J.graph,!X){if(Z.current=((Y=U.graph)==null?void 0:Y.instances)||A.instances,ne(Z.current),U.merged&&U.graph){const fe=Iu(U.graph,be),Ne=hh((he=(ae=U.graph)==null?void 0:ae.ui)==null?void 0:he.displayPage,fe.nodes);Z.current=fe.instances,ne(fe.instances),g(fe.nodes),x(fe.edges),F.current=Ne,I(Ne)}ot.current=!1}return ma(Lp(U.workspaceSchedules||[])),cl(null),ua(!1),Os(X?"dirty":"synced"),Ds(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,be,x,g,je]),Zt=m.useCallback((w=b,S=k)=>{const _=_e.current,A={nextNodes:w,nextEdges:S,saveEditVersion:Be.current,waiters:[]},R=new Promise((J,Y)=>{A.waiters.push({resolve:J,reject:Y})});if(_.running)return _.pending=xC(_.pending,A),R;_.running=!0;const U=async()=>{let J=A;for(;J;){_.pending&&(J=xC(J,_.pending),_.pending=null);try{const Y=await PS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ae})=>ae(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Os("error"),Ds(String(Y.message||Y))),J.waiters.forEach(({reject:ae})=>ae(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&_.pending&&(_.pending.waiters.forEach(({reject:ae})=>ae(Y)),_.pending=null)}J=_.pending,_.pending=null}_.running=!1},X=Ce.current.catch(()=>{}).then(U);return Ce.current=X,R},[k,b,PS]),P$=m.useCallback(w=>{var _;const S=(_=w==null?void 0:w.extra)!=null&&_.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Z.current=S,ne(S),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),jn(""),ee(null)},[x,g]),I$=m.useMemo(()=>({instances:te}),[te]),R$=zU({nodes:b,edges:k,extra:I$,enabled:ce.current,onRestore:P$}),{resetHistory:cu,undo:IS,redo:RS}=R$,ks=m.useCallback(async(w={})=>{var Le,Mt;const S=(w==null?void 0:w.background)===!0,_=yt.current+1;yt.current=_;const A=Be.current,R=me.current;S||(ce.current=!1);const U=pY({background:S}),X=Tr(a);let J=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const De=Tr(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()}`),An()]);if(J=await dt.json(),!dt.ok)throw new Error(J.error||"读取节点定义失败");Y=Pt}const ae=await Y.json();if(!Y.ok)throw new Error(ae.error||"读取 workspace graph 失败");const he=oY({background:S,requestId:_,currentRequestId:yt.current,dirty:ot.current,startedEditVersion:A,currentEditVersion:Be.current,startedRevision:R,currentRevision:me.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const fe=S?Qt.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(De=>!gY.has(De.id)),vY,kY,xY,bY,yY,wY];S||(Qt.current=fe,Ht(fe));const Ne=ae.graph||JSON.parse(localStorage.getItem(mY)||"null")||{},We=Iu(Ne,fe),ze=hh((Le=Ne==null?void 0:Ne.ui)==null?void 0:Le.displayPage,We.nodes),Ve=!O.current;let He=z.current;if(Ve){let De=null;try{De=JSON.parse(window.localStorage.getItem(u)||"null")}catch{De=null}He=fb(De)||fb((Mt=Ne==null?void 0:Ne.ui)==null?void 0:Mt.viewport)}const Me=S?nY($e.current,Ne):null;if(S&&(Me!=null&&Me.safe)){const De=Me.nodesChanged?rY(N.current,We.nodes,Me.changedNodeIds):N.current,dt=Me.edgesChanged?sY(j.current,We.edges):j.current,Pt=Me.displayPageChanged||!eo(F.current,ze),_l=Me.nodesChanged||Me.edgesChanged||Pt;if(_l&&(Fe.current=!0),Me.nodesChanged){const ci=iY(Z.current,We.instances,Me.changedNodeIds);Z.current=ci,N.current=De,ne(ci),g(De)}if(Me.edgesChanged&&(j.current=dt,x(dt)),Pt&&(F.current=ze,I(ze)),_l&&cu(De,dt,{instances:Me.nodesChanged?Z.current:We.instances}),Me.nodesChanged||Pt){const ci=new Set(ze.nodeIds);K(wa=>{const xa=wa.filter(Uf=>ci.has(Uf));return xa.length===wa.length?wa:xa})}}else Z.current=We.instances,N.current=We.nodes,j.current=We.edges,F.current=ze,Fe.current=!0,ne(We.instances),g(We.nodes),x(We.edges),I(ze),K([]),cu(We.nodes,We.edges,{instances:We.instances});const Ft=Lp(ae.workspaceSchedules||[]);ma(De=>eo(De,Ft)?De:Ft),me.current=String(ae.revision||""),$e.current=Ne,ot.current=!1;const rt=ae.collaboration||null;gg(De=>eo(De,rt)?De:rt),cl(null),Ve&&(D(He),z.current=He,O.current=!0);const Ye=ae.writable!==!1;return u$(Ye),ge(Ye?"Workspace ready":"Readonly workspace"),Os(Ye?"synced":"readonly"),Ds(Ye?"所有修改已同步":"只读 Project"),ce.current=!0,{skipped:!1}},[a,t.language,An,cu,x,g,u]),Pf=m.useCallback((w={})=>{if(!ce.current)return;const S=String(w.revision||""),_=w.type==="graph.committed",A=!!(Te.current||st.current||gt.current);if(hY({eventType:w.type,revision:S,currentRevision:me.current,targetRevision:xe.current,refreshPending:A}))return;if(_&&S&&(xe.current=S),ot.current){gt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(gt.current=!0,Te.current||st.current)return;const R=async()=>{if(Te.current=null,lt.current){gt.current=!0,Te.current=window.setTimeout(R,80);return}if(ot.current){gt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}gt.current=!1,st.current=!0;try{await ks({background:!0}),xe.current=me.current}catch(U){xe.current="",ge(String(U.message||U))}finally{st.current=!1,gt.current&&!ot.current&&(Te.current=window.setTimeout(R,40))}};Te.current=window.setTimeout(R,40)},[ks]),uu=m.useCallback(async(w=ir)=>{const S=String(w||"").trim();tS(!0),pl("");try{const _=Tr(a);_.set("tapdId",S),_.set("runtimeOnly","1");const A=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),R=await A.json().catch(()=>({}));if(!A.ok)throw new Error(R.error||"读取 PRD Workflow 失败");Sf(R.snapshot||null),Nf(""),jf(null),eu(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;S?window.localStorage.setItem(U,S):window.localStorage.removeItem(U)}catch{}}catch(_){pl(String(_.message||_))}finally{tS(!1)}},[a,ir]),bl=m.useCallback(async(w=null,S={})=>{const _=w&&typeof w=="object"?w:ln==null?void 0:ln.nextAction,A=Yd(_);if(!A||Cg)return;const R=(S==null?void 0:S.confirm)===!0,U=String((S==null?void 0:S.expectedRevision)||(ln==null?void 0:ln.revision)||"");nS(!0),pl(""),R||(Nf(""),jf(null),eu(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:ir,action:A,stage:el(_),title:to(_,0),...ZY(_),dryRun:!R,confirm:R,issueKey:_.issueKey||_.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&Sf(J.snapshot),J.conflict&&eu({...J.conflict,action:_}),new Error(J.error||"执行 PRD Workflow action 失败");Nf(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),Sf(J.snapshot||ln),eu(null),jf(R?null:{action:_,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){pl(String(X.message||X))}finally{nS(!1)}},[a,Cg,ln,ir]),T$=m.useCallback((w=null)=>bl(w,{confirm:!1}),[bl]),M$=m.useCallback(()=>{const w=(xs==null?void 0:xs.action)||(ln==null?void 0:ln.nextAction);return bl(w,{confirm:!0,expectedRevision:(xs==null?void 0:xs.expectedRevision)||""})},[bl,xs,ln]),$$=m.useCallback(()=>{const w=(Zc==null?void 0:Zc.action)||(ln==null?void 0:ln.nextAction);return eu(null),bl(w,{confirm:!1})},[bl,Zc,ln]),L$=m.useCallback(async()=>{var U;const w=String(_g||(ln==null?void 0:ln.rawOutput)||"").trim();if(!w||Eg)return;const S=(xs==null?void 0:xs.action)||(ln==null?void 0:ln.nextAction)||{},_=`Review: ${to(S,0)||(ln==null?void 0:ln.pointer)||ir||"PRD Workflow"}`,A=/^[\[{]/.test(w),R=w.startsWith("#")?w:`# ${_}
|
|
246
|
+
|
|
247
|
+
${A?`\`\`\`json
|
|
248
|
+
${w}
|
|
249
|
+
\`\`\``:w}`;rS(!0),pl("");try{const X=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:ir,title:_,markdown:R,action:Yd(S),stage:el(S),issueKey:S.issueKey||S.issue_key||"",artifactLabel:"临时 Review"})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"生成 Review 链接失败");Sf(J.snapshot||ln);const Y=((U=J.review)==null?void 0:U.url)||"";Y&&Nf(ae=>`${ae||w}
|
|
250
|
+
|
|
251
|
+
Review link: ${Y}`)}catch(X){pl(String(X.message||X))}finally{rS(!1)}},[a,_g,xs,Eg,ln,ir]),O$=m.useCallback(async(w,S)=>{const _={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:S,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},A=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),R=await A.json().catch(()=>({}));if(!A.ok||(R==null?void 0:R.ok)===!1)throw new Error((R==null?void 0:R.error)||"Publish failed");return await ks(),ge(`Published node ${R.definitionId||R.id||_.packageId}`),R},[a,ks]),ga=m.useCallback((w=Ls)=>{const S=Array.isArray(w)?w:[],A=[...S].reverse().find(R=>(R==null?void 0:R.status)==="running"||(R==null?void 0:R.status)==="stopping")||[...S].reverse().find(R=>R==null?void 0:R.id);return String((A==null?void 0:A.id)||"workspace")},[Ls]),D$=m.useCallback(w=>{const S=String(w||"").trim();!S||S==="workspace"||qn(_=>{const A=(Array.isArray(_)?_:[]).filter(R=>R.id!==S);return bs(R=>R===S?ga(A):R),A})},[ga]);m.useCallback((w="")=>{ml(!0),gl(null),ws(null),bs(w||ga())},[ga]);const TS=m.useCallback((w={})=>{gl({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),ml(!1),ws(null),jn("")},[]),Fg=m.useCallback(async(w="")=>{const S=String(w||"").trim();if(!(!S||!je)){vS(S),ge(`Optimizing run: ${S}`);try{await Zt(N.current,j.current);const _=Ml(N.current,j.current,Z.current),A=qC(N.current,Z.current,S,Li),R=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:S,graph:_,model:A})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,J=Iu(X,be);Z.current=J.instances,ne(J.instances),g(J.nodes),x(J.edges),ma(Lp(U.workspaceSchedules||[])),cu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(U.optimized)?U.optimized.length:0;ge(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(_){ge(String(_.message||_))}finally{vS("")}}},[Li,j,a,N,be,cu,Zt,x,g,je]),MS=m.useCallback(async(w="")=>{const S=String(w||"").trim(),_=su.current||{},A=Object.entries(_).find(([Y,ae])=>Y===S||String((ae==null?void 0:ae.runNodeId)||"")===S)||Object.entries(_)[0]||null,R=(A==null?void 0:A[0])||"",U=(A==null?void 0:A[1])||null,X=String((U==null?void 0:U.runNodeId)||S||"").trim();if((U==null?void 0:U.status)==="stopping")return;const J=new Set([X,...Array.isArray(U==null?void 0:U.plannedNodeIds)?U.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));R&&Di(Y=>{const ae={...Y};return ae[R]&&(ae[R]={...ae[R],status:"stopping"}),ae}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),qn(Y=>Y.map(ae=>(R?ae.id===R:!X||ae.runNodeId===X)&&ae.status==="running"?{...ae,status:"stopping"}:ae));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:R,runNodeId:X})}),ae=await Y.json().catch(()=>({}));if(!Y.ok||(ae==null?void 0:ae.stopped)!==!0)throw new Error(ae.error||"Workspace run stop failed");const he=R?iu.current.get(R):null;he&&(he.abort(),iu.current.delete(R)),R&&Di(fe=>{const Ne={...fe};return delete Ne[R],Ne}),wl(fe=>{const Ne=new Set(fe);for(const We of J)Ne.delete(We);return Ne}),xl(fe=>{var We;const Ne={...fe};for(const ze of J)ze&&(!Ne[ze]||((We=Ne[ze])==null?void 0:We.status)==="running")&&(Ne[ze]={status:"stopped"});return Ne}),ge(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),qn(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&&Di(he=>{const fe={...he};return fe[R]&&(fe[R]={...fe[R],status:"running"}),fe});const ae=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${ae}`),qn(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:`停止失败:${ae}`,at:Date.now()}].slice(-160)}:fe))}},[a,Di]),If=m.useCallback(async()=>{if(a.flowId)try{const w=Tr(a),S=await fetch(`/api/workspace/run/status?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok||!_.running)return;const A=Array.isArray(_.runs)&&_.runs.length?_.runs:[{runId:`run-restored-${_.startedAt||Date.now()}`,runNodeId:_.runNodeId||"",startedAt:_.startedAt||Date.now(),plannedNodeIds:[]}],R={},U=[];for(const X of A){const J=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ae=String((X==null?void 0:X.label)||"").trim()||sw(N.current,Z.current,J,"Workspace Run");R[Y]={id:Y,runNodeId:J,label:ae,status:(X==null?void 0:X.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(X==null?void 0:X.plannedNodeIds)?X.plannedNodeIds:[],startedAt:(X==null?void 0:X.startedAt)||Date.now()},J&&U.push(J)}if(!Object.keys(R).length)return;Di(X=>({...X,...R})),wl(X=>{const J=new Set(X);for(const Y of U)J.add(Y);return J}),xl(X=>{const J={...X};for(const Y of U)J[Y]={status:"running"};return J}),ge(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),qn(X=>{const J=[...X];for(const[Y,ae]of Object.entries(R)){if(J.some(Ne=>Ne.id===Y||["running","stopping"].includes(Ne.status)&&Ne.runNodeId===ae.runNodeId))continue;const he=String(ae.runNodeId||""),fe=String(ae.label||"").trim()||sw(N.current,Z.current,he,"Workspace Run");J.push({id:Y,label:iw(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:ae.status,startedAt:ae.startedAt||Date.now(),steps:he?[{id:he,label:iw(fe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ae.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,N,Di]),$S=m.useCallback(async w=>{if(!je){ge("Readonly workspace");return}if(!w)return;if(Object.values(su.current||{}).find(rt=>String((rt==null?void 0:rt.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let _=N.current,A=j.current,R=Z.current;const U=Rv.current;if(U!=null&&U.id){const rt=_.find(Le=>Le.id===U.id),Ye=YC({nodes:_,edges:A,instances:R,selectedNode:rt,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){al(Ye.error),ge(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,A=Ye.edges,R=Ye.instances,Z.current=R,N.current=_,j.current=A,ne(R),g(_),x(A),Br(Ye.nextId||U.id))}const X=Ml(_,A,R),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=sw(_,R,w,"Workspace Run"),ae=iw(Y,w,"Workspace Run");let he=[w];try{const rt=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:w})}),Ye=await rt.json().catch(()=>({}));if(!rt.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(Mt=>String(Mt||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Le=Ye.conflict||null;if(Le!=null&&Le.runNodeId||Le!=null&&Le.runId){const Mt=Array.isArray(Le.conflictNodeIds)&&Le.conflictNodeIds.length?`: ${Le.conflictNodeIds.join(", ")}`:"";ge(`Run ${w} conflicts with running ${Le.runNodeId||Le.runId}${Mt}`);return}}catch(rt){ge(String(rt.message||rt));return}const fe=new Set(he),Ne=Object.values(su.current||{}).find(rt=>(Array.isArray(rt==null?void 0:rt.plannedNodeIds)?rt.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(Ne){const rt=(Array.isArray(Ne.plannedNodeIds)?Ne.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));ge(`Run ${w} conflicts with running ${Ne.runNodeId||"workspace run"}${rt.length?`: ${rt.join(", ")}`:""}`);return}const We=new AbortController;iu.current.set(J,We),ou.current.delete(J),Di(rt=>({...rt,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),wl(rt=>new Set([...rt,w])),xl(rt=>({...rt,[w]:{status:"running"}})),ge(`Running ${ae}...`),bs(J),qn(rt=>[...rt.slice(-7),{id:J,label:ae,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let ze=w;const Ve=new Map,He=()=>ou.current.has(J),Me=rt=>{const Ye=new Set((rt||[]).map(Le=>String(Le||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),wl(Le=>{const Mt=new Set(Le);for(const De of Ye)Mt.delete(De);return Mt})},Ft=(rt,Ye)=>{const Le=new Set((rt||[]).map(Mt=>String(Mt||"").trim()).filter(Boolean));Le.size||Le.add(String(w||"")),xl(Mt=>{var dt;const De={...Mt};for(const Pt of Le)Pt&&(!De[Pt]||((dt=De[Pt])==null?void 0:dt.status)==="running")&&(De[Pt]={status:Ye});return De})};try{await Zt(_,A);const rt=qC(_,R,w,Li),Ye=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:We.signal,body:JSON.stringify({...a,graph:X,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:me.current,clientId:ke.current,model:rt,selectedSkills:$s,stream:!0})});if(!Ye.ok){const ye=await Ye.json().catch(()=>({}));throw new Error(ye.error||"Workspace run failed")}if(!Ye.body)throw new Error("Workspace run stream unavailable");const Le=Ye.body.getReader(),Mt=new TextDecoder;let De="",dt=[],Pt=[];const _l=(ye,nt)=>{var ct,Et;const Ge=b.find(Ot=>Ot.id===ye),pt=String(((ct=Ge==null?void 0:Ge.data)==null?void 0:ct.label)||ye||"").trim(),we=String(nt||((Et=Ge==null?void 0:Ge.data)==null?void 0:Et.definitionId)||"").trim();return we&&we!==pt?`${pt} (${we})`:pt},ci=(ye,nt,Ge)=>{const pt=String(ye||"").trim();pt&&qn(we=>we.map(ct=>{if(ct.id!==J)return ct;const Ot=[...Array.isArray(ct.steps)?ct.steps:[]],ht=Ot.findIndex(fn=>fn.id===pt),vt={id:pt,label:_l(pt,nt),status:Ge};ht>=0?Ot[ht]={...Ot[ht],...vt}:Ot.push(vt);const un=Ot.map((fn,bo)=>{const Bi=fn.status==="done"?"[done]":fn.status==="failed"?"[failed]":"[running]";return`${bo+1}. ${Bi} ${fn.label}`}).join(`
|
|
252
|
+
`),Yt=Array.isArray(ct.messages)?ct.messages:[],rn=Yt.findIndex(fn=>fn.kind==="run-summary"),xn={role:"assistant",kind:"run-summary",text:un||"准备运行...",at:Date.now()},zt=[...Yt];return rn>=0?zt[rn]=xn:zt.unshift(xn),{...ct,steps:Ot,messages:zt.slice(-160)}}))},wa=(ye,nt)=>{var _0,E0,A0,P0,I0,R0,T0,M0,$0,L0;const Ge=String(ye||"").trim(),pt=String(nt||"").trim();if(!Ge||!pt)return;const we=(_0=Z.current)==null?void 0:_0[Ge];if(!ei(we==null?void 0:we.definitionId))return;const ct=ta(we==null?void 0:we.input,"displayType","markdown"),Et=lM(ct),Ot=cM(Ge),ht=be.find(Rr=>Rr.id===Et),vt=HC(ht==null?void 0:ht.inputs,Et,pt),un=HC(ht==null?void 0:ht.outputs,Et,pt),Yt=String((we==null?void 0:we.label)||Ge||"一键任务").trim(),rn={...Z.current||{},[Ge]:{...we||{},output:VC(we==null?void 0:we.output)},[Ot]:{...((E0=Z.current)==null?void 0:E0[Ot])||{},definitionId:Et,label:Yt,role:"normal",body:pt,input:vt,output:un,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};Z.current=rn,ne(rn);const xn=N.current||[],zt=xn.find(Rr=>Rr.id===Ge),fn=xn.find(Rr=>Rr.id===Ot),bo=Number(((A0=zt==null?void 0:zt.measured)==null?void 0:A0.width)||(zt==null?void 0:zt.width)||((I0=(P0=zt==null?void 0:zt.data)==null?void 0:P0.nodeSize)==null?void 0:I0.width)||520),Bi=(fn==null?void 0:fn.position)||{x:Number(((R0=zt==null?void 0:zt.position)==null?void 0:R0.x)||0)+bo+120,y:Number(((T0=zt==null?void 0:zt.position)==null?void 0:T0.y)||0)},ar=((M0=fn==null?void 0:fn.data)==null?void 0:M0.displaySize)||(($0=fn==null?void 0:fn.data)==null?void 0:$0.nodeSize)||{width:ob,height:ab},ui=rb({id:Ot,type:pc,position:Bi,width:Number(ar.width)||ob,height:Number(ar.height)||ab,data:{label:Yt,definitionId:Et,role:"normal",body:pt,inputs:vt,outputs:un,sourceContextRunNodeId:Ge,displayReloadKey:rn[Ot].displayReloadKey,nodeSize:ar,displaySize:ar}},rn,be),ko=xn.map(Rr=>{if(Rr.id===Ge){const{width:kce,height:vce,measured:Sce,...LL}=Rr,{nodeSize:Nce,displaySize:jce,...Qf}=Rr.data||{};return{...LL,data:{...Qf,outputs:VC(Qf==null?void 0:Qf.outputs),contextRunResultNonce:Date.now()}}}return Rr.id===Ot?{...ui,selected:Rr.selected}:Rr});fn||ko.push(ui),N.current=ko,g(ko);const vo=j.current||[],Xf=uM(Et),Zg=WC((we==null?void 0:we.output)||((L0=zt==null?void 0:zt.data)==null?void 0:L0.outputs),"output",["content","result"],["text"]),ML=WC(vt,"input",[Xf,"content"],["text"]),$L={id:`we-${Ge}-${Ot}`,source:Ge,target:Ot,sourceHandle:Zg,targetHandle:ML,markerEnd:{type:bi.ArrowClosed}},C0=[...vo.filter(Rr=>!(Rr.source===Ge&&Rr.target===Ot)),$L];j.current=C0,x(C0),window.requestAnimationFrame(()=>{o(Ge),o(Ot)})},xa=(ye,nt=null)=>{const Ge=ye!=null&&ye.instances&&typeof ye.instances=="object"?ye.instances:{},pt=nt instanceof Set?nt:null;for(const[we,ct]of Object.entries(Ge)){if(pt&&!pt.has(we)||!ei(ct==null?void 0:ct.definitionId))continue;const Et=lg({outputs:ct.output});Et&&wa(we,Et)}},Uf=ye=>{const nt=String(ye||"").trim();if(!nt)return;const Ge=ze;ze=nt,wl(pt=>{const we=new Set(pt);return Ge&&Ge!==nt&&Ge!==w&&we.delete(Ge),w&&we.add(w),we.add(nt),we}),xl(pt=>{var we;return{...pt,...Ge&&Ge!==nt&&Ge!==w&&((we=pt[Ge])==null?void 0:we.status)==="running"?{[Ge]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},S0=ye=>{const nt=String(ye||"").trim();nt&&(wl(Ge=>{const pt=new Set(Ge);return pt.delete(nt),pt}),xl(Ge=>({...Ge,[nt]:{status:"success"}})))},N0=(ye,nt)=>{const Ge=String(nt||"");if(!Ge.trim())return;const pt=["assistant","thinking","result","error","prompt"].includes(ye)?ye:"assistant";qn(we=>we.map(ct=>{if(ct.id!==J)return ct;let Et=Array.isArray(ct.messages)?ct.messages:[];if(pt==="result"){const vt=[...Et].reverse().find(un=>un.kind==="assistant");if(String((vt==null?void 0:vt.text)||"").trim()===Ge.trim())return ct}if(pt==="assistant"){const vt=Et.findIndex(un=>un.kind==="result"&&String(un.text||"").trim()===Ge.trim());vt>=0&&(Et=Et.filter((un,Yt)=>Yt!==vt))}const Ot=[...Et],ht=Ot[Ot.length-1];return ht&&ht.kind===pt&&!ht.error?Ot[Ot.length-1]={...ht,text:`${ht.text||""}${ht.text?`
|
|
253
|
+
`:""}${Ge}`}:Ot.push({role:"assistant",kind:pt,text:Ge,...pt==="error"?{error:!0}:{},at:Date.now()}),{...ct,messages:Ot.slice(-160)}}))},Yf=ye=>{const nt=String(ye||"");nt.trim()&&qn(Ge=>Ge.map(pt=>{var Ot;if(pt.id!==J)return pt;const we=Array.isArray(pt.messages)?pt.messages:[],ct=we.findIndex(ht=>ht.kind==="thinking"),Et=[...we];if(ct>=0){const ht=String(((Ot=Et[ct])==null?void 0:Ot.text)||"");Et[ct]={...Et[ct],text:`${ht}${ht&&!ht.endsWith(`
|
|
254
|
+
`),""}${nt}`,at:Date.now()}}else{const ht=Et.findIndex(vt=>vt.kind==="activity");Et.splice(ht>=0?ht+1:Et.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...pt,messages:Et.slice(-160)}}))},xo=(ye,nt=null)=>{const Ge=$Y(ye);Ge&&qn(pt=>pt.map(we=>{if(we.id!==J)return we;const ct=Number(nt==null?void 0:nt.ts)||Date.now(),Et=Number(we.startedAt)||ct,Ot=Number(we.lastActivityAt)||Et,ht=Math.max(0,ct-Ot),vt=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,ct-Et),un=Array.isArray(we.activities)?we.activities:[],Yt=un[un.length-1],xn=(typeof Yt=="string"?Yt:String((Yt==null?void 0:Yt.text)||""))===Ge?un:[...un,{text:Ge,kind:OY(Ge),stepMs:ht,totalMs:vt,at:ct}].slice(-30),zt=Array.isArray(we.timingEntries)?we.timingEntries:[],fn=Array.isArray(we.messages)?we.messages:[],bo=fn.findIndex(ui=>ui.kind==="activity"),Bi={role:"assistant",kind:"activity",text:jC(xn,zt,Et,ct),at:Date.now()},ar=[...fn];if(bo>=0)ar[bo]=Bi;else{const ui=ar.findIndex(ko=>ko.kind==="run-summary");ar.splice(ui>=0?ui+1:0,0,Bi)}return{...we,activities:xn,lastActivityAt:ct,messages:ar.slice(-160)}}))},j0=ye=>{const nt=String((ye==null?void 0:ye.source)||"runner"),Ge=String((ye==null?void 0:ye.stream)||""),pt=String((ye==null?void 0:ye.eventType)||"event"),we=String((ye==null?void 0:ye.text)||"").trim();if(!we)return;const ct=`[${nt}${Ge?`:${Ge}`:""}] ${pt}
|
|
255
|
+
${we}`,Et=mG(ye);qn(Ot=>Ot.map(ht=>{if(ht.id!==J)return ht;const un=[...Array.isArray(ht.rawTrace)?ht.rawTrace:[],ct].slice(-80),Yt=Array.isArray(ht.timingEntries)?ht.timingEntries:[],rn=Et?[...Yt,Et].slice(-80):Yt,xn=Array.isArray(ht.activities)?ht.activities:[],zt=Number(ht.startedAt)||Number(ye==null?void 0:ye.ts)||Date.now(),fn=Number(Et==null?void 0:Et.at)||Number(ye==null?void 0:ye.ts)||Date.now(),bo=Array.isArray(ht.messages)?ht.messages:[],Bi={role:"assistant",kind:"raw",text:un.join(`
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
`),at:Date.now()},ar=[...bo],ui=ar.findIndex(vo=>vo.kind==="activity");if(Et){const vo={role:"assistant",kind:"activity",text:jC(xn,rn,zt,fn),at:Date.now()};if(ui>=0)ar[ui]=vo;else{const Xf=ar.findIndex(Zg=>Zg.kind==="run-summary");ar.splice(Xf>=0?Xf+1:0,0,vo)}}const ko=ar.findIndex(vo=>vo.kind==="raw");return ko>=0?ar[ko]=Bi:ar.push(Bi),{...ht,rawTrace:un,timingEntries:rn,messages:ar.slice(-160)}}))},TL=ye=>{qn(nt=>nt.map(Ge=>Ge.id===J?{...Ge,status:ye,endedAt:Date.now()}:Ge))},Gf=ye=>{const nt=new Set,Ge=String((ye==null?void 0:ye.nodeId)||"").trim();Ge&&nt.add(Ge);for(const pt of Array.isArray(ye==null?void 0:ye.displayNodeIds)?ye.displayNodeIds:[]){const we=String(pt||"").trim();we&&nt.add(we)}for(const pt of Array.isArray(ye==null?void 0:ye.touchedNodeIds)?ye.touchedNodeIds:[]){const we=String(pt||"").trim();we&&nt.add(we)}if(nt.size===0)for(const pt of Array.isArray(ye==null?void 0:ye.order)?ye.order:[]){const we=String(pt||"").trim();we&&nt.add(we)}return nt},Jf=(ye,nt=null)=>{const Ge=Iu(ye||X,be),pt=new Map(Ge.nodes.map(ht=>[ht.id,ht])),we=Ge.instances||{},ct=nt instanceof Set?nt:null,Et=(ht,vt)=>{const un={...ht||vt};Array.isArray(vt==null?void 0:vt.output)&&(un.output=vt.output);for(const Yt of["scriptRef","implementationRef","implementationMode"])(vt==null?void 0:vt[Yt])!=null&&String(vt[Yt]).trim()!==""&&(un[Yt]=vt[Yt]);return un},Ot=(ht,vt)=>{const un={...ht||{}};Array.isArray(vt==null?void 0:vt.outputs)&&(un.outputs=vt.outputs);for(const Yt of["scriptRef","implementationRef","implementationMode"])(vt==null?void 0:vt[Yt])!=null&&String(vt[Yt]).trim()!==""&&(un[Yt]=vt[Yt]);return un};g(ht=>{const vt=new Set(ht.map(rn=>rn.id)),Yt={...Ml(ht,j.current,Z.current).instances||{}};for(const[rn,xn]of Object.entries(we)){if(ct&&!ct.has(rn)||!vt.has(rn))continue;const zt=Yt[rn];tl((xn==null?void 0:xn.definitionId)||(zt==null?void 0:zt.definitionId))?Yt[rn]=xn:Array.isArray(xn==null?void 0:xn.output)&&(Yt[rn]=Et(zt,xn))}return Z.current=Yt,ne(Yt),ht.map(rn=>{var zt,fn;if(ct&&!ct.has(rn.id))return rn;const xn=pt.get(rn.id);return xn?tl(((zt=xn.data)==null?void 0:zt.definitionId)||((fn=rn.data)==null?void 0:fn.definitionId))?{...rn,data:{...rn.data,...xn.data}}:{...rn,data:Ot(rn.data,xn.data)}:rn})})};for(;;){const{value:ye,done:nt}=await Le.read();if(nt)break;De+=Mt.decode(ye,{stream:!0});const Ge=De.split(`
|
|
260
|
+
`);De=Ge.pop()||"";for(const pt of Ge){if(!pt.trim())continue;const we=JSON.parse(pt);if(we.type==="error")throw new Error(we.error||"Workspace run failed");if(we.type==="stopped"){ou.current.add(J),dt=Array.isArray(we.order)?we.order:dt,xo("运行停止",we);continue}if(we.type==="node-start"&&(ge(`Running ${we.nodeId}...`),Uf(we.nodeId),ci(we.nodeId,we.definitionId,"running")),we.type==="node-done"){const ct=Ve.get(String(we.nodeId||"").trim());ct&&wa(we.nodeId,ct),S0(we.nodeId),ci(we.nodeId,we.definitionId,"done")}if(we.type==="status"&&xo(we.line||we.message||"",we),we.type==="paused"&&(Pt=Array.isArray(we.nodeIds)?we.nodeIds:[],xo("运行暂停",we)),we.type==="natural"&&((we.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(we.text||"")))&&we.nodeId&&Ve.set(String(we.nodeId||"").trim(),String(we.text||"")),we.kind==="thinking"?Yf(we.text||""):N0(we.kind,we.text||"")),we.type==="raw"){const ct=CC(we);ct&&Yf(ct),j0(we)}if(we.type==="graph"&&we.graph){const ct=Gf(we);Jf(we.graph,ct),xa(we.graph,ct)}if(we.type==="done"){if(we.revision&&(me.current=String(we.revision)),we.graph){$e.current=we.graph;const ct=Gf(we);Jf(we.graph,ct),xa(we.graph,ct)}dt=Array.isArray(we.order)?we.order:[],Pt=Array.isArray(we.pauseNodeIds)?we.pauseNodeIds:Pt,xo(Pt.length?"运行暂停":"运行完成",we)}}}if(De.trim()){const ye=JSON.parse(De);if(ye.type==="error")throw new Error(ye.error||"Workspace run failed");if(ye.type==="stopped"&&(ou.current.add(J),xo("运行停止",ye)),ye.type==="node-start"&&(ge(`Running ${ye.nodeId}...`),Uf(ye.nodeId),ci(ye.nodeId,ye.definitionId,"running")),ye.type==="node-done"){const nt=Ve.get(String(ye.nodeId||"").trim());nt&&wa(ye.nodeId,nt),S0(ye.nodeId),ci(ye.nodeId,ye.definitionId,"done")}if(ye.type==="status"&&xo(ye.line||ye.message||"",ye),ye.type==="paused"&&(Pt=Array.isArray(ye.nodeIds)?ye.nodeIds:[],xo("运行暂停",ye)),ye.type==="natural"&&((ye.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(ye.text||"")))&&ye.nodeId&&Ve.set(String(ye.nodeId||"").trim(),String(ye.text||"")),ye.kind==="thinking"?Yf(ye.text||""):N0(ye.kind,ye.text||"")),ye.type==="raw"){const nt=CC(ye);nt&&Yf(nt),j0(ye)}if(ye.type==="graph"&&ye.graph){const nt=Gf(ye);Jf(ye.graph,nt),xa(ye.graph,nt)}if(ye.type==="done"){if(ye.revision&&(me.current=String(ye.revision)),ye.graph){$e.current=ye.graph;const nt=Gf(ye);Jf(ye.graph,nt),xa(ye.graph,nt)}dt=Array.isArray(ye.order)?ye.order:[],Pt=Array.isArray(ye.pauseNodeIds)?ye.pauseNodeIds:Pt,xo(Pt.length?"运行暂停":"运行完成",ye)}}He()&&(Me(he),Ft(he,"stopped"));const Qg=He()?`Workspace run stopped: ${w}`:Pt.length?`Workspace run paused at ${Pt.join(", ")}`:`Workspace run done: ${dt.length?dt.join(" -> "):w}`;if(ge(Qg),He()||Ft(he,Pt.length?"paused":"success"),TL(He()?"stopped":Pt.length?"paused":"done"),!He()){try{await Zt(N.current,j.current),ge(Qg)}catch(ye){ge(`${Qg},但保存结果失败:${String(ye.message||ye)}`)}await An()}}catch(rt){if(He()||(rt==null?void 0:rt.name)==="AbortError"){Me(he),Ft(he,"stopped"),ge(`Workspace run stopped: ${w}`),qn(Ye=>Ye.map(Le=>Le.id===J?{...Le,status:"stopped",endedAt:Date.now()}:Le));return}Me(he),Ft([w,ze].filter(Boolean),"failed"),ge(String(rt.message||rt)),qn(Ye=>Ye.map(Le=>Le.id===J?{...Le,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Le.messages)?Le.messages:[],{role:"assistant",error:!0,text:String(rt.message||rt),at:Date.now()}].slice(-160)}:Le))}finally{iu.current.get(J)===We&&iu.current.delete(J),Di(rt=>{const Ye={...rt};return delete Ye[J],Ye}),ou.current.delete(J),Me(he)}},[Li,k,a,An,b,be,Br,Zt,$s,x,g,Di,o,je]),Rf=m.useCallback(async()=>{try{const S=await(await fetch("/api/skills")).json().catch(()=>({})),_=Array.isArray(S.skills)?S.skills.map(A=>({key:String(A.key),name:String(A.name||A.id||A.key),description:A.description?String(A.description):"",sourceLabel:A.sourceLabel?String(A.sourceLabel):""})):[];w$(_),Gv(!0)}catch{Gv(!0)}},[]),Tf=m.useCallback(async()=>{try{const S=await(await fetch("/api/mcps")).json().catch(()=>({})),_=Array.isArray(S.servers)?S.servers.map(A=>({name:String((A==null?void 0:A.name)||""),type:String((A==null?void 0:A.type)||""),url:String((A==null?void 0:A.url)||""),command:String((A==null?void 0:A.command)||""),args:Array.isArray(A==null?void 0:A.args)?A.args.map(String):[],description:String((A==null?void 0:A.description)||"")})).filter(A=>A.name):[];Qv(_)}catch{Qv([])}},[]),Mf=m.useCallback(async()=>{try{const w=Tr(a),_=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),A=Array.isArray(_.workspaces)?_.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):[];eS(A)}catch{eS([])}},[a]),LS=m.useCallback(async()=>{Ke.current=!1;try{const w=Tr(a),S=await fetch(`/api/workspace/conversations?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok)throw new Error(_.error||`HTTP ${S.status}`);const A=kC(_.conversations||{});hl(A.composer.messages),qn(A.composer.runSessions),bs(A.composer.activeSessionId||"workspace"),yo(A.nodeChats)}catch{hl([]),qn([]),bs("workspace"),yo({})}finally{Ke.current=!0}},[a]),OS=m.useCallback(async()=>{if(!je||a.archived)return;const w=kC({composer:{activeSessionId:Hr,messages:pa,runSessions:Ls},nodeChats:ha});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async S=>{if(!S.ok){const _=await S.json().catch(()=>({}));throw new Error(_.error||`HTTP ${S.status}`)}})},[Hr,pa,Ls,a,ha,je]);m.useEffect(()=>{let w=!1;return(async()=>{const _=new URL(window.location.href),A=String(_.searchParams.get("invite")||"").trim();if(A){ge("正在加入共享 Workspace...");const R=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:A})}),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"加入共享 Workspace 失败");_.searchParams.delete("invite"),window.history.replaceState({},"",`${_.pathname}${_.search}${_.hash}`)}w||(await ks(),w||await LS())})().catch(_=>{const A=String(_.message||_);ge(A),Os("error"),Ds(A)}),Af(),fetch("/api/model-lists").then(_=>_.json()).then(_=>g$({cursor:Array.isArray(_.cursor)?_.cursor.map(String):[],opencode:Array.isArray(_.opencode)?_.opencode.map(String):[],claudeCode:Array.isArray(_.claudeCode)?_.claudeCode.map(String):[],codex:Array.isArray(_.codex)?_.codex.map(String):[]})).catch(()=>{}),Rf(),Tf(),Mf(),If(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{x$(Oa(_)),b$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{pS(_.user||null),mS(!0)}).catch(()=>{pS(null),mS(!0)}),()=>{w=!0}},[ks,LS,Af,Tf,Rf,If,Mf,Oi]),m.useEffect(()=>{if(CS(""),!(!Yv||!Jv)){if(!Oi){Qc([]);return}Qc(_F(Oi,"workspace",Ms,fl)),CS(Oi)}},[fl,Jv,Ms,Yv,Oi]),m.useEffect(()=>{if(!(jS!==Oi||!Oi))try{localStorage.setItem(Oi,JSON.stringify($s))}catch{}},[$s,Oi,jS]),m.useEffect(()=>{Z.current=te},[te]),m.useEffect(()=>{N.current=b},[b]),m.useEffect(()=>{if(lt.current)return;const w=H.current,S=new Map,_=[];for(const A of b){const R=VT(A);S.set(A.id,R),w.get(A.id)!==R&&_.push(A.id)}H.current=S,_.length!==0&&Br(_)},[b,Br]),m.useEffect(()=>{j.current=k},[k]),m.useEffect(()=>{F.current=P},[P]),m.useEffect(()=>{z.current=$},[$]),m.useEffect(()=>{Rv.current=at},[at]),m.useEffect(()=>{go.current=Ut},[Ut]),m.useEffect(()=>{ue.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=_=>{_.key==="Escape"&&ee(null)},S=_=>{var A,R;(R=(A=_.target)==null?void 0:A.closest)!=null&&R.call(A,".af-connect-node-menu")||ee(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S)}},[G]),m.useEffect(()=>{if(!ce.current||!je)return;if(lt.current){de.current&&window.clearTimeout(de.current);return}if(Fe.current){Fe.current=!1;return}li(),de.current&&window.clearTimeout(de.current);const w=oe.current?0:650;return oe.current=!1,de.current=window.setTimeout(()=>{Zt().catch(S=>ge(String(S.message||S)))},w),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,P,li,Zt,je]),m.useEffect(()=>{if(Ke.current&&!(!je||a.archived))return Ue.current&&window.clearTimeout(Ue.current),Ue.current=window.setTimeout(()=>{OS().catch(w=>ge(String(w.message||w)))},900),()=>{Ue.current&&window.clearTimeout(Ue.current)}},[Hr,pa,Ls,a.archived,ha,OS,je]);const du=m.useMemo(()=>b.filter(w=>{var S;return((S=w==null?void 0:w.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"}).map(w=>{var S;return{id:w.id,config:gv(((S=w.data)==null?void 0:S.body)||"")}}),[b]),F$=m.useMemo(()=>du.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[du]);m.useEffect(()=>{if(!ce.current||d!=="workspace"||!a.flowId){ma({});return}if(!du.length){ma({});return}let w=!1;const S=async()=>{try{const A=Tr(a),R=await fetch(`/api/workspace/schedules?${A.toString()}`),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||ma(Lp(U.schedules||[]))}catch{w||ma(A=>{var U;const R={};for(const X of du)R[X.id]={...A[X.id]||{},lastStatus:((U=A[X.id])==null?void 0:U.lastStatus)||"unknown"};return R})}};S();const _=window.setInterval(S,5e3);return()=>{w=!0,window.clearInterval(_)}},[a,du,F$,d]);const DS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=BC(S),A=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="skillKeys"&&(ae==null?void 0:ae.name)!=="skillsContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],R=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:A((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:A(X.input)}};Z.current=J,g(R),ne(J),ws(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:A(Y.inputs)}),Zt(R,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,Zt,g,je]),FS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=NJ(S),A=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="serverNames"&&(ae==null?void 0:ae.name)!=="mcpContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],R=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:A((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:A(X.input)}};Z.current=J,g(R),ne(J),ws(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:A(Y.inputs)}),Zt(R,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,Zt,g,je]),zS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=(Array.isArray(S)?S:S?[S]:[]).filter(ze=>String((ze==null?void 0:ze.path)||"").trim()),A=_[0]||null,R=String((A==null?void 0:A.path)||"").trim(),U=_.length===1?String((A==null?void 0:A.label)||(A==null?void 0:A.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(cg(_)):"",J=A?JSON.stringify({version:1,id:(A==null?void 0:A.id)||"",label:String((A==null?void 0:A.label)||(A==null?void 0:A.id)||"知识库").trim(),kind:(A==null?void 0:A.kind)||"local",cwd:R,workspaceRoot:R,repoUrl:(A==null?void 0:A.repoUrl)||"",branch:(A==null?void 0:A.branch)||"",mountPath:(A==null?void 0:A.mountPath)||"",type:(A==null?void 0:A.type)||""}):"",Y=ze=>Array.isArray(ze)?ze.map(Ve=>(Ve==null?void 0:Ve.name)==="path"?{...Ve,default:R,value:R}:(Ve==null?void 0:Ve.name)==="label"?{...Ve,default:U,value:U}:(Ve==null?void 0:Ve.name)==="knowledgeContext"?{...Ve,default:X,value:X}:(Ve==null?void 0:Ve.name)==="workspaceContext"?{...Ve,default:J,value:J}:(Ve==null?void 0:Ve.name)==="mode"?{...Ve,default:"set",value:"set"}:Ve):[],ae=ze=>Array.isArray(ze)?ze.map(Ve=>(Ve==null?void 0:Ve.name)==="knowledgeContext"?{...Ve,default:X,value:X}:(Ve==null?void 0:Ve.name)==="workspaceContext"?{...Ve,default:J,value:J,showOnNode:!1}:(Ve==null?void 0:Ve.name)==="cwd"?{...Ve,default:R,value:R,showOnNode:!1}:Ve):[],he=b.map(ze=>{var Ve,He,Me;return ze.id===w?{...ze,data:{...ze.data,label:((Ve=ze.data)==null?void 0:Ve.label)||"加载知识库",inputs:Y((He=ze.data)==null?void 0:He.inputs),outputs:ae((Me=ze.data)==null?void 0:Me.outputs)}}:ze}),fe=Z.current||{},Ne=fe[w]&&typeof fe[w]=="object"?fe[w]:{},We={...fe,[w]:{...Ne,label:Ne.label||"加载知识库",input:Y(Ne.input),output:ae(Ne.output)}};Z.current=We,g(he),ne(We),ws(ze=>(ze==null?void 0:ze.id)===w?{...ze,inputs:Y(ze.inputs),outputs:ae(ze.outputs)}:ze),Zt(he,k).catch(ze=>ge(String(ze.message||ze)))},[k,b,Zt,g,je]),BS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=String(w||"");if(!_)return;const A=BC((S==null?void 0:S.skillKeys)||[]),R=gf((S==null?void 0:S.displayType)||"markdown"),U=String((S==null?void 0:S.model)||"").trim(),X=(S==null?void 0:S.includeWorkspaceContext)===!1?"false":"true",J=S!=null&&S.workspaceContext&&typeof S.workspaceContext=="object"?JSON.stringify(S.workspaceContext):"",Y=S!=null&&S.knowledgeContext&&typeof S.knowledgeContext=="object"?JSON.stringify(S.knowledgeContext):"",ae=He=>Array.isArray(He)?He.map(Me=>(Me==null?void 0:Me.name)==="skillKeys"?{...Me,default:A,value:A}:(Me==null?void 0:Me.name)==="displayType"?{...Me,default:R,value:R}:(Me==null?void 0:Me.name)==="includeWorkspaceContext"?{...Me,default:X,value:X}:(Me==null?void 0:Me.name)==="knowledgeContext"?{...Me,default:Y,value:Y}:(Me==null?void 0:Me.name)==="workspaceContext"?{...Me,default:J,value:J}:Me):[],he=He=>Array.isArray(He)?He.map(Me=>(Me==null?void 0:Me.name)==="displayType"?{...Me,default:R,value:R}:Me):[],fe=String((S==null?void 0:S.task)??""),Ne=b.map(He=>{var Me,Ft;return He.id===_?{...He,data:{...He.data,body:fe,model:U,inputs:ae((Me=He.data)==null?void 0:Me.inputs),outputs:he((Ft=He.data)==null?void 0:Ft.outputs)}}:He}),We=Z.current||{},ze=We[_]&&typeof We[_]=="object"?We[_]:{},Ve={...We,[_]:{...ze,body:fe,model:U,input:ae(ze.input),output:he(ze.output)}};Z.current=Ve,g(Ne),ne(Ve),ws(He=>(He==null?void 0:He.id)===_?{...He,body:fe,model:U,inputs:ae(He.inputs),outputs:he(He.outputs)}:He),Zt(Ne,k).catch(He=>ge(String(He.message||He)))},[k,b,Zt,g,je]),HS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=jG(S),A=b.map(J=>J.id===w?{...J,data:{...J.data,body:_}}:J),R=Z.current||{},U=R[w]&&typeof R[w]=="object"?R[w]:{},X={...R,[w]:{...U,body:_}};Z.current=X,Fe.current=!0,g(A),ne(X),ws(J=>(J==null?void 0:J.id)===w?{...J,body:_}:J),Zt(A,k).catch(J=>ge(String(J.message||J)))},[k,b,Zt,g,je]),WS=m.useCallback(w=>{const S=String(w||"").trim();S&&(fS(_=>_===S?"":S),yo(_=>({..._,[S]:_[S]||{sessionId:`nodechat_${Date.now()}_${S.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),VS=m.useCallback(()=>fS(""),[]),KS=m.useCallback((w,S)=>{const _=String(w||"").trim();_&&yo(A=>({...A,[_]:{...A[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(S||""),error:""}}))},[]),Fs=m.useCallback((w,S,_="replace",A={})=>{var rt,Ye;if(!je){ge("Readonly workspace");return}const R=String(w||"").trim();if(!R)return;const U=N.current.find(Le=>Le.id===R),X=In(U==null?void 0:U.data),J=ei((rt=U==null?void 0:U.data)==null?void 0:rt.definitionId),Y=Ei(S),ae=X==="html"?Hc(Y):X==="react"?ag(Y):String(Y||""),he=U?no(U.data):"",fe=_==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
|
|
261
|
+
|
|
262
|
+
${ae.trim()}`:ae,Ne=X==="image"?"src":"content",We=A!=null&&A.reloadDisplay?Date.now():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,ze=Le=>{let Mt=!1;return(Array.isArray(Le)?Le:[]).map(dt=>{const Pt=String((dt==null?void 0:dt.name)||""),_l=String((dt==null?void 0:dt.type)||"");return(J?Pt===Ne||Pt==="result"||Pt==="filePath":Pt===Ne||Pt==="filePath"||_l==="text")?Mt?{...dt,default:"",value:""}:(Mt=!0,{...dt,default:fe,value:fe}):dt})},Ve=N.current.map(Le=>{var Mt,De;return Le.id!==R?Le:{...Le,data:{...Le.data,body:J?Le.data.body:fe,...We?{displayReloadKey:We}:{},inputs:ze((Mt=Le.data)==null?void 0:Mt.inputs),outputs:ze((De=Le.data)==null?void 0:De.outputs)}}}),He=Z.current||{},Me=He[R]&&typeof He[R]=="object"?He[R]:{},Ft={...He,[R]:{...Me,body:J?Me.body:fe,input:ze(Me.input),output:ze(Me.output)}};Z.current=Ft,g(Ve),ne(Ft),ws(Le=>(Le==null?void 0:Le.id)===R?{...Le,...J?{}:{body:fe}}:Le),(A==null?void 0:A.logChat)!==!1&&yo(Le=>{var Mt;return{...Le,[R]:{...Le[R]||{},candidateContent:"",messages:[...(Mt=Le[R])!=null&&Mt.messages&&Array.isArray(Le[R].messages)?Le[R].messages:[],{role:"assistant",text:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Zt(Ve,j.current).catch(Le=>ge(String(Le.message||Le))),ge(String((A==null?void 0:A.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[Zt,g,je]),$f=m.useCallback(async(w,S="")=>{if(!je)return ge("Readonly workspace"),"";if(!w)return"";try{const _=new FormData;_.set("file",w),_.set("dir",String(S||"")),a.flowId&&_.set("flowId",a.flowId),a.flowSource&&_.set("flowSource",a.flowSource),a.archived&&_.set("archived","1");const A=await fetch("/api/workspace/upload",{method:"POST",body:_}),R=await A.json().catch(()=>({}));if(!A.ok)throw new Error(R.error||"上传文件失败");const U=String(R.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await An(),dl(X=>{const J=new Set(X);for(const Y of Dp(U))J.delete(Y);return J}),ge(`已上传 ${U}`),U}catch(_){return ge(String(_.message||_)),""}},[a,An,je]),Lf=m.useCallback(async w=>cm(w)?$f(w,"img"):(ge("请选择图片文件"),""),[$f]),qS=m.useCallback((w="")=>{var S;if(!je){ge("Readonly workspace");return}Kv.current=String(w||""),(S=Vv.current)==null||S.click()},[je]),z$=m.useCallback(async w=>{const S=Array.from(w.target.files||[]);if(w.target.value="",!S.length)return;const _=Kv.current||"";Wv(!0);try{let A="";for(const R of S){const U=await $f(R,_);U&&(A=U)}S.length>1&&ge(`已上传 ${S.length} 个文件${A?`,最后一个:${A}`:""}`)}catch(A){ge(String(A.message||A))}finally{Wv(!1)}},[$f]),US=m.useCallback(async(w,S)=>{const _=String(w||"").trim();if(!_)return;const A=await Lf(S);A&&Fs(_,A,"replace",{logChat:!1,statusMessage:`已上传图片 ${A}`})},[Fs,Lf]),YS=m.useCallback(async(w,S=void 0)=>{var ze,Ve;if(!je){ge("Readonly workspace");return}const _=String(w||"").trim();if(!_)return;const A=ha[_]||{},R=String(S!==void 0?S:A.draft||"").trim();if(!R||A.running)return;const U=N.current.find(He=>He.id===_);if(!U)return;const X=In(U.data)||"markdown",J=no(U.data);let Y=ea(J,X),ae=Ei(J);if(Y)try{ae=await nl(a,Y)}catch(He){ge(String(He.message||He))}else if(X!=="image"&&String(ae||"").trim()){const He=Ma(X,ae);if(He){ge(`${He} 未进入微调。`);return}try{const Me=await hb(a,FC(_,U.data),ae);await An(),Fs(_,Me,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Me}`}),Y=Me,ae=""}catch(Me){ge(String(Me.message||Me));return}}const he=HG(_,N.current,j.current),fe={role:"user",text:R,at:Date.now()},Ne=Array.isArray(A.messages)?A.messages:[],We=A.sessionId||`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;yo(He=>({...He,[_]:{...A,sessionId:We,messages:[...Ne,fe],draft:"",running:!0,error:""}}));try{const He=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:We,node:{id:_,label:((ze=U.data)==null?void 0:ze.label)||_,definitionId:((Ve=U.data)==null?void 0:Ve.definitionId)||""},nodeKind:X,currentContent:Y?"":ae,sourceContext:he,targetFilePath:Y,messages:Ne,message:R,model:Li})}),Me=await He.json().catch(()=>({}));if(!He.ok)throw new Error(Me.error||"节点微调失败");const Ft=String(Me.candidateContent||Me.reply||"").trim(),rt=!!Me.directFileEdit,Ye=String(Me.artifactPath||Y||"").trim();if(rt&&Ye){const Le=Ma(X,Ft);if(Le)throw new Error(`${Le} 文件已由 agent 修改,请检查 ${Ye}。`);await An(),Fs(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(Ft){const Le=Ma(X,Ft);if(Le)throw new Error(`${Le} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Mt=await hb(a,Y,Ft);await An(),Fs(_,Mt,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Mt}`})}else Fs(_,Ft,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}yo(Le=>{var Mt;return{...Le,[_]:{...Le[_]||{},sessionId:String(Me.sessionId||We),running:!1,candidateContent:"",messages:[...(Mt=Le[_])!=null&&Mt.messages&&Array.isArray(Le[_].messages)?Le[_].messages:[...Ne,fe],{role:"assistant",text:Ft||rt?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(He){const Me=String(He.message||He);yo(Ft=>({...Ft,[_]:{...Ft[_]||{},running:!1,error:Me}})),ge(Me)}},[Li,a,An,ha,Fs,je]),GS=m.useCallback(async(w,S)=>{if(!je){ge("Readonly workspace");return}const _=In(S)||"markdown",A=no(S),R=ea(A,_);let U=Ei(A);if(R)try{U=await nl(a,R)}catch(ae){ge(String(ae.message||ae));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const X=Ma(_,U);if(X){ge(`${X} 未保存文件。`);return}const J=FC(w,S),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const ae=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:U})}),he=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||Y,Ne=Tr(a);Ne.set("path",fe);const We=await fetch(`/api/workspace/file?${Ne.toString()}`);if(!We.ok){const ze=await We.json().catch(()=>({}));throw new Error(ze.error||`保存后读取失败:${fe}`)}await An(),Tv(ze=>mJ(ze,fe,String(U||"").length)),dl(ze=>{const Ve=new Set(ze);for(const He of Dp(fe))Ve.delete(He);return Ve}),Fs(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(ae){ge(String(ae.message||ae))}},[a,An,Fs,je]),JS=m.useCallback(w=>{var R,U;const S=String(w||"").trim();if(!S||ve)return;const _=N.current.find(X=>X.id===S);if(!_||!In(_==null?void 0:_.data)){ge("展示节点不可用");return}const A=String(((R=_.data)==null?void 0:R.label)||((U=_.data)==null?void 0:U.displayName)||S).trim()||"AgentFlow Display";le(lw({title:A,layout:"single",nodeIds:[S],mode:"single-node",sourceNodeId:S})),sr(""),Gt(null),Pr(!0)},[ve]),Of=m.useCallback((w,S)=>{const _=String(w||"");_&&ws(A=>{if(!A||A.id!==_)return A;const R=typeof S=="function"?S(A):S;return!R||typeof R!="object"?A:{...A,...R}})},[]),XS=m.useCallback((w,S)=>{const _=String(w||"");!_||!je||(g(A=>A.map(R=>{var X;if(R.id!==_)return R;const U=Array.isArray((X=R.data)==null?void 0:X.outputs)&&R.data.outputs.length?R.data.outputs.map((J,Y)=>Y===0?{...J,default:S,value:S}:J):[{type:"file",name:"value",default:S,value:S}];return{...R,data:{...R.data,body:"",outputs:U}}})),Of(_,A=>({body:"",outputs:Array.isArray(A==null?void 0:A.outputs)&&A.outputs.length?A.outputs.map((U,X)=>X===0?{...U,default:S,value:S}:U):[{type:"file",name:"value",default:S,value:S}]})),ge(`已选择文件 ${S}`))},[g,Of,je]),QS=m.useCallback(w=>{Sg({nodeId:String(w||""),query:""})},[]),zg=m.useCallback(()=>{Sg({nodeId:"",query:""})},[]),B$=m.useCallback(w=>{const S=String((w==null?void 0:w.path)||"").trim();!S||!Xc.nodeId||(XS(Xc.nodeId,S),zg())},[zg,Xc.nodeId,XS]),ZS=m.useCallback(async(w,S)=>{if(!je)return;const _=sJ(w,S);if(_.length===0)return;const A=[];try{for(const R of _){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:R})});if(U.status===404)continue;const X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"清理节点输出失败");A.push(X.path||R)}if(A.length===0)return;ge(`已清理 ${A.join(", ")}`),await An(),vg(R=>_.some(U=>R===U||R.startsWith(`${U}/`))?"":R)}catch(R){ge(String(R.message||R))}},[a,An,je]),fu=m.useMemo(()=>({modelLists:da,showBodyPreview:!0,flowParams:a,readOnly:!je,onRunWorkspaceNode:$S,onStopWorkspaceNode:MS,onOpenWorkspaceRunLogs:TS,onOptimizeWorkspaceRun:Fg,onOptimizeWorkspaceSchedule:Fg,runningRunNodeIds:_S,onChangeScheduledRunConfig:HS,onChangeContextRunConfig:BS,skills:Ms,skillCollections:fl,onChangeLoadSkillKeys:DS,onRefreshSkills:Rf,mcpServers:Xv,onChangeLoadMcpNames:FS,onRefreshMcps:Tf,workspaceTargets:Zv,onChangeLoadWorkspace:zS,onRefreshWorkspaces:Mf,onSaveDisplayNodeToFile:GS,onShareDisplayNode:JS,onOpenDisplayPreview:zn,onRefreshNodeInternals:Br,onEnsureWorkspaceNodeDisplaySize:iS,sharingDisplayNodeId:ve,onUploadWorkspaceImage:Lf,onUploadImageToDisplayNode:US,onOpenProvideFilePicker:QS,onStatus:ge,onSetDisplayNodeContent:Fs,onToggleNodeChat:WS,onCloseNodeChat:VS,onUpdateNodeChatDraft:KS,onSendNodeChat:YS,onSyncNodePropDraft:Of,onCleanupWorkspaceNodeOutputs:ZS}),[BS,FS,DS,zS,HS,ZS,VS,iS,a,Xv,da,QS,TS,Fg,Tf,Br,Rf,Mf,$S,_S,GS,YS,Fs,JS,ve,fl,Ms,MS,Of,WS,KS,US,Lf,Zv,je]),H$=m.useRef(new Map),rs=m.useMemo(()=>{const w=H$.current,S=new Set,_=b.map(A=>{var Y,ae,he;const R={selected:A.selected===!0,isExecuting:bS.has(A.id),nodeStatus:((Y=Dg[A.id])==null?void 0:Y.status)??null,nodeElapsed:((ae=Dg[A.id])==null?void 0:ae.elapsed)??null,optimizingRun:kS===A.id,scheduledRunState:xS[A.id]||null,nodeChatActive:dS===A.id,nodeChat:ha[A.id]||null},U=w.get(A.id);if(U&&U.source===A&&U.commonData===fu&&IC(U.runtime,R))return S.add(A.id),U.node;const X=!!(U&&((he=U.source)==null?void 0:he.data)===A.data&&U.commonData===fu&&IC(U.runtime,R)),J={...A,data:X?U.node.data:{...A.data,...fu,...R}};return w.set(A.id,{source:A,commonData:fu,runtime:R,node:J}),S.add(A.id),J});for(const A of w.keys())S.has(A)||w.delete(A);return _},[dS,fu,ha,b,kS,xS,bS,Dg]),ut=d==="display",Pn=d==="workflow",e0=m.useMemo(()=>ut?new Map(rs.map(w=>[w.id,w])):IG,[rs,ut]),t0=m.useMemo(()=>qt&&rs.find(w=>w.id===qt)||null,[qt,rs]),n0=m.useRef(new Map),pu=m.useMemo(()=>{if(!ut)return n0.current.clear(),RG;const w=new Set(M),S=n0.current,_=new Set,A=P.nodeIds.map((R,U)=>{var We,ze,Ve,He;const X=e0.get(R);if(!X||!In(X.data))return null;const J=Fl(X)||{width:520,height:320},Y=za(P.nodeSizes[R]||J,{display:!0})||J,ae=P.nodePositions[R]||{x:180+U*36,y:120+U*28},he=w.has(R),fe=S.get(R);if(fe&&fe.source===X&&((We=fe.position)==null?void 0:We.x)===ae.x&&((ze=fe.position)==null?void 0:ze.y)===ae.y&&((Ve=fe.size)==null?void 0:Ve.width)===Y.width&&((He=fe.size)==null?void 0:He.height)===Y.height&&fe.selected===he)return _.add(R),fe.node;const Ne={...X,id:RC(R),position:ae,selected:he,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:R,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return S.set(R,{source:X,position:ae,size:Y,selected:he,node:Ne}),_.add(R),Ne}).filter(Boolean);for(const R of S.keys())_.has(R)||S.delete(R);return A},[P,e0,ut,M]),kl=m.useMemo(()=>rs.filter(w=>In(w==null?void 0:w.data)),[rs]);m.useEffect(()=>{if(!ut||!P.viewport)return;const w=P.viewport,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[P.viewport,ut,r]),m.useEffect(()=>{if(ut||Pn||!$)return;const w=$,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[ut,Pn,r,$]),m.useEffect(()=>{Pn&&uu(ir)},[Pn]),m.useEffect(()=>{if(!Pn||!ir)return;const w=Tr(a);w.set("tapdId",ir);let S=null,_=null,A=!1;const R=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{A||document.hidden||S||(S=new EventSource(`/api/prd-workflow/events?${w.toString()}`),S.onmessage=()=>{uu(ir)},S.onerror=()=>{R(),!A&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){R();return}uu(ir),U()};return U(),document.addEventListener("visibilitychange",X),()=>{A=!0,document.removeEventListener("visibilitychange",X),R()}},[a,Pn,uu,ir]),m.useEffect(()=>{if(!a.flowId||Pn)return;const w=Tr(a);w.set("clientId",ke.current);let S=null,_=null,A=!1;const R=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{A||document.hidden||S||(S=new EventSource(`/api/workspace/events?${w.toString()}`),S.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===ke.current)){if(Y.type==="graph.committed"){Pf(Y);return}if(Y.type==="runtime.committed"){Pf(Y);return}if(String(Y.type||"").startsWith("file.")){An();return}String(Y.type||"").startsWith("run.")&&If()}},S.onerror=()=>{R(),!A&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){R();return}Pf({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",X),()=>{A=!0,document.removeEventListener("visibilitychange",X),R(),Te.current&&(window.clearTimeout(Te.current),Te.current=null),gt.current=!1}},[a,Pn,An,If,Pf]),m.useEffect(()=>{if(lt.current)return;const w=L.current,S=new Map,_=[];for(const A of[...rs,...pu]){const R=PG(A);S.set(A.id,R),w.get(A.id)!==R&&_.push(A.id)}L.current=S,_.length!==0&&Br(_)},[pu,rs,Br]);const Vt=m.useMemo(()=>b.find(w=>w.id===Ut)||null,[b,Ut]),Bg=m.useRef({id:"",draft:null}),W$=m.useMemo(()=>{const w=KC(Vt);return w?JSON.stringify(w):""},[Vt==null?void 0:Vt.data,Vt==null?void 0:Vt.id]);m.useEffect(()=>{if(!Vt){Bg.current={id:"",draft:null},ws(null),al("");return}const w=KC(Vt),S=Bg.current;Bg.current={id:Vt.id,draft:w},ws(_=>!_||_.id!==Vt.id||S.id!==Vt.id||!S.draft?w:EJ(_,S.draft,w)),al("")},[Vt==null?void 0:Vt.id,W$]);const Hg=m.useCallback((w=!1)=>{if(!at||!Vt)return!1;if(!je)return al("Readonly workspace"),ge("Readonly workspace"),!1;al("");const S=YC({nodes:b,edges:k,instances:Z.current,selectedNode:Vt,draft:at,allowRename:w});return S!=null&&S.error?(al(S.error),!1):(!(S!=null&&S.ok)||!S.changed||(Z.current=S.instances,ne(S.instances),g(S.nodes),x(S.edges),S.nextId!==Vt.id&&jn(S.nextId),Br(S.nextId)),!0)},[k,at,b,Vt,x,g,Br,je]);m.useEffect(()=>{if(!je||!at||!Vt)return;const w=window.setTimeout(()=>{Hg(!1)},350);return()=>window.clearTimeout(w)},[at==null?void 0:at.label,at==null?void 0:at.role,at==null?void 0:at.model,at==null?void 0:at.body,JSON.stringify((at==null?void 0:at.images)||[]),at==null?void 0:at.script,at==null?void 0:at.scriptRef,at==null?void 0:at.implementationRef,at==null?void 0:at.implementationMode,JSON.stringify((at==null?void 0:at.inputs)||[]),JSON.stringify((at==null?void 0:at.outputs)||[]),Hg,Vt==null?void 0:Vt.id,je]);const r0=m.useRef({refs:new Map,nodeDataById:new Map}),Wg=m.useMemo(()=>{const w=r0.current;let S=w.refs.size!==b.length;const _=new Map;for(const R of b)_.set(R.id,R.data),(!w.refs.has(R.id)||w.refs.get(R.id)!==R.data)&&(S=!0);if(!S)return w.nodeDataById;const A=new Map(b.map(R=>[R.id,R.data]));return r0.current={refs:_,nodeDataById:A},A},[b]),V$=m.useMemo(()=>k.map(w=>{var Y,ae;const S=Wg.get(w.source),_=Wg.get(w.target),A=/^output-(\d+)$/.exec(w.sourceHandle||""),R=/^input-(\d+)$/.exec(w.targetHandle||""),U=S&&A?(Y=S.outputs)==null?void 0:Y[parseInt(A[1],10)]:null,X=_&&R?(ae=_.inputs)==null?void 0:ae[parseInt(R[1],10)]:null,J=U!=null&&U.type?Tn(U.type):X!=null&&X.type?Tn(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:bi.ArrowClosed,color:J}}:w}),[Wg,k]),Df=ut?pu:rs,K$=ut?[]:V$,s0=m.useRef(Df),vl=m.useRef([]);lt.current||(s0.current=Df);const q$=m.useMemo(()=>ut?pu.map(w=>({...w,id:Op(w.id)})):rs,[pu,rs,ut]),Vg=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=ut?RC(S):S;ut?K([S]):(g(R=>R.map(U=>({...U,selected:U.id===_}))),x(R=>R.map(U=>({...U,selected:!1}))),jn(_));const A=()=>{var ae,he,fe;const R=r.getNode(_);if(!R)return;const U=(ae=r.getInternalNode)==null?void 0:ae.call(r,_),X=((he=U==null?void 0:U.measured)==null?void 0:he.width)??(U==null?void 0:U.width)??R.width??260,J=((fe=U==null?void 0:U.measured)==null?void 0:fe.height)??(U==null?void 0:U.height)??R.height??120,{zoom:Y}=r.getViewport();r.setCenter(R.position.x+X/2,R.position.y+J/2,{zoom:DG(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(A))},[ut,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!ce.current||d!=="workspace"||rs.some(S=>S.id===w)&&(c.current="",Fe.current=!0,Vg(w))},[rs,Vg,d]);const i0=m.useCallback(()=>{const w=r.getViewport(),S={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(ut){const _={...F.current,viewport:S};F.current=_,I(_),ge("已固定 Display 进入视角")}else{z.current=S,D(S);try{window.localStorage.setItem(u,JSON.stringify(S))}catch{}ge("已固定 Workspace 进入视角");return}Zt(N.current,j.current).catch(_=>ge(String(_.message||_)))},[ut,r,Zt,u]),Kg=m.useMemo(()=>{const w=jt.trim().toLowerCase(),S={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of be)w&&![_.id,_.label,_.displayName,_.description].some(A=>String(A||"").toLowerCase().includes(w))||S[Wu(_)].push(_);for(const _ of Ol)S[_].sort((A,R)=>A.id.localeCompare(R.id));return S},[be,jt]),hu=m.useMemo(()=>{const w=Ee.trim().toLowerCase();return be.filter(S=>!w||[S.id,S.label,S.displayName,S.description].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>{const A=Ol.indexOf(Wu(S)),R=Ol.indexOf(Wu(_));return A!==R?A-R:Vu(S).localeCompare(Vu(_))}).slice(0,30)},[be,Ee]),mu=m.useMemo(()=>{const w=Ee.trim().toLowerCase();return Re.filter(S=>!w||[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>String(S.displayName||S.name||S.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[Re,Ee]);m.useEffect(()=>{kt(0)},[Ee,On,pe]),m.useEffect(()=>{if(!On)return;const w=window.setTimeout(()=>{var S;return(S=lS.current)==null?void 0:S.focus()},0);return()=>window.clearTimeout(w)},[On]);const U$=m.useMemo(()=>{const w=bg.trim().toLowerCase();return w?yv(ll).filter(S=>S.path.toLowerCase().includes(w)):ll},[bg,ll]),ya=m.useMemo(()=>nM(ll,kg),[ll,kg]),Fi=(ya==null?void 0:ya.type)==="directory"?ya.path:dJ((ya==null?void 0:ya.path)||""),Y$=m.useCallback(w=>{var S,_;(_=(S=w.target)==null?void 0:S.closest)!=null&&_.call(S,".af-work-file")||vg("")},[]),G$=[...(da.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(da.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(da.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(da.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],qg=m.useMemo(()=>new Set($s),[$s]),Sl=m.useMemo(()=>{const w=new Map(Ms.map(U=>[U.key,U])),S=new Set,_=new Set,A=fl.map(U=>{const X=Qo(U,Ms).map(J=>w.get(J)).filter(Boolean);for(const J of X)S.add(J.key),_.add(String(J.name||J.id||J.key||"").trim());return{...U,skills:X}}).filter(U=>U.skills.length>0),R=Ms.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!S.has(U.key)&&!_.has(X)});return{groups:A,ungrouped:R}},[fl,Ms]);m.useEffect(()=>{oS(w=>{let S=!1;const _=new Set(w);for(const A of Sl.groups)_.has(A.id)||(_.add(A.id),S=!0);return S?_:w})},[Sl.groups]);const er=m.useMemo(()=>{const w=b.filter(S=>S.selected);return w.length>0?w:Ut?b.filter(S=>S.id===Ut):[]},[b,Ut]),Ff=m.useMemo(()=>er.map(w=>w.id),[er]),o0=m.useCallback(()=>{if(ut)return;if(!je){ge("Readonly workspace");return}const w=(N.current||[]).filter(J=>(J==null?void 0:J.selected)&&!pm(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const S=w.reduce((J,Y)=>{var We,ze,Ve,He,Me,Ft,rt,Ye,Le,Mt,De,dt;const ae=Number(((We=Y.position)==null?void 0:We.x)||0),he=Number(((ze=Y.position)==null?void 0:ze.y)||0),fe=Number(((Ve=Y.measured)==null?void 0:Ve.width)||Y.width||((Me=(He=Y.data)==null?void 0:He.nodeSize)==null?void 0:Me.width)||((rt=(Ft=Y.data)==null?void 0:Ft.displaySize)==null?void 0:rt.width)||PT),Ne=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||((Mt=(Le=Y.data)==null?void 0:Le.nodeSize)==null?void 0:Mt.height)||((dt=(De=Y.data)==null?void 0:De.displaySize)==null?void 0:dt.height)||lm);return{minX:Math.min(J.minX,ae),minY:Math.min(J.minY,he),maxX:Math.max(J.maxX,ae+fe),maxY:Math.max(J.maxY,he+Ne)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(S.minX)||!Number.isFinite(S.minY))return;const _=new Set((N.current||[]).map(J=>J.id));let A=1,R=`group_${A}`;for(;_.has(R);)A+=1,R=`group_${A}`;const U=db({width:S.maxX-S.minX+Mp*2,height:S.maxY-S.minY+Mp*2})||{width:Qa,height:Za},X={id:R,type:pc,position:{x:S.minX-Mp,y:S.minY-Mp},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:hm(A-1),title:hm(A-1),color:"purple",nodeSize:U}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),jn(""),ge(`Created group for ${w.length} nodes`)},[ut,x,g,je]),gu=m.useMemo(()=>b.filter(w=>In(w==null?void 0:w.data)),[b]),Ug=m.useMemo(()=>er.filter(w=>In(w==null?void 0:w.data)).map(w=>w.id),[er]),J$=m.useMemo(()=>{const w=String((Ir==null?void 0:Ir.username)||(Ir==null?void 0:Ir.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Ir]),Yg=m.useMemo(()=>new Set(Ff),[Ff]),zf=m.useMemo(()=>k.filter(w=>Yg.has(w.source)&&Yg.has(w.target)),[k,Yg]),Gg=m.useCallback(w=>{const S=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(S),jn(""),K([]),ee(null),q(!1),Pe(!1);const _=Tr(a);S==="display"&&_.set("view","display"),S==="workflow"&&(_.set("view","workflow"),ir.trim()&&_.set("tapdId",ir.trim()));const A=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",A)},[a,ir]),a0=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=N.current.find(A=>A.id===S);if(!_||!In(_.data)){ge("展示节点不可用");return}I(A=>{if(A.nodeIds.includes(S))return A;const R=A.nodeIds.length,U=Fl(_);return{nodeIds:[...A.nodeIds,S],nodePositions:{...A.nodePositions,[S]:{x:180+R*36,y:120+R*28}},nodeSizes:{...A.nodeSizes,...U?{[S]:U}:{}}}}),K([S])},[]),l0=m.useCallback(w=>{const S=String(w||"").trim();S&&(I(_=>{const A=_.nodeIds.filter(X=>X!==S),R={..._.nodePositions},U={..._.nodeSizes};return delete R[S],delete U[S],{nodeIds:A,nodePositions:R,nodeSizes:U}}),K(_=>_.filter(A=>A!==S)))},[]),c0=m.useCallback(w=>{const S=String(w||"").trim();S&&(F.current.nodeIds.includes(S)?l0(S):a0(S))},[a0,l0]),Bf=m.useMemo(()=>{const w=xt.trim().toLowerCase();return w?kl.filter(S=>{var _,A;return[S.id,(_=S.data)==null?void 0:_.label,(A=S.data)==null?void 0:A.definitionId].filter(Boolean).some(R=>String(R).toLowerCase().includes(w))}):kl},[kl,xt]),u0=m.useMemo(()=>{const w=Bf.length,S=w<=1?1:w<=4?2:3,_=Array.from({length:S},()=>({height:0,nodes:[]}));for(const A of Bf){const R=Fl(A)||{width:420,height:260},U=Math.max(1,Number(R.width)||420),X=Math.max(1,Number(R.height)||260),J=Math.min(26,Math.max(5.5,X/U*16))+3.2;let Y=_[0];for(const ae of _)ae.height<Y.height&&(Y=ae);Y.nodes.push(A),Y.height+=J}return _.map(A=>A.nodes)},[Bf]),X$=m.useCallback(w=>{var U;const S=P.nodeIds.includes(w.id),_=Fl(w)||{width:420,height:260},A=Math.max(1,Math.round(Number(_.width)||420)),R=Math.max(1,Math.round(Number(_.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(S?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${A} / ${R}`},onClick:()=>c0(w.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:S,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(ZG,{node:w})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((U=w.data)==null?void 0:U.label)||w.id}),i.jsxs("small",{children:[In(w.data)," · ",w.id]})]})]},w.id)},[P.nodeIds,c0]),d0=m.useMemo(()=>{const w=jt.trim().toLowerCase();return w?Re.filter(S=>[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].filter(Boolean).some(_=>String(_).toLowerCase().includes(w))):Re},[Re,jt]),f0=m.useCallback((w,S)=>{const _=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let A=`${_}_${Date.now().toString(36)}`,R=2;for(;S.has(A);)A=`${_}_${Date.now().toString(36)}_${R}`,R+=1;return S.add(A),A},[]),yu=m.useCallback((w,S)=>{var Le,Mt;if(!je){ge("Readonly workspace");return}const _=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},A=_.instances&&typeof _.instances=="object"?_.instances:{},R=Object.keys(A);if(R.length===0)return;const U=new Set(N.current.map(De=>De.id)),X={};for(const De of R)X[De]=f0(De,U);const J=(Le=_.ui)!=null&&Le.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},Y=(Mt=_.ui)!=null&&Mt.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.ui.nodeSizes:{},ae=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(...ae.map(De=>De.x)),fe=Math.min(...ae.map(De=>De.y));let Ne=S||{x:360+N.current.length*24,y:180+N.current.length*18};if(!S){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 We={},ze={},Ve={};for(const De of ae){const dt=X[De.id];We[dt]={...A[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"&&(Ve[dt]={width:Pt.width,height:Pt.height})}const He=new Set(R),Me=(Array.isArray(_.edges)?_.edges:[]).filter(De=>He.has(De==null?void 0:De.source)&&He.has(De==null?void 0:De.target)).map(De=>({source:X[De.source],target:X[De.target],sourceHandle:De.sourceHandle??null,targetHandle:De.targetHandle??null})),Ft=Iu({instances:We,edges:Me,ui:{nodePositions:ze,nodeSizes:Ve}},be),rt=Ft.nodes.map(De=>De.id),Ye=Ft.nodes.map(De=>({...De,selected:!0}));Z.current={...Z.current,...Ft.instances},ne(Z.current),g(De=>[...De.map(dt=>({...dt,selected:!1})),...Ye]),x(De=>[...De.map(dt=>({...dt,selected:!1})),...Ft.edges.map(dt=>({...dt,selected:!1}))]),jn(""),K([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${rt.length} 个节点)`)},[f0,be,r,x,g,je]),Q$=m.useCallback(()=>{var _,A;if(er.length<2){Vn("请先在 workspace 画布上选择至少两个节点。"),re("flows");return}const w=er[0],S=er.length===2?`${((_=w.data)==null?void 0:_.label)||w.id} 片段`:`${((A=w.data)==null?void 0:A.label)||w.id} 等 ${er.length} 个节点`;Xn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Ar(""),xr(!0),re("flows")},[er]),Z$=m.useCallback(async()=>{var R,U;if(er.length<2)return;const w=wn.name.trim();if(!w){Ar("请填写片段名称。");return}const S={},_={};for(const X of er){S[X.id]={x:((R=X.position)==null?void 0:R.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const J=Fl(X);J&&(_[X.id]=J)}const A=zf.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));hr(!0),Ar("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:wn.id,name:w,displayName:w,version:"1.0.0",description:wn.description,snippet:{instances:av(er,Z.current),edges:A,ui:{nodePositions:S,nodeSizes:_}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");xr(!1),ge(`流程片段已发布:${J.id||w}`),sS(`流程片段已发布:${J.id||w}`),await Af(),re("flows")}catch(X){Ar(String(X.message||X))}finally{hr(!1)}},[Af,wn,zf,er,sS]),p0=m.useCallback(async()=>{var S;const w=Gc.trim();if(w){$v(!0),Yc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),A=await _.json().catch(()=>({}));if(!_.ok)throw new Error(A.error||"添加协作成员失败");gg(A.workspace||null),Ov(""),ge(`已将 Workspace 分享给 ${((S=A.member)==null?void 0:S.username)||w}`)}catch(_){Yc(String(_.message||_))}finally{$v(!1)}}},[a,Gc]),eL=m.useCallback(()=>{Yc(""),yg(!0)},[]),tL=m.useCallback(async w=>{const S=String((w==null?void 0:w.userId)||"").trim();if(!(!S||S===(an==null?void 0:an.ownerId))){Fv(S),Yc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:S})}),A=await _.json().catch(()=>({}));if(!_.ok)throw new Error(A.error||"取消成员分享失败");gg(A.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||S} 的分享`)}catch(_){Yc(String(_.message||_))}finally{Fv("")}}},[a,an==null?void 0:an.ownerId]),h0=m.useCallback(async()=>{const w=Ml(N.current,j.current,Z.current);w.ui={...w.ui||{},...z.current?{viewport:z.current}:{},displayPage:TC(F.current,N.current)};const S=new Blob([`${JSON.stringify(w,null,2)}
|
|
263
|
+
`],{type:"application/json"}),_=URL.createObjectURL(S),A=document.createElement("a");A.href=_,A.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(A),A.click(),A.remove(),URL.revokeObjectURL(_),await ks(),cl(null),ua(!1),ge("已备份本地草稿并载入远端最新版本")},[j,a.flowId,ks,N]),nL=m.useCallback(async()=>{const w=Array.isArray(En==null?void 0:En.conflictItems)?En.conflictItems:[];if(!w.length||!(En!=null&&En.mergeGraph)||!(En!=null&&En.currentGraph)){Jc("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let S=En.mergeGraph;try{w.forEach((A,R)=>{const U=xg[String(R)]||{mode:"local"};let X,J=!0;U.mode==="remote"?(X=A.current,J=A.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=A.incoming,J=A.hasIncoming!==!1),S=LJ(S,A.pathParts,X,J)})}catch(A){Jc(`手动值不是有效 JSON:${String(A.message||A)}`);return}zv(!0),Jc(""),Os("saving"),Ds("正在提交冲突解决结果");const _=Ce.current.catch(()=>{}).then(async()=>{const A=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:S,baseRevision:En.currentRevision,baseGraph:En.currentGraph,clientId:ke.current})}),R=await A.json().catch(()=>({}));if(!A.ok){if(A.status===409&&Array.isArray(R.conflictItems)){const U=R.conflictItems;cl({currentRevision:String(R.currentRevision||""),message:R.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(R.conflictPaths)?R.conflictPaths:[],conflictItems:U,mergeGraph:R.mergeGraph||null,currentGraph:R.currentGraph||null}),ul(Object.fromEntries(U.map((X,J)=>[String(J),{mode:"local",manual:Ru(X)}])))}throw new Error(R.error||"提交冲突解决结果失败")}await ks(),cl(null),ua(!1),ge("冲突已解决并保存")});Ce.current=_;try{await _}catch(A){Jc(String(A.message||A)),Os("error"),Ds(String(A.message||A))}finally{zv(!1)}},[a,ks,En,xg]);m.useCallback(()=>{if(gu.length===0){ge("当前 workspace 没有 display 节点");return}const w=Ug.length>0?Ug:gu.map(_=>_.id),S=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";le(lw({title:S,layout:"gallery",nodeIds:w,mode:"multi-node"})),sr(""),Gt(null),Pr(!0)},[a.flowId,Ug,gu]);const rL=m.useCallback(w=>{le(S=>{const _=Array.isArray(S.nodeIds)?S.nodeIds:[];return _.includes(w)?{...S,nodeIds:_.filter(A=>A!==w)}:{...S,nodeIds:[..._,w]}})},[]),zs=m.useCallback(async()=>{Ln(!0),zr("");try{const w=await fetch("/api/display/shares"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取分享列表失败");kr(Array.isArray(S.shares)?S.shares:[])}catch(w){zr(String(w.message||w)),kr([])}finally{Ln(!1)}},[]),sL=m.useCallback(()=>{nn(!0),ie(""),zs()},[zs]),iL=m.useCallback(async()=>{var _,A;const w=_t.title.trim(),S=Array.isArray(_t.nodeIds)?_t.nodeIds:[];if(S.length===0){sr("请选择至少一个 display 节点。");return}Qn(!0),sr(""),Gt(null);try{await Zt(b,k);const R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:_t.layout,nodeIds:S,...$C(_t)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const X=new URL(U.url||`/display/${((_=U.share)==null?void 0:_.id)||""}`,window.location.origin).href;Gt({...U,absoluteUrl:X}),ge((A=U.share)!=null&&A.expiresAt?"展示页已生成":"展示页已生成:永久有效"),mt&&zs()}catch(R){sr(String(R.message||R))}finally{Qn(!1)}},[_t,mt,k,a,zs,b,Zt]),oL=m.useCallback(async()=>{var S,_;const w=Array.isArray(P.nodeIds)?P.nodeIds:[];if(w.length===0){sr("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),Pe(!0);return}Qn(!0),sr("");try{await Zt(b,k);const A=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:A,layout:"canvas",nodeIds:w,...$C(_t)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const X=new URL(U.url||`/display/${((S=U.share)==null?void 0:S.id)||""}`,window.location.origin).href;Gt({...U,absoluteUrl:X}),Jt(!0),ge((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),mt&&zs()}catch(A){const R=String(A.message||A);sr(R),ge(R)}finally{Qn(!1)}},[P.nodeIds,_t,mt,k,a,zs,b,Zt]),m0=m.useCallback(async()=>{const w=Ct==null?void 0:Ct.absoluteUrl;if(!w)return;const S=await pb(w);Zn(S?"copied":"failed"),window.setTimeout(()=>Zn(""),1600)},[Ct==null?void 0:Ct.absoluteUrl]),aL=m.useCallback(async w=>{const S=LC(w),_=await pb(S);ie(_?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>ie(""),1600)},[]),lL=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.id)||"");if(_){ai(_),zr("");try{const A=S==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(S||30)},R=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await zs(),ge("分享有效期已更新")}catch(A){zr(String(A.message||A))}finally{ai("")}}},[zs]),cL=m.useCallback(async w=>{const S=String((w==null?void 0:w.id)||"");if(S){ai(S),zr("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(S)}`,{method:"DELETE"}),A=await _.json().catch(()=>({}));if(!_.ok||A.ok===!1)throw new Error(A.error||"撤销分享失败");await zs(),ge("分享已撤销")}catch(_){zr(String(_.message||_))}finally{ai("")}}},[zs]),uL=m.useCallback(w=>{g(S=>S.map(_=>_.id===w?{..._,selected:!1}:_)),jn(S=>S===w?"":S)},[g]),Nl=m.useCallback(()=>{const w=Ig.current;if(!w)return;const S=w.getBoundingClientRect(),_=Math.min(420,Math.max(320,S.width+160)),A=12,R=Math.max(180,S.top-A*2),U=Math.min(560,R);_$({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,S.left)),top:Math.max(A,S.top-U-A),width:_,maxHeight:U,zIndex:1e4})},[]);m.useEffect(()=>{if(!Cf)return;Nl();const w=_=>{var R,U;const A=_.target;(R=Ig.current)!=null&&R.contains(A)||(U=aS.current)!=null&&U.contains(A)||Pg(!1)},S=_=>{_.key==="Escape"&&Pg(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",S),window.addEventListener("resize",Nl),window.addEventListener("scroll",Nl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",S),window.removeEventListener("resize",Nl),window.removeEventListener("scroll",Nl,!0)}},[Cf,Nl]);const Hf=m.useCallback(w=>{const S=AT(w);if(S.active&&(lt.current=!0),S.finished&&(lt.current=!1,oe.current=!0),lY(w)&&li(),d==="display"){I(R=>{var Y,ae;let U=R.nodePositions,X=R.nodeSizes;for(const he of w||[]){const fe=Op(he==null?void 0:he.id);if(!(!fe||!R.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const Ne=U[fe];if((Ne==null?void 0:Ne.x)===he.position.x&&(Ne==null?void 0:Ne.y)===he.position.y)continue;U===R.nodePositions&&(U={...R.nodePositions}),U[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((ae=he.dimensions)!=null&&ae.height)){const Ne=za({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(Ne){const We=X[fe];if((We==null?void 0:We.width)===Ne.width&&(We==null?void 0:We.height)===Ne.height)continue;X===R.nodeSizes&&(X={...R.nodeSizes}),X[fe]=Ne}}}}if(U===R.nodePositions&&X===R.nodeSizes)return R;const J={...R,nodePositions:U,nodeSizes:X};return F.current=J,J});const A=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");A.length>0&&K(R=>{const U=new Set(R);for(const J of A){const Y=Op(J==null?void 0:J.id);Y&&(J.selected?U.add(Y):U.delete(Y))}const X=Array.from(U);return X.length===R.length&&X.every((J,Y)=>J===R[Y])?R:X});return}if(!je){const A=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");A.length>0&&g(R=>ad(A,R));return}const _=(w||[]).filter(A=>{var R,U;return(A==null?void 0:A.type)==="dimensions"&&((R=A.dimensions)==null?void 0:R.width)&&((U=A.dimensions)==null?void 0:U.height)});g(A=>{const R=new Map;if(_.length>0){const J=new Map(A.map(Y=>[Y.id,Y]));for(const Y of _){const ae=J.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=pm(ae)?db(he):za(he,{display:!!In(ae==null?void 0:ae.data)});fe&&R.set(Y.id,fe)}}const U=ad(w,A),X=R.size===0?U:U.map(J=>{const Y=R.get(J.id);if(!Y)return J;const ae={...J.data,nodeSize:Y};return In(J.data)&&(ae.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ae}});return N.current=X,X}),_.length>0&&Br(_.map(A=>A.id))},[li,Br,g,d,je]),Wf=m.useCallback((w=[],{finish:S=!1}={})=>{const _=S?fY([...V.current,...w]):ib(w);S&&(V.current=[]),_.length>0&&Hf(_)},[Hf]),dL=m.useCallback(w=>{const{transient:S,committed:_,finishesInteraction:A}=dY(w);if(S.length>0){lt.current||(lt.current=!0,vl.current=s0.current),V.current=ib([...V.current,...S]);const R=ad(S,vl.current);vl.current=R,s.getState().setNodes(R)}if(A){vl.current=[],Wf(_,{finish:!0});return}_.length>0&&Hf(_)},[Hf,Wf,s]);m.useEffect(()=>{const w=()=>{!lt.current&&V.current.length===0||(Wf([],{finish:!0}),vl.current=[])},S=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w),window.addEventListener("blur",w),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",S),V.current=[],vl.current=[]}},[Wf]);const fL=m.useCallback(w=>{if(d!=="display"){if(!je){const S=(w||[]).filter(_=>(_==null?void 0:_.type)==="select");S.length>0&&x(_=>{const A=Qh(S,_);return j.current=A,A});return}(w||[]).some(S=>(S==null?void 0:S.type)!=="select")&&li(),x(S=>{const _=Qh(w,S);return j.current=_,_})}},[li,x,d,je]),jl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const S=w.getBoundingClientRect();return r.screenToFlowPosition({x:S.left+S.width*.48,y:S.top+S.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),Vf=m.useCallback(()=>{var w,S,_;if(Vt){const A=Number(((w=Vt.measured)==null?void 0:w.width)||Vt.width||260);return{x:Number(((S=Vt.position)==null?void 0:S.x)||0)+A+140,y:Number(((_=Vt.position)==null?void 0:_.y)||0)}}return jl()},[jl,Vt]),zi=m.useCallback((w,S={})=>{if(!je)return ge("Readonly workspace"),null;if(!w)return null;const _=hv(w)||w.id,A=BT(w),R=WT(w),U=S.id||kG(_,b),X=qu(w.inputs),J=qu(w.outputs),Y={definitionId:_,...A?{marketplaceRef:A}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:S.label||fm(w),role:"normal",body:S.body||"",...S.script||R?{script:S.script||R}:{},...S.scriptRef?{scriptRef:S.scriptRef}:{},...S.implementationRef?{implementationRef:S.implementationRef}:{},...S.implementationMode?{implementationMode:S.implementationMode}:{},input:S.inputs||X,output:S.outputs||J},ae={id:U,type:pc,position:S.position||jl(),data:{label:Y.label,definitionId:_,...A?{marketplaceRef:A}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:zT(_,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={...rb(ae,{...Z.current,[U]:Y},be),selected:!0};return li(),g(fe=>[...fe.map(Ne=>({...Ne,selected:!1})),he]),S.openProperties&&jn(U),U},[jl,li,b,be,g,je]),pL=m.useCallback(w=>ow(w,N.current),[]),hL=m.useCallback(w=>{if(!je){ge("Readonly workspace");return}if(!ow(w,N.current)){ge("端口类型不匹配,已取消连线");return}ee(null),li(),g(S=>ew(S,w)),x(S=>{const _=S.filter(R=>!(R.target===w.target&&R.targetHandle===w.targetHandle)),A=uh({...w,markerEnd:{type:bi.ArrowClosed}},_);return j.current=A,A})},[li,x,g,je]),mL=m.useCallback((w,S)=>{if(!je)return;const _=wG(S,N.current);se.current=_?{..._,preferExisting:!!(w!=null&&w.shiftKey)}:null,ee(null)},[je]),gL=m.useCallback((w,S)=>{var He,Me,Ft,rt;if(!je)return;const _=se.current;if(se.current=null,!_||S!=null&&S.toNode)return;const A=xG(be,_),R=bG(N.current,j.current,_);if(A.length===0&&R.length===0){ge(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||_.preferExisting)?R.length>0?"existing":"create":A.length>0?"create":"existing",J=((Me=(He=w==null?void 0:w.changedTouches)==null?void 0:He[0])==null?void 0:Me.clientX)??(w==null?void 0:w.clientX),Y=((rt=(Ft=w==null?void 0:w.changedTouches)==null?void 0:Ft[0])==null?void 0:rt.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ae=document.querySelector(".af-workspace-canvas .react-flow");if(!ae)return;const he=ae.getBoundingClientRect(),fe=320,Ne=Math.max(A.length,R.length),We=Math.min(480,150+Ne*58),ze=Math.max(12,Math.min(J-he.left,he.width-fe-12)),Ve=Math.max(12,Math.min(Y-he.top,he.height-We-12));ee({left:ze,top:Ve,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:_,candidates:A,existingCandidates:R,mode:X,query:""})},[be,r,je]),yL=m.useCallback(w=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=ue.current;if(!S||!(w!=null&&w.def))return;const _=zi(w.def,{position:S.flowPosition});if(!_)return;const A=S.draft.handleType==="source"?{source:S.draft.nodeId,sourceHandle:S.draft.handleId,target:_,targetHandle:`input-${w.slotIndex}`}:{source:_,sourceHandle:`output-${w.slotIndex}`,target:S.draft.nodeId,targetHandle:S.draft.handleId};g(R=>ew(R,A)),x(R=>{const U=R.filter(J=>!(J.target===A.target&&J.targetHandle===A.targetHandle)),X=uh({...A,markerEnd:{type:bi.ArrowClosed}},U);return j.current=X,X}),ee(null)},[zi,x,je]),wL=m.useCallback(w=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=w==null?void 0:w.connection;if(!S||!ow(S,N.current)){ge("端口类型不匹配,已取消连线"),ee(null);return}g(_=>ew(_,S)),x(_=>{const A=_.filter(U=>!(U.target===S.target&&U.targetHandle===S.targetHandle)),R=uh({...S,markerEnd:{type:bi.ArrowClosed}},A);return j.current=R,R}),ee(null)},[x,g,je]),g0=m.useCallback(w=>{w&&(zi(w,{position:Vf()}),q(!1),et(""))},[zi,Vf]),y0=m.useCallback(w=>{w&&(yu(w,Vf()),q(!1),et(""))},[yu,Vf]),xL=m.useCallback(w=>{var _,A,R;if(ut||Pn)return;const S=w==null?void 0:w.target;vC(S)||(_=S==null?void 0:S.closest)!=null&&_.call(S,"button, a, [role='button'], .react-flow__handle")||(R=(A=C.current)==null?void 0:A.focus)==null||R.call(A,{preventScroll:!0})},[ut,Pn]);m.useEffect(()=>{const w=S=>{var ae;if(S.defaultPrevented)return;const _=fU(S.target)||vC(S.target);if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="s"){S.preventDefault(),Zt().catch(he=>ge(String(he.message||he)));return}if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"){S.preventDefault(),S.stopPropagation(),gS(he=>!he);return}if(Lg)return;if($g){(S.key==="Escape"||sC(S))&&(S.preventDefault(),Ef(!1));return}const A=S.key.toLowerCase(),R=(S.metaKey||S.ctrlKey)&&A==="c",U=(S.metaKey||S.ctrlKey)&&A==="v",X=_&&R&&MY(S.target);if(_&&!X)return;const J=(S.metaKey||S.ctrlKey)&&!S.shiftKey&&A==="z",Y=(S.metaKey||S.ctrlKey)&&(S.shiftKey&&A==="z"||A==="y");if(J||Y){if(ut){S.preventDefault(),S.stopPropagation(),ge("展示页布局会自动保存");return}if(!je){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),S.stopPropagation();const he=J?IS():RS();ge(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(R){if(ut)return;const he=go.current,fe=(N.current||[]).some(We=>We==null?void 0:We.selected)?N.current:(N.current||[]).map(We=>he&&We.id===he?{...We,selected:!0}:We),Ne=$q(fe,j.current,Z.current);Ne&&(S.preventDefault(),S.stopPropagation(),B.current=Ne,LG(Ne),X&&typeof((ae=S.target)==null?void 0:ae.blur)=="function"&&S.target.blur(),ge(`Copied ${Ne.nodes.length} node${Ne.nodes.length>1?"s":""}`));return}if(U){if(ut){S.preventDefault(),S.stopPropagation();return}if(!je){S.preventDefault(),ge("Readonly workspace");return}const he=B.current||OG();he&&!B.current&&(B.current=he);const fe=Lq(he,N.current,j.current,Z.current);fe&&(S.preventDefault(),S.stopPropagation(),Z.current=fe.instances,ne(fe.instances),g(fe.nodes),x(fe.edges),ge(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(sC(S)&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),Ef(!0);return}if(A==="g"&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),o0();return}if(S.key==="a"||S.key==="A"){if(S.metaKey||S.ctrlKey){S.preventDefault(),ut?K(F.current.nodeIds):(g(he=>he.map(fe=>({...fe,selected:!0}))),x(he=>he.map(fe=>({...fe,selected:!1}))));return}if(S.altKey)return;if(ut){S.preventDefault(),Pe(!0);return}if(!je){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),q(!0);return}if((S.key==="v"||S.key==="V")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),yS("select");return}if((S.key==="h"||S.key==="H")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),yS("pan");return}(S.key==="f"||S.key==="F")&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&(S.preventDefault(),i0())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[o0,ut,Lg,i0,RS,Zt,$g,x,g,IS,je]);const bL=m.useCallback(w=>{dl(S=>{const _=new Set(S);return _.has(w)?_.delete(w):_.add(w),_})},[]),kL=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:S.path,name:S.name,type:S.type})),w.dataTransfer.setData("text/plain",S.path)},[]),vL=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",S.id),w.dataTransfer.setData("text/plain",S.id)},[]),Kf=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),A=_.split(".").pop(),R=["jsx","tsx","js"].includes(A)?"display_react_app":A==="html"?"display_html":A==="csv"||A==="tsv"||A==="json"&&/\b(table|data|rows|report)\b/i.test(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(A)?"display_image":"display_markdown",U=be.find(fe=>fe.id===R);if(!U){ge("展示节点不可用");return}const X=R==="display_image";let J=String(w.path||"");if(!X){const fe=Tr(a);fe.set("path",w.path);const Ne=await fetch(`/api/workspace/file?${fe.toString()}`),We=await Ne.json();if(!Ne.ok)throw new Error(We.error||"读取文件失败");J=String(We.content||"")}const Y=R==="display_image"?"src":"content",ae=qu(U.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),he=qu(U.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);zi(U,{label:w.name||"Display",body:J,inputs:ae,outputs:he,position:S}),ge(`已创建展示:${w.path}`)},[zi,a,be]),SL=m.useCallback(w=>{if(!je){ge("Readonly workspace");return}Kf(w,jl()).catch(S=>ge(String(S.message||S)))},[Kf,jl,je]),NL=m.useCallback(w=>{if(!je){w.preventDefault(),ge("Readonly workspace");return}const S=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(S){w.preventDefault();let X;try{X=JSON.parse(S)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Kf(X,J).catch(Y=>ge(String(Y.message||Y)));return}const _=w.dataTransfer.getData("application/agentflow-snippet");if(_){const X=Re.find(Y=>`${Y.id}@${Y.version}`===_);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});yu(X,J);return}const A=w.dataTransfer.getData("application/agentflow-node");if(!A)return;const R=be.find(X=>X.id===A);if(!R)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});zi(R,{position:U})},[Kf,zi,Re,yu,be,r,je]),jL=m.useCallback(w=>{if(!je)return;const S=Array.from(w.dataTransfer.types||[]);!S.includes("application/x-agentflow-workspace-file")&&!S.includes("application/agentflow-node")&&!S.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=S.includes("application/agentflow-node")||S.includes("application/agentflow-snippet")?"move":"copy")},[je]),CL=m.useCallback(async(w="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const A=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_,content:""})}),R=await A.json();if(!A.ok)throw new Error(R.error||"创建文件失败");await An(),dl(U=>{const X=new Set(U);for(const J of Dp(R.path||_))X.delete(J);return X}),ge(`已创建 ${R.path}`)}catch(A){ge(String(A.message||A))}},[a,An,je]),_L=m.useCallback(async(w="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const A=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_})}),R=await A.json();if(!A.ok)throw new Error(R.error||"创建文件夹失败");await An(),dl(U=>{const X=new Set(U);for(const J of Dp(R.path||_))X.delete(J);return R.path&&X.delete(R.path),X}),ge(`已创建 ${R.path}`)}catch(A){ge(String(A.message||A))}},[a,An,je]),EL=m.useCallback(async w=>{if(!je){ge("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const S=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),_=await S.json();if(!S.ok)throw new Error(_.error||"删除失败");ge(`已删除 ${_.path}`),await An()}catch(S){ge(String(S.message||S))}},[a,An,je]),AL=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const S=Ud(w.path,a,{download:!0});if(!S)return;const _=document.createElement("a");_.href=S,_.download=w.name||w.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[a]),qf=m.useCallback(async()=>{if(!je){ge("Readonly workspace");return}const w=fa.trim(),S=Hr,_=Ls.find(X=>X.id===S)||null;if(!w||ns||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const A=_?Array.isArray(_.messages)?_.messages:[]:pa,R=Ml(b,k,Z.current);Rg(""),cS(!0),ml(!0),gl(null);const U={role:"user",text:w,at:Date.now()};_?qn(X=>X.map(J=>J.id===S?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(bs("workspace"),hl(X=>[...X,U]));try{await Zt(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:Li,selectedSkills:$s,selectedNodeIds:Ff,messages:A})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const ae={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};_?qn(he=>he.map(fe=>fe.id===S?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],ae].slice(-180)}:fe)):hl(he=>[...he,ae]),await ks(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};_?qn(ae=>ae.map(he=>he.id===S?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):hl(ae=>[...ae,Y]),ge(J)}finally{cS(!1)}},[Hr,pa,Li,Ls,ns,fa,k,a,ks,b,Zt,Ff,$s,je]),or=Ls.find(w=>w.id===Hr)||null,Jg=or?Array.isArray(or.messages)?or.messages:[]:pa,Cl=or&&(or.status==="running"||or.status==="stopping")||ns,PL=wJ(Jg,Cl),Xg=xJ(Jg),w0=or?or.status==="stopping"?`${or.label} stopping`:or.status==="running"?`${or.label} running`:or.status==="paused"?`${or.label} paused`:or.status==="failed"?`${or.label} failed`:`${or.label} done`:ns?"Workspace agent running":pa.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Hr!=="workspace"&&(Ls.some(w=>w.id===Hr)||bs(ga()))},[Hr,Ls,ga]),m.useEffect(()=>{if(!tu)return;const w=window.requestAnimationFrame(()=>{var _,A;const S=uS.current;S&&(S.scrollTop=S.scrollHeight),(A=(_=Tg.current)==null?void 0:_.scrollIntoView)==null||A.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[Jg.length,Hr,w0,Xg.length,tu]);const IL=String(a.flowId||"").trim()||"Workspace",wo=(_t==null?void 0:_t.mode)==="single-node",x0=wo&&gu.find(w=>{var S;return w.id===_t.sourceNodeId||((S=_t.nodeIds)==null?void 0:S.includes(w.id))})||null,RL=wo&&x0?[x0]:gu;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("/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} · ${Mv}`:Mv||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:IL}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",jY,"-STABLE"]})]}),i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:d==="workspace"?"af-view-switch__active":"",onClick:()=>Gg("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:d==="display"?"af-view-switch__active":"",onClick:()=>Gg("display"),children:"Display"}),i.jsx("button",{type:"button",className:d==="workflow"?"af-view-switch__active":"",onClick:()=>Gg("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${SS}`,title:`${AS} · ${NS}`,role:"status","aria-label":`${AS}:${NS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),En?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=En.conflictItems)!=null&&w.length?ua(!0):h0()},title:["先下载当前本地草稿,再载入远端最新版本",...En.conflictPaths||[]].join(`
|
|
264
|
+
`),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:dn||!(Ct!=null&&Ct.absoluteUrl)&&P.nodeIds.length===0,onClick:()=>{Zn(""),Jt(!0)},title:Ct!=null&&Ct.absoluteUrl?"查看展示链接":P.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:dn?"hourglass_empty":"ios_share"}),dn?"生成中":Ct!=null&&Ct.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:kl.length===0,onClick:()=>Pe(!0),title:kl.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:!!(an!=null&&an.role&&an.role!=="owner"),onClick:eL,title:an!=null&&an.role&&an.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:sL,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:!ES,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:!ES&&!lu,onClick:()=>v(!0),"aria-label":lu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:lu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:lu?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ef(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(tu?" af-composer-topbar-btn--active":"")+(ns?" af-composer-topbar-btn--running":""),disabled:ut||Pn,onClick:()=>{gl(null),ml(w=>(w||bs(ga()),!w))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!je,onClick:()=>Zt().catch(w=>ge(String(w.message||w))),children:"Save"})]})]}),gs?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:gs}),i.jsx("button",{type:"button",onClick:()=>ys(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!ut&&!Pn&&(tu||at)?" af-workspace-body--drawer":"")+(!ut&&!Pn&&ru?" af-workspace-body--sidebar-collapsed":"")+(ut?" af-workspace-body--display-mode":"")+(Pn?" af-workspace-body--workflow-mode":""),children:[!ut&&!Pn&&ru?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:()=>q(!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:()=>_f(!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:()=>_f(!1),"aria-label":"展开侧边栏",title:(Ir==null?void 0:Ir.username)||(Ir==null?void 0:Ir.userId)||"展开侧边栏",children:J$})]})}):null,!ut&&!Pn?i.jsxs("aside",{ref:Ng,className:"af-workspace-sidebar"+(m$?" af-workspace-sidebar--resizing":""),"aria-hidden":ru,style:{"--af-work-files-pane-height":`${Math.round(jg)}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:()=>_f(!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:()=>CL(Fi),"aria-label":"新增文件",title:Fi?`在 ${Fi} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je,onClick:()=>_L(Fi),"aria-label":"新增文件夹",title:Fi?`在 ${Fi} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je||Hv,onClick:()=>qS(Fi),"aria-label":"上传文件",title:Fi?`上传到 ${Fi}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:Hv?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void An(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:Vv,type:"file",multiple:!0,className:"af-visually-hidden",onChange:z$})]})]}),i.jsx("input",{className:"af-workspace-search",value:bg,onChange:w=>p$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:Y$,children:i.jsx(iM,{items:U$,onOpen:SL,selectedPath:kg,collapsedDirs:h$,onToggleDir:bL,onSelect:w=>vg(w.path||""),onFileDragStart:kL,onDelete:EL,onDownload:AL})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:N$,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:on==="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:jt,onChange:w=>yn(w.target.value),placeholder:on==="flows"?"搜索流程片段...":"搜索节点...","aria-label":on==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":on==="nodes",className:"af-palette-tab"+(on==="nodes"?" af-palette-tab--active":""),onClick:()=>re("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":on==="flows",className:"af-palette-tab"+(on==="flows"?" af-palette-tab--active":""),onClick:()=>re("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:on==="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:Q$,disabled:er.length<2,title:er.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",er.length," 节点 / ",zf.length," 连线"]})]})}),At?i.jsx("p",{className:"af-err af-palette-list-err",children:At}):null,Ze?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):d0.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:d0.map(w=>{const S=`${w.id}@${w.version}`,_=w.displayName||w.name||w.id,A=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",S),R.dataTransfer.setData("text/plain",S)},onClick:()=>yu(w),title:A,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:_}),i.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),A?i.jsx("span",{className:"af-palette-card-desc",children:A}):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"]})]})]},S)})})]}):i.jsx("p",{className:"af-palette-empty",children:jt.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Ol.map(w=>{var S;return(S=Kg[w])!=null&&S.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:Kg[w].map(_=>{const A=AC(_.inputs,"input"),R=AC(_.outputs,"output"),U=ub(_),X=Vu(_);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>vL(J,_),onClick:()=>zi(_),title:U||_.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:_C(w)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:X}),X!==_.id?i.jsx("span",{className:"af-palette-card-id",children:_.id}):null]})]}),U?i.jsx("span",{className:"af-palette-card-desc",children:U}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[A.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[A.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:EC("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Tn(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:$p(J,Y)})]},`in-${Y}`)),A.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",A.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:EC("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:$p(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Tn(J==null?void 0:J.type)}})]},`out-${Y}`)),R.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",R.hidden]}):null]})]})]})]},_.id)})})]},w):null}),be.length>0&&jt.trim()&&Ol.every(w=>{var S;return!((S=Kg[w])!=null&&S.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,Pn?i.jsx($J,{flowParams:a,tapdId:ir,setTapdId:k$,snapshot:ln,loading:v$,error:S$,actionRunning:Cg,actionOutput:_g,pendingConfirm:xs,conflict:Zc,reviewPublishing:Eg,onRefresh:()=>uu(ir),onRunDryRun:T$,onConfirmAction:M$,onRetryConflict:$$,onPublishReview:L$}):i.jsxs("main",{ref:C,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:xL,children:[i.jsx(gR,{className:"af-flow-canvas af-workspace-flow"+(Og==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ut?" af-workspace-flow--display-mode":""),nodes:Df,edges:K$,nodeTypes:uJ,onNodesChange:dL,onEdgesChange:fL,onConnect:ut?void 0:hL,onConnectStart:ut?void 0:mL,onConnectEnd:ut?void 0:gL,isValidConnection:ut?void 0:pL,onNodeClick:(w,S)=>{var _;if(ut){K([Op(S.id)]);return}if((_=S==null?void 0:S.data)!=null&&_.isWorkspaceGroup){jn("");return}if(w.detail>=3){ml(!1),g(A=>A.map(R=>({...R,selected:R.id===S.id}))),x(A=>A.map(R=>({...R,selected:!1}))),jn(S.id);return}Ut&&jn(S.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{ut?K([]):jn("")},onDrop:ut?void 0:NL,onDragOver:ut?void 0:jL,nodesDraggable:ut?!0:je,nodesConnectable:ut?!1:je,edgesReconnectable:ut?!1:je,onlyRenderVisibleElements:Df.length>=80,deleteKeyCode:ut?null:je?["Backspace","Delete"]:null,selectionOnDrag:Og==="select",panOnDrag:Og==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(wR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ut&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),S=G.mode==="create"?"create":"existing",_=Array.isArray(G.candidates)?G.candidates:[],A=Array.isArray(G.existingCandidates)?G.existingCandidates:[],R=w?_.filter(Y=>{var ae,he,fe;return[(ae=Y.def)==null?void 0:ae.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(Ne=>String(Ne).toLowerCase().includes(w))}):_,U=w?A.filter(Y=>{var ae,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ae=Y.slot)==null?void 0:ae.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):A,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:Tn((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:()=>ee(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:S==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:A.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:A.length})]}),i.jsxs("button",{type:"button",className:S==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:_.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:_.length})]})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:G.query,onChange:Y=>ee(ae=>ae&&{...ae,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[S==="create"?R.map(Y=>{var fe,Ne;const ae=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),he=$p(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>yL(Y),title:Y.description||Y.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),ae!==Y.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Tn((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}`)}):U.map(Y=>{var fe;const ae=Y.nodeLabel||Y.nodeId,he=$p(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>wL(Y),title:`${Y.definitionId||Y.nodeId} · ${he}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Tn((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}`)}),(S==="create"?R.length:U.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ut&&!Pn&&!E$?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:()=>Mg(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),i.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:er.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):er.map(w=>{var R,U;const S=String(((R=w.data)==null?void 0:R.label)??w.id),_=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",A=_&&_!==S?`${S} · ${w.id} · ${_}`:`${S} · ${w.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:A,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:_||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:S}),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:fa,rows:2,onChange:w=>Rg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),qf())},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:Ig,type:"button",className:"af-composer-skills-button"+($s.length>0?" af-composer-skills-button--active":""),disabled:ns||!je,"aria-haspopup":"listbox","aria-expanded":Cf,onClick:()=>Pg(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:$s.length>0?`Skills ${$s.length}`:"Skills"})]}),Cf&&!ns?cr.createPortal(i.jsx("div",{ref:aS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:C$,children:Ms.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Sl.groups.map(w=>{const S=Qo(w,Ms),_=jF(w,qg,Ms),A=j$.has(w.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(A?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:_==="all",disabled:S.length===0,onChange:R=>{const U=R.target.checked;Qc(X=>U?SF(X,S):NF(X,S))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:w.name}),w.builtin?i.jsx("em",{children:"built-in"}):null,_==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":A?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{oS(R=>{const U=new Set(R);return U.has(w.id)?U.delete(w.id):U.add(w.id),U})},children:[i.jsx("span",{children:w.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:A?"expand_more":"expand_less"})]})]}),A?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:qg.has(R.key),onChange:U=>{const X=U.target.checked;Qc(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)}),Sl.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:Sl.ungrouped.length})]}),Sl.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:qg.has(w.key),onChange:S=>{const _=S.target.checked;Qc(A=>_?A.includes(w.key)?A:[...A,w.key]:A.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:Li,onChange:w=>y$(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),G$.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(fa.trim()&&!ns?" af-composer-send--active":"")+(ns?" af-composer-send--stop":""),disabled:ns||!fa.trim()||!je,"aria-label":ns?"Running":"Send",onClick:()=>void qf(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ns?"sync":"arrow_upward"})})]})]})]})}):!ut&&!Pn?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Mg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!ut&&!Pn&&tu?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:()=>ml(!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"+(Hr==="workspace"?" af-composer-session-tab--active":""),ref:Hr==="workspace"?Tg:null,onClick:()=>bs("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Ls.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:Hr===w.id?Tg:null,className:"af-composer-session-tab"+(Hr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>bs(w.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),bs(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:S=>{S.preventDefault(),S.stopPropagation(),D$(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"+(Cl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:w0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:uS,children:[i.jsx(zC,{messages:PL,running:Cl,showRunningIndicator:!or}),Xg.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",...Cl?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(zC,{messages:Xg,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:fa,rows:3,onChange:w=>Rg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),qf())},placeholder:or?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!je||Cl}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!je||Cl||!fa.trim(),onClick:()=>void qf(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!ut&&!Pn&&at&&Vt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(MU,{draft:at,setDraft:ws,definitionId:String(((b0=Vt.data)==null?void 0:b0.definitionId)||Vt.id),systemPromptReadonly:String(((k0=Vt.data)==null?void 0:k0.description)||""),modelLists:da,disabled:!je,onIdBlur:()=>Hg(!0),onClose:()=>jn(""),onPublishToMarketplace:O$,error:l$,ioSlots:{inputs:Array.isArray(at==null?void 0:at.inputs)?at.inputs:[],outputs:Array.isArray(at==null?void 0:at.outputs)?at.outputs:[]}})}):null,!ut&&!Pn&&nu?cr.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>gl(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(xU,{flowParams:a,scheduleNodeId:nu.scheduleNodeId,runNodeId:nu.runNodeId,lastRunId:nu.lastRunId,label:nu.label,onClose:()=>gl(null)})})}),document.body):null,i.jsx(mU,{open:$g,onClose:()=>Ef(!1)}),i.jsx(yU,{open:Lg,onClose:()=>gS(!1),onJump:Vg,nodes:q$}),i.jsx($U,{open:p,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:au,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(LU,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:au,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:lu,onDeleted:async()=>{v(!1),n("/projects")}}),f$&&En?cr.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"}),"解决 ",((v0=En.conflictItems)==null?void 0:v0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ua(!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:()=>ul(Object.fromEntries((En.conflictItems||[]).map((w,S)=>[String(S),{mode:"local",manual:Ru(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>ul(Object.fromEntries((En.conflictItems||[]).map((w,S)=>[String(S),{mode:"remote",manual:Ru(w)}]))),children:"全部使用远端"})]})]}),(En.conflictItems||[]).map((w,S)=>{const _=xg[String(S)]||{mode:"local",manual:Ru(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(([A,R])=>i.jsx("button",{type:"button",className:_.mode===A?"is-active":"",onClick:()=>ul(U=>({...U,[String(S)]:{..._,mode:A}})),children:R},A))}),i.jsxs("div",{className:"af-workspace-conflict-values",children:[i.jsxs("div",{className:_.mode==="local"?"is-selected":"",children:[i.jsx("span",{children:"我的修改"}),i.jsx("pre",{children:GC(w,"incoming")})]}),i.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:GC(w,"current")})]})]}),_.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:_.manual,onChange:A=>ul(R=>({...R,[String(S)]:{..._,manual:A.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${S}`)}),Bv?i.jsx("div",{className:"af-flow-snippet-error",children:Bv}):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:vf,onClick:()=>void h0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:vf,onClick:()=>ua(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:vf||!(En.conflictItems||[]).length,onClick:()=>void nL(),children:vf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,Sn?cr.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:()=>xr(!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:wn.name,onChange:w=>{const S=w.target.value;Xn(_=>({..._,name:S,id:_.id?_.id:S.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:wn.id,onChange:w=>Xn(S=>({...S,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:wn.description,onChange:w=>Xn(S=>({...S,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",er.length," 个节点和 ",zf.length," 条内部连线。"]}),ts?i.jsx("div",{className:"af-flow-snippet-error",children:ts}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>xr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Kn||!wn.name.trim(),onClick:()=>void Z$(),children:Kn?"发布中...":"发布"})]})]})}),document.body):null,t0?i.jsx(QG,{node:t0,onClose:()=>zn("")}):null,rr?cr.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":wo?"新建分享":"发布展示页",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"}),wo?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Pr(!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:_t.title,onChange:w=>le(S=>({...S,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),wo?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:_t.layout,onChange:w=>le(S=>({...S,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:MC(_t),onChange:w=>{const S=w.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:aw.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":wo?"分享内容":"选择展示节点",children:[wo?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,RL.map(w=>{var _;const S=Array.isArray(_t.nodeIds)&&_t.nodeIds.includes(w.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:S,disabled:wo,onChange:()=>rL(w.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((_=w.data)==null?void 0:_.label)||w.id}),i.jsxs("small",{children:[In(w.data)," · ",w.id]})]})]},w.id)})]}),Ct!=null&&Ct.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:Ct.absoluteUrl,onFocus:w=>w.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(Ct.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void m0(),children:tn==="copied"?"已复制":tn==="failed"?"复制失败":"复制"})]}):null,br?i.jsx("div",{className:"af-flow-snippet-error",children:br}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Pr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:dn||!Array.isArray(_t.nodeIds)||_t.nodeIds.length===0,onClick:()=>void iL(),children:dn?"生成中...":"生成链接"})]})]})}),document.body):null,Dt?cr.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:()=>{Zn(""),Jt(!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:[Ct!=null&&Ct.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:Ct.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(Ct.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 m0(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:tn==="copied"?"check":"content_copy"}),tn==="copied"?"已复制":tn==="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:MC(_t),onChange:w=>{const S=w.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:aw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),br?i.jsx("div",{className:"af-flow-snippet-error",children:br}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Zn(""),Jt(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:dn||P.nodeIds.length===0,onClick:()=>void oL(),children:dn?"生成中...":Ct!=null&&Ct.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,d$?cr.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:()=>yg(!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.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:Gc,onChange:w=>Ov(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Gc.trim()&&!wg&&(w.preventDefault(),p0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:wg||!Gc.trim(),onClick:()=>void p0(),children:wg?"添加中...":"添加成员"})]}),Lv?i.jsx("div",{className:"af-flow-snippet-error",children:Lv}):null,i.jsx("div",{className:"af-workspace-member-list",children:((an==null?void 0:an.members)||[]).map(w=>{const S=w.userId===(an==null?void 0:an.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:S?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:w.username||w.userId}),i.jsx("small",{children:S?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),S?null:i.jsx("button",{type:"button",disabled:Dv===w.userId,onClick:()=>void tL(w),children:Dv===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:()=>yg(!1),children:"完成"})})]})}),document.body):null,mt?cr.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:()=>nn(!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:Wt.length?`${Wt.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void zs(),disabled:tt,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),$i?i.jsx("div",{className:"af-flow-snippet-error",children:$i}):null,tt?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!tt&&Wt.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:Wt.map(w=>{const S=LC(w),_=mo===w.id,A=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:TG(w)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:S,onFocus:R=>R.target.select()}),i.jsx("select",{className:"af-display-share-select",value:A,disabled:_,onChange:R=>void lL(w,R.target.value),"aria-label":"修改分享有效期",children:aw.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(S,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void aL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ts===w.id?"check":"content_copy"}),Ts===w.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:_,onClick:()=>void cL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,Se?cr.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:()=>Pe(!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:xt,onChange:w=>Lt(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":u0.length||1},children:Bf.length>0?u0.map((w,S)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(X$)},`display-picker-column-${S}`)):i.jsx("div",{className:"af-display-picker-empty",children:kl.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:()=>Pe(!1),children:"完成"})})]})}),document.body):null,Xc.nodeId?cr.createPortal(i.jsx(yJ,{files:ll,query:Xc.query,onQueryChange:w=>Sg(S=>({...S,query:w})),onSelect:B$,onUpload:qS,onClose:zg}),document.body):null,!ut&&!Pn&&On?cr.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>q(!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":pe==="nodes",className:"af-workspace-quick-add__tab"+(pe==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Oe("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":pe==="flows",className:"af-workspace-quick-add__tab"+(pe==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Oe("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:lS,value:Ee,onChange:w=>et(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),q(!1);else if(w.key==="ArrowDown"){w.preventDefault();const S=pe==="flows"?mu.length:hu.length;kt(_=>Math.min(Math.max(0,S-1),_+1))}else w.key==="ArrowUp"?(w.preventDefault(),kt(S=>Math.max(0,S-1))):w.key==="Tab"?(w.preventDefault(),Oe(S=>S==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),pe==="flows"?y0(mu[Nn]||mu[0]):g0(hu[Nn]||hu[0]))},placeholder:pe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":pe==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:pe==="flows"?mu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Ze?"正在加载流程片段...":At||"没有匹配的流程片段"}):mu.map((w,S)=>{const _=w.displayName||w.name||w.id,A=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,R=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,U=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(A||{}).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"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>kt(S),onClick:()=>y0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:_}),i.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${U} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):hu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):hu.map((w,S)=>{const _=Wu(w),A=Vu(w),R=ub(w);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>kt(S),onClick:()=>g0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:_C(_)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:A}),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:_})]},w.id)})})]})}),document.body):null]})]})}function DJ(){return i.jsx(Fk,{children:i.jsx(OJ,{})})}function FJ(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 zJ(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 BJ(e){let t=String(e||"").replace(/\r\n/g,`
|
|
265
|
+
`).trim();return t.includes(`
|
|
266
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
267
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
268
|
+
$2`)),t}function gM(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=BJ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
269
|
+
`).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
|
|
270
|
+
`).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function wv(e){let t=gM(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 HJ(e){const t=wv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function WJ(e){const t=wv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
271
|
+
(() => {
|
|
272
|
+
document.addEventListener("click", (event) => {
|
|
273
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
274
|
+
if (!link) return;
|
|
275
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
276
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
277
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
283
|
+
}, true);
|
|
284
|
+
})();
|
|
285
|
+
<\/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 yM(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 VJ(e,t,n={}){const r=String(e||"").trim();return r?yM(r,t,n):""}function KJ({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=x=>{x.preventDefault(),l(c(x.clientY,b))},k=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[i.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function gb({node:e,shareId:t,style:n,bare:r=!1}){const s=FJ(e),o=e.kind==="html"?wv(s):e.kind==="react"?ag(s):gM(s),a=e.kind==="html"?HJ(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:zJ(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(KJ,{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:WJ(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:lv(o)}):null,e.kind==="image"?i.jsx("img",{src:yM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(nv,{content:o,resolveSrc:(c,u)=>VJ(c,t,u)})}):null,e.kind==="chart"?i.jsx(sv,{content:o}):null,e.kind==="table"?i.jsx(rv,{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 qJ({data:e}){return i.jsx(gb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const UJ={publicDisplay:qJ};function YJ(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 wM(){var l,c,u,d;const{path:e}=si(),t=m.useMemo(()=>YJ(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function p(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return p(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((p,h)=>{const y=p.position&&typeof p.position.x=="number"&&typeof p.position.y=="number"?p.position:{x:120+h*40,y:100+h*32},v=p.size&&typeof p.size.width=="number"&&typeof p.size.height=="number"?p.size:{width:520,height:320};return{id:p.id,type:"publicDisplay",position:y,data:{node:p,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(v.width)||520),height:Math.max(1,Number(v.height)||320)}}}),[t,n.nodes]),o=m.useMemo(()=>{var v;const f=(v=n.share)==null?void 0:v.viewport;if(!f||typeof f!="object")return null;const p=Number(f.x),h=Number(f.y),y=Number(f.zoom);return!Number.isFinite(p)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:p,y:h,zoom:Math.min(Math.max(y,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return i.jsx("main",{className:"af-public-display-page",children:i.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return i.jsx("main",{className:"af-public-display-page",children:i.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),i.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return i.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>i.jsx(gb,{node:p,shareId:t,bare:!0},p.id))})});const f=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return i.jsxs("main",{className:`af-public-display-page ${f}`,children:[i.jsxs("header",{className:"af-public-display-hero",children:[i.jsxs("div",{children:[i.jsx("p",{children:"AgentFlow Display"}),i.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),i.jsx("span",{children:(d=n.share)!=null&&d.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>i.jsx(gb,{node:p,shareId:t},p.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(Fk,{children:i.jsx(gR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:UJ,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(wR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const bt=e=>typeof e=="string",Tu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},JC=e=>e==null?"":""+e,GJ=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},JJ=/###/g,XC=e=>e&&e.indexOf("###")>-1?e.replace(JJ,"."):e,QC=e=>!e||bt(e),pd=(e,t,n)=>{const r=bt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(QC(e))return{};const o=XC(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return QC(e)?{}:{obj:e,k:XC(r[s])}},ZC=(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},XJ=(e,t,n,r)=>{const{obj:s,k:o}=pd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},ym=(e,t)=>{const{obj:n,k:r}=pd(e,t);if(n)return n[r]},QJ=(e,t,n)=>{const r=ym(e,n);return r!==void 0?r:ym(t,n)},xM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?bt(e[r])||e[r]instanceof String||bt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):xM(e[r],t[r],n):e[r]=t[r]);return e},$l=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ZJ={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const eX=e=>bt(e)?e.replace(/[&<>"'\/]/g,t=>ZJ[t]):e;class tX{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 nX=[" ",",","?","!",";"],rX=new tX(20),sX=(e,t,n)=>{t=t||"",n=n||"";const r=nX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=rX.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!s.test(e);if(!o){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(o=!0)}return o},yb=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},wm=e=>e&&e.replace("_","-"),iX={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 xm{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||iX,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:(bt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new xm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new xm(this.logger,t)}}var Si=new xm;class ug{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 e_ extends ug{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):bt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=ym(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!bt(r)?c:yb(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),ZC(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)(bt(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=ym(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?xM(c,r,o):c={...c,...r},ZC(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 bM={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 t_={};class bm extends ug{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),GJ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Si.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&&!sX(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:bt(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:bt(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(d){const N=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${N}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${N}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(p),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!bt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&x&&b.indexOf(v)<0&&!(bt(g)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const N=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=N,f.usedParams=this.getUsedParamsDetails(n),f):N}if(o){const N=Array.isArray(p),j=N?[]:{},C=N?y:h;for(const P in p)if(Object.prototype.hasOwnProperty.call(p,P)){const I=`${C}${o}${P}`;j[P]=this.translate(I,{...n,joinArrays:!1,ns:l}),j[P]===I&&(j[P]=p[P])}p=j}}else if(k&&bt(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let N=!1,j=!1;const C=n.count!==void 0&&!bt(n.count),P=bm.hasDefaultValue(n),I=C?this.pluralResolver.getSuffix(u,n.count,n):"",F=n.ordinal&&C?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",$=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),D=$&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${I}`]||n[`defaultValue${F}`]||n.defaultValue;!this.isValidLookup(p)&&P&&(N=!0,p=D),this.isValidLookup(p)||(j=!0,p=a);const O=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:p,M=P&&D!==p&&this.options.updateMissing;if(j||N||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?D:p),o){const T=this.resolve(a,{...n,keySeparator:!1});T&&T.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 K=[];const H=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&H&&H[0])for(let T=0;T<H.length;T++)K.push(H[T]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(n.lng||this.language):K.push(n.lng||this.language);const L=(T,W,E)=>{const Q=P&&E!==p?E:O;this.options.missingKeyHandler?this.options.missingKeyHandler(T,c,W,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(T,c,W,Q,M,n),this.emit("missingKey",T,c,W,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?K.forEach(T=>{const W=this.pluralResolver.getSuffixes(T,n);$&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(E=>{L([T],a+E,n[`defaultValue${E}`]||D)})}):L(K,a,D))}p=this.extendTranslation(p,t,n,f,r),j&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(j||N)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,N?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,s,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=bt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(u){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=r.replace&&!bt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),y=0;y<p;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=bt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=bM.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 bt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;s=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!bt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(bt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!t_[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(t_[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(g=>{if(this.isValidLookup(r))return;a=g;const k=[d];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,d,g,b,n);else{let N;p&&(N=this.pluralResolver.getSuffix(g,n.count,n));const j=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(d+N),n.ordinal&&N.indexOf(C)===0&&k.push(d+N.replace(C,this.options.pluralSeparator)),h&&k.push(d+j)),y){const P=`${d}${this.options.contextSeparator}${n.context}`;k.push(P),p&&(k.push(P+N),n.ordinal&&N.indexOf(C)===0&&k.push(P+N.replace(C,this.options.pluralSeparator)),h&&k.push(P+j))}}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&&!bt(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 uw=e=>e.charAt(0).toUpperCase()+e.slice(1);class n_{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Si.create("languageUtils")}getScriptPartFromCode(t){if(t=wm(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=wm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(bt(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]=uw(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]=uw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=uw(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)),bt(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 bt(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))):bt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let oX=[{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}],aX={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 lX=["v1","v2","v3"],cX=["v4"],r_={zero:0,one:1,two:2,few:3,many:4,other:5},uX=()=>{const e={};return oX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:aX[t.fc]}})}),e};class dX{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Si.create("pluralResolver"),(!this.options.compatibilityJSON||cX.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=uX(),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=wm(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)=>r_[s]-r_[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!lX.includes(this.options.compatibilityJSON)}}const s_=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=QJ(e,t,n);return!o&&s&&bt(n)&&(o=yb(e,n,r),o===void 0&&(o=yb(t,n,r))),o},dw=e=>e.replace(/\$/g,"$$$$");class fX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Si.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:o,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:eX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?$l(o):a||"{{",this.suffix=l?$l(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?$l(p):h||$l("$t("),this.nestingSuffix=y?$l(y):v||$l(")"),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=s_(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(s_(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>dw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?dw(this.escape(h)):dw(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof d=="function"){const b=d(t,o,s);a=bt(b)?b:""}else if(s&&Object.prototype.hasOwnProperty.call(s,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!bt(a)&&!this.useRawValueToEscape&&(a=JC(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,o,a;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),y=p.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!bt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const d=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=d.shift(),c=d,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!bt(o))return o;bt(o)||(o=JC(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const pX=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Ll=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(wm(r),s),t[a]=l),l(n)}};class hX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Si.create("formatter"),this.options=t,this.formats={number:Ll((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Ll((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Ll((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Ll((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Ll((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()]=Ll(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(c=>c.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,c)=>{const{formatName:u,formatOptions:d}=pX(c);if(this.formats[u]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...d,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const mX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class gX extends ug{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=Si.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const o={},a={},l={},c={};return t.forEach(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,d=!1,a[p]===void 0&&(a[p]=!0),o[p]===void 0&&(o[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),o=s[0],a=s[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{XJ(c.loaded,[o],a),mX(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:o,callback:a});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();bt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),bt(n)&&(n=[n]);const o=this.queueLoad(t,n,r,s);if(!o.toLoad.length)return o.pending.length||s(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],o=r[1];this.read(s,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(t,n,r,s,c):d=u(t,n,r,s),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const i_=()=>({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]),bt(e[1])&&(t.defaultValue=e[1]),bt(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}}),o_=e=>(bt(e.ns)&&(e.ns=[e.ns]),bt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),bt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Fp=()=>{},yX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Jd extends ug{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=o_(t),this.services={},this.logger=Si,this.modules={external:[]},yX(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&&(bt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=i_();this.options={...s,...this.options,...o_(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Si.init(o(this.modules.logger),this.options):Si.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=hX);const f=new n_(this.options);this.store=new e_(this.options.resources,this.options);const p=this.services;p.logger=Si,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new dX(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=o(d),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new fX(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new gX(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=o(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=o(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new bm(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=Fp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=function(){return t.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return t.store[d](...arguments),t}});const c=Tu(),u=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fp;const s=bt(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=Tu();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=Fp),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"&&bM.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=Tu();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=bt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,d=>{a(d,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,d=new Array(u>2?u-2:0),f=2;f<u;f++)d[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(d))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const p=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${p}${y}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return bt(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=Tu();return this.options.ns?(bt(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=Tu();bt(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 n_(i_());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 Jd(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new Jd(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 e_(this.store.data,s),o.services.resourceStore=o.store),o.translator=new bm(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];o.emit(l,...u)}),o.init(s,n),o.translator.options=s,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const wr=Jd.createInstance();wr.createInstance=Jd.createInstance;wr.createInstance;wr.dir;wr.init;wr.loadResources;wr.reloadResources;wr.use;wr.changeLanguage;wr.getFixedT;wr.t;wr.exists;wr.setDefaultNamespace;wr.hasLoadedNamespace;wr.loadNamespaces;wr.loadLanguages;function wX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xd(e){"@babel/helpers - typeof";return Xd=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},Xd(e)}function xX(e,t){if(Xd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Xd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function bX(e){var t=xX(e,"string");return Xd(t)=="symbol"?t:t+""}function kX(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,bX(r.key),r)}}function vX(e,t,n){return t&&kX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var kM=[],SX=kM.forEach,NX=kM.slice;function jX(e){return SX.call(NX.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var a_=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,CX=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(!a_.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!a_.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},l_={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=CX(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)}},_X={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=l_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&l_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},EX={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}},Mu=null,c_=function(){if(Mu!==null)return Mu;try{Mu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Mu=!1}return Mu},AX={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&c_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&c_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},$u=null,u_=function(){if($u!==null)return $u;try{$u=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{$u=!1}return $u},PX={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&u_()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&u_()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},IX={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}},RX={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}},TX={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}},MX={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]}},vM=!1;try{document.cookie,vM=!0}catch{}var SM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];vM||SM.splice(1,1);function $X(){return{order:SM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var NM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};wX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return vX(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=jX(r,this.options||{},$X()),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(_X),this.addDetector(EX),this.addDetector(AX),this.addDetector(PX),this.addDetector(IX),this.addDetector(RX),this.addDetector(TX),this.addDetector(MX)}},{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)}))}}])}();NM.type="languageDetector";const LX={name:"AgentFlow",tagline:"AI Workflow Orchestration"},OX={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},DX={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"},FX={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},zX={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},BX={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},HX={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},WX={app:LX,nav:OX,common:DX,status:FX,nodeTypes:zX,engine:BX,links:HX},VX="Flow Editor",KX="Nodes",qX="Edges",UX="Properties",YX={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"},GX={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}}"},JX={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},XX={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},QX={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"},ZX={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)"},eQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},tQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},nQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},rQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},sQ={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"},iQ={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"},oQ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},aQ={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."},lQ={mainNav:"Main Navigation"},cQ={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'},uQ={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):
|
|
286
|
+
{{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
|
|
287
|
+
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}}"},dQ={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"},fQ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},pQ={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}}"},hQ={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"},mQ={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"},gQ={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"},yQ={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"},wQ={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"},xQ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},bQ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},kQ={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"},vQ={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."},SQ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},NQ={save:"Save",cancel:"Cancel"},jQ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},CQ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},_Q={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"},EQ={title:VX,nodes:KX,edges:qX,properties:UX,node:YX,nodeProps:GX,actions:JX,panel:XX,palette:QX,pipeline:ZX,status:eQ,roles:tQ,phases:nQ,types:rQ,runContext:sQ,shortcuts:iQ,jumpPalette:oQ,emptyCanvas:aQ,sidebar:lQ,validation:cQ,composer:uQ,topbar:dQ,palette2:fQ,run:pQ,fileEdit:hQ,settings:mQ,schedule:gQ,history:yQ,nodePropsError:wQ,placeholder:xQ,time:bQ,userCheck:kQ,userAsk:vQ,toolPrint:SQ,provideEdit:NQ,runParams:jQ,runPreset:CQ,runConfig:_Q},AQ="Settings",PQ={engine:"Engine Settings",preferences:"Global Preferences"},IQ={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)."},RQ={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..."}},TQ={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."},MQ={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."},$Q={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."},LQ={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)"},OQ={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"},DQ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},FQ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},zQ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},BQ={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."},HQ={title:AQ,crumb:PQ,workspace:IQ,cursor:RQ,opencode:TQ,claudeCode:MQ,codex:$Q,env:LQ,allowlist:OQ,system:DQ,shortcuts:FQ,language:zQ,onboarding:BQ},WQ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},VQ={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)"},KQ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},qQ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},UQ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},YQ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},GQ={aiLabels:WQ,placeholders:VQ,actions:KQ,labels:qQ,tooltips:UQ,rightPanel:YQ},JQ="Projects",XQ="All",QQ="Archived",ZQ="Nodes",eZ="My Nodes",tZ="My Flows",nZ="Skills",rZ="Active Projects",sZ="Archived Pipelines",iZ="Global Nodes",oZ="All Nodes",aZ="My Nodes",lZ="Manage node versions published to the current workspace marketplace, {{count}} total.",cZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",uZ="Global Skills",dZ="Create New Project",fZ="New Pipeline",pZ="SEARCH PIPELINES...",hZ="SEARCH NODES...",mZ="SEARCH FLOW SNIPPETS...",gZ="SEARCH SKILLS...",yZ="Refresh Resources",wZ="Loading pipelines...",xZ="Loading global resources...",bZ="Filter result: {{count}} items (matching title, description, path and tags)",kZ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",vZ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",SZ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",NZ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",jZ="Executable building blocks for pipeline runtime",CZ="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.",_Z="Published local node packages",EZ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",AZ="Published flow snippets",PZ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",IZ="Operating guides for Composer and agents",RZ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",TZ="No archived projects.",MZ="No active pipelines; archived items are in the Archived tab.",$Z="No global nodes available.",LZ="No marketplace nodes have been published.",OZ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",DZ="No skills available.",FZ="No description.",zZ='No node matches "{{query}}".',BZ='No flow snippet matches "{{query}}".',HZ='No skill matches "{{query}}".',WZ="{{inputs}} in / {{outputs}} out",VZ="Flow Snippet",KZ="{{nodes}} nodes / {{edges}} edges",qZ="Skill",UZ="Node detail",YZ="Flow snippet detail",GZ="Skill detail",JZ="Type",XZ="Source",QZ="Package",ZZ="Version",eee="Path",tee="Editable",nee="Read only",ree="Editable",see="Schema",iee="Inputs",oee="Outputs",aee="Runtime",lee="Node Body",cee="Files",uee="Usage",dee="No runtime manifest.",fee="No node body or README.",pee="No previewable files.",hee="Select a file to preview.",mee="Binary file preview is not supported.",gee="Large file; showing the first 256KB only.",yee="No pipelines using this node were found.",wee="Node Management",xee="Delete Node Version",bee="Deleting...",kee="AgentFlow checks all flow references before deleting; installed or used versions are kept.",vee="Delete {{id}}@{{version}}? This cannot be undone.",See="Deleted {{id}}@{{version}}.",Nee="{{count}} flow(s) still use it.",jee="Flow Snippet Management",Cee="Delete Flow Snippet",_ee="Deleting...",Eee="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",Aee="Delete {{id}}@{{version}}? This cannot be undone.",Pee="Deleted {{id}}@{{version}}.",Iee="No slots",Ree="Purpose",Tee="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",Mee="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.",$ee="Scale",Lee="Flow Preview",Oee="Edges",Dee="Snippet JSON",Fee="{{count}} more edge(s)",zee="No previewable nodes.",Bee="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Hee="SKILL.md Preview",Wee="No preview content available.",Vee="Select a resource to inspect details.",Kee="Failed to load pipeline list.",qee="No pipelines in current workspace.",Uee="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.",Yee='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Gee="Recent Activity",Jee="No recent activity",Xee="No recent activity matching the keyword",Qee="Recent Run",Zee="Recent Open",ete={builtin:"Built-in",workspace:"Workspace",user:"User"},tte={flow:"Flow",global:"Global",marketplace:"Marketplace"},nte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},rte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},ste="Open to edit this pipeline in the node canvas.",ite={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>"},ote={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"},ate={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"},lte={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"},cte={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"},ute={title:JQ,all:XQ,archived:QQ,nodes:ZQ,myNodes:eZ,myFlows:tZ,skills:nZ,activeProjects:rZ,archivedPipelines:sZ,globalNodes:iZ,nodeScopeAll:oZ,nodeScopeMine:aZ,myNodesHint:lZ,myFlowsHint:cZ,globalSkills:uZ,createNew:dZ,newPipeline:fZ,searchPipelines:pZ,searchNodes:hZ,searchFlows:mZ,searchSkills:gZ,refreshResources:yZ,loadingPipelines:wZ,loadingResources:xZ,filterResult:bZ,archivedHint:kZ,activeHint:vZ,nodesHint:SZ,skillsHint:NZ,nodesPurposeTitle:jZ,nodesPurposeDesc:CZ,myNodesPurposeTitle:_Z,myNodesPurposeDesc:EZ,myFlowsPurposeTitle:AZ,myFlowsPurposeDesc:PZ,skillsPurposeTitle:IZ,skillsPurposeDesc:RZ,noArchived:TZ,noActive:MZ,noNodes:$Z,noMyNodes:LZ,noMyFlows:OZ,noSkills:DZ,noDescription:FZ,noNodeMatch:zZ,noFlowSnippetMatch:BZ,noSkillMatch:HZ,nodeSlots:WZ,flowSnippet:VZ,flowSnippetNodes:KZ,skill:qZ,nodeDetail:UZ,flowDetail:YZ,skillDetail:GZ,detailType:JZ,detailSource:XZ,detailPackage:QZ,detailVersion:ZZ,detailPath:eee,detailEditable:tee,readOnly:nee,editable:ree,nodeSchema:see,nodeInputs:iee,nodeOutputs:oee,nodeRuntime:aee,nodeBody:lee,nodeFiles:cee,nodeUsage:uee,noRuntimeManifest:dee,noNodeBody:fee,noNodeFiles:pee,selectNodeFile:hee,binaryFile:mee,fileTruncated:gee,noNodeUsage:yee,myNodeManagement:wee,deleteMyNode:xee,deletingMyNode:bee,deleteMyNodeHint:kee,deleteMyNodeConfirm:vee,deleteMyNodeSuccess:See,deleteMyNodeUsedBy:Nee,myFlowManagement:jee,deleteMyFlow:Cee,deletingMyFlow:_ee,deleteMyFlowHint:Eee,deleteMyFlowConfirm:Aee,deleteMyFlowSuccess:Pee,noSlots:Iee,resourceMeaning:Ree,nodesMeaning:Tee,myFlowsMeaning:Mee,flowSnippetScale:$ee,flowSnippetPreview:Lee,flowSnippetEdges:Oee,flowSnippetJson:Dee,flowSnippetMoreEdges:Fee,noFlowSnippetPreview:zee,skillsMeaning:Bee,skillPreview:Hee,skillPreviewEmpty:Wee,selectResource:Vee,loadFailed:Kee,noPipelines:qee,emptyHint:Uee,noMatch:Yee,recentActivity:Gee,noRecentActivity:Jee,noMatchRecent:Xee,recentRun:Qee,recentOpen:Zee,sourceBadge:ete,resourceSource:tte,resourceFilter:nte,nodeDetailTabs:rte,defaultCardDesc:ste,hubCard:ite,newPipelineModal:ote,importModal:ate,deleteModal:lte,archiveModal:cte},dte="Back",fte="Next",pte="Skip",hte="Done",mte="Start Creating",gte={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
|
|
288
|
+
|
|
289
|
+
Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
|
|
290
|
+
|
|
291
|
+
Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},yte={intro:`Now you're in the flow editor.
|
|
292
|
+
|
|
293
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
294
|
+
|
|
295
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
|
|
296
|
+
|
|
297
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
298
|
+
|
|
299
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`},wte={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"},xte={back:dte,next:fte,skip:pte,done:hte,startCreate:mte,projects:gte,flow:yte,newPipeline:wte},bte={name:"AgentFlow",tagline:"AI 工作流编排"},kte={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},vte={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},Ste={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},Nte={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},jte={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},Cte={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},_te={app:bte,nav:kte,common:vte,status:Ste,nodeTypes:Nte,engine:jte,links:Cte},Ete="流程编辑器",Ate="节点",Pte="连线",Ite="属性",Rte={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:"编辑内容"},Tte={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}}"},Mte={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},$te={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},Lte={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Ote={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Dte={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Fte={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},zte={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Bte={node:"节点",text:"文本",file:"文件",bool:"布尔"},Hte={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:"等待"},Wte={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},Vte={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Kte={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},qte={mainNav:"主导航"},Ute={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Yte={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}} 步):
|
|
300
|
+
{{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
|
|
301
|
+
当前:{{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}}"},Gte={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},Jte={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Xte={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}} 的分支"},Qte={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Zte={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:"已复制"},ene={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:"定时配置已保存"},tne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},nne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},rne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},sne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},ine={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},one={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},ane={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},lne={save:"保存",cancel:"取消"},cne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},une={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},dne={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},fne={title:Ete,nodes:Ate,edges:Pte,properties:Ite,node:Rte,nodeProps:Tte,actions:Mte,panel:$te,palette:Lte,pipeline:Ote,status:Dte,roles:Fte,phases:zte,types:Bte,runContext:Hte,shortcuts:Wte,jumpPalette:Vte,emptyCanvas:Kte,sidebar:qte,validation:Ute,composer:Yte,topbar:Gte,palette2:Jte,run:Xte,fileEdit:Qte,settings:Zte,schedule:ene,history:tne,nodePropsError:nne,placeholder:rne,time:sne,userCheck:ine,userAsk:one,toolPrint:ane,provideEdit:lne,runParams:cne,runPreset:une,runConfig:dne},pne="设置",hne={engine:"引擎设置",preferences:"全局首选项"},mne={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},gne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},yne={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},wne={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},xne={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},bne={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},kne={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:"添加"},vne={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},Sne={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},Nne={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},jne={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},Cne={title:pne,crumb:hne,workspace:mne,cursor:gne,opencode:yne,claudeCode:wne,codex:xne,env:bne,allowlist:kne,system:vne,shortcuts:Sne,language:Nne,onboarding:jne},_ne={thinking:"思考",result:"结果",reply:"回复",error:"错误"},Ene={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},Ane={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},Pne={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Ine={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},Rne={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Tne={aiLabels:_ne,placeholders:Ene,actions:Ane,labels:Pne,tooltips:Ine,rightPanel:Rne},Mne="项目",$ne="全部",Lne="已归档",One="Nodes",Dne="我的 Nodes",Fne="我的流程",zne="Skills",Bne="活跃项目",Hne="已归档流水线",Wne="全局 Nodes",Vne="全部 Nodes",Kne="我的 Nodes",qne="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Une="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Yne="全局 Skills",Gne="创建新项目",Jne="新建流水线",Xne="搜索流水线…",Qne="搜索 nodes…",Zne="搜索流程片段…",ere="搜索 skills…",tre="刷新资源",nre="加载流水线列表…",rre="加载全局资源…",sre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",ire="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",ore="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",are="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",lre="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",cre="流程运行时的可执行积木",ure="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",dre="已发布的本地节点包",fre="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",pre="已发布的流程片段",hre="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",mre="Composer/Agent 的操作指南",gre="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",yre="暂无归档项目。",wre="暂无未归档流水线;已归档项在 Archived 标签中查看。",xre="暂无可用全局 nodes。",bre="暂无已发布的 marketplace nodes。",kre="暂无已发布的流程片段。可在画布中选中多个节点后发布。",vre="暂无可用 skills。",Sre="暂无描述。",Nre="未找到与「{{query}}」匹配的 node。",jre="未找到与「{{query}}」匹配的流程片段。",Cre="未找到与「{{query}}」匹配的 skill。",_re="{{inputs}} in / {{outputs}} out",Ere="流程片段",Are="{{nodes}} 节点 / {{edges}} 连线",Pre="Skill",Ire="Node 详情",Rre="流程片段详情",Tre="Skill 详情",Mre="类型",$re="来源",Lre="包",Ore="版本",Dre="路径",Fre="可编辑",zre="只读",Bre="可编辑",Hre="Schema",Wre="输入",Vre="输出",Kre="Runtime",qre="节点内容",Ure="Files",Yre="Usage",Gre="暂无 runtime manifest。",Jre="暂无节点正文或 README。",Xre="暂无可预览文件。",Qre="请选择文件查看内容。",Zre="二进制文件暂不支持预览。",ese="文件较大,仅显示前 256KB。",tse="暂未发现使用此 node 的流水线。",nse="节点管理",rse="删除节点版本",sse="删除中…",ise="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",ose="确定删除 {{id}}@{{version}}?此操作不可撤销。",ase="已删除 {{id}}@{{version}}。",lse="仍有 {{count}} 个 Flow 使用它。",cse="流程片段管理",use="删除流程片段",dse="删除中…",fse="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",pse="确定删除 {{id}}@{{version}}?此操作不可撤销。",hse="已删除 {{id}}@{{version}}。",mse="无槽位",gse="作用",yse="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",wse="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",xse="规模",bse="流程预览",kse="连线",vse="片段 JSON",Sse="还有 {{count}} 条连线",Nse="暂无可预览节点。",jse="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Cse="SKILL.md 预览",_se="暂无可预览内容。",Ese="请选择一个资源查看详情。",Ase="未能加载流水线列表。",Pse="当前工作区暂无流水线。",Ise="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Rse="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Tse="最近打开或最近运行",Mse="暂无打开或运行记录",$se="暂无与关键词匹配的最近记录",Lse="最近运行",Ose="最近打开",Dse={builtin:"内置",workspace:"工作区",user:"用户"},Fse={flow:"Flow",global:"Global",marketplace:"Marketplace"},zse={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Bse={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Hse="打开以在节点画布中编辑此流水线。",Wse={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Vse={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:"关闭"},Kse={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},qse={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Use={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Yse={title:Mne,all:$ne,archived:Lne,nodes:One,myNodes:Dne,myFlows:Fne,skills:zne,activeProjects:Bne,archivedPipelines:Hne,globalNodes:Wne,nodeScopeAll:Vne,nodeScopeMine:Kne,myNodesHint:qne,myFlowsHint:Une,globalSkills:Yne,createNew:Gne,newPipeline:Jne,searchPipelines:Xne,searchNodes:Qne,searchFlows:Zne,searchSkills:ere,refreshResources:tre,loadingPipelines:nre,loadingResources:rre,filterResult:sre,archivedHint:ire,activeHint:ore,nodesHint:are,skillsHint:lre,nodesPurposeTitle:cre,nodesPurposeDesc:ure,myNodesPurposeTitle:dre,myNodesPurposeDesc:fre,myFlowsPurposeTitle:pre,myFlowsPurposeDesc:hre,skillsPurposeTitle:mre,skillsPurposeDesc:gre,noArchived:yre,noActive:wre,noNodes:xre,noMyNodes:bre,noMyFlows:kre,noSkills:vre,noDescription:Sre,noNodeMatch:Nre,noFlowSnippetMatch:jre,noSkillMatch:Cre,nodeSlots:_re,flowSnippet:Ere,flowSnippetNodes:Are,skill:Pre,nodeDetail:Ire,flowDetail:Rre,skillDetail:Tre,detailType:Mre,detailSource:$re,detailPackage:Lre,detailVersion:Ore,detailPath:Dre,detailEditable:Fre,readOnly:zre,editable:Bre,nodeSchema:Hre,nodeInputs:Wre,nodeOutputs:Vre,nodeRuntime:Kre,nodeBody:qre,nodeFiles:Ure,nodeUsage:Yre,noRuntimeManifest:Gre,noNodeBody:Jre,noNodeFiles:Xre,selectNodeFile:Qre,binaryFile:Zre,fileTruncated:ese,noNodeUsage:tse,myNodeManagement:nse,deleteMyNode:rse,deletingMyNode:sse,deleteMyNodeHint:ise,deleteMyNodeConfirm:ose,deleteMyNodeSuccess:ase,deleteMyNodeUsedBy:lse,myFlowManagement:cse,deleteMyFlow:use,deletingMyFlow:dse,deleteMyFlowHint:fse,deleteMyFlowConfirm:pse,deleteMyFlowSuccess:hse,noSlots:mse,resourceMeaning:gse,nodesMeaning:yse,myFlowsMeaning:wse,flowSnippetScale:xse,flowSnippetPreview:bse,flowSnippetEdges:kse,flowSnippetJson:vse,flowSnippetMoreEdges:Sse,noFlowSnippetPreview:Nse,skillsMeaning:jse,skillPreview:Cse,skillPreviewEmpty:_se,selectResource:Ese,loadFailed:Ase,noPipelines:Pse,emptyHint:Ise,noMatch:Rse,recentActivity:Tse,noRecentActivity:Mse,noMatchRecent:$se,recentRun:Lse,recentOpen:Ose,sourceBadge:Dse,resourceSource:Fse,resourceFilter:zse,nodeDetailTabs:Bse,defaultCardDesc:Hse,hubCard:Wse,newPipelineModal:Vse,importModal:Kse,deleteModal:qse,archiveModal:Use},Gse="返回",Jse="下一步",Xse="跳过",Qse="完成",Zse="开始创建",eie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
|
|
302
|
+
|
|
303
|
+
点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
|
|
304
|
+
|
|
305
|
+
在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},tie={intro:`现在进入流程编辑器。
|
|
306
|
+
|
|
307
|
+
在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
|
|
308
|
+
|
|
309
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
|
|
310
|
+
|
|
311
|
+
在下方输入框用自然语言描述需求,AI 会自动生成流程图。
|
|
312
|
+
|
|
313
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`},nie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},rie={back:Gse,next:Jse,skip:Xse,done:Qse,startCreate:Zse,projects:eie,flow:tie,newPipeline:nie},sie={en:{common:WX,flow:EQ,settings:HQ,composer:GQ,project:ute,onboarding:xte},zh:{common:_te,flow:fne,settings:Cne,composer:Tne,project:Yse,onboarding:rie}};wr.use(NM).use(SD).init({resources:sie,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 iie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function oie(e){return wr.changeLanguage(e)}const wb="agentflow-settings-opencode-plan-v1",Uu="CURSOR_API_KEYS",Yu="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",fw=new Set([Uu,Yu,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),jM=["cursor","opencode","claudeCode","codex"];function CM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function xb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function ba(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of jM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(xb).filter(Boolean))]:[];return n}function Wi(e){if(!e||typeof e!="object")return CM();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 mc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function aie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function ja(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()||mc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function d_(e){return ja(e).map(({key:t,value:n})=>({key:t,value:n}))}function f_(){try{return localStorage.getItem(wb)??""}catch{return""}}function _M(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function lie(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()||mc(),name:String(r.name??"").trim()||`Key ${s+1}`,key:o,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,s)=>n(r,s)).filter(Boolean)}function p_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||mc(),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 cie(e){const t=String(e||"").trim();return t?t.length<=10?_M(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function uie(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 die({authUser:e}){const{t,i18n:n}=Fr(["common","settings"]),r=n.language||"zh",[s,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[d,f]=m.useState(CM()),[p,h]=m.useState(()=>ba({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[N,j]=m.useState(!1),[C,P]=m.useState(!1),[I,F]=m.useState(""),[$,D]=m.useState([]),[z,O]=m.useState(""),[M,K]=m.useState(!1),[H,L]=m.useState(""),[T,W]=m.useState(""),[E,Q]=m.useState(!1),[V,B]=m.useState(()=>new Set),[se,ue]=m.useState(""),[G,ee]=m.useState(""),[te,ne]=m.useState(!!(e!=null&&e.isAdmin)),[Z,ce]=m.useState(""),[de,me]=m.useState([]),[$e,Ce]=m.useState([]),[_e,Be]=m.useState(""),[ot,yt]=m.useState(""),[Te,st]=m.useState(!1),[gt,xe]=m.useState(!1),[Fe,lt]=m.useState(""),[oe,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,Ht]=m.useState(null),[Qt,jt]=m.useState(!1),[yn,on]=m.useState(!1),[re,Re]=m.useState(""),Je=m.useRef(null),Ze=m.useRef(!1),Tt=m.useRef(!1),At=m.useRef(""),Vn=m.useCallback(async()=>{l("");try{const ie=await fetch("/api/ui-context");if(!ie.ok)throw new Error("HTTP "+ie.status);const Se=await ie.json();o(typeof Se.workspaceRoot=="string"?Se.workspaceRoot:"")}catch(ie){l(String(ie.message||ie)),o("")}},[]),Sn=m.useCallback(async()=>{x(""),j(!0),g("");try{const ie=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!ie.ok)throw new Error("HTTP "+ie.status);const Se=await ie.json();if(e!=null&&e.isAdmin)u(Wi(Se.modelLists)),f(Wi(Se.allModelLists)),h(ba(Se.hiddenModels));else{const Pe=Wi(Se);u(Pe),f(Pe),h(ba({}))}}catch(ie){x(String(ie.message||ie))}finally{j(!1)}},[e==null?void 0:e.isAdmin]),xr=m.useCallback(async()=>{O("");try{const ie=await fetch("/api/user-env"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Pe=ja(Array.isArray(Se.env)?Se.env:[],"user").map(qt=>({...qt,scope:"user"})),Lt=[...e!=null&&e.isAdmin?ja(Array.isArray(Se.globalEnv)?Se.globalEnv:[],"global").map(qt=>({...qt,scope:"global"})):[],...Pe];At.current=JSON.stringify(Lt),D(Lt)}catch(ie){D([]),O(String(ie.message||ie))}finally{Tt.current=!0}},[e==null?void 0:e.isAdmin]),wn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){st(!0),lt("");try{const ie=await fetch("/api/admin/user-allowlist"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Pe=Se.allowlist&&typeof Se.allowlist=="object"?Se.allowlist:{};me(Array.isArray(Pe.fileUsers)?Pe.fileUsers.map(String):[]),Ce(Array.isArray(Pe.envUsers)?Pe.envUsers.map(String):[]),Be(typeof Pe.path=="string"?Pe.path:"")}catch(ie){lt(String(ie.message||ie))}finally{st(!1)}}},[e==null?void 0:e.isAdmin]),Xn=m.useCallback(async ie=>{if(e!=null&&e.isAdmin){xe(!0),lt("");try{const Se=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ie})}),Pe=await Se.json().catch(()=>({}));if(!Se.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+Se.status);const xt=Pe.allowlist&&typeof Pe.allowlist=="object"?Pe.allowlist:{};me(Array.isArray(xt.fileUsers)?xt.fileUsers.map(String):[]),Ce(Array.isArray(xt.envUsers)?xt.envUsers.map(String):[]),Be(typeof xt.path=="string"?xt.path:"")}catch(Se){lt(String(Se.message||Se))}finally{xe(!1)}}},[e==null?void 0:e.isAdmin]),Kn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){jt(!0),Re("");try{const ie=await fetch("/api/admin/storage-config"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};Ht(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(ie){Re(String(ie.message||ie))}finally{jt(!1)}}},[e==null?void 0:e.isAdmin]),hr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){on(!0),Re("");try{const ie=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:oe.trim(),skillsRoot:Ke.trim(),migrateLegacySkills:!0})}),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};Ht(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(ie){Re(String(ie.message||ie))}finally{on(!1)}}},[e==null?void 0:e.isAdmin,oe,Ke]),ts=m.useCallback(async ie=>{const Se=ja(ie),Pe=Se.filter(Lt=>Lt.scope!=="global"),xt=Se.filter(Lt=>Lt.scope==="global");K(!0),O("");try{const Lt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:d_(Pe),...e!=null&&e.isAdmin?{globalEnv:d_(xt)}:{}})}),qt=await Lt.json().catch(()=>({}));if(!Lt.ok)throw new Error(typeof qt.error=="string"?qt.error:"HTTP "+Lt.status);const zn=ja(Array.isArray(qt.env)?qt.env:[],"user").map(pe=>({...pe,scope:"user"})),q=[...e!=null&&e.isAdmin?ja(Array.isArray(qt.globalEnv)?qt.globalEnv:[],"global").map(pe=>({...pe,scope:"global"})):[],...zn];At.current=JSON.stringify(q),D(q)}catch(Lt){O(String(Lt.message||Lt))}finally{K(!1)}},[e==null?void 0:e.isAdmin]),Ar=m.useCallback(async()=>{x(""),j(!0);try{const ie=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);u(Wi(Se.modelLists)),e!=null&&e.isAdmin?await Sn():f(Wi(Se.modelLists))}catch(ie){x(String(ie.message||ie))}finally{j(!1)}},[e==null?void 0:e.isAdmin,Sn,Z]),gs=m.useCallback(async ie=>{if(!(e!=null&&e.isAdmin))return;const Se=ba(ie);h(Se),v(!0),g("");try{const Pe=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:Se})}),xt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof xt.error=="string"?xt.error:"HTTP "+Pe.status);u(Wi(xt.modelLists)),f(Wi(xt.allModelLists)),h(ba(xt.hiddenModels))}catch(Pe){g(String(Pe.message||Pe)),Sn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,Sn]),ys=m.useCallback((ie,Se,Pe)=>{const xt=jM.includes(ie)?ie:"cursor",Lt=xb(Se);if(!Lt)return;const qt=ba(p),zn=new Set(qt[xt]);Pe?zn.delete(Lt):zn.add(Lt),gs({...qt,[xt]:Array.from(zn)})},[p,gs]);m.useEffect(()=>{xr(),e!=null&&e.isAdmin?(Vn(),Sn(),wn(),Kn(),(async()=>{try{const ie=await fetch("/api/agentflow-config");if(ie.ok){const Se=await ie.json(),Pe=typeof Se.opencodeProvider=="string"?Se.opencodeProvider:"";ce(Pe),Je.current=Pe;try{localStorage.setItem(wb,Pe)}catch{}}else{const Se=f_();ce(Se),Je.current=Se}}catch{const ie=f_();ce(ie),Je.current=ie}finally{Ze.current=!0}})()):(o(""),Ze.current=!1)},[e==null?void 0:e.isAdmin,Vn,Sn,Kn,wn,xr]),m.useEffect(()=>{if(!Tt.current||JSON.stringify(ja($))===At.current)return;const Se=setTimeout(()=>{ts($)},350);return()=>clearTimeout(Se)},[$,ts]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!Ze.current)return;const ie=Z.trim();if(ie===Je.current)return;const Se=setTimeout(()=>{(async()=>{P(!0),F("");try{const Pe=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ie})}),xt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof xt.error=="string"?xt.error:"HTTP "+Pe.status);Je.current=ie;try{localStorage.setItem(wb,ie)}catch{}xt.modelLists&&(u(Wi(xt.modelLists)),e!=null&&e.isAdmin?Sn():f(Wi(xt.modelLists)))}catch(Pe){F(String(Pe.message||Pe))}finally{P(!1)}})()},450);return()=>clearTimeout(Se)},[e==null?void 0:e.isAdmin,Sn,Z]);const cn=e!=null&&e.isAdmin?d:c,rr=cn.cursor.length>0,Pr=cn.opencode.length>0,dn=cn.claudeCode.length>0,Qn=cn.codex.length>0,br=ba(p),sr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Ct=m.useCallback((ie,Se,Pe)=>{const xt=Array.isArray(Se)?Se:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Pe,children:xt.join(`
|
|
314
|
+
`)});const Lt=new Set(br[ie]||[]);return i.jsxs("div",{className:"af-set-model-visibility","aria-label":Pe,children:[i.jsxs("div",{className:"af-set-model-visibility-head",children:[i.jsxs("span",{children:["展示 ",sr[ie]||0," / ",xt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:xt.map(qt=>{const zn=xb(qt),On=!Lt.has(zn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:On,disabled:y,onChange:q=>ys(ie,qt,q.target.checked)}),i.jsx("span",{children:qt})]},`${ie}-${qt}`)})})]})},[e==null?void 0:e.isAdmin,br,y,sr,ys]),Gt=de.length>0||$e.length>0,_t=e!=null&&e.isAdmin?$:$.filter(ie=>!fw.has(String((ie==null?void 0:ie.key)||"").trim())),le=e!=null&&e.isAdmin&&te?"global":"user",ve=m.useMemo(()=>$.find(ie=>ie.key===Uu&&(ie.scope||"user")===le)||null,[le,$]),it=m.useMemo(()=>lie((ve==null?void 0:ve.value)||""),[ve==null?void 0:ve.value]),Dt=m.useMemo(()=>$.find(ie=>ie.key===Yu&&(ie.scope||"user")===le)||null,[le,$]),Jt=Dt!=null&&Dt.value?String(Dt.value):"30",tn=m.useCallback((ie,Se,Pe)=>{const xt=String(ie||"").trim();if(!xt)return;const Lt=String(Se??"");D(qt=>{const zn=qt.find(On=>On.key===xt&&(On.scope||"user")===Pe);return Lt?zn?qt.map(On=>On.id===zn.id?{...On,value:Lt,scope:Pe}:On):[{id:mc(),key:xt,value:Lt,scope:Pe},...qt]:qt.filter(On=>!(On.key===xt&&(On.scope||"user")===Pe))})},[]),Zn=m.useCallback(()=>{const ie=G.trim();if(!ie)return;const Se=[...it,{id:mc(),name:se.trim()||`Key ${it.length+1}`,key:ie,createdAt:new Date().toISOString()}];tn(Uu,p_(Se),le),ue(""),ee("")},[se,it,le,G,tn]),mt=m.useCallback(ie=>{const Se=it.filter(Pe=>Pe.id!==ie);tn(Uu,Se.length?p_(Se):"",le)},[it,le,tn]),nn=m.useCallback(ie=>{const Se=String(ie||"").replace(/[^\d]/g,"");if(!Se){tn(Yu,"",le);return}const Pe=Math.min(1440,Math.max(1,Number(Se)||30));tn(Yu,String(Pe),le)},[le,tn]),Wt=m.useCallback(()=>{var ie;s&&((ie=navigator.clipboard)==null||ie.writeText(s))},[s]),kr=m.useCallback(()=>{const ie=H.trim(),Se=T;if(ie){if(!aie(ie)){O(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&fw.has(ie)){O("该运行基础设施变量仅管理员可配置。");return}D(Pe=>[{id:mc(),key:ie,value:Se,scope:e!=null&&e.isAdmin&&E?"global":"user"},...Pe]),L(""),W("")}},[e==null?void 0:e.isAdmin,E,H,T,t]),tt=m.useCallback(ie=>{D(Se=>Se.filter(Pe=>Pe.id!==ie))},[]),Ln=m.useCallback((ie,Se)=>{const Pe=String((Se==null?void 0:Se.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Pe&&fw.has(Pe)){O("该运行基础设施变量仅管理员可配置。");return}D(xt=>xt.map(Lt=>Lt.id===ie?{...Lt,...Se}:Lt))},[e==null?void 0:e.isAdmin]),$i=m.useCallback(ie=>{B(Se=>{const Pe=new Set(Se);return Pe.has(ie)?Pe.delete(ie):Pe.add(ie),Pe})},[]),zr=m.useCallback(()=>{const ie=ot.trim();if(!ie)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ie)){lt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Pe=>String(Pe||"").trim().toLowerCase())).has(ie.toLowerCase())){yt("");return}yt(""),Xn([...de,ie])},[ot,de,Xn]),mo=m.useCallback(ie=>{const Se=String(ie||"").trim().toLowerCase();Se&&Xn(de.filter(Pe=>String(Pe||"").trim().toLowerCase()!==Se))},[de,Xn]),ai=m.useCallback(ie=>{const Se=ie.target.value;oie(Se)},[]),Ts=ie=>{const Se=uie(ie,r);return Se?t("settings:cursor.modelList.fetchedAt",{time:Se}):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,z?i.jsx("p",{className:"af-err af-settings-api-hint",children:z}):null,re?i.jsx("p",{className:"af-err af-settings-api-hint",children:re}):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:Wt,"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?` / ${cn.cursor.length}`:"")+" · "+Ts(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),rr?Ct("cursor",cn.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:()=>Ar(),disabled:N,children:t(N?"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"+(it.length?" af-set-badge--ok":" af-set-badge--muted"),children:[it.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:te?"":"is-active",onClick:()=>ne(!1),children:"个人"}),i.jsx("button",{type:"button",className:te?"is-active":"",onClick:()=>ne(!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:Jt,onChange:ie=>nn(ie.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":le==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:it.length?it.map(ie=>i.jsxs("div",{className:"af-set-cursor-key-row",children:[i.jsxs("div",{className:"af-set-cursor-key-main",children:[i.jsx("strong",{children:ie.name}),i.jsx("code",{children:cie(ie.key)})]}),i.jsx("span",{className:"af-set-cursor-key-meta",children:ie.createdAt?new Date(ie.createdAt).toLocaleString():"历史 Key"}),i.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${ie.name}`,onClick:()=>mt(ie.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie.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:se,onChange:ie=>ue(ie.target.value),placeholder:"名称,例如 Team Key 1"}),i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:ie=>ee(ie.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Zn,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",Uu,";冷却时间保存到 ",Yu,"。个人配置会覆盖全局配置。"]})]}),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"+(Pr?" af-set-badge--ok":" af-set-badge--err"),children:t(Pr?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),i.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),i.jsxs("div",{children:[i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),i.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:Z,onChange:ie=>ce(ie.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),C?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,I?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:I}):null]}),Pr?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?` / ${cn.opencode.length}`:"")+" · "+Ts(c.opencodeFetchedAt)}),Ct("opencode",cn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Ar(),disabled:N,children:t(N?"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"+(dn?" af-set-badge--ok":" af-set-badge--err"),children:t(dn?"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:dn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(dn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:dn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${cn.claudeCode.length}`:"")+" · "+Ts(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),dn?Ct("claudeCode",cn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Ar(),disabled:N,children:t(N?"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"+(Qn?" af-set-badge--ok":" af-set-badge--err"),children:t(Qn?"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:Qn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Qn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Qn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${cn.codex.length}`:"")+" · "+Ts(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Qn?Ct("codex",cn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Ar(),disabled:N,children:t(N?"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:H,onChange:ie=>L(ie.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:E?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:E?"is-active":"",onClick:()=>Q(!0),children:t("settings:env.global")})]})}):null,i.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:T,onChange:ie=>W(ie.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:kr,disabled:!H.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),_t.map(ie=>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:ie.key,onChange:Se=>Ln(ie.id,{key:Se.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:ie.scope!=="global"?"is-active":"",onClick:()=>Ln(ie.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:ie.scope==="global"?"is-active":"",onClick:()=>Ln(ie.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:V.has(ie.id)?"text":"password",value:ie.value,onChange:Se=>Ln(ie.id,{value:Se.target.value}),placeholder:_M(ie.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>$i(ie.id),"aria-label":V.has(ie.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:V.has(ie.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:ie.key}),onClick:()=>tt(ie.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ie.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"+(be!=null&&be.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:be!=null&&be.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Kn(),disabled:Qt||yn,children:Qt?"刷新中...":"刷新"})]}),re?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:re}):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:oe,onChange:ie=>ke(ie.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(be!=null&&be.envLocked)||yn}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Data Root",disabled:yn||!!(be!=null&&be.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:yn?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(be==null?void 0:be.dataRoot)||oe||"-"}),be!=null&&be.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:be.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 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",be!=null&&be.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:Ke,onChange:ie=>Ue(ie.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(be!=null&&be.skillsEnvLocked)||yn}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Skills Root",disabled:yn||!!(be!=null&&be.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:yn?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(be==null?void 0:be.skillsRoot)||Ke||"-"}),be!=null&&be.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:be.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",be!=null&&be.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"+(Gt?" af-set-badge--ok":" af-set-badge--muted"),children:t(Gt?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void wn(),disabled:Te,children:t(Te?"settings:allowlist.refreshing":"common:common.refresh")})]}),Fe?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Fe}):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:gt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(ie=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:ie}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>mo(ie),"aria-label":t("settings:allowlist.remove",{username:ie}),disabled:gt,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie)):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:ot,onChange:ie=>yt(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&zr()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:zr,disabled:gt||!ot.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:$e.length>0?$e.map(ie=>i.jsx("code",{children:ie},ie)):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:ai,"aria-label":t("settings:language.description"),children:iie.map(ie=>i.jsxs("option",{value:ie.code,children:[ie.flag," ",ie.name]},ie.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function Wr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function zp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function pw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function fie(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function hw(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 pie(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function hie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function mie({authUser:e}){const[t,n]=m.useState(null),[r,s]=m.useState(!1),[o,a]=m.useState(""),l=m.useCallback(async()=>{if(e!=null&&e.isAdmin){s(!0),a("");try{const h=await fetch("/api/admin/usage-dashboard"),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(typeof y.error=="string"?y.error:"HTTP "+h.status);n(y)}catch(h){n(null),a(String((h==null?void 0:h.message)||h))}finally{s(!1)}}},[e==null?void 0:e.isAdmin]);m.useEffect(()=>{l()},[l]);const c=Array.isArray(t==null?void 0:t.dailyTrend)?t.dailyTrend:[],u=m.useMemo(()=>{const v={top:20,right:24,bottom:42,left:42},b=980-v.left-v.right,g=250-v.top-v.bottom,k=c.length>0?c:[],x=Math.max(1,...k.map(F=>Number(F.runs||0))),N=Math.max(1,...k.flatMap(F=>[Number(F.users||0),Number(F.pipelines||0)])),j=F=>v.left+(k.length<=1?b/2:F*b/(k.length-1)),C=F=>v.top+g-Math.max(0,Number(F||0))/x*g,P=F=>v.top+g-Math.max(0,Number(F||0))/N*g,I=F=>k.map(($,D)=>`${D===0?"M":"L"} ${j(D)} ${P($[F])}`).join(" ");return{width:980,height:250,margin:v,innerHeight:g,rows:k,x:j,yRuns:C,yLine:P,lineUsers:I("users"),linePipelines:I("pipelines"),barWidth:Math.min(34,Math.max(12,b/Math.max(1,k.length)*.44))}},[c]),d=(t==null?void 0:t.usage)||{},f=(t==null?void 0:t.totals)||{},p=Array.isArray(t==null?void 0:t.recentRuns)?t.recentRuns:[];return e!=null&&e.isAdmin?i.jsxs("main",{className:"af-admin-usage-page",children:[i.jsxs("section",{className:"af-admin-usage-hero",children:[i.jsxs("div",{children:[i.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),i.jsx("h1",{children:"管理看板"}),i.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),i.jsxs("button",{type:"button",onClick:()=>void l(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),r?"刷新中":"刷新"]})]}),o?i.jsx("div",{className:"af-project-admin-usage__error",children:o}):null,i.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[i.jsxs("div",{children:[i.jsx("span",{children:"7日活跃用户率"}),i.jsx("strong",{children:zp(d.activeUserRate)}),i.jsxs("em",{children:[Wr(d.activeUsers)," / ",Wr(f.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:zp(d.activePipelineRate)}),i.jsxs("em",{children:[Wr(d.activePipelines)," / ",Wr(f.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Wr(d.runs)}),i.jsxs("em",{children:[Wr(d.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:zp(d.successRate)}),i.jsxs("em",{children:["失败率 ",zp(d.failureRate)," · avg ",pw(d.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 ${u.width} ${u.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:u.margin.left,y1:u.margin.top+u.innerHeight,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight}),[.25,.5,.75,1].map(h=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:u.margin.left,y1:u.margin.top+u.innerHeight-u.innerHeight*h,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight-u.innerHeight*h},h)),u.rows.map((h,y)=>{const v=u.x(y),b=u.yRuns(h.runs),g=u.margin.top+u.innerHeight,k=Math.max(2,g-b);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:v-u.barWidth/2,y:g-k,width:u.barWidth,height:k,rx:"5",children:i.jsx("title",{children:`${h.date}: ${h.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:v,y:g+22,children:Wr(h.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:v,y:g+42,children:fie(h.date)})]},h.date)}),u.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:u.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:u.linePipelines}),u.rows.map((h,y)=>{const v=u.x(y);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:v,cy:u.yLine(h.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:v,cy:u.yLine(h.pipelines),r:"3.5"})]},`${h.date}-points`)})]}):null]})})]}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"用户"}),i.jsx("th",{children:"流水线"}),i.jsx("th",{children:"运行时间"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"耗时"}),i.jsx("th",{children:"Run ID"})]})}),i.jsx("tbody",{children:p.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):p.map(h=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:h.username||h.userId||"-"}),i.jsx("span",{children:h.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:h.flowId||"-"}),i.jsxs("span",{children:[h.runType==="workspace"?"Workspace Run":"Pipeline"," · ",h.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:hw(h.at)}),h.endedAt?i.jsxs("span",{children:["结束 ",hw(h.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:hie(h.status)})})}),i.jsx("td",{children:pw(h.durationMs)}),i.jsx("td",{children:i.jsx("code",{className:"af-admin-usage-run-id",children:pie(h.runId)})})]},`${h.userId}:${h.flowSource}:${h.flowId}:${h.runId}:${h.at}`))})]})})]}),i.jsxs("section",{className:"af-project-admin-usage",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"用户使用明细"}),i.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"User"}),i.jsx("th",{children:"Pipeline"}),i.jsx("th",{children:"Runs"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"最近运行"})]})}),i.jsx("tbody",{children:r&&!t?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"正在加载..."})}):((t==null?void 0:t.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,children:"暂无用户数据"})}):((t==null?void 0:t.users)||[]).map(h=>{var y,v,b,g,k,x,N,j,C,P,I;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:h.username||h.userId}),i.jsxs("span",{children:[h.userId,h.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Wr((y=h.pipelines)==null?void 0:y.total)}),i.jsxs("span",{children:[Wr((v=h.pipelines)==null?void 0:v.active)," active / ",Wr((b=h.pipelines)==null?void 0:b.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Wr((g=h.runs)==null?void 0:g.total)}),i.jsxs("span",{children:["avg ",pw((k=h.runs)==null?void 0:k.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Wr((x=h.runs)==null?void 0:x.success)]}),i.jsxs("em",{children:["失败 ",Wr((N=h.runs)==null?void 0:N.failed)]}),i.jsxs("em",{children:["运行中 ",Wr((j=h.runs)==null?void 0:j.running)]})]})}),i.jsx("td",{children:(C=h.runs)!=null&&C.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((P=h.runs)==null?void 0:P.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((I=h.runs)==null?void 0:I.lastRunStatus)||"unknown"," · ",hw(h.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})})]},h.userId)})})]})})]})]}):i.jsx("main",{className:"af-admin-usage-page",children:i.jsx("section",{className:"af-project-admin-usage",children:i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"管理看板"}),i.jsx("span",{children:"需要管理员权限。"})]})})})})}function gie(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 yie({authUser:e}){const{navigate:t}=si(),[n,r]=m.useState(""),[s,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(k){v(!0),g("");try{const j=await fetch("/api/feedback"),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||"加载失败");h(Array.isArray(C.feedback)?C.feedback:[])}catch(j){g(String(j.message||j)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const N=async j=>{if(j.preventDefault(),!a){l(!0),u("");try{const C=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"提交失败");f(!0),r(""),o("")}catch(C){u(String(C.message||C))}finally{l(!1)}}};return k?i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"查看用户提交的问题、建议和功能需求。"})]}),i.jsxs("div",{className:"af-feedback-admin-actions",children:[i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:y,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":"refresh"}),y?"刷新中...":"刷新"]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?i.jsx("p",{className:"af-err af-feedback-error",children:b}):null,i.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:p.length>0?p.map(j=>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:j.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:j.username||j.userId||"unknown"}),i.jsx("span",{children:gie(j.createdAt)})]})]}),j.contact?i.jsx("span",{className:"af-feedback-item__contact",children:j.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:j.content}),j.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:j.pageUrl}):null]},j.id)):i.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?i.jsxs("div",{className:"af-feedback-success",role:"status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("div",{children:[i.jsx("strong",{children:"已提交"}),i.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,i.jsxs("form",{className:"af-feedback-form",onSubmit:N,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:n,onChange:j=>r(j.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:j=>o(j.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 EM(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function h_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:EM(),key:r,value:String(s??""),private:n.has(r)}))}function m_(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 mh(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(`
|
|
315
|
+
`),description:String((e==null?void 0:e.description)||t.description||""),envRows:h_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:h_(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 mw(){return mh({name:"",raw:{command:""}})}function wie(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=m_(e.envRows),s=m_(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 g_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function y_(e){return e?e.ok?"ok":"error":"unknown"}function bb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function xie(e,t){return e&&e.label||t}async function gw(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 xv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function AM({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:xv(t)}}}},null,2)}function PM({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(xv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
|
|
316
|
+
`)}function bie({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=AM({baseUrl:n,token:t}),s=PM({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: ${xv(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(`
|
|
317
|
+
`)}function kie({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--${bb(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:xie(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 w_({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:EM(),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 vie(){var ue;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(mw),[a,l]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[N,j]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[C,P]=m.useState(""),[I,F]=m.useState(""),$=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),D=$&&y[$.name]||null,z=m.useMemo(()=>AM({baseUrl:N,token:C}),[N,C]),O=m.useMemo(()=>PM({baseUrl:N,token:C}),[N,C]),M=m.useMemo(()=>bie({baseUrl:N,token:C}),[N,C]),K=m.useCallback(async()=>{u(!0),g("");try{const G=await fetch("/api/mcps"),ee=await G.json().catch(()=>({}));if(!G.ok)throw new Error(ee.error||"MCP HTTP "+G.status);const te=Array.isArray(ee.servers)?ee.servers:[];t(String(ee.path||"")),r(te),a&&te.some(ne=>ne.name===a)&&o(mh(te.find(ne=>ne.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{K()},[K]);const H=()=>{l(""),o(mw()),x(""),g("")},L=G=>{l(G.name),o(mh(G)),x(""),g("")},T=m.useCallback(async()=>{if(!M)return;const G=await gw(M);F(G?"prompt":"copy-failed"),window.setTimeout(()=>F(""),1200)},[M]),W=m.useCallback(async()=>{const G=await gw(z);F(G?"cursor":"copy-failed"),window.setTimeout(()=>F(""),1200)},[z]),E=m.useCallback(async()=>{const G=await gw(O);F(G?"codex":"copy-failed"),window.setTimeout(()=>F(""),1200)},[O]),Q=m.useCallback(async()=>{try{const G=await fetch("/api/auth/session-token"),ee=await G.json().catch(()=>({}));if(!G.ok)throw new Error(typeof ee.error=="string"?ee.error:"HTTP "+G.status);P(String(ee.token||"")),F("token"),window.setTimeout(()=>F(""),1200)}catch(G){F(""),g(String(G.message||G))}},[]),V=async(G="")=>{h(!0),g(""),x("");try{const ee=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G?{name:G}:{})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"检测 MCP 失败");const ne=Array.isArray(te.results)?te.results:[];v(Z=>{const ce={...Z};for(const de of ne)de!=null&&de.name&&(ce[de.name]=de);return ce}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(ee){g(String(ee.message||ee))}finally{h(!1)}},B=async()=>{f(!0),g(""),x("");try{const G=wie(s);if(!G.nextName)throw new Error("请填写 MCP 名称");const ee=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"保存 MCP 失败");const ne=Array.isArray(te.servers)?te.servers:[];r(ne),t(String(te.path||e)),l(G.nextName),o(mh(ne.find(Z=>Z.name===G.nextName)||null)),v(Z=>{const ce={...Z};return s.originalName&&s.originalName!==G.nextName&&delete ce[s.originalName],delete ce[G.nextName],ce}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{f(!1)}},se=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){f(!0),g(""),x("");try{const ee=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"删除 MCP 失败");r(Array.isArray(te.servers)?te.servers:[]),l(""),o(mw()),v(ne=>{const Z={...ne};return delete Z[G.name],Z}),x("已删除。")}catch(ee){g(String(ee.message||ee))}finally{f(!1)}}};return i.jsxs("main",{className:"af-settings-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),i.jsxs("div",{className:"af-settings-top-right",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:K,disabled:c||d,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(),disabled:p||c||d||n.length===0,children:p?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:H,disabled:d,children:"新增 MCP"})]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),i.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"lan"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),i.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),i.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),i.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),i.jsxs("div",{className:"af-set-mcp-connect-grid",children:[i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Base URL"}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:N,onChange:G=>j(G.target.value),placeholder:"http://127.0.0.1:8875"})]}),i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Token"}),i.jsxs("div",{className:"af-set-mcp-token-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:C,onChange:G=>P(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:I==="token"?"已填入":"使用当前登录 Token"})]})]})]}),i.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Cursor mcp.json"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:W,children:I==="cursor"?"已复制":I==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:z})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Codex config.toml"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:E,children:I==="codex"?"已复制":I==="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:T,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),I==="prompt"?"已复制 Prompt":I==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),I==="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:H,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?i.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?i.jsxs("div",{className:"af-mcp-empty",children:[i.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:H,disabled:d,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var ee,te,ne,Z;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>L(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--${y_(y[G.name])}`,children:g_(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${bb((te=(ee=G.backends)==null?void 0:ee.cursor)==null?void 0:te.status)}`,children:"Cursor"}),i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${bb((Z=(ne=G.backends)==null?void 0:ne.codex)==null?void 0:Z.status)}`,children:"Codex"})]}),i.jsx("em",{children:G.url||[G.command,...G.args||[]].filter(Boolean).join(" ")})]})]},G.name)})})]}),i.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:$?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),$?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V($.name),disabled:p||d,children:p?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>se($),disabled:d,children:"删除"})]}):null]}),b?i.jsx("p",{className:"af-mcp-error",children:b}):null,k?i.jsx("p",{className:"af-mcp-status",children:k}):null,$?i.jsx(kie,{server:$}):null,D?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${y_(D)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:g_(D)}),i.jsxs("span",{children:[D.elapsedMs||0,"ms"]})]}),D.error?i.jsx("p",{children:D.error}):null,(ue=D.tools)!=null&&ue.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(ee=>({...ee,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(ee=>({...ee,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(ee=>({...ee,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(ee=>({...ee,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(ee=>({...ee,argsText:G.target.value})),placeholder:`mcp-server-example
|
|
318
|
+
--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(ee=>({...ee,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(w_,{title:"Headers",rows:s.headerRows,onChange:G=>o(ee=>({...ee,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(w_,{title:"Env",rows:s.envRows,onChange:G=>o(ee=>({...ee,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(ee=>({...ee,extraJson:G.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:H,disabled:d,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function Sie(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 x_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function b_(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 Nie(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function jie(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 Cie(){const{navigate:e}=si(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{s(!0),a("");try{const p=await fetch("/api/schedules"),h=await p.json().catch(()=>({}));if(!p.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(p){a(String(p.message||p)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`;c(h),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:p.kind,flowId:p.flowId,flowSource:p.flowSource||"user",scheduleNodeId:p.scheduleNodeId||"",enabled:!p.enabled})}),v=await y.json().catch(()=>({}));if(!y.ok||v.success===!1)throw new Error(v.error||"更新定时任务失败");await u()}catch(y){a(String(y.message||y))}finally{c("")}},[u]),f=m.useMemo(()=>{const p=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:p,workspace:h,pipeline:t.length-h}},[t]);return i.jsxs("div",{className:"af-settings-page af-schedules-page",children:[i.jsxs("div",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"定时任务"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"定时任务"}),i.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),i.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部"}),i.jsx("strong",{children:f.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"启用中"}),i.jsx("strong",{children:f.enabled})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("strong",{children:f.workspace})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Pipeline"}),i.jsx("strong",{children:f.pipeline})]})]}),o?i.jsx("div",{className:"af-schedules-error",children:o}):null,r?i.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?i.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,i.jsx("div",{className:"af-schedules-list",children:t.map(p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`,y=l===h,v=Sie(p);return i.jsxs("article",{className:"af-schedule-card",children:[i.jsxs("div",{className:"af-schedule-card__main",children:[i.jsxs("div",{className:"af-schedule-card__title-row",children:[i.jsx("strong",{children:p.label||p.flowId||"-"}),i.jsx("span",{className:`af-schedule-badge af-schedule-badge--${p.kind||"pipeline"}`,children:Nie(p)}),i.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:jie(p)})]}),i.jsxs("div",{className:"af-schedule-card__meta",children:[i.jsx("span",{children:p.flowId||"-"}),i.jsx("span",{children:p.flowSource||"user"}),p.scheduleNodeId?i.jsx("span",{children:p.scheduleNodeId}):null]}),i.jsxs("div",{className:"af-schedule-card__grid",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Cron"}),i.jsx("strong",{children:p.cron||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"时区"}),i.jsx("strong",{children:p.timezone||"Asia/Shanghai"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"下次执行"}),i.jsx("strong",{children:b_(p.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:b_(p.lastTriggeredAt)})]})]}),p.lastError?i.jsx("p",{className:"af-schedule-card__error",children:p.lastError}):null]}),i.jsxs("div",{className:"af-schedule-card__actions",children:[v?i.jsxs("button",{type:"button",className:"af-schedule-open",title:x_(p),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),x_(p)]}):null,i.jsxs("button",{type:"button",className:p.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":p.enabled,title:p.enabled?"点击停用":"点击启用",onClick:()=>void d(p),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":p.enabled?"toggle_on":"toggle_off"}),p.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const k_={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 v_(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 _ie(e){var c,u,d,f,p,h,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((d=(u=t.ui)==null?void 0:u.card)==null?void 0:d.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(N=>[`input.${N.name||"-"}`,`${N.type||"text"}${N.required?" · required":""}${N.default?` · default: ${N.default}`:""}`]),...s.map(N=>[`output.${N.name||"-"}`,N.type||"text"]),...o.map(N=>[`config.${N.key||"-"}`,N.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((p=t.runtime)==null?void 0:p.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(N=>[`action.${N.id||N.label||"-"}`,N.variant||N.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([N,j])=>[`sample.${N}`,String(j)]),["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 Eie(){var O,M,K,H,L,T,W;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState(""),y=e||k_,v=m.useMemo(()=>_ie(y),[y]),b=m.useMemo(()=>v.find(E=>E.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((O=y==null?void 0:y.test)==null?void 0:O.inputs)||{},N=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],j=((H=(K=g.ui)==null?void 0:K.card)==null?void 0:H.icon)||"event_repeat",C=((T=(L=g.ui)==null?void 0:L.card)==null?void 0:T.variant)||"default",P=k.enabled===!0,I=m.useCallback(async()=>{var E;l(!0),u("");try{const Q=await fetch("/api/node-studio/drafts"),V=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(V.error||"读取节点草稿失败");const B=Array.isArray(V.drafts)?V.drafts[0]:null;if(!(B!=null&&B.id)){t(null),h("");return}const se=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(B.id)}`),ue=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ue.error||"读取节点草稿失败");t(ue.draft||null),h(String(((E=ue.draft)==null?void 0:E.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{I()},[I]);const F=m.useCallback(async(E={})=>{var Q;f(!0),u("");try{const V=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",...E})}),B=await V.json().catch(()=>({}));if(!V.ok||B.ok===!1)throw new Error(B.error||"保存节点草稿失败");t(B.draft||e),h(String(((Q=B.draft||e)==null?void 0:Q.promptDraft)||""))}catch(V){u(String(V.message||V))}finally{f(!1)}},[e]),$=()=>{o(!0),window.setTimeout(()=>o(!1),900)},D=E=>{const Q={...k,enabled:E};t(V=>({...V||k_,config:Q})),F({config:{enabled:E}})},z=()=>{F({promptDraft:p,appendUserMessage:!0})};return i.jsxs("div",{className:"af-node-studio-page",children:[i.jsxs("header",{className:"af-node-studio-top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"Node Studio"})]}),i.jsx("h1",{children:"节点编辑器"})]}),i.jsxs("div",{className:"af-node-studio-actions",children:[i.jsxs("button",{type:"button",onClick:()=>void I(),disabled:a,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),i.jsxs("button",{type:"button",onClick:$,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),i.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),i.jsxs("main",{className:"af-node-studio-shell",children:[i.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),i.jsx("strong",{children:"AI Agent"})]}),c?i.jsx("div",{className:"af-node-studio-error",children:c}):null,i.jsxs("div",{className:"af-node-studio-thread",children:[e?null:i.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((E,Q)=>i.jsx("div",{className:E.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:E.text||""},`${E.role||"message"}-${Q}`)),i.jsxs("div",{className:"af-node-studio-agent-tools",children:[i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),i.jsxs("label",{className:"af-node-studio-prompt",children:[i.jsx("span",{children:"需求"}),i.jsx("textarea",{value:p,onChange:E=>h(E.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:z,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:d?"sync":"send"}),d?"Saving":"Send"]})]}),i.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),i.jsx("strong",{children:"Preview / Test"})]}),i.jsxs("div",{className:"af-node-studio-preview-grid",children:[i.jsx("div",{className:"af-node-studio-preview-stage",children:e?C==="schedule"?i.jsxs("div",{className:"af-node-preview-card",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:v_(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:P,onChange:E=>D(E.target.checked)}),i.jsx("span",{children:P?"定时开启":"定时关闭"})]}),i.jsxs("div",{className:"af-node-preview-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:k.scheduleType||"daily",onChange:E=>F({config:{scheduleType:E.target.value}}),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{children:[i.jsxs("select",{value:k.hour||"09",onChange:E=>F({config:{hour:E.target.value}}),children:[i.jsx("option",{children:"09"}),i.jsx("option",{children:"10"})]}),i.jsxs("select",{value:k.minute||"00",onChange:E=>F({config:{minute:E.target.value}}),children:[i.jsx("option",{children:"00"}),i.jsx("option",{children:"30"})]})]})]})]}),i.jsxs("div",{className:"af-node-preview-meta",children:[i.jsxs("span",{children:[k.scheduleType==="weekly"?"每周":"每天"," ",k.hour||"09",":",k.minute||"00"]}),i.jsx("span",{children:"Next -"}),i.jsx("span",{children:P?"enabled":"disabled"})]}),i.jsxs("div",{className:"af-node-preview-actions",children:[i.jsxs("button",{type:"button",className:"af-node-preview-run",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):i.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:v_(y)})]}),i.jsxs("div",{className:"af-node-preview-default-body",children:[i.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),i.jsxs("div",{children:[i.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),i.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),i.jsx("span",{children:((W=g.runtime)==null?void 0:W.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):i.jsxs("div",{className:"af-node-preview-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),i.jsx("strong",{children:"暂无预览"}),i.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),i.jsxs("div",{className:"af-node-studio-test",children:[i.jsxs("div",{className:"af-node-studio-subhead",children:[i.jsx("strong",{children:"Test Inputs"}),i.jsxs("button",{type:"button",onClick:$,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..."]:N.length?N:["No test run yet."]).map((E,Q)=>i.jsx("span",{children:E},`${E}-${Q}`))})]})]})]}),i.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),i.jsx("strong",{children:"Internals"})]}),i.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(E=>i.jsxs("button",{type:"button",className:E.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(E.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:E.icon}),E.label]},E.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([E,Q])=>i.jsxs("div",{className:"af-node-studio-internal-row",children:[i.jsx("span",{children:E}),i.jsx("strong",{children:Q})]},E))}),i.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(g.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((y==null?void 0:y.test)||{},null,2):JSON.stringify({runtime:g.runtime||{},files:(y==null?void 0:y.files)||{}},null,2)})]})]})]})}function Aie(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Pie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function gh(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 Iie(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 yw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function Bp(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 Rie(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||gh(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 Vi(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 Tie({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function S_({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(Tie,{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 Mie(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState(yw),[k,x]=m.useState(""),[N,j]=m.useState([]),[C,P]=m.useState(""),I=m.useMemo(()=>y.findIndex((V,B)=>Vi(V,B)===C),[y,C]),$=!!m.useMemo(()=>p.find((V,B)=>Vi(V,B)===C)||null,[p,C]),D=m.useMemo(()=>{const V=String(b.credentialRef||"").trim();return V?N.some(B=>String((B==null?void 0:B.key)||"").trim()===V&&String((B==null?void 0:B.value)??"")!==""):!1},[b.credentialRef,N]),z=m.useCallback(async()=>{t(!0),l("");try{const[V,B]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),se=await V.json().catch(()=>({})),ue=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof ue.error=="string"?ue.error:"ENV HTTP "+B.status);if(!V.ok)throw new Error(typeof se.error=="string"?se.error:"HTTP "+V.status);const G=Array.isArray(se.workspaces)?se.workspaces:[],ee=Array.isArray(se.customWorkspaces)?se.customWorkspaces:[];f(String(se.path||"")),h(G.filter(te=>te==null?void 0:te.builtin)),v(ee),j(Array.isArray(ue.env)?ue.env.map(te=>({key:String((te==null?void 0:te.key)||""),value:String((te==null?void 0:te.value)??"")})):[])}catch(V){l(String(V.message||V))}finally{t(!1)}},[]);m.useEffect(()=>{z()},[z]);const O=m.useCallback(async(V,B="")=>{r(!0),l(""),u("");try{const se=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:V})}),ue=await se.json().catch(()=>({}));if(!se.ok)throw new Error(typeof ue.error=="string"?ue.error:"HTTP "+se.status);const G=Array.isArray(ue.customWorkspaces)?ue.customWorkspaces:V;v(G),h((Array.isArray(ue.workspaces)?ue.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin)),f(String(ue.path||d)),B&&P(B),u("已保存")}catch(se){l(String(se.message||se))}finally{r(!1)}},[d]),M=m.useCallback(()=>{P(""),g(yw()),x(""),u(""),l("")},[]),K=m.useCallback((V,B)=>{P(Vi(V,B)),g(Bp(V)),x(""),u("")},[]),H=m.useCallback((V,B)=>{P(Vi(V,B)),g(Bp(V)),x(""),u("")},[]),L=m.useCallback(async(V,B)=>{const se=String(V||"").trim(),ue=String(B??"");if(!se||!ue)return;const G=N.filter(ne=>String((ne==null?void 0:ne.key)||"").trim()!==se);G.push({key:se,value:ue});const ee=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof te.error=="string"?te.error:"ENV HTTP "+ee.status);j(Array.isArray(te.env)?te.env.map(ne=>({key:String((ne==null?void 0:ne.key)||""),value:String((ne==null?void 0:ne.value)??"")})):G)},[N]),T=m.useCallback(()=>{const V=Rie({...b,id:b.id||Aie()}),B=k.trim();if(V.kind==="git"&&B&&!V.credentialRef&&(V.credentialRef=Iie(b,V)),V.kind==="local"&&!V.path){l("本地知识库需要填写路径");return}if(V.kind==="git"&&!V.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!V.label){l("请填写名称");return}if(V.kind==="git"&&V.credentialRef&&!Pie(V.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const se=I>=0?y.map((ue,G)=>G===I?V:ue):[V,...y];g(Bp(V)),(async()=>{r(!0);try{B&&await L(V.credentialRef,B),x(""),await O(se,Vi(V))}catch(ue){l(String(ue.message||ue)),r(!1)}})()},[y,b,O,L,I,k]),W=m.useCallback(()=>{if(I<0)return;const V=y.filter((B,se)=>se!==I);g(yw()),P(""),O(V)},[y,O,I]),E=m.useCallback(async()=>{if(!$){if(I<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const V=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),B=await V.json().catch(()=>({}));if(!V.ok)throw new Error(typeof B.error=="string"?B.error:"HTTP "+V.status);const se=Array.isArray(B.customWorkspaces)?B.customWorkspaces:y;v(se),h((Array.isArray(B.workspaces)?B.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin));const ue=se.find(ee=>String((ee==null?void 0:ee.id)||"")===String(b.id||""));ue&&g(Bp(ue));const G=String(B.commit||"").trim();u(B.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(V){l(String(V.message||V))}finally{o(!1)}}},[y,b,$,I]),Q=m.useCallback(V=>{g(B=>({...B,...V}))},[]);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:z,disabled:e,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),i.jsx("main",{className:"af-settings-body",children:i.jsxs("div",{className:"af-workspaces-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"知识库"}),i.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),d?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",d]}):null,a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?i.jsx("p",{className:"af-workspaces-status",children:c}):null]}),i.jsxs("section",{className:"af-workspaces-summary",children:[i.jsxs("div",{children:[i.jsx("span",{children:"内置"}),i.jsx("strong",{children:p.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"自定义"}),i.jsx("strong",{children:y.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Git"}),i.jsx("strong",{children:y.filter(V=>V.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((V,B)=>i.jsx(S_,{item:V,selected:Vi(V,B)===C,onClick:()=>K(V,B)},Vi(V,B))):i.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),i.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:i.jsx("h2",{children:"内置知识库"})}),p.map((V,B)=>i.jsx(S_,{item:V,selected:Vi(V,B)===C,onClick:()=>H(V,B),readOnly:!0},Vi(V,B)))]}),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:$?"查看内置知识库":I>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:$?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:$,onChange:V=>Q({enabled:V.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:$,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:$,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:$,onChange:V=>Q({label:V.target.value}),placeholder:"Likee Android"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"类型"}),i.jsxs("select",{value:b.type,disabled:$,onChange:V=>Q({type:V.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:$,onChange:V=>Q({path:V.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:$,onChange:V=>{const B=V.target.value,se=gh(b.repoUrl),ue=String(b.mountPath||"").trim();Q({repoUrl:B,...!ue||ue===se?{mountPath:gh(B)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:b.branch,disabled:$,onChange:V=>Q({branch:V.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:b.mountPath,disabled:$,onChange:V=>Q({mountPath:V.target.value}),placeholder:gh(b.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:b.credentialRef,disabled:$,onChange:V=>Q({credentialRef:V.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:$,onChange:V=>x(V.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:$,onChange:V=>Q({description:V.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!$&&I>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:W,disabled:n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):i.jsx("span",{}),i.jsxs("div",{children:[b.kind==="git"&&I>=0?i.jsxs("button",{type:"button",onClick:E,disabled:$||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:T,disabled:$||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const $ie=[{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"}],Lie=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Oie=[{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"}],Die=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Hp({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 Fie(){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(Hp,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(Hp,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(Hp,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(Hp,{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 yh({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 zie(){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(yh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:Oie.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 IM(){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(Fie,{}),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(yh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:$ie.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(yh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:Lie.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(zie,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(yh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Die.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 RM(e){return t=>typeof t===e}var Bie=RM("function"),Hie=e=>e===null,N_=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",j_=e=>!Wie(e)&&!Hie(e)&&(Bie(e)||typeof e=="object"),Wie=RM("undefined");function Vie(e,t,n){return Xie(n,e,t)?!0:(Qie(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Kie(e,t,n):e instanceof Map&&t instanceof Map?Yie(e,t,n):e instanceof Set&&t instanceof Set?Jie(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?qie(e,t):N_(e)&&N_(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Uie(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Gie(e,t,n))}function yf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!j_(e)||!t||!j_(t)?!1:Vie(e,t,n)}function Kie(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!yf(e[s],t[s],n))return!1;return!0}function qie(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 Uie(e,t,n){return e.message===t.message&&e.name===t.name&&yf(e.cause,t.cause,n)}function Yie(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(!yf(r[1],t.get(r[0]),n))return!1;return!0}function Gie(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)&&!yf(e[o],t[o],n))return!1}return!0}function Jie(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 Xie(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Qie(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function bv(e,t){return yf(e,t,new WeakMap)}function ww(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Zie(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function eoe(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function toe(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function noe(e,t){const n=toe();m.useEffect(()=>{if(!n)return e()},t)}function TM(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function roe(e,t){const n=m.useRef(t);return bv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function soe(e){m.useEffect(()=>{e()},[])}function ioe(e=0){const[t,n]=m.useState({height:ww()?window.innerHeight:0,width:ww()?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(!ww())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),eoe(window,"resize",o),()=>{Zie(window,"resize",o)}},[]),t}var ooe=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],aoe=["bigint","boolean","null","number","string","symbol","undefined"];function wf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(loe(t))return t}function oi(e){return t=>wf(t)===e}function loe(e){return ooe.includes(e)}function Wc(e){return t=>typeof t===e}function coe(e){return aoe.includes(e)}var uoe=["innerHTML","ownerDocument","style","attributes","nodeValue"],xf=e=>Array.isArray(e),doe=e=>wf(e)==="AsyncGeneratorFunction",foe=oi("AsyncFunction"),poe=Wc("bigint"),hoe=e=>e===!0||e===!1,moe=oi("Date"),goe=oi("Error"),na=Wc("function"),yoe=oi("GeneratorFunction"),woe=e=>typeof e=="number"&&Number.isInteger(e),kb=oi("Map"),MM=e=>Number.isNaN(e),kv=e=>e===null,$M=oi("Function"),xoe=oi("Promise"),boe=oi("RegExp"),vb=oi("Set"),bf=Wc("string"),koe=Wc("symbol"),vv=Wc("undefined"),voe=oi("WeakMap"),Soe=oi("WeakSet"),Sv=e=>kv(e)||vv(e),LM=e=>!vv(e),Noe=e=>Wc("number")(e)&&!MM(e),joe=e=>bf(e)&&e.trim().length>0,Coe=e=>{if(!bf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},dg=e=>!Sv(e)&&(na(e)||typeof e=="object"),OM=e=>{if(wf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},_oe=e=>kv(e)||coe(typeof e),Eoe=e=>wf(e)==="URL",DM=e=>!Sv(e)&&na(e[Symbol.iterator]),Aoe=e=>DM(e)&&na(e.next)&&na(e.throw),Poe=e=>na(e)&&/^class\s/.test(e.toString()),Ioe=(e,t)=>!xf(e)||!na(t)?!1:e.every(n=>t(n)),Roe=e=>dg(e)&&!OM(e)&&e.nodeType===1&&bf(e.nodeName)&&uoe.every(t=>t in e),Toe=e=>bf(e)&&e.length===0||xf(e)&&e.length===0||dg(e)&&!kb(e)&&!vb(e)&&Object.keys(e).length===0||vb(e)&&e.size===0||kb(e)&&e.size===0,Moe=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,$oe=(e,t)=>xf(e)?e.indexOf(t)>-1:!1,Loe=(e,t,n)=>{if(!dg(e)||!t)return!1;const r=e[t];return na(n)?n(r):LM(r)};function Nt(e){if(e===null)return"null";switch(typeof e){case"bigint":return"bigint";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"undefined":return"undefined"}if(xf(e))return"Array";if($M(e))return"Function";const t=wf(e);return t||"Object"}Nt.array=xf;Nt.arrayOf=Ioe;Nt.asyncGeneratorFunction=doe;Nt.asyncFunction=foe;Nt.bigint=poe;Nt.boolean=hoe;Nt.class=Poe;Nt.date=moe;Nt.defined=LM;Nt.domElement=Roe;Nt.empty=Toe;Nt.error=goe;Nt.function=na;Nt.generator=Aoe;Nt.generatorFunction=yoe;Nt.instanceOf=Moe;Nt.integer=woe;Nt.iterable=DM;Nt.map=kb;Nt.nan=MM;Nt.null=kv;Nt.nullOrUndefined=Sv;Nt.nonEmptyString=joe;Nt.number=Noe;Nt.numericString=Coe;Nt.object=dg;Nt.oneOf=$oe;Nt.plainFunction=$M;Nt.plainObject=OM;Nt.primitive=_oe;Nt.promise=xoe;Nt.propertyOf=Loe;Nt.regexp=boe;Nt.set=vb;Nt.string=bf;Nt.symbol=koe;Nt.undefined=vv;Nt.url=Eoe;Nt.weakMap=voe;Nt.weakSet=Soe;var Cr=Nt;/* v8 ignore next -- @preserve */var Ooe=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Doe=function(e,t){return e+Qd(t)},Qd=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(Doe,""):Ooe(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Qd(e.props.children):""};Qd.default=Qd;var Foe=Qd;const xw=sa(Foe);var FM={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(j){return j!=="constructor"&&j!=="prototype"&&j!=="__proto__"}function a(j){let C=0;const P=j.length,I=new Array(P);for(C;C<P;++C)I[C]=g(j[C]);return I}function l(j){const C={};if(p&&Object.getPrototypeOf(j)!==t)return p(j);const P=f(j);let I,F,$;for(I=0,F=P.length;I<F;++I)o($=P[I])&&(C[$]=g(j[$]));return C}function c(j,C){const P=j.length,I=C.length;let F=0;const $=new Array(P+I);for(F;F<P;++F)$[F]=g(j[F]);for(F=0;F<I;++F)$[F+P]=g(C[F]);return $}const u=Object.prototype.propertyIsEnumerable;function d(j){const C=Object.keys(j),P=Object.getOwnPropertySymbols(j);for(let I=0,F=P.length;I<F;++I)u.call(j,P[I])&&C.push(P[I]);return C}const f=s!=null&&s.symbols?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),y=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(j){return typeof j!="object"||j===null}const b=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:g,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function g(j){return h(j)?Array.isArray(j)?a(j):l(j):j}function k(j,C){const P={},I=f(j),F=f(C);let $,D,z;for($=0,D=I.length;$<D;++$)o(z=I[$])&&F.indexOf(z)===-1&&(P[z]=g(j[z]));for($=0,D=F.length;$<D;++$)if(o(z=F[$]))if(z in j)I.indexOf(z)!==-1&&(p&&h(C[z])&&Object.getPrototypeOf(C[z])!==t?P[z]=p(C[z]):P[z]=x(j[z],C[z]));else{if(y&&typeof C[z]>"u")continue;P[z]=g(C[z])}return P}function x(j,C){if(y&&typeof C>"u")return g(j);const P=Array.isArray(C),I=Array.isArray(j);return v(C)?C:h(j)?P&&I?b(j,C):P!==I?g(C):k(j,C):g(C)}function N(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let j;for(let C=0,P=arguments.length;C<P;++C)j=x(j,arguments[C]);return j}return s!=null&&s.all?N:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(FM);var zoe=FM.exports;const Boe=sa(zoe);var Hoe=new Error("Element already at target scroll position"),Woe=new Error("Scroll cancelled"),Voe=Math.min,C_=Date.now,Koe={left:__("scrollLeft"),top:__("scrollTop")};function __(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=Uoe);var a=C_(),l=n[e],c=s.ease||qoe,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?o(Hoe,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(h){if(d)return o(Woe,n[e]);var y=C_(),v=Voe(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){o(null,n[e])})}}}function qoe(e){return .5*(1-Math.cos(Math.PI*e))}function Uoe(){}const Yoe=sa(Koe);var zM={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(hd,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})})(zM);var Goe=zM.exports;const BM=sa(Goe),Joe=["top","right","bottom","left"],E_=["start","end"],A_=Joe.reduce((e,t)=>e.concat(t,t+"-"+E_[0],t+"-"+E_[1]),[]),Tc=Math.min,Ba=Math.max,km=Math.round,Wp=Math.floor,Ai=e=>({x:e,y:e}),Xoe={left:"right",right:"left",bottom:"top",top:"bottom"};function Sb(e,t,n){return Ba(e,Tc(t,n))}function Vc(e,t){return typeof e=="function"?e(t):e}function co(e){return e.split("-")[0]}function Pi(e){return e.split("-")[1]}function HM(e){return e==="x"?"y":"x"}function Nv(e){return e==="y"?"height":"width"}function Fo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function jv(e){return HM(Fo(e))}function WM(e,t,n){n===void 0&&(n=!1);const r=Pi(e),s=jv(e),o=Nv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Sm(a)),[a,Sm(a)]}function Qoe(e){const t=Sm(e);return[vm(e),t,vm(t)]}function vm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const P_=["left","right"],I_=["right","left"],Zoe=["top","bottom"],eae=["bottom","top"];function tae(e,t,n){switch(e){case"top":case"bottom":return n?t?I_:P_:t?P_:I_;case"left":case"right":return t?Zoe:eae;default:return[]}}function nae(e,t,n,r){const s=Pi(e);let o=tae(co(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(vm)))),o}function Sm(e){const t=co(e);return Xoe[t]+e.slice(t.length)}function rae(e){return{top:0,right:0,bottom:0,left:0,...e}}function VM(e){return typeof e!="number"?rae(e):{top:e,right:e,bottom:e,left:e}}function Nm(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 R_(e,t,n){let{reference:r,floating:s}=e;const o=Fo(t),a=jv(t),l=Nv(a),c=co(t),u=o==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Pi(t)){case"start":h[a]-=p*(n&&u?-1:1);break;case"end":h[a]+=p*(n&&u?-1:1);break}return h}async function sae(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=Vc(t,e),y=VM(h),b=l[p?f==="floating"?"reference":"floating":f],g=Nm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),k=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),N=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},j=Nm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-j.top+y.top)/N.y,bottom:(j.bottom-g.bottom+y.bottom)/N.y,left:(g.left-j.left+y.left)/N.x,right:(j.right-g.right+y.right)/N.x}}const iae=50,oae=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:sae},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=R_(u,r,c),p=r,h=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:N,data:j,reset:C}=await k({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});d=x??d,f=N??f,y[g]={...y[g],...j},C&&h<iae&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:d,y:f}=R_(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:y}},aae=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=Vc(e,t)||{};if(u==null)return{};const f=VM(d),p={x:n,y:r},h=jv(s),y=Nv(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",N=o.reference[y]+o.reference[h]-p[h]-o.floating[y],j=p[h]-o.reference[h],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=C?C[x]:0;(!P||!await(a.isElement==null?void 0:a.isElement(C)))&&(P=l.floating[x]||o.floating[y]);const I=N/2-j/2,F=P/2-v[y]/2-1,$=Tc(f[g],F),D=Tc(f[k],F),z=$,O=P-v[y]-D,M=P/2-v[y]/2+I,K=Sb(z,M,O),H=!c.arrow&&Pi(s)!=null&&M!==K&&o.reference[y]/2-(M<z?$:D)-v[y]/2<0,L=H?M<z?M-z:M-O:0;return{[h]:p[h]+L,data:{[h]:K,centerOffset:M-K-L,...H&&{alignmentOffset:L}},reset:H}}});function lae(e,t,n){return(e?[...n.filter(s=>Pi(s)===e),...n.filter(s=>Pi(s)!==e)]:n.filter(s=>co(s)===s)).filter(s=>e?Pi(s)===e||(t?vm(s)!==s:!1):!0)}const cae=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:o,middlewareData:a,placement:l,platform:c,elements:u}=t,{crossAxis:d=!1,alignment:f,allowedPlacements:p=A_,autoAlignment:h=!0,...y}=Vc(e,t),v=f!==void 0||p===A_?lae(f||null,h,p):p,b=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const x=WM(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const N=[b[co(k)],b[x[0]],b[x[1]]],j=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:N}],C=v[g+1];if(C)return{data:{index:g+1,overflows:j},reset:{placement:C}};const P=j.map($=>{const D=Pi($.placement);return[$.placement,D&&d?$.overflows.slice(0,2).reduce((z,O)=>z+O,0):$.overflows[0],$.overflows]}).sort(($,D)=>$[1]-D[1]),F=((s=P.filter($=>$[2].slice(0,Pi($[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||P[0][0];return F!==l?{data:{index:g+1,overflows:j},reset:{placement:F}}:{}}}},uae=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=Vc(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=co(s),k=Fo(l),x=co(l)===l,N=await(c.isRTL==null?void 0:c.isRTL(u.floating)),j=p||(x||!v?[Sm(l)]:Qoe(l)),C=y!=="none";!p&&C&&j.push(...nae(l,v,y,N));const P=[l,...j],I=await c.detectOverflow(t,b),F=[];let $=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&F.push(I[g]),f){const M=WM(s,a,N);F.push(I[M[0]],I[M[1]])}if($=[...$,{placement:s,overflows:F}],!F.every(M=>M<=0)){var D,z;const M=(((D=o.flip)==null?void 0:D.index)||0)+1,K=P[M];if(K&&(!(f==="alignment"?k!==Fo(K):!1)||$.every(T=>Fo(T.placement)===k?T.overflows[0]>0:!0)))return{data:{index:M,overflows:$},reset:{placement:K}};let H=(z=$.filter(L=>L.overflows[0]<=0).sort((L,T)=>L.overflows[1]-T.overflows[1])[0])==null?void 0:z.placement;if(!H)switch(h){case"bestFit":{var O;const L=(O=$.filter(T=>{if(C){const W=Fo(T.placement);return W===k||W==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(W=>W>0).reduce((W,E)=>W+E,0)]).sort((T,W)=>T[1]-W[1])[0])==null?void 0:O[0];L&&(H=L);break}case"initialPlacement":H=l;break}if(s!==H)return{reset:{placement:H}}}return{}}}},dae=new Set(["left","top"]);async function fae(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=co(n),l=Pi(n),c=Fo(n)==="y",u=dae.has(a)?-1:1,d=o&&c?-1:1,f=Vc(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}const pae=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 fae(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}}}}},hae=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}=Vc(e,t),d={x:n,y:r},f=await o.detectOverflow(t,u),p=Fo(co(s)),h=HM(p);let y=d[h],v=d[p];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+f[g],N=y-f[k];y=Sb(x,y,N)}if(l){const g=p==="y"?"top":"left",k=p==="y"?"bottom":"right",x=v+f[g],N=v-f[k];v=Sb(x,v,N)}const b=c.fn({...t,[h]:y,[p]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[p]:l}}}}}};function fg(){return typeof window<"u"}function Kc(e){return KM(e)?(e.nodeName||"").toLowerCase():"#document"}function ds(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mi(e){var t;return(t=(KM(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function KM(e){return fg()?e instanceof Node||e instanceof ds(e).Node:!1}function ni(e){return fg()?e instanceof Element||e instanceof ds(e).Element:!1}function ho(e){return fg()?e instanceof HTMLElement||e instanceof ds(e).HTMLElement:!1}function T_(e){return!fg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ds(e).ShadowRoot}function kf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=ri(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function mae(e){return/^(table|td|th)$/.test(Kc(e))}function pg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const gae=/transform|translate|scale|rotate|perspective|filter/,yae=/paint|layout|strict|content/,ka=e=>!!e&&e!=="none";let bw;function Cv(e){const t=ni(e)?ri(e):e;return ka(t.transform)||ka(t.translate)||ka(t.scale)||ka(t.rotate)||ka(t.perspective)||!_v()&&(ka(t.backdropFilter)||ka(t.filter))||gae.test(t.willChange||"")||yae.test(t.contain||"")}function wae(e){let t=ra(e);for(;ho(t)&&!Mc(t);){if(Cv(t))return t;if(pg(t))return null;t=ra(t)}return null}function _v(){return bw==null&&(bw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),bw}function Mc(e){return/^(html|body|#document)$/.test(Kc(e))}function ri(e){return ds(e).getComputedStyle(e)}function hg(e){return ni(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ra(e){if(Kc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||T_(e)&&e.host||Mi(e);return T_(t)?t.host:t}function qM(e){const t=ra(e);return Mc(t)?e.ownerDocument?e.ownerDocument.body:e.body:ho(t)&&kf(t)?t:qM(t)}function Zd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=qM(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ds(s);if(o){const l=Nb(a);return t.concat(a,a.visualViewport||[],kf(s)?s:[],l&&n?Zd(l):[])}else return t.concat(s,Zd(s,[],n))}function Nb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function UM(e){const t=ri(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ho(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=km(n)!==o||km(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Ev(e){return ni(e)?e:e.contextElement}function gc(e){const t=Ev(e);if(!ho(t))return Ai(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=UM(t);let a=(o?km(n.width):n.width)/r,l=(o?km(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const xae=Ai(0);function YM(e){const t=ds(e);return!_v()||!t.visualViewport?xae:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bae(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ds(e)?!1:t}function rl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Ev(e);let a=Ai(1);t&&(r?ni(r)&&(a=gc(r)):a=gc(e));const l=bae(o,n,r)?YM(o):Ai(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,d=s.width/a.x,f=s.height/a.y;if(o){const p=ds(o),h=r&&ni(r)?ds(r):r;let y=p,v=Nb(y);for(;v&&r&&h!==y;){const b=gc(v),g=v.getBoundingClientRect(),k=ri(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,N=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=x,u+=N,y=ds(v),v=Nb(y)}}return Nm({width:d,height:f,x:c,y:u})}function mg(e,t){const n=hg(e).scrollLeft;return t?t.left+n:rl(Mi(e)).left+n}function GM(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-mg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function kae(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Mi(r),l=t?pg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Ai(1);const d=Ai(0),f=ho(r);if((f||!f&&!o)&&((Kc(r)!=="body"||kf(a))&&(c=hg(r)),f)){const h=rl(r);u=gc(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=a&&!f&&!o?GM(a,c):Ai(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function vae(e){return Array.from(e.getClientRects())}function Sae(e){const t=Mi(e),n=hg(e),r=e.ownerDocument.body,s=Ba(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ba(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+mg(e);const l=-n.scrollTop;return ri(r).direction==="rtl"&&(a+=Ba(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const M_=25;function Nae(e,t){const n=ds(e),r=Mi(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const d=_v();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=mg(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-h);y<=M_&&(o-=y)}else u<=M_&&(o+=u);return{width:o,height:a,x:l,y:c}}function jae(e,t){const n=rl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=ho(e)?gc(e):Ai(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 $_(e,t,n){let r;if(t==="viewport")r=Nae(e,n);else if(t==="document")r=Sae(Mi(e));else if(ni(t))r=jae(t,n);else{const s=YM(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Nm(r)}function JM(e,t){const n=ra(e);return n===t||!ni(n)||Mc(n)?!1:ri(n).position==="fixed"||JM(n,t)}function Cae(e,t){const n=t.get(e);if(n)return n;let r=Zd(e,[],!1).filter(l=>ni(l)&&Kc(l)!=="body"),s=null;const o=ri(e).position==="fixed";let a=o?ra(e):e;for(;ni(a)&&!Mc(a);){const l=ri(a),c=Cv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||kf(a)&&!c&&JM(e,a))?r=r.filter(d=>d!==a):s=l,a=ra(a)}return t.set(e,r),r}function _ae(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?pg(t)?[]:Cae(t,this._c):[].concat(n),r],l=$_(t,a[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const h=$_(t,a[p],s);c=Ba(h.top,c),u=Tc(h.right,u),d=Tc(h.bottom,d),f=Ba(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function Eae(e){const{width:t,height:n}=UM(e);return{width:t,height:n}}function Aae(e,t,n){const r=ho(t),s=Mi(t),o=n==="fixed",a=rl(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Ai(0);function u(){c.x=mg(s)}if(r||!r&&!o)if((Kc(t)!=="body"||kf(s))&&(l=hg(t)),r){const h=rl(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?GM(s,l):Ai(0),f=a.left+l.scrollLeft-c.x-d.x,p=a.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:a.width,height:a.height}}function kw(e){return ri(e).position==="static"}function L_(e,t){if(!ho(e)||ri(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Mi(e)===n&&(n=n.ownerDocument.body),n}function XM(e,t){const n=ds(e);if(pg(e))return n;if(!ho(e)){let s=ra(e);for(;s&&!Mc(s);){if(ni(s)&&!kw(s))return s;s=ra(s)}return n}let r=L_(e,t);for(;r&&mae(r)&&kw(r);)r=L_(r,t);return r&&Mc(r)&&kw(r)&&!Cv(r)?n:r||wae(e)||n}const Pae=async function(e){const t=this.getOffsetParent||XM,n=this.getDimensions,r=await n(e.floating);return{reference:Aae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Iae(e){return ri(e).direction==="rtl"}const Rae={convertOffsetParentRelativeRectToViewportRelativeRect:kae,getDocumentElement:Mi,getClippingRect:_ae,getOffsetParent:XM,getElementRects:Pae,getClientRects:vae,getDimensions:Eae,getScale:gc,isElement:ni,isRTL:Iae};function QM(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Tae(e,t){let n=null,r;const s=Mi(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=u;if(l||t(),!p||!h)return;const y=Wp(f),v=Wp(s.clientWidth-(d+p)),b=Wp(s.clientHeight-(f+h)),g=Wp(d),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Ba(0,Tc(1,c))||1};let N=!0;function j(C){const P=C[0].intersectionRatio;if(P!==c){if(!N)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!QM(u,e.getBoundingClientRect())&&a(),N=!1}try{n=new IntersectionObserver(j,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(j,x)}n.observe(e)}return a(!0),o}function O_(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=Ev(e),d=s||o?[...u?Zd(u):[],...t?Zd(t):[]]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?Tae(u,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?rl(e):null;c&&b();function b(){const g=rl(e);v&&!QM(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;d.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const Mae=pae,$ae=cae,Lae=hae,Oae=uae,D_=aae,Dae=(e,t,n)=>{const r=new Map,s={platform:Rae,...n},o={...s.platform,_c:r};return oae(e,t,{...s,platform:o})};var Fae=typeof document<"u",zae=function(){},wh=Fae?m.useLayoutEffect:zae;function jm(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(!jm(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)&&!jm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function ZM(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function F_(e,t){const n=ZM(e);return Math.round(t*n)/n}function vw(e){const t=m.useRef(e);return wh(()=>{t.current=e}),t}function z_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);jm(p,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback(T=>{T!==C.current&&(C.current=T,v(T))},[]),x=m.useCallback(T=>{T!==P.current&&(P.current=T,g(T))},[]),N=o||y,j=a||b,C=m.useRef(null),P=m.useRef(null),I=m.useRef(d),F=c!=null,$=vw(c),D=vw(s),z=vw(u),O=m.useCallback(()=>{if(!C.current||!P.current)return;const T={placement:t,strategy:n,middleware:p};D.current&&(T.platform=D.current),Dae(C.current,P.current,T).then(W=>{const E={...W,isPositioned:z.current!==!1};M.current&&!jm(I.current,E)&&(I.current=E,cr.flushSync(()=>{f(E)}))})},[p,t,n,D,z]);wh(()=>{u===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,f(T=>({...T,isPositioned:!1})))},[u]);const M=m.useRef(!1);wh(()=>(M.current=!0,()=>{M.current=!1}),[]),wh(()=>{if(N&&(C.current=N),j&&(P.current=j),N&&j){if($.current)return $.current(N,j,O);O()}},[N,j,O,$,F]);const K=m.useMemo(()=>({reference:C,floating:P,setReference:k,setFloating:x}),[k,x]),H=m.useMemo(()=>({reference:N,floating:j}),[N,j]),L=m.useMemo(()=>{const T={position:n,left:0,top:0};if(!H.floating)return T;const W=F_(H.floating,d.x),E=F_(H.floating,d.y);return l?{...T,transform:"translate("+W+"px, "+E+"px)",...ZM(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:E}},[n,l,H.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:O,refs:K,elements:H,floatingStyles:L}),[d,O,K,H,L])}const Bae=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?D_({element:r.current,padding:s}).fn(n):{}:r?D_({element:r,padding:s}).fn(n):{}}}},B_=(e,t)=>{const n=Mae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Hae=(e,t)=>{const n=Lae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wae=(e,t)=>{const n=Oae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Vae=(e,t)=>{const n=$ae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kae=(e,t)=>{const n=Bae(e);return{name:n.name,fn:n.fn,options:[e,t]}},qae={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},Uae={beaconOptions:{offset:-18}},e$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Yae={isFixed:!1,locale:e$,placement:"bottom"},Gae={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},$t={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},lr={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Xe={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},yi={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},It={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Jae="react-joyride-portal";function Xae(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function nc(...e){return Boe({all:!0,isMergeableObject:t=>!(!Cr.plainObject(t)||m.isValidElement(t))})(...e)}function t$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Ui(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=xw(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&&t$(e.type)==="function")try{o=Ui(e.type({}),t)}catch{o=xw(n)}else o=xw(n);return o}function fr(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 Qae(e,t){const n=Xae(t);return{...e,...n}}function ef(){}function Zae(e){return Object.keys(e)}function Cm(e,...t){if(!Cr.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 H_(e,...t){if(!Cr.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 jb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(t$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Cr.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):jb(o,t,n))});if(Cr.function(e.type)&&!Object.values(e.props).length)try{return jb(e.type({}),t,n)}catch{return e}return e}function W_(e){return Zae(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Av(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function V_(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 Pv(e){return e?e.getBoundingClientRect():null}function ele(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 Es(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 tle(e,t,n){const r=Pv(e),s=qc(e),o=s?!s.isSameNode(Gr()):!1,a=n??Uc(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(Gr())||(c+=Gr().scrollTop)),Math.floor(c-t)}function qc(e,t){if(!e)return Gr();const n=BM(e);if(n){if(n.isSameNode(Gr()))return t?document:Gr();if(!(n.scrollHeight>n.offsetHeight))return Gr()}return n}function nle(e){const t=e.getBoundingClientRect(),n=Gr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function rle(e,t){if(!e)return 0;const n=BM(e)??Gr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Pv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(n$(e)||sle(e))){const d=e.getBoundingClientRect(),f=d.top-((s==null?void 0:s.top)??0),p=f+d.height,h=n.clientHeight,y=h*.2;f>=y&&p<=h-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function sle(e){return e.offsetParent!==document.body}function n$(e){if(!e)return!1;const t=qc(e);return t?!t.isSameNode(Gr()):!1}function Uc(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?Uc(e.parentNode,t):!1}function Vp(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 K_(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?qc(s):Gr(),l=a?!a.isSameNode(Gr()):!1;return(r.isFixed||Uc(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Gr(){return document.scrollingElement??document.documentElement}function q_(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=Yoe.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function ile(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 r$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Kp={...r$,borderRadius:4,padding:8};function ole(e,t){const{styles:n}=e,r=nc(n??{},t.styles??{});let{width:s}=t;Av()&&(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 nc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...r$,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(${ile(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:{...Kp,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Kp,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Kp,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Kp,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 ale=["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 Iv(e,t){if(!t)return null;const n=nc(Yae,H_(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=nc(qae,e.options??{},H_(t,...ale)),s=ole(e,{...n,...r}),o=nc(Uae,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:nc(e$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:lle(r.spotlightPadding),styles:s}}function lle(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 cle(e,t,n){const{action:r}=t,s=n&&[$t.PREV,$t.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function s$(e,t=!1){return Cr.plainObject(e)?e.target?!0:(fr(t,"tour","target is missing from the step"),!1):(fr(t,"tour","step must be an object"),!1)}function i$(e,t=!1){return Cr.array(e)?e.every(n=>s$(n,t)):(fr(t,"tour","steps must be an array"),!1)}var ule=class{constructor(e){Dn(this,"beaconPosition",null);Dn(this,"debug");Dn(this,"eventListeners",new Map);Dn(this,"listeners",new Set);Dn(this,"props");Dn(this,"snapshot");Dn(this,"state");Dn(this,"steps");Dn(this,"tooltipPosition",null);Dn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Dn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Dn(this,"getServerSnapshot",()=>this.snapshot);Dn(this,"getSnapshot",()=>this.snapshot);Dn(this,"getEventState",()=>Cm(this.snapshot,"positioned"));Dn(this,"getState",()=>Cm(this.snapshot,"positioned"));Dn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&fr(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)});Dn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Dn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Dn(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)}});Dn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Dn(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,!bv(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=Cr.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,Cr.number(t)&&fr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Cr.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&fr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:$t.INIT,controlled:s,index:o,lifecycle:Xe.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?It.READY:It.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===It.WAITING&&e.size>0?{...e,status:It.RUNNING}:e}getStep(e){return Iv(this.props,this.steps[e??this.state.index])}};function dle(e){return new ule(e)}function U_(e,t){return Math.min(Math.max(e,0),t)}function fle(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===It.RUNNING&&e.current.updateState({action:$t.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){fr(r.current,"tour","go() is not supported in controlled mode");return}x===It.RUNNING&&e.current.updateState({action:$t.GO,index:b,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:It.FINISHED,waiting:!1})},info:()=>Cm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===It.RUNNING&&e.current.updateState({action:$t.NEXT,index:U_(g+1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===It.RUNNING&&e.current.updateState({action:$t.UPDATE,lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===It.RUNNING&&e.current.updateState({action:$t.PREV,index:U_(g-1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){fr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:$t.RESET,index:0,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:b?It.RUNNING:It.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===It.RUNNING&&e.current.updateState({action:$t.SKIP,lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:It.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:$t.START,index:Cr.number(b)?b:g,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:k?It.RUNNING:It.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[It.FINISHED,It.SKIPPED].includes(k)||e.current.updateState({action:$t.STOP,index:g+(b?1:0),lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:It.PAUSED,waiting:!1})}}},[e])}const ple=new Set(["origin","positioned"]);function hle(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return fr(!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]&&!ple.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||fr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function mle(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 Io(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 gle(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:u,index:d,lifecycle:f,positioned:p,scrolling:h,size:y,status:v}=a,b=TM(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),N=m.useRef(s),j=m.useRef(l),C=m.useRef(b),P=m.useRef(n),I=m.useRef(null),F=m.useRef(null),$=m.useRef(null);k.current=o,x.current=a,N.current=s,j.current=l,C.current=b,P.current=n;const D=()=>{I.current&&(clearInterval(I.current),I.current=null),F.current=null,$.current&&($.current.cancel(),$.current=null)};m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:z}=Io(x.current,N.current);(z("action",[$t.NEXT,$t.PREV,$t.SKIP,$t.CLOSE])||g.current===$t.CLOSE&&u===$t.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!N.current)return()=>{D()};const{hasChanged:z}=Io(x.current,N.current),O=j.current;if(z("index")&&D(),v!==It.RUNNING||!O||f!==Xe.INIT)return()=>{D()};const{hasChangedTo:M}=Io(x.current,N.current);M("status",It.RUNNING)&&[It.IDLE,It.READY,It.PAUSED].includes(N.current.status)&&r(lr.TOUR_START,O),c.current.cleanupPositionData();const{debug:K}=k.current;if(O.before&&!$.current){fr(K,`step:${d}`,"before()",O),$.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(lr.STEP_BEFORE_HOOK,O,{action:g.current??x.current.action});const H=()=>{$.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Xe.READY})},L=new AbortController,T=O.beforeTimeout;$.current={cancel:()=>L.abort()};const W=T?setTimeout(()=>{L.signal.aborted||(fr(K,`step:${d}`,"before()","timed out",`${T}ms`),L.abort(),t(O,"before_hook"),r(lr.ERROR,O,{error:new Error("Step before hook timed out")}),H())},T):null;O.before({...c.current.getState(),action:g.current??c.current.getState().action,step:O}).then(()=>{L.signal.aborted||(W&&clearTimeout(W),H())}).catch(E=>{L.signal.aborted||(W&&clearTimeout(W),t(O,"before_hook"),r(lr.ERROR,O,{error:E instanceof Error?E:new Error(String(E))}),H())})}else if(!$.current){I.current&&F.current!==O.target&&D();const H=Es(O.target);if(H&&Vp(H))D(),c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(O.targetWaitTimeout===0)c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(!I.current){const{targetWaitTimeout:L}=O,T=Date.now();F.current=O.target,fr(K,`step:${d}`,"polling","started",`${L}ms`),c.current.updateState({waiting:!0}),I.current=setInterval(()=>{const W=Es(O.target),E=Date.now()-T,Q=E>=L;(W&&Vp(W)||Q)&&(fr(K,`step:${d}`,"polling",W&&Vp(W)?"found":"timed out",`${E}ms`),D(),c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1}))},100)}}return()=>{D()}},[t,r,d,f,v,c]),m.useEffect(()=>{if(!N.current)return;const{hasChanged:z,hasChangedTo:O,previous:M}=Io(x.current,N.current),K=j.current;if(!K)return;const H=Es(K.target),L=!!H;if(L&&Vp(H)){if(O("lifecycle",Xe.READY)&&M.lifecycle===Xe.INIT&&r(lr.STEP_BEFORE,K,{action:g.current??x.current.action}),O("lifecycle",Xe.READY)){const T=x.current,W=cle(K,T,k.current.continuous)?Xe.TOOLTIP:Xe.BEACON,E=Es(K.scrollTarget??K.spotlightTarget??K.target),Q=K_({isFirstStep:T.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:K,target:E,targetLifecycle:W}),V=W===Xe.TOOLTIP?Xe.TOOLTIP_BEFORE:Xe.BEACON_BEFORE;fr(k.current.debug,`step:${d}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:$t.UPDATE,lifecycle:V,scrolling:Q})}}else if(x.current.status===It.RUNNING&&f!==Xe.INIT&&f!==Xe.COMPLETE&&z("lifecycle")){fr(k.current.debug,`step:${d}`,L?"Target not visible":"Target not mounted",K),t(K,"target_not_found"),r(lr.TARGET_NOT_FOUND,K);const T=x.current;T.controlled||c.current.updateState({action:$t.UPDATE,index:T.index+(T.action===$t.PREV?-1:1),lifecycle:Xe.INIT})}},[t,r,d,f,c]),m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:z,previous:O}=Io(x.current,N.current),M=j.current,K=C.current;if(M&&z("lifecycle",Xe.TOOLTIP_BEFORE)&&O.lifecycle===Xe.BEACON){const T=Es(M.scrollTarget??M.spotlightTarget??M.target);if(K_({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:T,targetLifecycle:Xe.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const H=f===Xe.BEACON_BEFORE||f===Xe.TOOLTIP_BEFORE;if(M&&H&&!h){const T=f===Xe.TOOLTIP_BEFORE?Xe.TOOLTIP:Xe.BEACON;c.current.updateState({action:$t.UPDATE,lifecycle:T})}M&&z("lifecycle",Xe.BEACON)&&r(lr.BEACON,M),M&&z("lifecycle",Xe.TOOLTIP)&&r(lr.TOOLTIP,M);const L=x.current;if((L.status===It.RUNNING||L.controlled&&L.status===It.PAUSED&&M)&&K&&z("lifecycle",Xe.COMPLETE)&&O.lifecycle===Xe.TOOLTIP&&(r(lr.STEP_AFTER,K,{action:g.current??$t.UPDATE,index:O.index??L.index,lifecycle:L.lifecycle}),K.after)){r(lr.STEP_AFTER_HOOK,K,{action:g.current??$t.UPDATE,index:O.index??L.index,lifecycle:L.lifecycle});try{K.after({...c.current.getState(),action:g.current??$t.UPDATE,index:O.index??L.index,lifecycle:L.lifecycle,step:K})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!N.current)return;const{hasChangedTo:z,previous:O}=Io(x.current,N.current),M=j.current,K=C.current;y&&!M&&f===Xe.INIT&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.COMPLETE,status:It.FINISHED}),!x.current.controlled&&v===It.RUNNING&&z("lifecycle",Xe.COMPLETE)&&d<y&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.INIT}),z("lifecycle",Xe.COMPLETE)&&d>=y&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.COMPLETE,status:It.FINISHED});const H=M??K??Iv(k.current,k.current.steps[d-1]);if(H&&z("status",[It.FINISHED,It.SKIPPED])){let L;M?L=d:K?L=O.index??d:L=d-1,r(lr.TOUR_END,H,{index:L}),x.current.controlled||P.current.reset(),g.current=null}M&&z("action",$t.STOP)&&(g.current=null,r(lr.TOUR_STATUS,M)),M&&z("action",$t.RESET)&&(r(lr.TOUR_STATUS,M),g.current=null)},[u,r,d,f,y,v,c])}function yle({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,d=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=d.current;if(d.current=n,!h||n===h)return;const{hasChanged:y}=Io(n,h);if(bv(h.steps,u)||(i$(u,o)?s.current.setSteps(u):(fr(o,"tour","Steps are not valid",u),t(lr.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?s.current.getState().size&&p.current.start(c??a):p.current.stop();else if(Cr.number(c)&&y("stepIndex")){const v=Cr.number(h.stepIndex)&&h.stepIndex<c?$t.NEXT:$t.PREV;[It.FINISHED,It.SKIPPED].includes(f.current.status)||s.current.updateState({action:v,index:c,lifecycle:Xe.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,s])}function wle(e,t){var l,c,u,d;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Xe.BEACON_BEFORE&&(n!=null&&n.placement)){const f=xle(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Xe.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+h;a-=p+y}else if(f==="left"||f==="right"){const p=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((d=Es(o.target))==null?void 0:d.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+h/2-p/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function xle(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 ble({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:d}=r,f=m.useRef(null),p=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(s);p.current=r,h.current=t,y.current=n,v.current=s,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var j;if(!h.current||!v.current)return;const{hasChangedTo:b}=Io(p.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,N=l===Xe.BEACON_BEFORE||l===Xe.TOOLTIP_BEFORE;if(d===It.RUNNING&&N&&u&&b("positioned",!0)){const C=Es(g.scrollTarget??g.spotlightTarget??g.target),P=o.current.getPositionData("beacon"),I=qc(C),F=I?!I.isSameNode(Gr()):!1;(j=f.current)==null||j.call(f),(async()=>{if(F&&!Uc(I)){const L=Gr(),T=nle(I),W={initial:L.scrollTop,target:T,element:L,duration:x};e(lr.SCROLL_START,g,{scroll:W});const{cancel:E,promise:Q}=q_(T,{element:L,duration:x});f.current=E,await Q,e(lr.SCROLL_END,g,{scroll:W})}const D=Math.floor(rle(C,g.scrollOffset))||0,z=F?D:wle(D,{beaconPosition:P,lifecycle:l,scrollOffset:g.scrollOffset,step:g});fr(k,`step:${a}`,"scroll",F?"custom":"document",`${D} → ${z}`);const O=I,M={initial:O.scrollTop,target:z,element:O,duration:x};e(lr.SCROLL_START,g,{scroll:M});const{cancel:K,promise:H}=q_(z,{element:O,duration:x});f.current=K,await H,e(lr.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,d,o])}function kle(e){const t=roe(()=>Qae(Gae,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(dle(t)),u=FI.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=m.useState([]),p=m.useCallback((j,C)=>{f(P=>[...P,{reason:C,step:j}])},[]),h=m.useCallback(()=>{f([])},[]);hle(c,n);const y=fle(c,n,h),v=mle(s,y,c),{index:b,size:g,status:k}=u,x=TM(u),N=m.useMemo(()=>Iv(t,l[b]),[b,t,l]);return soe(()=>{o&&g&&i$(l,n)&&y.start(a??r)}),noe(()=>{o&&g&&k===It.IDLE&&c.current.updateState({status:It.READY})},[o,g,k]),yle({controls:y,emitEvent:v,props:t,state:u,store:c}),gle({addFailure:p,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:N,store:c}),ble({emitEvent:v,previousState:x,props:t,state:u,step:N,store:c}),{controls:y,failures:d,mergedProps:t,state:u,step:N,store:c}}function vle(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Cr.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=Jae,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Sle={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Nle({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return ef;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
|
|
319
|
+
@keyframes joyride-loader-spin {
|
|
320
|
+
to { transform: rotate(360deg); }
|
|
321
|
+
}
|
|
322
|
+
`)),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:{...Sle,height:s,width:o,borderTopColor:t.primaryColor}});return ft.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const jle={height:0,isFixed:!1,left:0,top:0,width:0};function Lu(e,t){const n=Es(e);if(!n)return jle;const r=Pv(n),s=Uc(n),o=tle(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 Cle(e,t,n){const[r,s]=m.useState(()=>Lu(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(f=>{const p=Lu(e,t);return f.top===p.top&&f.left===p.left&&f.width===p.width&&f.height===p.height&&f.isFixed===p.isFixed?f:p})},100)},[e,t]);m.useEffect(()=>{let f=null;const p=y=>{a.current=qc(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(Lu(e,t))},h=Es(e);return h?p(h):(f=new MutationObserver(()=>{const y=Es(e);y&&(f==null||f.disconnect(),f=null,p(y))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(y=c.current)==null||y.disconnect(),clearTimeout(o.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&s(Lu(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=Lu(e,t)),d}function _le(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function Y_(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 Ele=[Xe.BEACON_BEFORE,Xe.BEACON];function Ale(e){var H,L;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:d,spotlightRadius:f,spotlightTarget:p,styles:h,target:y,waiting:v}=e,b=ioe(),g=Cle(p??y,d,u||v),k=m.useRef(null),x=(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE)&&l!=="center",[N,j]=m.useState(!1),C=c?(H=k.current)==null?void 0:H.offsetParent:null,P=(C==null?void 0:C.clientWidth)??b.width,I=(C==null?void 0:C.clientHeight)??ele()??b.height,F=((L=h.overlay)==null?void 0:L.backgroundColor)??"rgba(0, 0, 0, 0.5)",$=m.useMemo(()=>{const{backgroundColor:T,mixBlendMode:W,...E}=h.overlay;return{height:I,pointerEvents:"none",...E}},[I,h.overlay]),D=x&&!u&&!v;m.useEffect(()=>{D?requestAnimationFrame(()=>j(!0)):j(!1)},[D]);const z=n&&Ele.includes(s),O=!n&&s!==Xe.TOOLTIP;if(r||!v&&(z||O))return null;let M="";if(D)if(c&&C){const T=Es(p??y);if(T){const W=V_(T),E=V_(C);M=Y_(W.left-E.left-d.left,W.top-E.top-d.top,T.offsetWidth+d.left+d.right,T.offsetHeight+d.top+d.bottom,f)}}else M=Y_(g.left,g.top,g.width,g.height,f);const K=_le(P,I,M);return ft.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:$},ft.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:I,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:P}},ft.createElement("path",{d:K,fill:F,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&ft.createElement("path",{d:M,fill:F,style:{opacity:N?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 o$(e){const{children:t,element:n}=e;return n?cr.createPortal(t,n):null}const Ple='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Ile(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return ef;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Ple)],{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 Qi(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 Rle(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Qi(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Qi(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Qi(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Qi(e,t,n)};default:return null}}function Tle(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Qi(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Qi(e,r,n)};case"left":return{right:-n,top:t.y??0,...Qi(e,r,n)};case"right":return{left:-n,top:t.y??0,...Qi(e,r,n)};default:return{}}}function Mle({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!Qi(r,n,o))return null;c=ft.createElement("span",{style:{flexShrink:0}},ft.createElement(l,{base:n,placement:r,size:o}))}else{const u=Rle(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,...Tle(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function $le(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:d,styles:f}=e,p=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return ef;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
|
|
323
|
+
@keyframes joyride-beacon-inner {
|
|
324
|
+
20% {
|
|
325
|
+
opacity: 0.9;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
90% {
|
|
329
|
+
opacity: 0.7;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@keyframes joyride-beacon-outer {
|
|
334
|
+
0% {
|
|
335
|
+
transform: scale(1);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
45% {
|
|
339
|
+
opacity: 0.7;
|
|
340
|
+
transform: scale(0.75);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
100% {
|
|
344
|
+
opacity: 0.9;
|
|
345
|
+
transform: scale(1);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
`)),document.head.appendChild(b);const g=setTimeout(()=>{Cr.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=Ui(o.open);let v;if(t){const b=t;v=ft.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=ft.createElement("span",{style:f.beacon},ft.createElement("span",{style:f.beaconOuter}),ft.createElement("span",{style:f.beaconInner}));return ft.createElement("button",{ref:p,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function Lle({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 Ole(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=ft.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=ft.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=ft.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&ft.createElement(Lle,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Ui(d),"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:f.tooltip,...c,...y},ft.createElement("div",{style:f.tooltipContainer},p&&ft.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),ft.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&ft.createElement("div",{style:f.tooltipFooter},ft.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Dle(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(yi.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(yi.BUTTON_CLOSE):n.close(yi.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(yi.BUTTON_PRIMARY);return}n.next(yi.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(yi.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:N,nextWithProgress:j,skip:C}=a.locale,P=Ui(g),I=Ui(k),F=Ui(x),$=Ui(N),D=Ui(C);let z=k,O=I;if(t){if(z=N,O=$,a.showProgress&&!s){const M=Ui(j,{step:r+1,steps:o});z=jb(j,r+1,o),O=M}s&&(z=x,O=F)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:l,role:"button",title:P},closeProps:{"aria-label":I,children:k,"data-action":"close",onClick:c,role:"button",title:I},primaryProps:{"aria-label":O,children:z,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":D,children:C,"data-action":"skip",onClick:d,role:"button",title:D},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=ft.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=ft.createElement(Ole,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Fle(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function zle(e,t,n){var r,s;return e?[Vae()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Wae({crossAxis:!1,fallbackPlacements:Fle(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Ble(e){var W,E,Q,V,B;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:d,size:f,step:p,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=p.placement==="center",x=p.placement==="auto",N=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),j=m.useMemo(()=>n$(h)?qc(h):void 0,[h]),C=m.useMemo(()=>Uc(h),[h]),P=m.useMemo(()=>j?{boundary:j,rootBoundary:"viewport"}:{},[j]),I=k||x?"bottom":p.placement,F=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),$=m.useMemo(()=>{var se,ue,G,ee;return k?[{name:"center",fn:({rects:te})=>({x:(window.innerWidth-te.floating.width)/2,y:(window.innerHeight-te.floating.height)/2})}]:[B_(({placement:te})=>{var ce;let ne="right";te.startsWith("top")?ne="top":te.startsWith("bottom")?ne="bottom":te.startsWith("left")&&(ne="left");const Z=p.spotlightTarget?0:p.spotlightPadding[ne];return p.offset+Z+((ce=p.floatingOptions)!=null&&ce.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...zle(x,p,I),Hae({padding:10,...P,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[Kae({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ee=p.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,p,x,I,P]),D=z_({...k?{elements:{reference:N}}:{},placement:I,strategy:F,middleware:$}),z=z_({strategy:F,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ue;return[B_(((ue=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:O_});g.current=D.middlewareData,b.current=z.middlewareData,m.useEffect(()=>{var G;const{floating:se,reference:ue}=D.elements;if(!(!ue||!se||s!==Xe.TOOLTIP))return O_(ue,se,D.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,D.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,D.elements]),m.useEffect(()=>{!k&&h&&D.refs.setReference(h),h&&z.refs.setReference(h)},[z.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(()=>{z.isPositioned&&c("beacon",{placement:z.placement,x:z.x??0,y:z.y??0,middlewareData:b.current})},[c,z.isPositioned,z.placement,z.x,z.y]);const O=p.zIndex+100,M=m.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),K=m.useCallback(se=>{se&&(D.refs.setFloating(se),u(se))},[D.refs,u]),{arrow:H,floater:L}=p.styles;let T=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const se=W_({...L,...D.floatingStyles,zIndex:O,opacity:a&&D.isPositioned?1:0,...!a&&{transition:"none"}});T=ft.createElement("div",{ref:K,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},ft.createElement(Dle,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((B=p.floatingOptions)!=null&&B.hideArrow)&&ft.createElement(Mle,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:D.placement,position:D.middlewareData.arrow,size:p.arrowSize,styles:H}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&(T=ft.createElement("div",{ref:z.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:W_({...z.floatingStyles,zIndex:O})},ft.createElement($le,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:o,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return ft.createElement(o$,{element:l},T)}function Hle(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,h]=m.useState(null);Ile(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Es(d.target),v=s===Xe.TOOLTIP;return!s$(d)||!Cr.domElement(y)?null:ft.createElement(Ble,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function Wle({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=vle(c),{index:f,lifecycle:p,status:h}=n,y=h===It.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 j=C=>{!r||p!==Xe.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(yi.KEYBOARD):e.close(yi.KEYBOARD))};return document.body.addEventListener("keydown",j,{passive:!0}),()=>{document.body.removeEventListener("keydown",j)}},[e,y,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(yi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(yi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const N=n.action===$t.START&&!r.skipBeacon&&r.placement!=="center";return ft.createElement(ft.Fragment,null,p!==Xe.INIT&&ft.createElement(Hle,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),ft.createElement(o$,{element:d},ft.createElement(ft.Fragment,null,v&&ft.createElement(Nle,{nonce:l,step:r}),!N&&ft.createElement(Ale,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Vle(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=kle(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Cm(s,"positioned"),[s]),step:o,Tour:Av()?ft.createElement(Wle,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function Kle(e){const{Tour:t}=Vle(e);return t}function qle(e){return Av()?ft.createElement(Kle,e):null}function Ule(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 Yle(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Gle(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const qp="af:onboarding";function Jle({page:e,hasNodes:t=!1}){const{t:n}=Fr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Ule(n):t?Yle(n):Gle(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(qp),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(qp,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(qp)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(qp,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(qle,{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 Xle="agentflow:recent-runs:v1",Qle="agentflow:recent-runs:poller",Zle=3e3,ece=8e3,tce=2e3,G_=5e3,nce=16e3,J_=[1e4,3e4,6e4];function rce(e){return J_[Math.min(Math.max(e-1,0),J_.length-1)]}function sce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ice(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function oce(){const{navigate:e,path:t}=si(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let N=!1,j=!1,C=!1,P=null,I=0,F=0,$=0,D=0,z=null,O=0,M=0;const K=sce(),H=new Map,L=typeof BroadcastChannel=="function"?new BroadcastChannel(Xle):null,T=Ce=>{try{L==null||L.postMessage({...Ce,tabId:K,sentAt:Date.now()})}catch{}},W=()=>{const Ce=Date.now()-nce;for(const[_e,Be]of H)Be<Ce&&H.delete(_e);l(1+H.size)},E=(Ce="presence")=>{T({type:Ce,visible:!document.hidden})},Q=Ce=>{if(!N&&(Array.isArray(Ce.runs)&&r(Ce.runs),Ce.syncHealth&&typeof Ce.syncHealth=="object")){const _e=Ce.syncHealth;O=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},V=Ce=>{Q(Ce),T({type:"state",...Ce})},B=()=>{I&&(window.clearTimeout(I),I=0)},se=Ce=>{B(),!(N||!j||document.hidden)&&(I=window.setTimeout(()=>{I=0,ue()},Math.max(0,Ce)))},ue=async()=>{if(N||!j||document.hidden||z)return;const Ce=new AbortController;z=Ce;let _e=!1;const Be=window.setTimeout(()=>{_e=!0,Ce.abort()},ece);try{const ot=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!ot.ok)throw new Error(`HTTP ${ot.status}`);const yt=await ot.json();if(N||!j||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(yt.runs)?yt.runs:[];V({runs:Te.filter(st=>st&&st.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),se(Zle)}catch(ot){const yt=Ce.signal.aborted&&!_e;if(N||!j||document.hidden||yt)return;O+=1,V({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ot==null?void 0:ot.message)||ot)}`}}),se(rce(O))}finally{window.clearTimeout(Be),z===Ce&&(z=null)}},G=()=>{B(),z&&(z.abort(),z=null)},ee=()=>{if(G(),P){const Ce=P;P=null,Ce()}j=!1},te=(Ce=tce)=>{F&&window.clearTimeout(F),!(N||document.hidden||j||C)&&(F=window.setTimeout(()=>{F=0,Z()},Ce))},ne=()=>{N||document.hidden||j||(j=!0,se(0))},Z=async()=>{var Ce;if(!(N||document.hidden||j||C)){if(!((Ce=navigator.locks)!=null&&Ce.request)){ne();return}C=!0;try{await navigator.locks.request(Qle,{mode:"exclusive",ifAvailable:!0},async _e=>{if(C=!1,!_e||N||document.hidden){te();return}j=!0,se(0),await new Promise(Be=>{P=Be}),P=null,j=!1})}catch{C=!1}finally{te()}}},ce=()=>{if(!N){if(j){O=0,se(0);return}T({type:"retry"}),te(0)}};d.current=ce,L&&(L.onmessage=Ce=>{const _e=Ce.data;if(!(!_e||_e.tabId===K)){if(_e.type==="hello"||_e.type==="presence"){H.set(_e.tabId,Date.now()),W(),_e.type==="hello"&&E();return}if(_e.type==="bye"){H.delete(_e.tabId),W(),te(0);return}if(_e.type==="state"){H.set(_e.tabId,Date.now()),W(),Q(_e);return}_e.type==="retry"&&j&&(O=0,se(0))}});const de=()=>{E(),document.hidden?ee():te(0)},me=()=>{E("bye"),ee()},$e=()=>{E("hello"),te(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",me),window.addEventListener("pageshow",$e),E("hello"),$=window.setInterval(E,G_),D=window.setInterval(W,G_),te(0),()=>{N=!0,d.current=()=>{},E("bye"),ee(),F&&window.clearTimeout(F),$&&window.clearInterval($),D&&window.clearInterval(D),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",$e),L==null||L.close()}},[]);const f=N=>{const j=new URLSearchParams({flowId:N.flowId,flowSource:N.flowSource||"workspace"});e(`/flow?${j.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,h=(p==null?void 0:p.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y&&!v)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:`${a} 个标签页 · 同步已合并`,k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(N=>!N)};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:["最近成功:",ice(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:N=>{N.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(N=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(N.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(N),title:`${N.flowId} · ${N.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:N.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:N.runId.slice(0,12)})]},`${N.flowId}:${N.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 Sw="0.1.113",ace=6e4,lce=30*6e4;function $c(e){return String(e||"").trim().replace(/^v/i,"")}function cce(e,t){const n=$c(e),r=$c(t);return!!(n&&r&&n!==r)}function uce(e,t){return`agentflow.app-version.snooze:${$c(e)}:${$c(t)}`}function dce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function fce(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=$c(u.version);if(!cce(Sw,d)){t(null);return}const f=uce(Sw,d);if(dce(f)>Date.now())return;t({clientVersion:$c(Sw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),ace);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()+lce))}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 a$(e){return e==="/likee-context"||e==="/likee_context"}function pce(){const{navigate:e}=si();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 hce 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 mce({authUser:e}){const{path:t}=si();return t==="/projects"||t==="/"?i.jsx(Pl,{authUser:e}):t==="/nodes"?i.jsx(Pl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Pl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Pl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Pl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Mie,{authUser:e}):t==="/mcps"?i.jsx(vie,{}):t==="/schedules"?i.jsx(Cie,{}):t==="/node-studio"?i.jsx(Eie,{}):t==="/flow"?i.jsx(pce,{}):t==="/workspace"?i.jsx(DJ,{}):t.startsWith("/display")?i.jsx(wM,{}):t==="/settings"?i.jsx(die,{authUser:e}):t==="/admin/usage"?i.jsx(mie,{authUser:e}):t==="/feedback"?i.jsx(yie,{authUser:e}):a$(t)?i.jsx(IM,{}):i.jsx(Pl,{})}function gce({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,d]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),d(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),d("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(y){d(String(y.message||y))}finally{c(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:p,autoComplete:"on",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function yce({authUser:e,onLogout:t}){const{path:n}=si(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(Jle,{page:r?"flow":"projects"}):null,r?null:i.jsx(PD,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(mce,{authUser:e})}),i.jsx(oce,{})]})}function wce(){return i.jsx(hce,{children:i.jsxs(dD,{children:[i.jsx(xce,{}),i.jsx(fce,{})]})})}function xce(){const{path:e}=si();return e.startsWith("/display")?i.jsx(wM,{}):a$(e)?i.jsx(IM,{}):i.jsx(gce,{children:({user:t,onLogout:n})=>i.jsx(yce,{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 X_=document.querySelector('link[rel="icon"]');X_&&(X_.href=pP);Nw.createRoot(document.getElementById("root")).render(i.jsx(ft.StrictMode,{children:i.jsx(wce,{})}));
|